@opentripplanner/core-utils 12.0.2 → 13.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/esm/graphql.d.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/itinerary.js +78 -114
- package/esm/itinerary.js.map +1 -1
- package/esm/map.js +3 -3
- package/esm/map.js.map +1 -1
- package/esm/otpSchema.json +12 -0
- package/esm/profile.js +18 -19
- package/esm/profile.js.map +1 -1
- package/esm/query-gen.js +35 -45
- package/esm/query-gen.js.map +1 -1
- package/esm/query.js +139 -191
- package/esm/query.js.map +1 -1
- package/esm/route.js +74 -97
- package/esm/route.js.map +1 -1
- package/esm/storage.js +10 -7
- package/esm/storage.js.map +1 -1
- package/esm/suspense.js +1 -3
- package/esm/suspense.js.map +1 -1
- package/esm/time.js +13 -17
- package/esm/time.js.map +1 -1
- package/esm/ui.js +0 -5
- package/esm/ui.js.map +1 -1
- package/lib/graphql.d.js.map +1 -1
- package/lib/index.js +3 -19
- package/lib/index.js.map +1 -1
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +151 -247
- package/lib/itinerary.js.map +1 -1
- package/lib/map.d.ts +1 -1
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +9 -20
- package/lib/map.js.map +1 -1
- package/lib/otpSchema.json +12 -0
- package/lib/profile.js +19 -21
- package/lib/profile.js.map +1 -1
- package/lib/query-gen.d.ts +4 -4
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +35 -47
- package/lib/query-gen.js.map +1 -1
- package/lib/query-params.jsx +893 -0
- package/lib/query.js +72 -122
- package/lib/query.js.map +1 -1
- package/lib/route.js +73 -101
- package/lib/route.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js +12 -13
- package/lib/storage.js.map +1 -1
- package/lib/suspense.d.ts +1 -1
- package/lib/suspense.d.ts.map +1 -1
- package/lib/suspense.js +3 -9
- package/lib/suspense.js.map +1 -1
- package/lib/time.js +21 -44
- package/lib/time.js.map +1 -1
- package/lib/ui.js +1 -8
- package/lib/ui.js.map +1 -1
- package/package.json +7 -8
- package/src/core-utils.story.tsx +1 -1
- package/src/itinerary.ts +2 -0
- package/src/otpSchema.json +12 -0
- package/src/profile.js +1 -1
- package/src/query-gen.ts +1 -1
- package/src/query-params.jsx +893 -0
- package/src/query.js +4 -1
- package/src/storage.ts +9 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/esm/query-params.js +0 -786
- package/esm/query-params.js.map +0 -1
- package/lib/query-params.js +0 -756
- package/lib/query-params.js.map +0 -1
- /package/{src/query-params.js → esm/query-params.jsx} +0 -0
package/lib/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 if (window) {\n window.localStorage.setItem(\n `${STORAGE_PREFIX}.${key}`,\n JSON.stringify(object)\n );\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 if (window) {\n window.localStorage.removeItem(`${STORAGE_PREFIX}.${key}`);\n }\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;EAC5D,IAAIC,MAAM,EAAE;IACVA,MAAM,CAACC,YAAY,CAACC,OAAO,CACzB,GAAGN,cAAc,IAAIE,GAAG,EAAE,EAC1BK,IAAI,CAACC,SAAS,CAACL,MAAM,CACvB,CAAC;EACH;AACF;;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;EAC5C,IAAIE,MAAM,EAAE;IACVA,MAAM,CAACC,YAAY,CAACY,UAAU,CAAC,GAAGjB,cAAc,IAAIE,GAAG,EAAE,CAAC;EAC5D;AACF;;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/suspense.d.ts
CHANGED
package/lib/suspense.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../src/suspense.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../src/suspense.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjE,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,YAAY,2BAA4B,KAAK,KAAG,YASrD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/lib/suspense.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
10
|
const SafeSuspense = ({
|
|
15
11
|
children,
|
|
16
12
|
fallback
|
|
@@ -20,7 +16,5 @@ const SafeSuspense = ({
|
|
|
20
16
|
fallback: fallback
|
|
21
17
|
}, children);
|
|
22
18
|
};
|
|
23
|
-
|
|
24
|
-
var _default = SafeSuspense;
|
|
25
|
-
exports.default = _default;
|
|
19
|
+
var _default = exports.default = SafeSuspense;
|
|
26
20
|
//# sourceMappingURL=suspense.js.map
|
package/lib/suspense.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"suspense.js","names":["_react","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SafeSuspense","children","fallback","IS_TEST_RUNNER","window","navigator","userAgent","match","createElement","Fragment","Suspense","_default","exports"],"sources":["../src/suspense.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode, Suspense } from \"react\";\n\ntype Props = {\n children: ReactNode;\n fallback: ReactNode;\n};\n\nconst SafeSuspense = ({ children, fallback }: Props): ReactElement => {\n const IS_TEST_RUNNER = window.navigator.userAgent.match(\n /StorybookTestRunner/\n );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CAAA;AAOjE,MAAMW,YAAY,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAgB,CAAC,KAAmB;EACpE,MAAMC,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACC,SAAS,CAACC,KAAK,CACrD,qBACF,CAAC;EACD,OAAOJ,cAAc,gBACnB1B,MAAA,CAAAS,OAAA,CAAAsB,aAAA,CAAA/B,MAAA,CAAAS,OAAA,CAAAuB,QAAA,QAAGP,QAAW,CAAC,gBAEfzB,MAAA,CAAAS,OAAA,CAAAsB,aAAA,CAAC/B,MAAA,CAAAiC,QAAQ;IAACR,QAAQ,EAAEA;EAAS,GAAED,QAAmB,CACnD;AACH,CAAC;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEac,YAAY","ignoreList":[]}
|
package/lib/time.js
CHANGED
|
@@ -3,34 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.OTP_API_TIME_FORMAT = exports.OTP_API_DATE_FORMAT = void 0;
|
|
7
|
+
exports.formatSecondsAfterMidnight = formatSecondsAfterMidnight;
|
|
8
|
+
exports.getCurrentDate = getCurrentDate;
|
|
9
|
+
exports.getCurrentTime = getCurrentTime;
|
|
8
10
|
exports.getDateFormat = getDateFormat;
|
|
9
11
|
exports.getLongDateFormat = getLongDateFormat;
|
|
10
|
-
exports.
|
|
11
|
-
exports.formatSecondsAfterMidnight = formatSecondsAfterMidnight;
|
|
12
|
+
exports.getTimeFormat = getTimeFormat;
|
|
12
13
|
exports.getUserTimezone = getUserTimezone;
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.OTP_API_TIME_FORMAT = exports.OTP_API_DATE_FORMAT = void 0;
|
|
16
|
-
|
|
14
|
+
exports.offsetTime = offsetTime;
|
|
15
|
+
exports.toHoursMinutesSeconds = toHoursMinutesSeconds;
|
|
17
16
|
var _dateFns = require("date-fns");
|
|
18
|
-
|
|
19
17
|
var _dateFnsTz = require("date-fns-tz");
|
|
20
|
-
|
|
21
18
|
// Date/time formats (per date-fns) when sending/receiving date from OTP
|
|
22
19
|
// regardless of whatever the user has configured as the display format.
|
|
23
|
-
const OTP_API_DATE_FORMAT = "yyyy-MM-dd";
|
|
24
|
-
exports.
|
|
25
|
-
|
|
20
|
+
const OTP_API_DATE_FORMAT = exports.OTP_API_DATE_FORMAT = "yyyy-MM-dd";
|
|
21
|
+
const OTP_API_TIME_FORMAT = exports.OTP_API_TIME_FORMAT = "HH:mm";
|
|
22
|
+
|
|
26
23
|
/**
|
|
27
24
|
* Breaks up a duration in seconds into hours, minutes, and seconds.
|
|
28
25
|
* @param {number} seconds The number of seconds to break up
|
|
29
26
|
* @returns an object with fields with the corresponding, hours, minutes, seconds.
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
exports.OTP_API_TIME_FORMAT = OTP_API_TIME_FORMAT;
|
|
33
|
-
|
|
34
28
|
function toHoursMinutesSeconds(seconds) {
|
|
35
29
|
return {
|
|
36
30
|
hours: Math.floor(seconds / 3600),
|
|
@@ -38,82 +32,65 @@ function toHoursMinutesSeconds(seconds) {
|
|
|
38
32
|
seconds: seconds % 60
|
|
39
33
|
};
|
|
40
34
|
}
|
|
35
|
+
|
|
41
36
|
/**
|
|
42
37
|
* @param {[type]} config the OTP config object found in store
|
|
43
38
|
* @return {string} the config-defined time formatter or HH:mm (24-hr time)
|
|
44
39
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
40
|
function getTimeFormat(config) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return (config === null || config === void 0 ? void 0 : (_config$dateTime = config.dateTime) === null || _config$dateTime === void 0 ? void 0 : _config$dateTime.timeFormat) || OTP_API_TIME_FORMAT;
|
|
41
|
+
return config?.dateTime?.timeFormat || OTP_API_TIME_FORMAT;
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
function getDateFormat(config) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return (config === null || config === void 0 ? void 0 : (_config$dateTime2 = config.dateTime) === null || _config$dateTime2 === void 0 ? void 0 : _config$dateTime2.dateFormat) || OTP_API_DATE_FORMAT;
|
|
44
|
+
return config?.dateTime?.dateFormat || OTP_API_DATE_FORMAT;
|
|
57
45
|
}
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
|
|
60
46
|
|
|
47
|
+
/** @deprecated */
|
|
61
48
|
function getLongDateFormat(config) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return (config === null || config === void 0 ? void 0 : (_config$dateTime3 = config.dateTime) === null || _config$dateTime3 === void 0 ? void 0 : _config$dateTime3.longDateFormat) || "D MMMM YYYY";
|
|
49
|
+
return config?.dateTime?.longDateFormat || "D MMMM YYYY";
|
|
65
50
|
}
|
|
66
51
|
/**
|
|
67
52
|
* Offsets a time according to the provided time options
|
|
68
53
|
* and returns the result.
|
|
69
54
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
55
|
function offsetTime(ms, options) {
|
|
73
|
-
return ms + (
|
|
56
|
+
return ms + (options?.offset || 0);
|
|
74
57
|
}
|
|
58
|
+
|
|
75
59
|
/**
|
|
76
60
|
* Formats a seconds after midnight value for display in narrative
|
|
77
61
|
* @param {number} seconds time since midnight in seconds
|
|
78
62
|
* @param {string} timeFormat A valid date-fns time format
|
|
79
63
|
* @return {string} formatted text representation
|
|
80
64
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
65
|
function formatSecondsAfterMidnight(seconds, timeFormat) {
|
|
84
66
|
const time = (0, _dateFns.add)((0, _dateFns.startOfDay)(new Date()), {
|
|
85
67
|
seconds
|
|
86
68
|
});
|
|
87
69
|
return (0, _dateFns.format)(time, timeFormat);
|
|
88
70
|
}
|
|
71
|
+
|
|
89
72
|
/**
|
|
90
73
|
* Uses Intl.DateTimeFormat() api to get the user's time zone. In a test
|
|
91
74
|
* environment, pulls timezone information from an env variable. Default to
|
|
92
75
|
* GMT+0 if the Intl API is unavailable.
|
|
93
76
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
77
|
function getUserTimezone(fallbackTimezone = "Etc/Greenwich") {
|
|
97
|
-
var _Intl;
|
|
98
|
-
|
|
99
78
|
if (process.env.NODE_ENV === "test") return process.env.TZ;
|
|
100
|
-
return
|
|
79
|
+
return Intl?.DateTimeFormat().resolvedOptions().timeZone || fallbackTimezone;
|
|
101
80
|
}
|
|
81
|
+
|
|
102
82
|
/**
|
|
103
83
|
* Formats current time for use in OTP query
|
|
104
84
|
* The conversion to the user's timezone is needed for testing purposes.
|
|
105
85
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
86
|
function getCurrentTime(timezone = getUserTimezone()) {
|
|
109
87
|
return (0, _dateFns.format)((0, _dateFnsTz.utcToZonedTime)(Date.now(), timezone), OTP_API_TIME_FORMAT);
|
|
110
88
|
}
|
|
89
|
+
|
|
111
90
|
/**
|
|
112
91
|
* Formats current date for use in OTP query
|
|
113
92
|
* The conversion to the user's timezone is needed for testing purposes.
|
|
114
93
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
94
|
function getCurrentDate(timezone = getUserTimezone()) {
|
|
118
95
|
return (0, _dateFns.format)((0, _dateFnsTz.utcToZonedTime)(Date.now(), timezone), OTP_API_DATE_FORMAT);
|
|
119
96
|
}
|
package/lib/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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","getTimeFormat","config","dateTime","timeFormat","getDateFormat","dateFormat","getLongDateFormat","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 * @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,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;AACO,SAASK,aAAaA,CAACC,MAAc,EAAU;EACpD,OAAOA,MAAM,EAAEC,QAAQ,EAAEC,UAAU,IAAIV,mBAAmB;AAC5D;AAEO,SAASW,aAAaA,CAACH,MAAc,EAAU;EACpD,OAAOA,MAAM,EAAEC,QAAQ,EAAEG,UAAU,IAAId,mBAAmB;AAC5D;;AAEA;AACO,SAASe,iBAAiBA,CAACL,MAAc,EAAU;EACxD,OAAOA,MAAM,EAAEC,QAAQ,EAAEK,cAAc,IAAI,aAAa;AAC1D;AACA;AAC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
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isMobile = isMobile;
|
|
7
6
|
exports.enableScrollForSelector = enableScrollForSelector;
|
|
8
|
-
|
|
7
|
+
exports.isMobile = isMobile;
|
|
9
8
|
function isMobile() {
|
|
10
9
|
// TODO: consider using 3rd-party library?
|
|
11
10
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
@@ -16,8 +15,6 @@ function isMobile() {
|
|
|
16
15
|
* and intended to fix issues with iOS elastic scrolling, e.g.,
|
|
17
16
|
* https://github.com/conveyal/trimet-mod-otp/issues/92.
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
18
|
function enableScrollForSelector(selector) {
|
|
22
19
|
const overlay = document.querySelector(selector);
|
|
23
20
|
let clientY = null; // remember Y position on touch start
|
|
@@ -26,21 +23,17 @@ function enableScrollForSelector(selector) {
|
|
|
26
23
|
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
|
|
27
24
|
return overlay.scrollHeight - overlay.scrollTop <= overlay.clientHeight;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
function disableRubberBand(event) {
|
|
31
27
|
const clientYDelta = event.targetTouches[0].clientY - clientY;
|
|
32
|
-
|
|
33
28
|
if (overlay.scrollTop === 0 && clientYDelta > 0) {
|
|
34
29
|
// element is at the top of its scroll
|
|
35
30
|
event.preventDefault();
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
if (isOverlayTotallyScrolled() && clientYDelta < 0) {
|
|
39
33
|
// element is at the top of its scroll
|
|
40
34
|
event.preventDefault();
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
overlay.addEventListener("touchstart", function (event) {
|
|
45
38
|
if (event.targetTouches.length === 1) {
|
|
46
39
|
// detect single touch
|
package/lib/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/core-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.2",
|
|
4
4
|
"description": "Core functionality that is shared among numerous UI components",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=13"
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@conveyal/lonlat": "^1.4.1",
|
|
16
16
|
"@mapbox/polyline": "^1.1.0",
|
|
17
|
-
"@opentripplanner/geocoder": "^3.0.2",
|
|
18
17
|
"@styled-icons/foundation": "^10.34.0",
|
|
19
18
|
"@turf/along": "^6.0.1",
|
|
20
19
|
"chroma-js": "^2.4.2",
|
|
@@ -23,14 +22,14 @@
|
|
|
23
22
|
"graphql": "^16.6.0",
|
|
24
23
|
"lodash.clonedeep": "^4.5.0",
|
|
25
24
|
"lodash.isequal": "^4.5.0",
|
|
26
|
-
"qs": "^6.9.1"
|
|
25
|
+
"qs": "^6.9.1",
|
|
26
|
+
"@opentripplanner/geocoder": "4.0.0-alpha.3"
|
|
27
27
|
},
|
|
28
28
|
"gitHead": "0af1b7cda60bd4252b219dcf893e01c2acb2ed5d",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@opentripplanner/types": "7.0.0-alpha.16"
|
|
31
|
+
},
|
|
29
32
|
"scripts": {
|
|
30
33
|
"tsc": "tsc"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@opentripplanner/types": "^6.5.2",
|
|
34
|
-
"@types/chroma-js": "^2.1.4"
|
|
35
34
|
}
|
|
36
|
-
}
|
|
35
|
+
}
|
package/src/core-utils.story.tsx
CHANGED
|
@@ -50,7 +50,7 @@ export const RouteColorTester = (): JSX.Element => {
|
|
|
50
50
|
</>
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
|
-
// Disable color contrast checking for the uncorrected color pairs
|
|
53
|
+
// Disable color contrast checking for the uncorrected color pairs.
|
|
54
54
|
RouteColorTester.parameters = {
|
|
55
55
|
a11y: { config: { rules: [{ id: "color-contrast", reviewOnFail: true }] } },
|
|
56
56
|
storyshots: { disable: true }
|
package/src/itinerary.ts
CHANGED
package/src/otpSchema.json
CHANGED
|
@@ -9671,6 +9671,18 @@
|
|
|
9671
9671
|
"isDeprecated": false,
|
|
9672
9672
|
"deprecationReason": null
|
|
9673
9673
|
},
|
|
9674
|
+
{
|
|
9675
|
+
"name": "stopPosition",
|
|
9676
|
+
"description": "The sequence of the stop in the pattern. This is not required to start from 0 or be consecutive - any\nincreasing integer sequence along the stops is valid.\n\nThe purpose of this field is to identify the stop within the pattern so it can be cross-referenced\nbetween it and the itinerary. It is safe to cross-reference when done quickly, i.e. within seconds.\nHowever, it should be noted that realtime updates can change the values, so don't store it for\nlonger amounts of time.\n\nDepending on the source data, this might not be the GTFS `stop_sequence` but another value, perhaps\neven generated.",
|
|
9677
|
+
"args": [],
|
|
9678
|
+
"type": {
|
|
9679
|
+
"kind": "SCALAR",
|
|
9680
|
+
"name": "Int",
|
|
9681
|
+
"ofType": null
|
|
9682
|
+
},
|
|
9683
|
+
"isDeprecated": false,
|
|
9684
|
+
"deprecationReason": null
|
|
9685
|
+
},
|
|
9674
9686
|
{
|
|
9675
9687
|
"name": "scheduledArrival",
|
|
9676
9688
|
"description": "Scheduled arrival time. Format: seconds since midnight of the departure date",
|
package/src/profile.js
CHANGED
package/src/query-gen.ts
CHANGED
|
@@ -58,7 +58,7 @@ export function extractAdditionalModes(
|
|
|
58
58
|
return prev;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// In checkboxes, mode must be enabled and have a transport mode in it
|
|
61
|
+
// In checkboxes (or submode checkboxes), mode must be enabled and have a transport mode in it
|
|
62
62
|
if (
|
|
63
63
|
(cur.type === "CHECKBOX" || cur.type === "SUBMODE") &&
|
|
64
64
|
cur.addTransportMode &&
|