@opentripplanner/core-utils 6.0.1-alpha.1 → 7.0.0-alpha.1

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 (45) hide show
  1. package/esm/itinerary.js +74 -11
  2. package/esm/itinerary.js.map +1 -1
  3. package/esm/map.js +19 -16
  4. package/esm/map.js.map +1 -1
  5. package/esm/query.js +14 -11
  6. package/esm/query.js.map +1 -1
  7. package/esm/time.js +5 -56
  8. package/esm/time.js.map +1 -1
  9. package/lib/itinerary.d.ts +14 -7
  10. package/lib/itinerary.d.ts.map +1 -1
  11. package/lib/itinerary.js +79 -65
  12. package/lib/itinerary.js.map +1 -1
  13. package/lib/map.d.ts +3 -3
  14. package/lib/map.d.ts.map +1 -1
  15. package/lib/map.js +18 -32
  16. package/lib/map.js.map +1 -1
  17. package/lib/query.js +11 -15
  18. package/lib/query.js.map +1 -1
  19. package/lib/time.d.ts +1 -16
  20. package/lib/time.d.ts.map +1 -1
  21. package/lib/time.js +4 -72
  22. package/lib/time.js.map +1 -1
  23. package/package.json +4 -6
  24. package/src/__tests__/__snapshots__/itinerary.js.snap +2 -38
  25. package/src/__tests__/__snapshots__/time.js.snap +7 -13
  26. package/src/__tests__/itinerary.js +6 -29
  27. package/src/__tests__/time.js +7 -27
  28. package/src/itinerary.ts +72 -27
  29. package/src/map.ts +17 -22
  30. package/src/query.js +19 -16
  31. package/src/time.ts +11 -76
  32. package/tsconfig.tsbuildinfo +1294 -1311
  33. package/esm/deprecated-with-types.js +0 -47
  34. package/esm/deprecated-with-types.js.map +0 -1
  35. package/esm/deprecated.js +0 -325
  36. package/esm/deprecated.js.map +0 -1
  37. package/lib/deprecated-with-types.d.ts +0 -23
  38. package/lib/deprecated-with-types.d.ts.map +0 -1
  39. package/lib/deprecated-with-types.js +0 -61
  40. package/lib/deprecated-with-types.js.map +0 -1
  41. package/lib/deprecated.js +0 -355
  42. package/lib/deprecated.js.map +0 -1
  43. package/src/__tests__/__mocks__/multi-currency-itinerary.json +0 -1728
  44. package/src/deprecated-with-types.ts +0 -62
  45. package/src/deprecated.js +0 -334
@@ -1,47 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import { format } from "date-fns";
3
- import { logDeprecationWarning } from "./deprecated";
4
- import { formatDurationLikeMoment, offsetTime, OTP_API_TIME_FORMAT } from "./time"; // time.ts
5
-
6
- /**
7
- * Formats a time value for display in narrative
8
- * TODO: internationalization/timezone
9
- * @param {number} ms epoch time value in milliseconds
10
- * @returns {string} formatted text representation
11
- */
12
-
13
- export function formatTime(ms, options) {
14
- logDeprecationWarning("formatTime", "formatjs");
15
- return format(offsetTime(ms, options), (options === null || options === void 0 ? void 0 : options.format) || OTP_API_TIME_FORMAT);
16
- }
17
- /**
18
- * Formats an elapsed time duration for display in narrative.
19
- * TODO: internationalization
20
- * @param {number} seconds duration in seconds
21
- * @returns {string} formatted text representation
22
- */
23
- // TS TODO: region as type?
24
-
25
- export function formatDuration(seconds, region) {
26
- logDeprecationWarning("formatDuration", "formatjs");
27
- return formatDurationLikeMoment(seconds, false, {
28
- enabled: true,
29
- code: region
30
- });
31
- }
32
- /**
33
- * Formats an elapsed time in seconds, minutes, hours duration for display in narrative
34
- * @param {number} seconds duration in seconds
35
- * @param {object} region an object that allows internationalization of the time
36
- * @returns {string} formatted text representation
37
- */
38
- // TS TODO: region as type?
39
-
40
- export function formatDurationWithSeconds(seconds, region) {
41
- logDeprecationWarning("formatDurationWithSeconds", "formatjs");
42
- return formatDurationLikeMoment(seconds, true, {
43
- enabled: true,
44
- code: region
45
- });
46
- }
47
- //# sourceMappingURL=deprecated-with-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deprecated-with-types.ts"],"names":["format","logDeprecationWarning","formatDurationLikeMoment","offsetTime","OTP_API_TIME_FORMAT","formatTime","ms","options","formatDuration","seconds","region","enabled","code","formatDurationWithSeconds"],"mappings":"AAAA;AAEA,SAASA,MAAT,QAAuB,UAAvB;AAEA,SAASC,qBAAT,QAAsC,cAAtC;AACA,SACEC,wBADF,EAEEC,UAFF,EAGEC,mBAHF,QAIO,QAJP,C,CAMA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAoBC,EAApB,EAAgCC,OAAhC,EAA8D;AACnEN,EAAAA,qBAAqB,CAAC,YAAD,EAAe,UAAf,CAArB;AAEA,SAAOD,MAAM,CACXG,UAAU,CAACG,EAAD,EAAKC,OAAL,CADC,EAEX,CAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEP,MAAT,KAAmBI,mBAFR,CAAb;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,cAAT,CAAwBC,OAAxB,EAAyCC,MAAzC,EAAiE;AACtET,EAAAA,qBAAqB,CAAC,gBAAD,EAAmB,UAAnB,CAArB;AAEA,SAAOC,wBAAwB,CAACO,OAAD,EAAU,KAAV,EAAiB;AAC9CE,IAAAA,OAAO,EAAE,IADqC;AAE9CC,IAAAA,IAAI,EAAEF;AAFwC,GAAjB,CAA/B;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,yBAAT,CACLJ,OADK,EAELC,MAFK,EAGG;AACRT,EAAAA,qBAAqB,CAAC,2BAAD,EAA8B,UAA9B,CAArB;AAEA,SAAOC,wBAAwB,CAACO,OAAD,EAAU,IAAV,EAAgB;AAC7CE,IAAAA,OAAO,EAAE,IADoC;AAE7CC,IAAAA,IAAI,EAAEF;AAFuC,GAAhB,CAA/B;AAID","sourcesContent":["/* eslint-disable import/no-cycle */\nimport { TimeOptions } from \"@opentripplanner/types\";\nimport { format } from \"date-fns\";\n\nimport { logDeprecationWarning } from \"./deprecated\";\nimport {\n formatDurationLikeMoment,\n offsetTime,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n// time.ts\n\n/**\n * Formats a time value for display in narrative\n * TODO: internationalization/timezone\n * @param {number} ms epoch time value in milliseconds\n * @returns {string} formatted text representation\n */\nexport function formatTime(ms: number, options: TimeOptions): string {\n logDeprecationWarning(\"formatTime\", \"formatjs\");\n\n return format(\n offsetTime(ms, options),\n options?.format || OTP_API_TIME_FORMAT\n );\n}\n\n/**\n * Formats an elapsed time duration for display in narrative.\n * TODO: internationalization\n * @param {number} seconds duration in seconds\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDuration(seconds: number, region: string): string {\n logDeprecationWarning(\"formatDuration\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, false, {\n enabled: true,\n code: region\n });\n}\n\n/**\n * Formats an elapsed time in seconds, minutes, hours duration for display in narrative\n * @param {number} seconds duration in seconds\n * @param {object} region an object that allows internationalization of the time\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDurationWithSeconds(\n seconds: number,\n region: string\n): string {\n logDeprecationWarning(\"formatDurationWithSeconds\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, true, {\n enabled: true,\n code: region\n });\n}\n"],"file":"deprecated-with-types.js"}
package/esm/deprecated.js DELETED
@@ -1,325 +0,0 @@
1
- import moment from "moment";
2
- /**
3
- * To disable cyclic dependency resolution we need to require() within methods
4
- * This is a good reason to disable this eslint-rule
5
- */
6
-
7
- /* eslint-disable global-require */
8
-
9
- /**
10
- * Generates a warning to tell developer that they are using deprecated methods!
11
- */
12
-
13
- export function logDeprecationWarning(method, alternative) {
14
- console.warn("".concat(method || "This method", " is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.\n ").concat(alternative ? "\n\n Use ".concat(alternative, " instead, which provides a new interface that doesn't return English strings.") : ""));
15
- } // itinerary.js
16
-
17
- export function getStepDirection(step) {
18
- logDeprecationWarning("getStepDirection");
19
-
20
- switch (step.relativeDirection) {
21
- case "DEPART":
22
- return "Head ".concat(step.absoluteDirection.toLowerCase());
23
-
24
- case "LEFT":
25
- return "Left";
26
-
27
- case "HARD_LEFT":
28
- return "Hard left";
29
-
30
- case "SLIGHTLY_LEFT":
31
- return "Slight left";
32
-
33
- case "CONTINUE":
34
- return "Continue";
35
-
36
- case "SLIGHTLY_RIGHT":
37
- return "Slight right";
38
-
39
- case "RIGHT":
40
- return "Right";
41
-
42
- case "HARD_RIGHT":
43
- return "Hard right";
44
-
45
- case "CIRCLE_CLOCKWISE":
46
- return "Follow circle clockwise";
47
-
48
- case "CIRCLE_COUNTERCLOCKWISE":
49
- return "Follow circle counterclockwise";
50
-
51
- case "ELEVATOR":
52
- return "Take elevator";
53
-
54
- case "UTURN_LEFT":
55
- return "Left U-turn";
56
-
57
- case "UTURN_RIGHT":
58
- return "Right U-turn";
59
-
60
- default:
61
- return step.relativeDirection;
62
- }
63
- }
64
- export function getStepInstructions(step) {
65
- logDeprecationWarning("getStepInstructions");
66
- var conjunction = step.relativeDirection === "ELEVATOR" ? "to" : "on";
67
- return "".concat(getStepDirection(step), " ").concat(conjunction, " ").concat(step.streetName);
68
- }
69
- export function getStepStreetName(step) {
70
- logDeprecationWarning("getStepStreetName");
71
- if (step.streetName === "road") return "Unnamed Road";
72
- if (step.streetName === "path") return "Unnamed Path";
73
- return step.streetName;
74
- }
75
- export function getLegModeLabel(leg) {
76
- logDeprecationWarning("getLegModeLabel");
77
-
78
- switch (leg.mode) {
79
- case "BICYCLE_RENT":
80
- return "Biketown";
81
-
82
- case "CAR":
83
- return leg.hailedCar ? "Ride" : "Drive";
84
-
85
- case "GONDOLA":
86
- return "Aerial Tram";
87
-
88
- case "TRAM":
89
- if (leg.routeLongName.toLowerCase().indexOf("streetcar") !== -1) return "Streetcar";
90
- return "Light Rail";
91
-
92
- case "MICROMOBILITY":
93
- case "SCOOTER":
94
- return "Ride";
95
-
96
- default:
97
- return require("./itinerary").toSentenceCase(leg.mode);
98
- }
99
- }
100
- /**
101
- * Returns mode name by checking the vertex type (VertexType class in OTP) for
102
- * the provided place. NOTE: this is currently only intended for vehicles at
103
- * the moment (not transit or walking).
104
- *
105
- * @param {string} place place from itinerary leg
106
- */
107
-
108
- export function getModeForPlace(place) {
109
- logDeprecationWarning("getModeForPlace");
110
-
111
- switch (place.vertexType) {
112
- case "CARSHARE":
113
- return "car";
114
-
115
- case "VEHICLERENTAL":
116
- return "E-scooter";
117
- // TODO: Should the type change depending on bike vertex type?
118
-
119
- case "BIKESHARE":
120
- case "BIKEPARK":
121
- return "bike";
122
- // If company offers more than one mode, default to `vehicle` string.
123
-
124
- default:
125
- return "vehicle";
126
- }
127
- }
128
- export function getPlaceName(place, companies) {
129
- logDeprecationWarning("getPlaceName"); // If address is provided (i.e. for carshare station, use it)
130
-
131
- if (place.address) return place.address.split(",")[0];
132
-
133
- if (place.networks && place.vertexType === "VEHICLERENTAL") {
134
- // For vehicle rental pick up, do not use the place name. Rather, use
135
- // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just
136
- // a UUID that has no relevance to the actual vehicle. For bikeshare, however,
137
- // there are often hubs or bikes that have relevant names to the user.
138
- var company = require("./itinerary").getCompanyForNetwork(place.networks[0], companies);
139
-
140
- if (company) {
141
- return "".concat(company.label, " ").concat(getModeForPlace(place));
142
- }
143
- } // Default to place name
144
-
145
-
146
- return place.name;
147
- }
148
- /**
149
- * For a given fare component (either total fare or component parts), returns
150
- * an object with string formatters and the fare value (in cents).
151
- */
152
-
153
- export function getTransitFare(fareComponent) {
154
- logDeprecationWarning("getTransitFare", "the fare object and getTncFare"); // Default values (if fare component is not valid).
155
-
156
- var digits = 2;
157
- var transitFare = 0;
158
- var symbol = "$";
159
- var currencyCode = "USD";
160
-
161
- if (fareComponent) {
162
- // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration
163
- var _fareComponent$curren = fareComponent.currency;
164
- currencyCode = _fareComponent$curren.currencyCode;
165
- digits = _fareComponent$curren.defaultFractionDigits;
166
- symbol = _fareComponent$curren.symbol;
167
- transitFare = fareComponent.cents;
168
- } // For cents to string conversion, use digits from fare component.
169
-
170
-
171
- var centsToString = function centsToString(cents) {
172
- var dollars = (cents / Math.pow(10, digits)).toFixed(digits);
173
- return "".concat(symbol).concat(dollars);
174
- }; // For dollars to string conversion, assume we're rounding to two digits.
175
-
176
-
177
- var dollarsToString = function dollarsToString(dollars) {
178
- return "".concat(symbol).concat(dollars.toFixed(2));
179
- };
180
-
181
- return {
182
- centsToString: centsToString,
183
- currencyCode: currencyCode,
184
- dollarsToString: dollarsToString,
185
- transitFare: transitFare
186
- };
187
- }
188
- /**
189
- * For an itinerary, calculates the transit/TNC fares and returns an object with
190
- * these values, currency info, as well as string formatters.
191
- * It is assumed that the same currency is used for transit and TNC legs.
192
- *
193
- * multiple being set to true will change the output behavior:
194
- * - dollarsToString and centsToString will be returned as part of each fare
195
- * - currencyCode will be returned separately for each fare
196
- * - tnc currency code will be returned separately
197
- * - each fare type will be returned separately within a new transitFares property
198
- *
199
- * FIXME: a new approach to fare calculation must be found:
200
- * the current approach is not sustainable, as centsToString and DollarsToString
201
- * must be replaced by i18n anyway.
202
- *
203
- * However, the current behavior should ideally be kept to avoid a breaking change.
204
- * The "multiple" mode is helpful, but only prevents tnc fare calculation from being duplicated.
205
- * This method could be split out into a new one, along with tnc fare calculation.
206
- * If this is done, the individual fare calculation should also be modified to support
207
- * a default fare not being called "regular". However, this again would be a breaking change.
208
- * This breaking change is avoided by adding the "multiple" parameter.
209
- *
210
- * When centsToString and dollarsToString are removed, this method should be split into
211
- * individual fare calculation on a variable fare key, fare calculation of an entire leg,
212
- * which will get fares for every fare key in the leg, and a method to calculate the fare of
213
- * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.
214
- */
215
-
216
- export function calculateFares(itinerary) {
217
- var multiple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
218
- logDeprecationWarning("calculateFares", "the fare object and getTncFare"); // Process any TNC fares
219
-
220
- var minTNCFare = 0;
221
- var maxTNCFare = 0;
222
- var tncCurrencyCode;
223
- itinerary.legs.forEach(function (leg) {
224
- if (leg.mode === "CAR" && leg.hailedCar && leg.tncData) {
225
- var _leg$tncData = leg.tncData,
226
- currency = _leg$tncData.currency,
227
- maxCost = _leg$tncData.maxCost,
228
- minCost = _leg$tncData.minCost; // TODO: Support non-USD
229
-
230
- minTNCFare += minCost;
231
- maxTNCFare += maxCost;
232
- tncCurrencyCode = currency;
233
- }
234
- });
235
-
236
- if (multiple) {
237
- // Return object of fares
238
- var transitFares = {};
239
-
240
- if (itinerary && itinerary.fare && itinerary.fare.fare) {
241
- Object.keys(itinerary.fare.fare).forEach(function (fareKey) {
242
- var fareComponent = itinerary.fare.fare[fareKey];
243
- transitFares[fareKey] = getTransitFare(fareComponent);
244
- });
245
- }
246
-
247
- return {
248
- maxTNCFare: maxTNCFare,
249
- minTNCFare: minTNCFare,
250
- tncCurrencyCode: tncCurrencyCode,
251
- transitFares: transitFares
252
- };
253
- } // Extract fare total from itinerary fares.
254
-
255
-
256
- var fareComponent = itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular; // Get string formatters and itinerary fare.
257
-
258
- var _getTransitFare = getTransitFare(fareComponent),
259
- centsToString = _getTransitFare.centsToString,
260
- transitCurrencyCode = _getTransitFare.currencyCode,
261
- dollarsToString = _getTransitFare.dollarsToString,
262
- transitFare = _getTransitFare.transitFare;
263
-
264
- return {
265
- centsToString: centsToString,
266
- currencyCode: transitCurrencyCode || tncCurrencyCode,
267
- dollarsToString: dollarsToString,
268
- maxTNCFare: maxTNCFare,
269
- minTNCFare: minTNCFare,
270
- transitFare: transitFare
271
- };
272
- } // map.js
273
-
274
- export function latlngToString(latlng) {
275
- logDeprecationWarning("latlngToString", "the latlng object");
276
- return latlng && "".concat(latlng.lat.toFixed(5), ", ").concat((latlng.lng || latlng.lon).toFixed(5));
277
- }
278
- export function coordsToString(coords) {
279
- logDeprecationWarning("coordsToString", "the coords object");
280
- return coords.length && coords.map(function (c) {
281
- return (+c).toFixed(5);
282
- }).join(", ");
283
- }
284
- export function getDetailText(location) {
285
- var detailText;
286
-
287
- if (location.type === "home" || location.type === "work") {
288
- detailText = location.name;
289
- }
290
-
291
- if (location.type === "stop") {
292
- detailText = location.id;
293
- } else if (location.type === "recent" && location.timestamp) {
294
- detailText = moment(location.timestamp).fromNow();
295
- }
296
-
297
- return detailText;
298
- } // query.js
299
-
300
- export function summarizeQuery(query) {
301
- var locations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
302
- logDeprecationWarning("summarizeQuery");
303
-
304
- function findLocationType(location) {
305
- var ls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
306
- var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ["home", "work", "suggested"];
307
- var match = ls.find(function (l) {
308
- return require("./map").matchLatLon(l, location);
309
- });
310
- return match && types.indexOf(match.type) !== -1 ? match.type : null;
311
- }
312
-
313
- var from = findLocationType(query.from, locations) || query.from.name.split(",")[0];
314
- var to = findLocationType(query.to, locations) || query.to.name.split(",")[0];
315
- var mode = require("./itinerary").hasTransit(query.mode) ? "Transit" : require("./itinerary").toSentenceCase(query.mode);
316
- return "".concat(mode, " from ").concat(from, " to ").concat(to);
317
- }
318
- export function getTimeZoneOffset(itinerary) {
319
- logDeprecationWarning("getTimeZoneOffset");
320
- if (!itinerary.legs || !itinerary.legs.length) return 0; // Determine if there is a DST offset between now and the itinerary start date
321
-
322
- var dstOffset = new Date(itinerary.startTime).getTimezoneOffset() - new Date().getTimezoneOffset();
323
- return itinerary.legs[0].agencyTimeZoneOffset + (new Date().getTimezoneOffset() + dstOffset) * 60000;
324
- }
325
- //# sourceMappingURL=deprecated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deprecated.js"],"names":["moment","logDeprecationWarning","method","alternative","console","warn","getStepDirection","step","relativeDirection","absoluteDirection","toLowerCase","getStepInstructions","conjunction","streetName","getStepStreetName","getLegModeLabel","leg","mode","hailedCar","routeLongName","indexOf","require","toSentenceCase","getModeForPlace","place","vertexType","getPlaceName","companies","address","split","networks","company","getCompanyForNetwork","label","name","getTransitFare","fareComponent","digits","transitFare","symbol","currencyCode","currency","defaultFractionDigits","cents","centsToString","dollars","toFixed","dollarsToString","calculateFares","itinerary","multiple","minTNCFare","maxTNCFare","tncCurrencyCode","legs","forEach","tncData","maxCost","minCost","transitFares","fare","Object","keys","fareKey","regular","transitCurrencyCode","latlngToString","latlng","lat","lng","lon","coordsToString","coords","length","map","c","join","getDetailText","location","detailText","type","id","timestamp","fromNow","summarizeQuery","query","locations","findLocationType","ls","types","match","find","l","matchLatLon","from","to","hasTransit","getTimeZoneOffset","dstOffset","Date","startTime","getTimezoneOffset","agencyTimeZoneOffset"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAA+BC,MAA/B,EAAuCC,WAAvC,EAAoD;AACzDC,EAAAA,OAAO,CAACC,IAAR,WACKH,MAAM,IACP,aAFJ,oJAIQC,WAAW,6BAGPA,WAHO,qFAIP,EARZ;AAWD,C,CAED;;AAEA,OAAO,SAASG,gBAAT,CAA0BC,IAA1B,EAAgC;AACrCN,EAAAA,qBAAqB,CAAC,kBAAD,CAArB;;AAEA,UAAQM,IAAI,CAACC,iBAAb;AACE,SAAK,QAAL;AACE,4BAAeD,IAAI,CAACE,iBAAL,CAAuBC,WAAvB,EAAf;;AACF,SAAK,MAAL;AACE,aAAO,MAAP;;AACF,SAAK,WAAL;AACE,aAAO,WAAP;;AACF,SAAK,eAAL;AACE,aAAO,aAAP;;AACF,SAAK,UAAL;AACE,aAAO,UAAP;;AACF,SAAK,gBAAL;AACE,aAAO,cAAP;;AACF,SAAK,OAAL;AACE,aAAO,OAAP;;AACF,SAAK,YAAL;AACE,aAAO,YAAP;;AACF,SAAK,kBAAL;AACE,aAAO,yBAAP;;AACF,SAAK,yBAAL;AACE,aAAO,gCAAP;;AACF,SAAK,UAAL;AACE,aAAO,eAAP;;AACF,SAAK,YAAL;AACE,aAAO,aAAP;;AACF,SAAK,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AK,CAACpE,IAA5C,CAFJ;AAGA,mBAAUA,IAAV,mBAAuB6E,IAAvB,iBAAkCC,EAAlC;AACD;AAED,OAAO,SAASE,iBAAT,CAA2BhD,SAA3B,EAAsC;AAC3ChD,EAAAA,qBAAqB,CAAC,mBAAD,CAArB;AAEA,MAAI,CAACgD,SAAS,CAACK,IAAX,IAAmB,CAACL,SAAS,CAACK,IAAV,CAAemB,MAAvC,EAA+C,OAAO,CAAP,CAHJ,CAK3C;;AACA,MAAMyB,SAAS,GACb,IAAIC,IAAJ,CAASlD,SAAS,CAACmD,SAAnB,EAA8BC,iBAA9B,KACA,IAAIF,IAAJ,GAAWE,iBAAX,EAFF;AAIA,SACEpD,SAAS,CAACK,IAAV,CAAe,CAAf,EAAkBgD,oBAAlB,GACA,CAAC,IAAIH,IAAJ,GAAWE,iBAAX,KAAiCH,SAAlC,IAA+C,KAFjD;AAID","sourcesContent":["import moment from \"moment\";\n\n/**\n * To disable cyclic dependency resolution we need to require() within methods\n * This is a good reason to disable this eslint-rule\n */\n/* eslint-disable global-require */\n\n/**\n * Generates a warning to tell developer that they are using deprecated methods!\n */\nexport function logDeprecationWarning(method, alternative) {\n console.warn(\n `${method ||\n \"This method\"} is deprecated and will be removed in a future otp-ui release. All language functionality should be handled using react-intl.\n ${\n alternative\n ? `\n\n Use ${alternative} instead, which provides a new interface that doesn't return English strings.`\n : \"\"\n }`\n );\n}\n\n// itinerary.js\n\nexport function getStepDirection(step) {\n logDeprecationWarning(\"getStepDirection\");\n\n switch (step.relativeDirection) {\n case \"DEPART\":\n return `Head ${step.absoluteDirection.toLowerCase()}`;\n case \"LEFT\":\n return \"Left\";\n case \"HARD_LEFT\":\n return \"Hard left\";\n case \"SLIGHTLY_LEFT\":\n return \"Slight left\";\n case \"CONTINUE\":\n return \"Continue\";\n case \"SLIGHTLY_RIGHT\":\n return \"Slight right\";\n case \"RIGHT\":\n return \"Right\";\n case \"HARD_RIGHT\":\n return \"Hard right\";\n case \"CIRCLE_CLOCKWISE\":\n return \"Follow circle clockwise\";\n case \"CIRCLE_COUNTERCLOCKWISE\":\n return \"Follow circle counterclockwise\";\n case \"ELEVATOR\":\n return \"Take elevator\";\n case \"UTURN_LEFT\":\n return \"Left U-turn\";\n case \"UTURN_RIGHT\":\n return \"Right U-turn\";\n default:\n return step.relativeDirection;\n }\n}\n\nexport function getStepInstructions(step) {\n logDeprecationWarning(\"getStepInstructions\");\n\n const conjunction = step.relativeDirection === \"ELEVATOR\" ? \"to\" : \"on\";\n return `${getStepDirection(step)} ${conjunction} ${step.streetName}`;\n}\n\nexport function getStepStreetName(step) {\n logDeprecationWarning(\"getStepStreetName\");\n\n if (step.streetName === \"road\") return \"Unnamed Road\";\n if (step.streetName === \"path\") return \"Unnamed Path\";\n return step.streetName;\n}\n\nexport function getLegModeLabel(leg) {\n logDeprecationWarning(\"getLegModeLabel\");\n\n switch (leg.mode) {\n case \"BICYCLE_RENT\":\n return \"Biketown\";\n case \"CAR\":\n return leg.hailedCar ? \"Ride\" : \"Drive\";\n case \"GONDOLA\":\n return \"Aerial Tram\";\n case \"TRAM\":\n if (leg.routeLongName.toLowerCase().indexOf(\"streetcar\") !== -1)\n return \"Streetcar\";\n return \"Light Rail\";\n case \"MICROMOBILITY\":\n case \"SCOOTER\":\n return \"Ride\";\n default:\n return require(\"./itinerary\").toSentenceCase(leg.mode);\n }\n}\n\n/**\n * Returns mode name by checking the vertex type (VertexType class in OTP) for\n * the provided place. NOTE: this is currently only intended for vehicles at\n * the moment (not transit or walking).\n *\n * @param {string} place place from itinerary leg\n */\nexport function getModeForPlace(place) {\n logDeprecationWarning(\"getModeForPlace\");\n\n switch (place.vertexType) {\n case \"CARSHARE\":\n return \"car\";\n case \"VEHICLERENTAL\":\n return \"E-scooter\";\n // TODO: Should the type change depending on bike vertex type?\n case \"BIKESHARE\":\n case \"BIKEPARK\":\n return \"bike\";\n // If company offers more than one mode, default to `vehicle` string.\n default:\n return \"vehicle\";\n }\n}\n\nexport function getPlaceName(place, companies) {\n logDeprecationWarning(\"getPlaceName\");\n\n // If address is provided (i.e. for carshare station, use it)\n if (place.address) return place.address.split(\",\")[0];\n if (place.networks && place.vertexType === \"VEHICLERENTAL\") {\n // For vehicle rental pick up, do not use the place name. Rather, use\n // company name + vehicle type (e.g., SPIN E-scooter). Place name is often just\n // a UUID that has no relevance to the actual vehicle. For bikeshare, however,\n // there are often hubs or bikes that have relevant names to the user.\n const company = require(\"./itinerary\").getCompanyForNetwork(\n place.networks[0],\n companies\n );\n if (company) {\n return `${company.label} ${getModeForPlace(place)}`;\n }\n }\n // Default to place name\n return place.name;\n}\n\n/**\n * For a given fare component (either total fare or component parts), returns\n * an object with string formatters and the fare value (in cents).\n */\nexport function getTransitFare(fareComponent) {\n logDeprecationWarning(\"getTransitFare\", \"the fare object and getTncFare\");\n\n // Default values (if fare component is not valid).\n let digits = 2;\n let transitFare = 0;\n let symbol = \"$\";\n let currencyCode = \"USD\";\n if (fareComponent) {\n // Assign values without declaration. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#assignment_without_declaration\n ({\n currencyCode,\n defaultFractionDigits: digits,\n symbol\n } = fareComponent.currency);\n transitFare = fareComponent.cents;\n }\n // For cents to string conversion, use digits from fare component.\n const centsToString = cents => {\n const dollars = (cents / 10 ** digits).toFixed(digits);\n return `${symbol}${dollars}`;\n };\n // For dollars to string conversion, assume we're rounding to two digits.\n const dollarsToString = dollars => `${symbol}${dollars.toFixed(2)}`;\n return {\n centsToString,\n currencyCode,\n dollarsToString,\n transitFare\n };\n}\n\n/**\n * For an itinerary, calculates the transit/TNC fares and returns an object with\n * these values, currency info, as well as string formatters.\n * It is assumed that the same currency is used for transit and TNC legs.\n *\n * multiple being set to true will change the output behavior:\n * - dollarsToString and centsToString will be returned as part of each fare\n * - currencyCode will be returned separately for each fare\n * - tnc currency code will be returned separately\n * - each fare type will be returned separately within a new transitFares property\n *\n * FIXME: a new approach to fare calculation must be found:\n * the current approach is not sustainable, as centsToString and DollarsToString\n * must be replaced by i18n anyway.\n *\n * However, the current behavior should ideally be kept to avoid a breaking change.\n * The \"multiple\" mode is helpful, but only prevents tnc fare calculation from being duplicated.\n * This method could be split out into a new one, along with tnc fare calculation.\n * If this is done, the individual fare calculation should also be modified to support\n * a default fare not being called \"regular\". However, this again would be a breaking change.\n * This breaking change is avoided by adding the \"multiple\" parameter.\n *\n * When centsToString and dollarsToString are removed, this method should be split into\n * individual fare calculation on a variable fare key, fare calculation of an entire leg,\n * which will get fares for every fare key in the leg, and a method to calculate the fare of\n * a tnc ride within the leg. This will make typescripting easier, as the types will be cleaner.\n */\nexport function calculateFares(itinerary, multiple = false) {\n logDeprecationWarning(\"calculateFares\", \"the fare object and getTncFare\");\n\n // Process any TNC fares\n let minTNCFare = 0;\n let maxTNCFare = 0;\n let tncCurrencyCode;\n itinerary.legs.forEach(leg => {\n if (leg.mode === \"CAR\" && leg.hailedCar && leg.tncData) {\n const { currency, maxCost, minCost } = leg.tncData;\n // TODO: Support non-USD\n minTNCFare += minCost;\n maxTNCFare += maxCost;\n tncCurrencyCode = currency;\n }\n });\n\n if (multiple) {\n // Return object of fares\n const transitFares = {};\n if (itinerary && itinerary.fare && itinerary.fare.fare) {\n Object.keys(itinerary.fare.fare).forEach(fareKey => {\n const fareComponent = itinerary.fare.fare[fareKey];\n transitFares[fareKey] = getTransitFare(fareComponent);\n });\n }\n\n return {\n maxTNCFare,\n minTNCFare,\n tncCurrencyCode,\n transitFares\n };\n }\n\n // Extract fare total from itinerary fares.\n const fareComponent =\n itinerary.fare && itinerary.fare.fare && itinerary.fare.fare.regular;\n // Get string formatters and itinerary fare.\n const {\n centsToString,\n currencyCode: transitCurrencyCode,\n dollarsToString,\n transitFare\n } = getTransitFare(fareComponent);\n\n return {\n centsToString,\n currencyCode: transitCurrencyCode || tncCurrencyCode,\n dollarsToString,\n maxTNCFare,\n minTNCFare,\n transitFare\n };\n}\n\n// map.js\n\nexport function latlngToString(latlng) {\n logDeprecationWarning(\"latlngToString\", \"the latlng object\");\n\n return (\n latlng &&\n `${latlng.lat.toFixed(5)}, ${(latlng.lng || latlng.lon).toFixed(5)}`\n );\n}\n\nexport function coordsToString(coords) {\n logDeprecationWarning(\"coordsToString\", \"the coords object\");\n\n return coords.length && coords.map(c => (+c).toFixed(5)).join(\", \");\n}\n\nexport function getDetailText(location) {\n let detailText;\n if (location.type === \"home\" || location.type === \"work\") {\n detailText = location.name;\n }\n if (location.type === \"stop\") {\n detailText = location.id;\n } else if (location.type === \"recent\" && location.timestamp) {\n detailText = moment(location.timestamp).fromNow();\n }\n return detailText;\n}\n\n// query.js\n\nexport function summarizeQuery(query, locations = []) {\n logDeprecationWarning(\"summarizeQuery\");\n\n function findLocationType(\n location,\n ls = [],\n types = [\"home\", \"work\", \"suggested\"]\n ) {\n const match = ls.find(l => require(\"./map\").matchLatLon(l, location));\n return match && types.indexOf(match.type) !== -1 ? match.type : null;\n }\n\n const from =\n findLocationType(query.from, locations) || query.from.name.split(\",\")[0];\n const to =\n findLocationType(query.to, locations) || query.to.name.split(\",\")[0];\n const mode = require(\"./itinerary\").hasTransit(query.mode)\n ? \"Transit\"\n : require(\"./itinerary\").toSentenceCase(query.mode);\n return `${mode} from ${from} to ${to}`;\n}\n\nexport function getTimeZoneOffset(itinerary) {\n logDeprecationWarning(\"getTimeZoneOffset\");\n\n if (!itinerary.legs || !itinerary.legs.length) return 0;\n\n // Determine if there is a DST offset between now and the itinerary start date\n const dstOffset =\n new Date(itinerary.startTime).getTimezoneOffset() -\n new Date().getTimezoneOffset();\n\n return (\n itinerary.legs[0].agencyTimeZoneOffset +\n (new Date().getTimezoneOffset() + dstOffset) * 60000\n );\n}\n"],"file":"deprecated.js"}
@@ -1,23 +0,0 @@
1
- import { TimeOptions } from "@opentripplanner/types";
2
- /**
3
- * Formats a time value for display in narrative
4
- * TODO: internationalization/timezone
5
- * @param {number} ms epoch time value in milliseconds
6
- * @returns {string} formatted text representation
7
- */
8
- export declare function formatTime(ms: number, options: TimeOptions): string;
9
- /**
10
- * Formats an elapsed time duration for display in narrative.
11
- * TODO: internationalization
12
- * @param {number} seconds duration in seconds
13
- * @returns {string} formatted text representation
14
- */
15
- export declare function formatDuration(seconds: number, region: string): string;
16
- /**
17
- * Formats an elapsed time in seconds, minutes, hours duration for display in narrative
18
- * @param {number} seconds duration in seconds
19
- * @param {object} region an object that allows internationalization of the time
20
- * @returns {string} formatted text representation
21
- */
22
- export declare function formatDurationWithSeconds(seconds: number, region: string): string;
23
- //# sourceMappingURL=deprecated-with-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated-with-types.d.ts","sourceRoot":"","sources":["../src/deprecated-with-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAYrD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAOnE;AAED;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOtE;AAED;;;;;GAKG;AAEH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAOR"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.formatTime = formatTime;
7
- exports.formatDuration = formatDuration;
8
- exports.formatDurationWithSeconds = formatDurationWithSeconds;
9
-
10
- var _dateFns = require("date-fns");
11
-
12
- var _deprecated = require("./deprecated");
13
-
14
- var _time = require("./time");
15
-
16
- /* eslint-disable import/no-cycle */
17
- // time.ts
18
-
19
- /**
20
- * Formats a time value for display in narrative
21
- * TODO: internationalization/timezone
22
- * @param {number} ms epoch time value in milliseconds
23
- * @returns {string} formatted text representation
24
- */
25
- function formatTime(ms, options) {
26
- (0, _deprecated.logDeprecationWarning)("formatTime", "formatjs");
27
- return (0, _dateFns.format)((0, _time.offsetTime)(ms, options), (options === null || options === void 0 ? void 0 : options.format) || _time.OTP_API_TIME_FORMAT);
28
- }
29
- /**
30
- * Formats an elapsed time duration for display in narrative.
31
- * TODO: internationalization
32
- * @param {number} seconds duration in seconds
33
- * @returns {string} formatted text representation
34
- */
35
- // TS TODO: region as type?
36
-
37
-
38
- function formatDuration(seconds, region) {
39
- (0, _deprecated.logDeprecationWarning)("formatDuration", "formatjs");
40
- return (0, _time.formatDurationLikeMoment)(seconds, false, {
41
- enabled: true,
42
- code: region
43
- });
44
- }
45
- /**
46
- * Formats an elapsed time in seconds, minutes, hours duration for display in narrative
47
- * @param {number} seconds duration in seconds
48
- * @param {object} region an object that allows internationalization of the time
49
- * @returns {string} formatted text representation
50
- */
51
- // TS TODO: region as type?
52
-
53
-
54
- function formatDurationWithSeconds(seconds, region) {
55
- (0, _deprecated.logDeprecationWarning)("formatDurationWithSeconds", "formatjs");
56
- return (0, _time.formatDurationLikeMoment)(seconds, true, {
57
- enabled: true,
58
- code: region
59
- });
60
- }
61
- //# sourceMappingURL=deprecated-with-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/deprecated-with-types.ts"],"names":["formatTime","ms","options","format","OTP_API_TIME_FORMAT","formatDuration","seconds","region","enabled","code","formatDurationWithSeconds"],"mappings":";;;;;;;;;AAEA;;AAEA;;AACA;;AALA;AAWA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAT,CAAoBC,EAApB,EAAgCC,OAAhC,EAA8D;AACnE,yCAAsB,YAAtB,EAAoC,UAApC;AAEA,SAAO,qBACL,sBAAWD,EAAX,EAAeC,OAAf,CADK,EAEL,CAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,MAAT,KAAmBC,yBAFd,CAAP;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAwBC,OAAxB,EAAyCC,MAAzC,EAAiE;AACtE,yCAAsB,gBAAtB,EAAwC,UAAxC;AAEA,SAAO,oCAAyBD,OAAzB,EAAkC,KAAlC,EAAyC;AAC9CE,IAAAA,OAAO,EAAE,IADqC;AAE9CC,IAAAA,IAAI,EAAEF;AAFwC,GAAzC,CAAP;AAID;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,yBAAT,CACLJ,OADK,EAELC,MAFK,EAGG;AACR,yCAAsB,2BAAtB,EAAmD,UAAnD;AAEA,SAAO,oCAAyBD,OAAzB,EAAkC,IAAlC,EAAwC;AAC7CE,IAAAA,OAAO,EAAE,IADoC;AAE7CC,IAAAA,IAAI,EAAEF;AAFuC,GAAxC,CAAP;AAID","sourcesContent":["/* eslint-disable import/no-cycle */\nimport { TimeOptions } from \"@opentripplanner/types\";\nimport { format } from \"date-fns\";\n\nimport { logDeprecationWarning } from \"./deprecated\";\nimport {\n formatDurationLikeMoment,\n offsetTime,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n// time.ts\n\n/**\n * Formats a time value for display in narrative\n * TODO: internationalization/timezone\n * @param {number} ms epoch time value in milliseconds\n * @returns {string} formatted text representation\n */\nexport function formatTime(ms: number, options: TimeOptions): string {\n logDeprecationWarning(\"formatTime\", \"formatjs\");\n\n return format(\n offsetTime(ms, options),\n options?.format || OTP_API_TIME_FORMAT\n );\n}\n\n/**\n * Formats an elapsed time duration for display in narrative.\n * TODO: internationalization\n * @param {number} seconds duration in seconds\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDuration(seconds: number, region: string): string {\n logDeprecationWarning(\"formatDuration\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, false, {\n enabled: true,\n code: region\n });\n}\n\n/**\n * Formats an elapsed time in seconds, minutes, hours duration for display in narrative\n * @param {number} seconds duration in seconds\n * @param {object} region an object that allows internationalization of the time\n * @returns {string} formatted text representation\n */\n// TS TODO: region as type?\nexport function formatDurationWithSeconds(\n seconds: number,\n region: string\n): string {\n logDeprecationWarning(\"formatDurationWithSeconds\", \"formatjs\");\n\n return formatDurationLikeMoment(seconds, true, {\n enabled: true,\n code: region\n });\n}\n"],"file":"deprecated-with-types.js"}