@opentripplanner/core-utils 15.0.0 → 16.0.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 (58) hide show
  1. package/esm/index.js +3 -0
  2. package/esm/index.js.map +1 -1
  3. package/esm/itinerary.js +95 -78
  4. package/esm/itinerary.js.map +1 -1
  5. package/esm/map.js +2 -2
  6. package/esm/map.js.map +1 -1
  7. package/esm/query-gen.js +9 -5
  8. package/esm/query-gen.js.map +1 -1
  9. package/esm/route.js +26 -20
  10. package/esm/route.js.map +1 -1
  11. package/esm/storage.js +4 -1
  12. package/esm/storage.js.map +1 -1
  13. package/esm/time.js +6 -5
  14. package/esm/time.js.map +1 -1
  15. package/esm/ui.js +4 -2
  16. package/esm/ui.js.map +1 -1
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +6 -0
  19. package/lib/index.js.map +1 -1
  20. package/lib/itinerary.d.ts +17 -11
  21. package/lib/itinerary.d.ts.map +1 -1
  22. package/lib/itinerary.js +89 -84
  23. package/lib/itinerary.js.map +1 -1
  24. package/lib/map.d.ts +2 -2
  25. package/lib/map.d.ts.map +1 -1
  26. package/lib/map.js +1 -1
  27. package/lib/map.js.map +1 -1
  28. package/lib/query-gen.d.ts +1 -19
  29. package/lib/query-gen.d.ts.map +1 -1
  30. package/lib/query-gen.js +9 -5
  31. package/lib/query-gen.js.map +1 -1
  32. package/lib/route.d.ts +10 -8
  33. package/lib/route.d.ts.map +1 -1
  34. package/lib/route.js +22 -16
  35. package/lib/route.js.map +1 -1
  36. package/lib/storage.d.ts +1 -1
  37. package/lib/storage.d.ts.map +1 -1
  38. package/lib/storage.js +4 -1
  39. package/lib/storage.js.map +1 -1
  40. package/lib/time.d.ts +3 -1
  41. package/lib/time.d.ts.map +1 -1
  42. package/lib/time.js +5 -4
  43. package/lib/time.js.map +1 -1
  44. package/lib/ui.d.ts.map +1 -1
  45. package/lib/ui.js +4 -2
  46. package/lib/ui.js.map +1 -1
  47. package/package.json +9 -7
  48. package/src/__tests__/itinerary.ts +55 -5
  49. package/src/index.ts +3 -0
  50. package/src/itinerary.ts +134 -97
  51. package/src/map.ts +5 -3
  52. package/src/query-gen.ts +15 -9
  53. package/src/route.ts +65 -38
  54. package/src/storage.ts +8 -2
  55. package/src/time.ts +7 -6
  56. package/src/ui.ts +8 -6
  57. package/tsconfig.json +1 -0
  58. package/tsconfig.tsbuildinfo +1 -1
package/lib/route.d.ts CHANGED
@@ -11,7 +11,7 @@ import { Leg, Route, TransitOperator } from "@opentripplanner/types";
11
11
  * @return {object} The transitOperator if a match was found or null if no match
12
12
  * was found
13
13
  */
14
- export declare function getTransitOperatorFromFeedIdAndAgencyId(feedId: string, agencyId: string | number, transitOperators: TransitOperator[]): TransitOperator;
14
+ export declare function getTransitOperatorFromFeedIdAndAgencyId(feedId: string, agencyId: string | number, transitOperators: TransitOperator[]): TransitOperator | null;
15
15
  /**
16
16
  * Looks up an operator from the provided leg.
17
17
  *
@@ -20,7 +20,7 @@ export declare function getTransitOperatorFromFeedIdAndAgencyId(feedId: string,
20
20
  * @param {object} transitOperators transitOperators from config.
21
21
  * @return {object} the operator if one was found or null if no match was found
22
22
  */
23
- export declare function getTransitOperatorFromLeg(leg: Leg, transitOperators: TransitOperator[]): TransitOperator;
23
+ export declare function getTransitOperatorFromLeg(leg: Leg, transitOperators: TransitOperator[]): TransitOperator | null;
24
24
  /**
25
25
  * Looks up an operator from the provided configuration given an OTP route.
26
26
  * NOTE: this assumes the use of the OTP Route model or a modified OTP
@@ -31,7 +31,7 @@ export declare function getTransitOperatorFromLeg(leg: Leg, transitOperators: Tr
31
31
  * @param {array} transitOperators transitOperators from config
32
32
  * @return {object} the operator if one was found or null if no match was found
33
33
  */
34
- export declare function getTransitOperatorFromOtpRoute(route: Route, transitOperators: TransitOperator[]): TransitOperator;
34
+ export declare function getTransitOperatorFromOtpRoute(route: Route, transitOperators: TransitOperator[]): TransitOperator | null;
35
35
  /**
36
36
  * Calculates the sort comparator value given two routes based off of the
37
37
  * route's agency and provided transitOperators config data.
@@ -67,7 +67,8 @@ export declare function alphabeticShortNameComparator(a: Route, b: Route): numbe
67
67
  * @param {function} [objGetterFn] An optional function to obtain the
68
68
  * comparison value from the comparator function arguments
69
69
  */
70
- export declare function makeNumericValueComparator(objGetterFn?: (item: Route) => number): (a: number, b: number) => number | null;
70
+ export declare function makeNumericValueComparator(): (a: number, b: number) => number;
71
+ export declare function makeNumericValueComparator<T>(objGetterFn: (item: T) => number | null | undefined): (a: T, b: T) => number;
71
72
  /**
72
73
  * Create a comparator function that compares string values. The comparison
73
74
  * values feed to the sort comparator function are assumed to be objects that
@@ -78,7 +79,8 @@ export declare function makeNumericValueComparator(objGetterFn?: (item: Route) =
78
79
  * @param {function} [objGetterFn] An optional function to obtain the
79
80
  * comparison value from the comparator function arguments
80
81
  */
81
- export declare function makeStringValueComparator(objGetterFn?: (item: Route) => string): (a: string, b: string) => number;
82
+ export declare function makeStringValueComparator(): (a: string, b: string) => number;
83
+ export declare function makeStringValueComparator<T>(objGetterFn: (item: T) => string | null | undefined): (a: T, b: T) => number;
82
84
  /**
83
85
  * OTP1 sets the routeSortOrder to -999 by default. If we're encountering that value in OTP1,
84
86
  * assume that it actually means that the route sortOrder is not set in the GTFS. If we encounter
@@ -88,7 +90,7 @@ export declare function makeStringValueComparator(objGetterFn?: (item: Route) =>
88
90
  * Also see https://github.com/opentripplanner/otp-react-redux/issues/122
89
91
  * This was updated in OTP2 TO be empty by default. https://docs.opentripplanner.org/en/v2.3.0/OTP2-MigrationGuide/#:~:text=the%20Alerts-,Changes%20to%20the%20Index%20API,-Error%20handling%20is
90
92
  */
91
- export declare function getRouteSortOrderValue(route: Route): number;
93
+ export declare function getRouteSortOrderValue(route: Route): number | null;
92
94
  /**
93
95
  * Create a multi-criteria sort comparator function composed of other sort
94
96
  * comparator functions. Each comparator function will be ran in the order given
@@ -96,7 +98,7 @@ export declare function getRouteSortOrderValue(route: Route): number;
96
98
  * returned. If all comparison functions return equivalence, then the values
97
99
  * are assumed to be equivalent.
98
100
  */
99
- export declare function makeMultiCriteriaSort(...criteria: ((a: unknown, b: unknown) => number)[]): (a: number, b: number) => number;
101
+ export declare function makeMultiCriteriaSort<T = unknown>(...criteria: ((a: T, b: T) => number)[]): (a: T, b: T) => number;
100
102
  /**
101
103
  * Creates a sort comparator function to compares routes for the purposes of
102
104
  * sorting and displaying in a user interface. This takes in a single optional
@@ -128,7 +130,7 @@ export declare function makeMultiCriteriaSort(...criteria: ((a: unknown, b: unkn
128
130
  * those with shortNames.
129
131
  * 7. longName as string.
130
132
  */
131
- export declare function makeRouteComparator(transitOperators: TransitOperator[]): (a: number, b: number) => number;
133
+ export declare function makeRouteComparator(transitOperators: TransitOperator[]): (a: Route, b: Route) => number;
132
134
  /**
133
135
  * Tests if a pair of colors is readable. If it is, that readable color is returned.
134
136
  * If it is not, a more appropriate alternative is returned.
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../src/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAQjB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,GAAG,EACR,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAQjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAkBjB;AA0DD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,eAAe,EAAE,IAE3B,GAAG,KAAK,EAAE,GAAG,KAAK,YAc3B;AA8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AAgB,yBAAyB,CAAC,CAAC,EACzC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,GAClD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAuB1B;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CASlE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,OAAO,EAC/C,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,IAE/B,GAAG,CAAC,EAAE,GAAG,CAAC,KAAG,MAAM,CAW5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,eAAe,EAAE,GAClC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,KAAK,MAAM,CAUhC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CA2BR"}
package/lib/route.js CHANGED
@@ -129,7 +129,7 @@ function makeTransitOperatorComparator(transitOperators) {
129
129
  return (a, b) => {
130
130
  const aVal = getTransitOperatorComparatorValue(a, transitOperators);
131
131
  const bVal = getTransitOperatorComparatorValue(b, transitOperators);
132
- if (typeof aVal === "string") {
132
+ if (typeof aVal === "string" && typeof bVal === "string") {
133
133
  // happens when transitOperators is undefined. Both aVal are guaranteed to
134
134
  // be strings. Make a string comparison.
135
135
  if (aVal < bVal) return -1;
@@ -146,19 +146,19 @@ function makeTransitOperatorComparator(transitOperators) {
146
146
  * Gets the desired sort values according to an optional getter function. If the
147
147
  * getter function is not defined, the original sort values are returned.
148
148
  */
149
- function getSortValues(getterFn, a, b) {
150
- let aVal;
151
- let bVal;
149
+
150
+ function getSortValues(a, b, getterFn) {
152
151
  if (typeof getterFn === "function") {
153
- aVal = getterFn(a);
154
- bVal = getterFn(b);
155
- } else {
156
- aVal = a;
157
- bVal = b;
152
+ return {
153
+ aVal: getterFn(a),
154
+ bVal: getterFn(b)
155
+ };
158
156
  }
157
+
158
+ // When no getter is provided, TValue is inferred as T via overload.
159
159
  return {
160
- aVal,
161
- bVal
160
+ aVal: a,
161
+ bVal: b
162
162
  };
163
163
  }
164
164
 
@@ -175,7 +175,11 @@ const modeComparatorValue = {
175
175
  CABLE_CAR: 6,
176
176
  FUNICULAR: 7,
177
177
  BUS: 8
178
+ // eslint-disable-next-line prettier/prettier
178
179
  };
180
+ function isSupportedTransitMode(mode) {
181
+ return mode in modeComparatorValue;
182
+ }
179
183
 
180
184
  // Lookup that maps route types to the OTP mode sort values.
181
185
  // Note: JSDoc format not used to avoid bug in documentationjs.
@@ -214,10 +218,10 @@ function getRouteTypeComparatorValue(route) {
214
218
  // string-based modes, but the long route response returns the
215
219
  // integer route type. This attempts to account for both of those cases.
216
220
  if (!route) throw new Error(`Route is undefined. ${route}`);
217
- if (typeof modeComparatorValue[route.mode] !== "undefined") {
221
+ if (route.mode && isSupportedTransitMode(route.mode)) {
218
222
  return modeComparatorValue[route.mode];
219
223
  }
220
- if (typeof routeTypeComparatorValue[route.type] !== "undefined") {
224
+ if (route.type && typeof routeTypeComparatorValue[route.type] !== "undefined") {
221
225
  return routeTypeComparatorValue[route.type];
222
226
  }
223
227
  // Default the comparator value to a large number (placing the route at the
@@ -293,12 +297,13 @@ const isNullOrNaN = val => {
293
297
  * @param {function} [objGetterFn] An optional function to obtain the
294
298
  * comparison value from the comparator function arguments
295
299
  */
300
+
296
301
  function makeNumericValueComparator(objGetterFn) {
297
302
  return (a, b) => {
298
303
  const {
299
304
  aVal,
300
305
  bVal
301
- } = getSortValues(objGetterFn, a, b);
306
+ } = typeof objGetterFn === "function" ? getSortValues(a, b, objGetterFn) : getSortValues(a, b);
302
307
 
303
308
  // if both values aren't valid numbers, use the next sort criteria
304
309
  if (isNullOrNaN(aVal) && isNullOrNaN(bVal)) {
@@ -311,7 +316,6 @@ function makeNumericValueComparator(objGetterFn) {
311
316
  if (isNullOrNaN(bVal)) return -1;
312
317
 
313
318
  // a and b are valid numbers, return the sort value
314
- // @ts-expect-error We know from the checks above that both aVal and bVal are valid numbers.
315
319
  return aVal - bVal;
316
320
  };
317
321
  }
@@ -326,12 +330,14 @@ function makeNumericValueComparator(objGetterFn) {
326
330
  * @param {function} [objGetterFn] An optional function to obtain the
327
331
  * comparison value from the comparator function arguments
328
332
  */
333
+
329
334
  function makeStringValueComparator(objGetterFn) {
330
335
  return (a, b) => {
331
336
  const {
332
337
  aVal,
333
338
  bVal
334
- } = getSortValues(objGetterFn, a, b);
339
+ } = typeof objGetterFn === "function" ? getSortValues(a, b, objGetterFn) : getSortValues(a, b);
340
+
335
341
  // both a and b are uncomparable strings, return equivalent value
336
342
  if (!aVal && !bVal) return 0;
337
343
  // a is not a comparable string, b gets priority
package/lib/route.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","names":["_chromaJs","_interopRequireDefault","require","getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","TROLLEYBUS","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","mode","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","isNullOrNaN","isNaN","makeNumericValueComparator","objGetterFn","makeStringValueComparator","getRouteSortOrderValue","isOTP1","sortOrder","undefined","makeMultiCriteriaSort","criteria","i","curCriteriaComparatorValue","makeRouteComparator","obj","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","chroma","luminance","bgLuminance","Math","abs"],"sources":["../src/route.ts"],"sourcesContent":["import { Leg, Route, TransitOperator } from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in OTP2\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in OTP1\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP2 Route\n if (route.agency) return route.agency.name;\n // OTP1 Route\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nexport function makeTransitOperatorComparator(\n transitOperators: TransitOperator[]\n) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues(\n getterFn: (item: unknown) => unknown,\n a: unknown,\n b: unknown\n) {\n let aVal: unknown;\n let bVal: unknown;\n if (typeof getterFn === \"function\") {\n aVal = getterFn(a);\n bVal = getterFn(b);\n } else {\n aVal = a;\n bVal = b;\n }\n return { aVal, bVal };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n TROLLEYBUS: 9,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n};\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL, // - Monorail.\n 13: modeComparatorValue.TROLLEYBUS\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (typeof modeComparatorValue[route.mode] !== \"undefined\") {\n return modeComparatorValue[route.mode];\n }\n if (typeof routeTypeComparatorValue[route.type] !== \"undefined\") {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nexport function routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nexport function alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\nconst isNullOrNaN = (val: any): boolean => {\n // isNaN(null) returns false so we have to check for null explicitly.\n // Note: Using the global version of isNaN (the Number version behaves differently.\n // eslint-disable-next-line no-restricted-globals\n if (typeof val === null || isNaN(val)) return true;\n\n return typeof val !== \"number\";\n};\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(\n objGetterFn?: (item: Route) => number\n) {\n return (a: number, b: number): number | null => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNullOrNaN(aVal) && isNullOrNaN(bVal)) {\n return 0;\n }\n // b is a valid number, b gets priority\n if (isNullOrNaN(aVal)) return 1;\n\n // a is a valid number, a gets priority\n if (isNullOrNaN(bVal)) return -1;\n\n // a and b are valid numbers, return the sort value\n // @ts-expect-error We know from the checks above that both aVal and bVal are valid numbers.\n return aVal - bVal;\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(\n objGetterFn?: (item: Route) => string\n) {\n return (a: string, b: string): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OTP1 sets the routeSortOrder to -999 by default. If we're encountering that value in OTP1,\n * assume that it actually means that the route sortOrder is not set in the GTFS. If we encounter\n * it in OTP2, it's a valid value, so we should return it.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n * This was updated in OTP2 TO be empty by default. https://docs.opentripplanner.org/en/v2.3.0/OTP2-MigrationGuide/#:~:text=the%20Alerts-,Changes%20to%20the%20Index%20API,-Error%20handling%20is\n */\nexport function getRouteSortOrderValue(route: Route): number {\n const isOTP1 = !!route.agencyId;\n const { sortOrder } = route;\n\n if ((isOTP1 && sortOrder === -999) || sortOrder === undefined) {\n return null;\n }\n\n return sortOrder;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nexport function makeMultiCriteriaSort(\n ...criteria: ((a: unknown, b: unknown) => number)[]\n) {\n return (a: number, b: number): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: number, b: number) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uCAAuCA,CACrDC,MAAc,EACdC,QAAyB,EACzBC,gBAAmC,EAClB;EACjB,OACEA,gBAAgB,CAACC,IAAI,CACnBC,eAAe,IACbA,eAAe,CAACJ,MAAM,KAAKA,MAAM,IACjCI,eAAe,CAACH,QAAQ,KAAKA,QACjC,CAAC,IAAI,IAAI;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,yBAAyBA,CACvCC,GAAQ,EACRJ,gBAAmC,EAClB;EACjB,IAAI,CAACI,GAAG,CAACC,OAAO,IAAI,CAACD,G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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CACtCC,eAAuB,EACvBC,iBAA0B,EAClB;EACR;EACA,IAAI,CAACD,eAAe,EAAEA,eAAe,GAAG,SAAS;EACjD,IAAI,CAACC,iBAAiB,EAAEA,iBAAiB,GAAG,SAAS;EAErD,IAAI,CAACD,eAAe,CAACE,UAAU,CAAC,GAAG,CAAC,EAAE;IACpCF,eAAe,GAAG,IAAIA,eAAe,EAAE;EACzC;EACA,IAAI,CAACC,iBAAiB,CAACC,UAAU,CAAC,GAAG,CAAC,EAAE;IACtCD,iBAAiB,GAAG,IAAIA,iBAAiB,EAAE;EAC7C;;EAEA;EACA;EACA,MAAME,WAAW,GAAG,IAAAC,iBAAM,EAACH,iBAAiB,CAAC,CAACI,SAAS,CAAC,CAAC;EACzD,MAAMC,WAAW,GAAG,IAAAF,iBAAM,EAACJ,eAAe,CAAC,CAACK,SAAS,CAAC,CAAC;EACvD,IACEC,WAAW,GAAGH,WAAW,GAAG,IAAI,IAChCG,WAAW,GAAGH,WAAW,GAAG,IAAI,IAChCI,IAAI,CAACC,GAAG,CAACF,WAAW,GAAGH,WAAW,CAAC,GAAG,GAAG,EACzC;IACA,OAAOF,iBAAiB;EAC1B;;EAEA;EACA;EACA,OAAO,IAAAG,iBAAM,EAACJ,eAAe,CAAC,CAACK,SAAS,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS;AAC1E","ignoreList":[]}
1
+ {"version":3,"file":"route.js","names":["_chromaJs","_interopRequireDefault","require","getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","TROLLEYBUS","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","isSupportedTransitMode","mode","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","isNullOrNaN","isNaN","makeNumericValueComparator","objGetterFn","makeStringValueComparator","getRouteSortOrderValue","isOTP1","sortOrder","undefined","makeMultiCriteriaSort","criteria","i","curCriteriaComparatorValue","makeRouteComparator","obj","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","chroma","luminance","bgLuminance","Math","abs"],"sources":["../src/route.ts"],"sourcesContent":["import {\n Leg,\n Route,\n TransitMode,\n TransitOperator\n} from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator | null {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator | null {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator | null {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in OTP2\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in OTP1\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string | undefined {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP2 Route\n if (route.agency) return route.agency.name;\n // OTP1 Route\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nexport function makeTransitOperatorComparator(\n transitOperators: TransitOperator[]\n) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\" && typeof bVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues<T>(a: T, b: T): { aVal: T; bVal: T };\nfunction getSortValues<T, TValue>(\n a: T,\n b: T,\n getterFn: (item: T) => TValue\n): { aVal: TValue; bVal: TValue };\nfunction getSortValues<T, TValue>(a: T, b: T, getterFn?: (item: T) => TValue) {\n if (typeof getterFn === \"function\") {\n return { aVal: getterFn(a), bVal: getterFn(b) };\n }\n\n // When no getter is provided, TValue is inferred as T via overload.\n return { aVal: (a as unknown) as TValue, bVal: (b as unknown) as TValue };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n TROLLEYBUS: 9,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n// eslint-disable-next-line prettier/prettier\n} as const satisfies Partial<Record<TransitMode, number>>;\n\ntype SupportedTransitMode = keyof typeof modeComparatorValue;\n\nfunction isSupportedTransitMode(mode: TransitMode): mode is SupportedTransitMode {\n return mode in modeComparatorValue;\n}\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue: Record<number, number> = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL, // - Monorail.\n 13: modeComparatorValue.TROLLEYBUS\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (route.mode && isSupportedTransitMode(route.mode)) {\n return modeComparatorValue[route.mode];\n }\n if (\n route.type &&\n typeof routeTypeComparatorValue[route.type] !== \"undefined\"\n ) {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nexport function routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nexport function alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\nconst isNullOrNaN = (val: any): boolean => {\n // isNaN(null) returns false so we have to check for null explicitly.\n // Note: Using the global version of isNaN (the Number version behaves differently.\n // eslint-disable-next-line no-restricted-globals\n if (typeof val === null || isNaN(val)) return true;\n\n return typeof val !== \"number\";\n};\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(): (a: number, b: number) => number;\nexport function makeNumericValueComparator<T>(\n objGetterFn: (item: T) => number | null | undefined\n): (a: T, b: T) => number;\nexport function makeNumericValueComparator<T>(\n objGetterFn?: (item: T) => number | null | undefined\n) {\n return (a: T, b: T): number => {\n const { aVal, bVal } =\n typeof objGetterFn === \"function\"\n ? getSortValues(a, b, objGetterFn)\n : getSortValues(a, b);\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNullOrNaN(aVal) && isNullOrNaN(bVal)) {\n return 0;\n }\n // b is a valid number, b gets priority\n if (isNullOrNaN(aVal)) return 1;\n\n // a is a valid number, a gets priority\n if (isNullOrNaN(bVal)) return -1;\n\n // a and b are valid numbers, return the sort value\n return (aVal as number) - (bVal as number);\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(): (a: string, b: string) => number;\nexport function makeStringValueComparator<T>(\n objGetterFn: (item: T) => string | null | undefined\n): (a: T, b: T) => number;\nexport function makeStringValueComparator<T>(\n objGetterFn?: (item: T) => string | null | undefined\n) {\n return (a: T, b: T): number => {\n const { aVal, bVal } =\n typeof objGetterFn === \"function\"\n ? getSortValues(a, b, objGetterFn)\n : getSortValues(a, b);\n\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OTP1 sets the routeSortOrder to -999 by default. If we're encountering that value in OTP1,\n * assume that it actually means that the route sortOrder is not set in the GTFS. If we encounter\n * it in OTP2, it's a valid value, so we should return it.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n * This was updated in OTP2 TO be empty by default. https://docs.opentripplanner.org/en/v2.3.0/OTP2-MigrationGuide/#:~:text=the%20Alerts-,Changes%20to%20the%20Index%20API,-Error%20handling%20is\n */\nexport function getRouteSortOrderValue(route: Route): number | null {\n const isOTP1 = !!route.agencyId;\n const { sortOrder } = route;\n\n if ((isOTP1 && sortOrder === -999) || sortOrder === undefined) {\n return null;\n }\n\n return sortOrder;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nexport function makeMultiCriteriaSort<T = unknown>(\n ...criteria: ((a: T, b: T) => number)[]\n) {\n return (a: T, b: T): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: Route, b: Route) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uCAAuCA,CACrDC,MAAc,EACdC,QAAyB,EACzBC,gBAAmC,EACX;EACxB,OACEA,gBAAgB,CAACC,IAAI,CACnBC,eAAe,IACbA,eAAe,CAACJ,MAAM,KAAKA,MAAM,IACjCI,eAAe,CAACH,QAAQ,KAAKA,QACjC,CAAC,IAAI,IAAI;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,yBAAyBA,CACvCC,GAAQ,EACRJ,gBAAmC,EACX;EACxB,IAAI,CAACI,GAAG,CAACC,OAAO,IAAI,CAACD,GAAG,CAACL,QAAQ,EAAE,OAAO,IAAI;EAC9C,MAAMD,MAAM,GAAGM,GAAG,CAACC,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACxC,OAAOT,uCAAuC,CAC5CC,MAAM,EACNM,GAAG,CAACL,QAAQ,EACZC,gBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,8BAA8BA,CAC5CC,KAAY,EACZR,gBAAmC,EACX;EACxB,IAAI,CAACQ,KAAK,CAACC,EAAE,EAAE,OAAO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B,EAClB;EACR;EACA,IAAI,CAACD,eAAe,EAAEA,eAAe,GAAG,SAAS;EACjD,IAAI,CAACC,iBAAiB,EAAEA,iBAAiB,GAAG,SAAS;EAErD,IAAI,CAACD,eAAe,CAACE,UAAU,CAAC,GAAG,CAAC,EAAE;IACpCF,eAAe,GAAG,IAAIA,eAAe,EAAE;EACzC;EACA,IAAI,CAACC,iBAAiB,CAACC,UAAU,CAAC,GAAG,CAAC,EAAE;IACtCD,iBAAiB,GAAG,IAAIA,iBAAiB,EAAE;EAC7C;;EAEA;EACA;EACA,MAAME,WAAW,GAAG,IAAAC,iBAAM,EAACH,iBAAiB,CAAC,CAACI,SAAS,CAAC,CAAC;EACzD,MAAMC,WAAW,GAAG,IAAAF,iBAAM,EAACJ,eAAe,CAAC,CAACK,SAAS,CAAC,CAAC;EACvD,IACEC,WAAW,GAAGH,WAAW,GAAG,IAAI,IAChCG,WAAW,GAAGH,WAAW,GAAG,IAAI,IAChCI,IAAI,CAACC,GAAG,CAACF,WAAW,GAAGH,WAAW,CAAC,GAAG,GAAG,EACzC;IACA,OAAOF,iBAAiB;EAC1B;;EAEA;EACA;EACA,OAAO,IAAAG,iBAAM,EAACJ,eAAe,CAAC,CAACK,SAAS,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS;AAC1E","ignoreList":[]}
package/lib/storage.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare function storeItem(key: string, object: unknown): void;
6
6
  * Retrieve a javascript object at the specified key. If not found, defaults to
7
7
  * null or, the optionally provided notFoundValue.
8
8
  */
9
- export declare function getItem(key: string, notFoundValue?: unknown): unknown;
9
+ export declare function getItem<T>(key: string, notFoundValue?: T | null): T | null;
10
10
  /**
11
11
  * Remove item at specified key.
12
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAK5D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,GAAE,OAAc,GAAG,OAAO,CAY3E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAI/B"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAK5D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,GAAG,EAAE,MAAM,EACX,aAAa,GAAE,CAAC,GAAG,IAAW,GAC7B,CAAC,GAAG,IAAI,CAeV;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAI/B"}
package/lib/storage.js CHANGED
@@ -23,9 +23,12 @@ function storeItem(key, object) {
23
23
  * null or, the optionally provided notFoundValue.
24
24
  */
25
25
  function getItem(key, notFoundValue = null) {
26
- let itemAsString;
26
+ let itemAsString = null;
27
27
  try {
28
28
  itemAsString = window.localStorage.getItem(`${STORAGE_PREFIX}.${key}`);
29
+ if (!itemAsString) {
30
+ return notFoundValue;
31
+ }
29
32
  const json = JSON.parse(itemAsString);
30
33
  if (json) return json;
31
34
  return notFoundValue;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","names":["STORAGE_PREFIX","storeItem","key","object","window","localStorage","setItem","JSON","stringify","getItem","notFoundValue","itemAsString","json","parse","e","console","warn","removeItem","randId","Math","random","toString","substr"],"sources":["../src/storage.ts"],"sourcesContent":["/* eslint-disable no-console */\n// Prefix to use with local storage keys.\nconst STORAGE_PREFIX = \"otp\";\n\n/**\n * Store a javascript object at the specified key.\n */\nexport function storeItem(key: string, object: unknown): void {\n window.localStorage.setItem(\n `${STORAGE_PREFIX}.${key}`,\n JSON.stringify(object)\n );\n}\n\n/**\n * Retrieve a javascript object at the specified key. If not found, defaults to\n * null or, the optionally provided notFoundValue.\n */\nexport function getItem(key: string, notFoundValue: unknown = null): unknown {\n let itemAsString: string;\n try {\n itemAsString = window.localStorage.getItem(`${STORAGE_PREFIX}.${key}`);\n const json = JSON.parse(itemAsString);\n if (json) return json;\n return notFoundValue;\n } catch (e) {\n // Catch any errors associated with parsing bad JSON.\n console.warn(e, itemAsString);\n return notFoundValue;\n }\n}\n\n/**\n * Remove item at specified key.\n */\nexport function removeItem(key: string): void {\n window.localStorage.removeItem(`${STORAGE_PREFIX}.${key}`);\n}\n\n/**\n * Generate a random ID. This might not quite be a UUID, but it serves our\n * purposes for now.\n */\nexport function randId(): string {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA,MAAMA,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACO,SAASC,SAASA,CAACC,GAAW,EAAEC,MAAe,EAAQ;EAC5DC,MAAM,CAACC,YAAY,CAACC,OAAO,CACzB,GAAGN,cAAc,IAAIE,GAAG,EAAE,EAC1BK,IAAI,CAACC,SAAS,CAACL,MAAM,CACvB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASM,OAAOA,CAACP,GAAW,EAAEQ,aAAsB,GAAG,IAAI,EAAW;EAC3E,IAAIC,YAAoB;EACxB,IAAI;IACFA,YAAY,GAAGP,MAAM,CAACC,YAAY,CAACI,OAAO,CAAC,GAAGT,cAAc,IAAIE,GAAG,EAAE,CAAC;IACtE,MAAMU,IAAI,GAAGL,IAAI,CAACM,KAAK,CAACF,YAAY,CAAC;IACrC,IAAIC,IAAI,EAAE,OAAOA,IAAI;IACrB,OAAOF,aAAa;EACtB,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,IAAI,CAACF,CAAC,EAAEH,YAAY,CAAC;IAC7B,OAAOD,aAAa;EACtB;AACF;;AAEA;AACA;AACA;AACO,SAASO,UAAUA,CAACf,GAAW,EAAQ;EAC5CE,MAAM,CAACC,YAAY,CAACY,UAAU,CAAC,GAAGjB,cAAc,IAAIE,GAAG,EAAE,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAASgB,MAAMA,CAAA,EAAW;EAC/B,OAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,CACjBC,QAAQ,CAAC,EAAE,CAAC,CACZC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB","ignoreList":[]}
1
+ {"version":3,"file":"storage.js","names":["STORAGE_PREFIX","storeItem","key","object","window","localStorage","setItem","JSON","stringify","getItem","notFoundValue","itemAsString","json","parse","e","console","warn","removeItem","randId","Math","random","toString","substr"],"sources":["../src/storage.ts"],"sourcesContent":["/* eslint-disable no-console */\n// Prefix to use with local storage keys.\nconst STORAGE_PREFIX = \"otp\";\n\n/**\n * Store a javascript object at the specified key.\n */\nexport function storeItem(key: string, object: unknown): void {\n window.localStorage.setItem(\n `${STORAGE_PREFIX}.${key}`,\n JSON.stringify(object)\n );\n}\n\n/**\n * Retrieve a javascript object at the specified key. If not found, defaults to\n * null or, the optionally provided notFoundValue.\n */\nexport function getItem<T>(\n key: string,\n notFoundValue: T | null = null\n): T | null {\n let itemAsString: string | null = null;\n try {\n itemAsString = window.localStorage.getItem(`${STORAGE_PREFIX}.${key}`);\n if (!itemAsString) {\n return notFoundValue;\n }\n const json = JSON.parse(itemAsString);\n if (json) return json;\n return notFoundValue;\n } catch (e) {\n // Catch any errors associated with parsing bad JSON.\n console.warn(e, itemAsString);\n return notFoundValue;\n }\n}\n\n/**\n * Remove item at specified key.\n */\nexport function removeItem(key: string): void {\n window.localStorage.removeItem(`${STORAGE_PREFIX}.${key}`);\n}\n\n/**\n * Generate a random ID. This might not quite be a UUID, but it serves our\n * purposes for now.\n */\nexport function randId(): string {\n return Math.random()\n .toString(36)\n .substr(2, 9);\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA,MAAMA,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACO,SAASC,SAASA,CAACC,GAAW,EAAEC,MAAe,EAAQ;EAC5DC,MAAM,CAACC,YAAY,CAACC,OAAO,CACzB,GAAGN,cAAc,IAAIE,GAAG,EAAE,EAC1BK,IAAI,CAACC,SAAS,CAACL,MAAM,CACvB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASM,OAAOA,CACrBP,GAAW,EACXQ,aAAuB,GAAG,IAAI,EACpB;EACV,IAAIC,YAA2B,GAAG,IAAI;EACtC,IAAI;IACFA,YAAY,GAAGP,MAAM,CAACC,YAAY,CAACI,OAAO,CAAC,GAAGT,cAAc,IAAIE,GAAG,EAAE,CAAC;IACtE,IAAI,CAACS,YAAY,EAAE;MACjB,OAAOD,aAAa;IACtB;IACA,MAAME,IAAI,GAAGL,IAAI,CAACM,KAAK,CAACF,YAAY,CAAC;IACrC,IAAIC,IAAI,EAAE,OAAOA,IAAI;IACrB,OAAOF,aAAa;EACtB,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,IAAI,CAACF,CAAC,EAAEH,YAAY,CAAC;IAC7B,OAAOD,aAAa;EACtB;AACF;;AAEA;AACA;AACA;AACO,SAASO,UAAUA,CAACf,GAAW,EAAQ;EAC5CE,MAAM,CAACC,YAAY,CAACY,UAAU,CAAC,GAAGjB,cAAc,IAAIE,GAAG,EAAE,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAASgB,MAAMA,CAAA,EAAW;EAC/B,OAAOC,IAAI,CAACC,MAAM,CAAC,CAAC,CACjBC,QAAQ,CAAC,EAAE,CAAC,CACZC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB","ignoreList":[]}
package/lib/time.d.ts CHANGED
@@ -30,7 +30,9 @@ export declare function getLongDateFormat(config: Config): string;
30
30
  * Offsets a time according to the provided time options
31
31
  * and returns the result.
32
32
  */
33
- export declare function offsetTime(ms: any, options: any): any;
33
+ export declare function offsetTime(ms: number, options?: {
34
+ offset: number;
35
+ }): number;
34
36
  /**
35
37
  * Formats a seconds after midnight value for display in narrative
36
38
  * @param {number} seconds time since midnight in seconds
package/lib/time.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMhD,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAChD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GACd;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAMA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,MAAM,KAAG,MAC3B,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,kBAAkB;AAClB,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD;AACD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAA,EAAE,OAAO,KAAA,OAErC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,CAGR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,SAAkB,GAAG,MAAM,CAG1E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAoB,GAAG,MAAM,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@@ function formatSecondsAfterMidnight(seconds, timeFormat) {
87
87
  * GMT+0 if the Intl API is unavailable.
88
88
  */
89
89
  function getUserTimezone(fallbackTimezone = "Etc/Greenwich") {
90
- if (process.env.NODE_ENV === "test") return process.env.TZ;
91
- return (Intl === null || Intl === void 0 ? void 0 : Intl.DateTimeFormat().resolvedOptions().timeZone) || fallbackTimezone;
90
+ var _process$env$TZ, _Intl$DateTimeFormat$;
91
+ if (process.env.NODE_ENV === "test") return (_process$env$TZ = process.env.TZ) !== null && _process$env$TZ !== void 0 ? _process$env$TZ : fallbackTimezone;
92
+ return (_Intl$DateTimeFormat$ = Intl === null || Intl === void 0 ? void 0 : Intl.DateTimeFormat().resolvedOptions().timeZone) !== null && _Intl$DateTimeFormat$ !== void 0 ? _Intl$DateTimeFormat$ : fallbackTimezone;
92
93
  }
93
94
 
94
95
  /**
@@ -96,7 +97,7 @@ function getUserTimezone(fallbackTimezone = "Etc/Greenwich") {
96
97
  * The conversion to the user's timezone is needed for testing purposes.
97
98
  */
98
99
  function getCurrentTime(timezone = getUserTimezone()) {
99
- return (0, _dateFns.format)((0, _dateFnsTz.utcToZonedTime)(Date.now(), timezone), OTP_API_TIME_FORMAT);
100
+ return (0, _dateFns.format)((0, _dateFnsTz.toZonedTime)(Date.now(), timezone), OTP_API_TIME_FORMAT);
100
101
  }
101
102
 
102
103
  /**
@@ -104,6 +105,6 @@ function getCurrentTime(timezone = getUserTimezone()) {
104
105
  * The conversion to the user's timezone is needed for testing purposes.
105
106
  */
106
107
  function getCurrentDate(timezone = getUserTimezone()) {
107
- return (0, _dateFns.format)((0, _dateFnsTz.utcToZonedTime)(Date.now(), timezone), OTP_API_DATE_FORMAT);
108
+ return (0, _dateFns.format)((0, _dateFnsTz.toZonedTime)(Date.now(), timezone), OTP_API_DATE_FORMAT);
108
109
  }
109
110
  //# sourceMappingURL=time.js.map
package/lib/time.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","names":["_dateFns","require","_dateFnsTz","OTP_API_DATE_FORMAT","exports","OTP_API_TIME_FORMAT","toHoursMinutesSeconds","seconds","hours","Math","floor","minutes","ensureAtLeastOneMinute","duration","getTimeFormat","config","_config$dateTime","dateTime","timeFormat","getDateFormat","_config$dateTime2","dateFormat","getLongDateFormat","_config$dateTime3","longDateFormat","offsetTime","ms","options","offset","formatSecondsAfterMidnight","time","add","startOfDay","Date","format","getUserTimezone","fallbackTimezone","process","env","NODE_ENV","TZ","Intl","DateTimeFormat","resolvedOptions","timeZone","getCurrentTime","timezone","utcToZonedTime","now","getCurrentDate"],"sources":["../src/time.ts"],"sourcesContent":["import { Config } from \"@opentripplanner/types\";\nimport { startOfDay, add, format } from \"date-fns\";\nimport { utcToZonedTime } from \"date-fns-tz\";\n\n// Date/time formats (per date-fns) when sending/receiving date from OTP\n// regardless of whatever the user has configured as the display format.\nexport const OTP_API_DATE_FORMAT = \"yyyy-MM-dd\";\nexport const OTP_API_TIME_FORMAT = \"HH:mm\";\n\n/**\n * Breaks up a duration in seconds into hours, minutes, and seconds.\n * @param {number} seconds The number of seconds to break up\n * @returns an object with fields with the corresponding, hours, minutes, seconds.\n */\nexport function toHoursMinutesSeconds(\n seconds: number\n): {\n hours: number;\n minutes: number;\n seconds: number;\n} {\n return {\n hours: Math.floor(seconds / 3600),\n minutes: Math.floor(seconds / 60) % 60,\n seconds: seconds % 60\n };\n}\n\n/**\n * If a duration is less than 60 seconds, round it to one minute, to avoid a duration\n * of 0 minutes on a leg.\n * @param {number} duration The leg or trip duration in seconds\n * @returns a duration in seconds of at least 60 seconds.\n */\nexport const ensureAtLeastOneMinute = (duration: number): number =>\n duration < 60 ? 60 : duration;\n\n/**\n * @param {[type]} config the OTP config object found in store\n * @return {string} the config-defined time formatter or HH:mm (24-hr time)\n */\nexport function getTimeFormat(config: Config): string {\n return config?.dateTime?.timeFormat || OTP_API_TIME_FORMAT;\n}\n\nexport function getDateFormat(config: Config): string {\n return config?.dateTime?.dateFormat || OTP_API_DATE_FORMAT;\n}\n\n/** @deprecated */\nexport function getLongDateFormat(config: Config): string {\n return config?.dateTime?.longDateFormat || \"D MMMM YYYY\";\n}\n/**\n * Offsets a time according to the provided time options\n * and returns the result.\n */\nexport function offsetTime(ms, options) {\n return ms + (options?.offset || 0);\n}\n\n/**\n * Formats a seconds after midnight value for display in narrative\n * @param {number} seconds time since midnight in seconds\n * @param {string} timeFormat A valid date-fns time format\n * @return {string} formatted text representation\n */\nexport function formatSecondsAfterMidnight(\n seconds: number,\n timeFormat: string\n): string {\n const time = add(startOfDay(new Date()), { seconds });\n return format(time, timeFormat);\n}\n\n/**\n * Uses Intl.DateTimeFormat() api to get the user's time zone. In a test\n * environment, pulls timezone information from an env variable. Default to\n * GMT+0 if the Intl API is unavailable.\n */\nexport function getUserTimezone(fallbackTimezone = \"Etc/Greenwich\"): string {\n if (process.env.NODE_ENV === \"test\") return process.env.TZ;\n return Intl?.DateTimeFormat().resolvedOptions().timeZone || fallbackTimezone;\n}\n\n/**\n * Formats current time for use in OTP query\n * The conversion to the user's timezone is needed for testing purposes.\n */\nexport function getCurrentTime(timezone = getUserTimezone()): string {\n return format(utcToZonedTime(Date.now(), timezone), OTP_API_TIME_FORMAT);\n}\n\n/**\n * Formats current date for use in OTP query\n * The conversion to the user's timezone is needed for testing purposes.\n */\nexport function getCurrentDate(timezone = getUserTimezone()): string {\n return format(utcToZonedTime(Date.now(), timezone), OTP_API_DATE_FORMAT);\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACO,MAAME,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,YAAY;AACxC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,OAAO;;AAE1C;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CACnCC,OAAe,EAKf;EACA,OAAO;IACLC,KAAK,EAAEC,IAAI,CAACC,KAAK,CAACH,OA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,IAAI,GAAG,IAAAC,YAAG,EAAC,IAAAC,mBAAU,EAAC,IAAIC,IAAI,CAAC,CAAC,CAAC,EAAE;IAAE1B;EAAQ,CAAC,CAAC;EACrD,OAAO,IAAA2B,eAAM,EAACJ,IAAI,EAAEZ,UAAU,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASiB,eAAeA,CAACC,gBAAgB,GAAG,eAAe,EAAU;EAC1E,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE,OAAOF,OAAO,CAACC,GAAG,CAACE,EAAE;EAC1D,OAAO,CAAAC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEC,cAAc,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC,CAACC,QAAQ,KAAIR,gBAAgB;AAC9E;;AAEA;AACA;AACA;AACA;AACO,SAASS,cAAcA,CAACC,QAAQ,GAAGX,eAAe,CAAC,CAAC,EAAU;EACnE,OAAO,IAAAD,eAAM,EAAC,IAAAa,yBAAc,EAACd,IAAI,CAACe,GAAG,CAAC,CAAC,EAAEF,QAAQ,CAAC,EAAEzC,mBAAmB,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACO,SAAS4C,cAAcA,CAACH,QAAQ,GAAGX,eAAe,CAAC,CAAC,EAAU;EACnE,OAAO,IAAAD,eAAM,EAAC,IAAAa,yBAAc,EAACd,IAAI,CAACe,GAAG,CAAC,CAAC,EAAEF,QAAQ,CAAC,EAAE3C,mBAAmB,CAAC;AAC1E","ignoreList":[]}
1
+ {"version":3,"file":"time.js","names":["_dateFns","require","_dateFnsTz","OTP_API_DATE_FORMAT","exports","OTP_API_TIME_FORMAT","toHoursMinutesSeconds","seconds","hours","Math","floor","minutes","ensureAtLeastOneMinute","duration","getTimeFormat","config","_config$dateTime","dateTime","timeFormat","getDateFormat","_config$dateTime2","dateFormat","getLongDateFormat","_config$dateTime3","longDateFormat","offsetTime","ms","options","offset","formatSecondsAfterMidnight","time","add","startOfDay","Date","format","getUserTimezone","fallbackTimezone","_process$env$TZ","_Intl$DateTimeFormat$","process","env","NODE_ENV","TZ","Intl","DateTimeFormat","resolvedOptions","timeZone","getCurrentTime","timezone","toZonedTime","now","getCurrentDate"],"sources":["../src/time.ts"],"sourcesContent":["import { Config } from \"@opentripplanner/types\";\nimport { startOfDay, add, format } from \"date-fns\";\nimport { toZonedTime } from \"date-fns-tz\";\n\n// Date/time formats (per date-fns) when sending/receiving date from OTP\n// regardless of whatever the user has configured as the display format.\nexport const OTP_API_DATE_FORMAT = \"yyyy-MM-dd\";\nexport const OTP_API_TIME_FORMAT = \"HH:mm\";\n\n/**\n * Breaks up a duration in seconds into hours, minutes, and seconds.\n * @param {number} seconds The number of seconds to break up\n * @returns an object with fields with the corresponding, hours, minutes, seconds.\n */\nexport function toHoursMinutesSeconds(\n seconds: number\n): {\n hours: number;\n minutes: number;\n seconds: number;\n} {\n return {\n hours: Math.floor(seconds / 3600),\n minutes: Math.floor(seconds / 60) % 60,\n seconds: seconds % 60\n };\n}\n\n/**\n * If a duration is less than 60 seconds, round it to one minute, to avoid a duration\n * of 0 minutes on a leg.\n * @param {number} duration The leg or trip duration in seconds\n * @returns a duration in seconds of at least 60 seconds.\n */\nexport const ensureAtLeastOneMinute = (duration: number): number =>\n duration < 60 ? 60 : duration;\n\n/**\n * @param {[type]} config the OTP config object found in store\n * @return {string} the config-defined time formatter or HH:mm (24-hr time)\n */\nexport function getTimeFormat(config: Config): string {\n return config?.dateTime?.timeFormat || OTP_API_TIME_FORMAT;\n}\n\nexport function getDateFormat(config: Config): string {\n return config?.dateTime?.dateFormat || OTP_API_DATE_FORMAT;\n}\n\n/** @deprecated */\nexport function getLongDateFormat(config: Config): string {\n return config?.dateTime?.longDateFormat || \"D MMMM YYYY\";\n}\n/**\n * Offsets a time according to the provided time options\n * and returns the result.\n */\nexport function offsetTime(ms: number, options?: { offset: number }): number {\n return ms + (options?.offset || 0);\n}\n\n/**\n * Formats a seconds after midnight value for display in narrative\n * @param {number} seconds time since midnight in seconds\n * @param {string} timeFormat A valid date-fns time format\n * @return {string} formatted text representation\n */\nexport function formatSecondsAfterMidnight(\n seconds: number,\n timeFormat: string\n): string {\n const time = add(startOfDay(new Date()), { seconds });\n return format(time, timeFormat);\n}\n\n/**\n * Uses Intl.DateTimeFormat() api to get the user's time zone. In a test\n * environment, pulls timezone information from an env variable. Default to\n * GMT+0 if the Intl API is unavailable.\n */\nexport function getUserTimezone(fallbackTimezone = \"Etc/Greenwich\"): string {\n if (process.env.NODE_ENV === \"test\")\n return process.env.TZ ?? fallbackTimezone;\n return Intl?.DateTimeFormat().resolvedOptions().timeZone ?? fallbackTimezone;\n}\n\n/**\n * Formats current time for use in OTP query\n * The conversion to the user's timezone is needed for testing purposes.\n */\nexport function getCurrentTime(timezone = getUserTimezone()): string {\n return format(toZonedTime(Date.now(), timezone), OTP_API_TIME_FORMAT);\n}\n\n/**\n * Formats current date for use in OTP query\n * The conversion to the user's timezone is needed for testing purposes.\n */\nexport function getCurrentDate(timezone = getUserTimezone()): string {\n return format(toZonedTime(Date.now(), timezone), OTP_API_DATE_FORMAT);\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACO,MAAME,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,YAAY;AACxC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,OAAO;;AAE1C;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CACnCC,OAAe,EAKf;EACA,OAAO;IACLC,KAAK,EAAEC,IAAI,CAACC,KAAK,CAACH,OAAO,GAAG,IAAI,CAAC;IACjCI,OAAO,EAAEF,IAAI,CAACC,KAAK,CAACH,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE;IACtCA,OAAO,EAAEA,OAAO,GAAG;EACrB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,M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AEA;AACA;AACA;AACA;AACA;AACO,SAASiB,eAAeA,CAACC,gBAAgB,GAAG,eAAe,EAAU;EAAA,IAAAC,eAAA,EAAAC,qBAAA;EAC1E,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EACjC,QAAAJ,eAAA,GAAOE,OAAO,CAACC,GAAG,CAACE,EAAE,cAAAL,eAAA,cAAAA,eAAA,GAAID,gBAAgB;EAC3C,QAAAE,qBAAA,GAAOK,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEC,cAAc,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC,CAACC,QAAQ,cAAAR,qBAAA,cAAAA,qBAAA,GAAIF,gBAAgB;AAC9E;;AAEA;AACA;AACA;AACA;AACO,SAASW,cAAcA,CAACC,QAAQ,GAAGb,eAAe,CAAC,CAAC,EAAU;EACnE,OAAO,IAAAD,eAAM,EAAC,IAAAe,sBAAW,EAAChB,IAAI,CAACiB,GAAG,CAAC,CAAC,EAAEF,QAAQ,CAAC,EAAE3C,mBAAmB,CAAC;AACvE;;AAEA;AACA;AACA;AACA;AACO,SAAS8C,cAAcA,CAACH,QAAQ,GAAGb,eAAe,CAAC,CAAC,EAAU;EACnE,OAAO,IAAAD,eAAM,EAAC,IAAAe,sBAAW,EAAChB,IAAI,CAACiB,GAAG,CAAC,CAAC,EAAEF,QAAQ,CAAC,EAAE7C,mBAAmB,CAAC;AACvE","ignoreList":[]}
package/lib/ui.d.ts.map CHANGED
@@ -1 +1 @@
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"}
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,CA8C9D"}
package/lib/ui.js CHANGED
@@ -21,9 +21,11 @@ function enableScrollForSelector(selector) {
21
21
 
22
22
  function isOverlayTotallyScrolled() {
23
23
  // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
24
+ if (!overlay) return false;
24
25
  return overlay.scrollHeight - overlay.scrollTop <= overlay.clientHeight;
25
26
  }
26
27
  function disableRubberBand(event) {
28
+ if (!overlay || clientY === null) return;
27
29
  const clientYDelta = event.targetTouches[0].clientY - clientY;
28
30
  if (overlay.scrollTop === 0 && clientYDelta > 0) {
29
31
  // element is at the top of its scroll
@@ -34,13 +36,13 @@ function enableScrollForSelector(selector) {
34
36
  event.preventDefault();
35
37
  }
36
38
  }
37
- overlay.addEventListener("touchstart", function (event) {
39
+ overlay === null || overlay === void 0 || overlay.addEventListener("touchstart", event => {
38
40
  if (event.targetTouches.length === 1) {
39
41
  // detect single touch
40
42
  clientY = event.targetTouches[0].clientY;
41
43
  }
42
44
  }, false);
43
- overlay.addEventListener("touchmove", function (event) {
45
+ overlay === null || overlay === void 0 || overlay.addEventListener("touchmove", event => {
44
46
  if (event.targetTouches.length === 1) {
45
47
  // detect single touch
46
48
  disableRubberBand(event);
package/lib/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","names":["isMobile","test","navigator","userAgent","enableScrollForSelector","selector","overlay","document","querySelector","clientY","isOverlayTotallyScrolled","scrollHeight","scrollTop","clientHeight","disableRubberBand","event","clientYDelta","targetTouches","preventDefault","addEventListener","length"],"sources":["../src/ui.ts"],"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"],"mappings":";;;;;;;AAAO,SAASA,QAAQA,CAAA,EAAY;EAClC;EACA,OAAO,gEAAgE,CAACC,IAAI,CAC1EC,SAAS,CAACC,SACZ,CAAC;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAACC,QAAgB,EAAQ;EAC9D,MAAMC,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAACH,QAAQ,CAAC;EAChD,IAAII,OAAO,GAAG,IAAI,CAAC,CAAC;;EAEpB,SAASC,wBAAwBA,CAAA,EAAY;IAC3C;IACA,OAAOJ,OAAO,CAACK,YAAY,GAAGL,OAAO,CAACM,SAAS,IAAIN,OAAO,CAACO,YAAY;EACzE;EAEA,SAASC,iBAAiBA,CAACC,KAAiB,EAAE;IAC5C,MAAMC,YAAY,GAAGD,KAAK,CAACE,aAAa,CAAC,CAAC,CAAC,CAACR,OAAO,GAAGA,OAAO;IAE7D,IAAIH,OAAO,CAACM,SAAS,KAAK,CAAC,IAAII,YAAY,GAAG,CAAC,EAAE;MAC/C;MACAD,KAAK,CAACG,cAAc,CAAC,CAAC;IACxB;IAEA,IAAIR,wBAAwB,CAAC,CAAC,IAAIM,YAAY,GAAG,CAAC,EAAE;MAClD;MACAD,KAAK,CAACG,cAAc,CAAC,CAAC;IACxB;EACF;EAEAZ,OAAO,CAACa,gBAAgB,CACtB,YAAY,EACZ,UAASJ,KAAiB,EAAE;IAC1B,IAAIA,KAAK,CAACE,aAAa,CAACG,MAAM,KAAK,CAAC,EAAE;MACpC;MACAX,OAAO,GAAGM,KAAK,CAACE,aAAa,CAAC,CAAC,CAAC,CAACR,OAAO;IAC1C;EACF,CAAC,EACD,KACF,CAAC;EAEDH,OAAO,CAACa,gBAAgB,CACtB,WAAW,EACX,UAASJ,KAAiB,EAAE;IAC1B,IAAIA,KAAK,CAACE,aAAa,CAACG,MAAM,KAAK,CAAC,EAAE;MACpC;MACAN,iBAAiB,CAACC,KAAK,CAAC;IAC1B;EACF,CAAC,EACD,KACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"ui.js","names":["isMobile","test","navigator","userAgent","enableScrollForSelector","selector","overlay","document","querySelector","clientY","isOverlayTotallyScrolled","scrollHeight","scrollTop","clientHeight","disableRubberBand","event","clientYDelta","targetTouches","preventDefault","addEventListener","length"],"sources":["../src/ui.ts"],"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<HTMLElement>(selector);\n let clientY: number | null = 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 if (!overlay) return false;\n return overlay.scrollHeight - overlay.scrollTop <= overlay.clientHeight;\n }\n\n function disableRubberBand(event: TouchEvent) {\n if (!overlay || clientY === null) return;\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 (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 (event: TouchEvent) => {\n if (event.targetTouches.length === 1) {\n // detect single touch\n disableRubberBand(event);\n }\n },\n false\n );\n}\n"],"mappings":";;;;;;;AAAO,SAASA,QAAQA,CAAA,EAAY;EAClC;EACA,OAAO,gEAAgE,CAACC,IAAI,CAC1EC,SAAS,CAACC,SACZ,CAAC;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAACC,QAAgB,EAAQ;EAC9D,MAAMC,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAcH,QAAQ,CAAC;EAC7D,IAAII,OAAsB,GAAG,IAAI,CAAC,CAAC;;EAEnC,SAASC,wBAAwBA,CAAA,EAAY;IAC3C;IACA,IAAI,CAACJ,OAAO,EAAE,OAAO,KAAK;IAC1B,OAAOA,OAAO,CAACK,YAAY,GAAGL,OAAO,CAACM,SAAS,IAAIN,OAAO,CAACO,YAAY;EACzE;EAEA,SAASC,iBAAiBA,CAACC,KAAiB,EAAE;IAC5C,IAAI,CAACT,OAAO,IAAIG,OAAO,KAAK,IAAI,EAAE;IAClC,MAAMO,YAAY,GAAGD,KAAK,CAACE,aAAa,CAAC,CAAC,CAAC,CAACR,OAAO,GAAGA,OAAO;IAE7D,IAAIH,OAAO,CAACM,SAAS,KAAK,CAAC,IAAII,YAAY,GAAG,CAAC,EAAE;MAC/C;MACAD,KAAK,CAACG,cAAc,CAAC,CAAC;IACxB;IAEA,IAAIR,wBAAwB,CAAC,CAAC,IAAIM,YAAY,GAAG,CAAC,EAAE;MAClD;MACAD,KAAK,CAACG,cAAc,CAAC,CAAC;IACxB;EACF;EAEAZ,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEa,gBAAgB,CACvB,YAAY,EACXJ,KAAiB,IAAK;IACrB,IAAIA,KAAK,CAACE,aAAa,CAACG,MAAM,KAAK,CAAC,EAAE;MACpC;MACAX,OAAO,GAAGM,KAAK,CAACE,aAAa,CAAC,CAAC,CAAC,CAACR,OAAO;IAC1C;EACF,CAAC,EACD,KACF,CAAC;EAEDH,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEa,gBAAgB,CACvB,WAAW,EACVJ,KAAiB,IAAK;IACrB,IAAIA,KAAK,CAACE,aAAa,CAACG,MAAM,KAAK,CAAC,EAAE;MACpC;MACAN,iBAAiB,CAACC,KAAK,CAAC;IAC1B;EACF,CAAC,EACD,KACF,CAAC;AACH","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/core-utils",
3
- "version": "15.0.0",
3
+ "version": "16.0.0",
4
4
  "description": "Core functionality that is shared among numerous UI components",
5
5
  "engines": {
6
6
  "node": ">=13"
@@ -15,18 +15,20 @@
15
15
  "@conveyal/lonlat": "^1.4.1",
16
16
  "@mapbox/polyline": "^1.1.1",
17
17
  "@styled-icons/foundation": "^10.34.0",
18
- "@turf/along": "^6.0.1",
19
- "chroma-js": "^2.4.2",
20
- "date-fns": "^2.28.0",
21
- "date-fns-tz": "^1.2.2",
18
+ "@turf/along": "^7.3.1",
19
+ "chroma-js": "^3.2.0",
20
+ "date-fns": "^3.6.0",
21
+ "date-fns-tz": "^3.2.0",
22
22
  "graphql": "^16.6.0",
23
23
  "lodash.clonedeep": "^4.5.0",
24
24
  "qs": "^6.9.1",
25
- "@opentripplanner/geocoder": "3.0.7"
25
+ "@opentripplanner/geocoder": "3.0.8"
26
26
  },
27
27
  "gitHead": "0af1b7cda60bd4252b219dcf893e01c2acb2ed5d",
28
28
  "devDependencies": {
29
- "@opentripplanner/types": "8.3.1"
29
+ "@types/chroma-js": "^3.1.2",
30
+ "@types/mapbox__polyline": "^1.0.5",
31
+ "@opentripplanner/types": "8.4.0"
30
32
  },
31
33
  "scripts": {
32
34
  "tsc": "tsc"