transit-departures-widget 2.3.0 → 2.4.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.4.0] - 2024-07-03
9
+
10
+ ## Updated
11
+
12
+ - Store routes and stops in separate JSON file
13
+ - Dependency updates
14
+
15
+ ## Fixed
16
+
17
+ - Copy img folder
18
+
8
19
  ## [2.3.0] - 2024-04-22
9
20
 
10
21
  ## Fixed
package/app/index.js CHANGED
@@ -10,6 +10,7 @@ import logger from 'morgan'
10
10
  import {
11
11
  setDefaultConfig,
12
12
  generateTransitDeparturesWidgetHtml,
13
+ generateTransitDeparturesWidgetJson,
13
14
  } from '../lib/utils.js'
14
15
 
15
16
  const { argv } = yargs(process.argv).option('c', {
@@ -57,6 +58,27 @@ router.get('/', async (request, response, next) => {
57
58
  }
58
59
  })
59
60
 
61
+ /*
62
+ * Provide data
63
+ */
64
+ router.get('/data/routes.json', async (request, response, next) => {
65
+ try {
66
+ const { routes } = await generateTransitDeparturesWidgetJson(config)
67
+ response.json(routes)
68
+ } catch (error) {
69
+ next(error)
70
+ }
71
+ })
72
+
73
+ router.get('/data/stops.json', async (request, response, next) => {
74
+ try {
75
+ const { stops } = await generateTransitDeparturesWidgetJson(config)
76
+ response.json(stops)
77
+ } catch (error) {
78
+ next(error)
79
+ }
80
+ })
81
+
60
82
  app.set('views', path.join(fileURLToPath(import.meta.url), '../../views'))
61
83
  app.set('view engine', 'pug')
62
84
 
@@ -1,18 +1,18 @@
1
- <svg width="375" height="375" viewBox="0 0 375 375" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path fill-rule="evenodd" clip-rule="evenodd" d="M328.142 240.458V119.026C328.142 106.956 321.684 95.822 311.162 89.7868L205.951 29.0187C195.43 22.9836 182.617 22.9836 172.096 29.0187L66.8843 89.6828C56.3632 95.718 49.9046 106.852 49.9046 119.026V240.458C49.9046 252.529 56.3632 263.663 66.8843 269.698L172.096 330.362C182.617 336.397 195.43 336.397 205.951 330.362L311.267 269.594C321.684 263.663 328.142 252.529 328.142 240.458Z" fill="#FF8038"/>
3
- <path fill-rule="evenodd" clip-rule="evenodd" d="M189.075 316.21C186.471 316.21 183.867 315.482 181.471 314.233L76.2596 253.465C71.5719 250.76 68.6552 245.765 68.6552 240.354V119.026C68.6552 113.615 71.5719 108.621 76.1554 105.915L181.471 45.1473C183.763 43.7945 186.367 43.1702 189.075 43.1702C191.784 43.1702 194.284 43.8986 196.68 45.1473L301.995 105.915C306.683 108.621 309.6 113.615 309.6 119.026V240.458C309.6 245.869 306.683 250.864 301.995 253.569L196.68 314.337C194.284 315.482 191.68 316.21 189.075 316.21Z" fill="#9CFC61"/>
4
- <mask id="mask0_4_2" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="59" y="157" width="259" height="61">
5
- <path d="M59.6457 157.301H317.646V217.301H59.6457V157.301Z" fill="white"/>
1
+ <svg width="280" height="311" viewBox="0 0 280 311" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M279.142 216.458V95.0263C279.142 82.9559 272.684 71.822 262.162 65.7868L156.951 5.01874C146.43 -1.01645 133.617 -1.01645 123.096 5.01874L17.8843 65.6828C7.36316 71.718 0.904633 82.8518 0.904633 95.0263V216.458C0.904633 228.529 7.36316 239.663 17.8843 245.698L123.096 306.362C133.617 312.397 146.43 312.397 156.951 306.362L262.267 245.594C272.684 239.663 279.142 228.529 279.142 216.458Z" fill="#FF8038"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M140.075 292.21C137.471 292.21 134.867 291.482 132.471 290.233L27.2596 229.465C22.5719 226.76 19.6552 221.765 19.6552 216.354V95.0263C19.6552 89.6154 22.5719 84.6208 27.1554 81.9154L132.471 21.1473C134.763 19.7945 137.367 19.1702 140.075 19.1702C142.784 19.1702 145.284 19.8986 147.68 21.1473L252.995 81.9154C257.683 84.6208 260.6 89.6154 260.6 95.0263V216.458C260.6 221.869 257.683 226.864 252.995 229.569L147.68 290.337C145.284 291.482 142.68 292.21 140.075 292.21Z" fill="#9CFC61"/>
4
+ <mask id="mask0_4_3" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="10" y="133" width="259" height="61">
5
+ <path d="M10.6457 133.301H268.646V193.301H10.6457V133.301Z" fill="white"/>
6
6
  </mask>
7
- <g mask="url(#mask0_4_2)">
8
- <path fill-rule="evenodd" clip-rule="evenodd" d="M59.6457 58.2317H317.646V316.232H59.6457V58.2317Z" fill="#FF8038"/>
7
+ <g mask="url(#mask0_4_3)">
8
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10.6457 34.2317H268.646V292.232H10.6457V34.2317Z" fill="#FF8038"/>
9
9
  </g>
10
- <mask id="mask1_4_2" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="171" y="268" width="36" height="35">
11
- <path d="M171 268H206.139V302.037H171V268Z" fill="white"/>
10
+ <mask id="mask1_4_3" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="122" y="244" width="36" height="35">
11
+ <path d="M122 244H157.139V278.037H122V244Z" fill="white"/>
12
12
  </mask>
13
- <g mask="url(#mask1_4_2)">
14
- <path fill-rule="evenodd" clip-rule="evenodd" d="M193.917 279.167L206.139 280.912L197.335 289.657L199.471 301.948L188.523 296.186L177.621 302.037L179.658 289.73L170.785 281.056L182.993 279.212L188.41 268L193.917 279.167Z" fill="white"/>
13
+ <g mask="url(#mask1_4_3)">
14
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M144.917 255.167L157.139 256.912L148.335 265.657L150.471 277.948L139.523 272.186L128.621 278.037L130.658 265.73L121.785 257.056L133.993 255.212L139.41 244L144.917 255.167Z" fill="white"/>
15
15
  </g>
16
- <path fill-rule="evenodd" clip-rule="evenodd" d="M227.87 89.8803C227.87 88.6713 227.312 87.7413 226.289 87.0903C226.103 86.9973 225.824 86.8113 225.638 86.7183C225.638 83.6494 225.545 80.4875 225.359 77.3256C224.987 70.0718 221.174 66.5378 214.013 66.4448C207.782 66.4448 201.551 66.4448 195.32 66.4448C185.183 66.4448 175.139 66.3518 165.002 66.5378C155.702 66.7238 151.982 70.6297 151.982 79.9295C151.982 82.1614 151.982 84.3934 151.982 86.7183C151.424 86.9043 150.959 87.3693 150.587 87.8343C149.936 88.3923 149.75 89.2293 149.75 90.1592C149.75 94.4371 149.75 98.715 149.75 103.086C149.75 104.388 150.215 105.411 151.331 106.062C151.61 106.248 151.796 106.341 152.075 106.434C152.075 115.641 152.075 124.754 152.075 133.961C152.075 135.263 151.889 136.751 152.54 137.867C153.935 140.099 153.656 142.517 153.749 144.935C153.842 147.911 155.795 149.957 158.771 150.05C160.91 150.143 163.049 150.143 165.188 150.05C168.257 149.957 170.21 148.19 170.303 145.121C170.396 143.819 170.582 143.354 172.07 143.354C183.23 143.447 194.483 143.447 205.643 143.354C207.038 143.354 207.41 143.726 207.41 145.121C207.503 148.376 209.456 150.05 212.711 150.05C214.571 150.05 216.431 150.05 218.291 150.05C222.104 150.05 223.964 148.097 224.057 144.284C224.057 142.796 223.592 141.122 224.429 139.727C225.452 137.867 225.731 136.007 225.731 133.961C225.731 125.312 225.731 116.664 225.731 106.434C226.382 106.341 226.94 105.783 227.312 105.225C227.777 104.667 227.963 103.923 227.963 103.179C227.87 98.808 227.87 94.3441 227.87 89.8803ZM173.279 73.1407C178.859 73.1407 184.439 73.1407 189.926 73.1407C195.32 73.1407 200.714 73.1407 206.201 73.1407C208.619 73.1407 208.898 73.5127 208.991 76.3026C208.991 79.3715 208.712 79.8365 206.387 79.8365C195.32 79.8365 184.253 79.8365 173.279 79.8365C170.861 79.8365 170.396 79.2785 170.396 76.4886C170.303 73.6987 170.768 73.1407 173.279 73.1407ZM166.304 135.077C163.049 135.077 160.352 132.38 160.352 129.125C160.445 125.963 163.142 123.359 166.211 123.359C169.466 123.359 171.884 125.87 171.884 129.218C171.977 132.473 169.466 135.077 166.304 135.077ZM165.467 114.99C161.933 114.99 160.352 113.316 160.352 109.689C160.352 103.179 160.352 96.6691 160.352 90.1592C160.352 86.5323 161.84 85.0444 165.467 85.0444C173.279 85.0444 180.998 85.0444 188.81 85.0444C196.436 85.0444 204.062 85.0444 211.688 85.0444C215.78 85.0444 217.175 86.4393 217.175 90.4382C217.175 96.6691 217.175 102.9 217.175 109.131C217.175 112.851 215.129 114.897 211.409 114.99C196.157 114.99 180.812 114.99 165.467 114.99ZM211.409 135.077C208.247 135.077 205.736 132.566 205.643 129.311C205.643 125.963 208.061 123.452 211.316 123.452C214.571 123.452 217.268 126.149 217.268 129.404C217.175 132.38 214.571 135.077 211.409 135.077Z" fill="white"/>
17
- <path d="M71.6277 177.8H68.5227V175.1H77.7027V177.8H74.5977V194H71.6277V177.8ZM79.1407 175.1H83.5417C85.0717 175.1 86.1877 175.46 86.8897 176.18C87.5917 176.882 87.9427 177.971 87.9427 179.447V180.608C87.9427 182.57 87.2947 183.812 85.9987 184.334V184.388C86.7187 184.604 87.2227 185.045 87.5107 185.711C87.8167 186.377 87.9697 187.268 87.9697 188.384V191.705C87.9697 192.245 87.9877 192.686 88.0237 193.028C88.0597 193.352 88.1497 193.676 88.2937 194H85.2697C85.1617 193.694 85.0897 193.406 85.0537 193.136C85.0177 192.866 84.9997 192.38 84.9997 191.678V188.222C84.9997 187.358 84.8557 186.755 84.5677 186.413C84.2977 186.071 83.8207 185.9 83.1367 185.9H82.1107V194H79.1407V175.1ZM83.1907 183.2C83.7847 183.2 84.2257 183.047 84.5137 182.741C84.8197 182.435 84.9727 181.922 84.9727 181.202V179.744C84.9727 179.06 84.8467 178.565 84.5947 178.259C84.3607 177.953 83.9827 177.8 83.4607 177.8H82.1107V183.2H83.1907ZM92.3253 175.1H96.3483L99.4263 194H96.4563L95.9163 190.247V190.301H92.5413L92.0013 194H89.2473L92.3253 175.1ZM95.5653 187.736L94.2423 178.394H94.1883L92.8923 187.736H95.5653ZM100.867 175.1H104.593L107.482 186.413H107.536V175.1H110.182V194H107.131L103.567 180.203H103.513V194H100.867V175.1ZM116.251 194.27C114.811 194.27 113.722 193.865 112.984 193.055C112.246 192.227 111.877 191.048 111.877 189.518V188.438H114.685V189.734C114.685 190.958 115.198 191.57 116.224 191.57C116.728 191.57 117.106 191.426 117.358 191.138C117.628 190.832 117.763 190.346 117.763 189.68C117.763 188.888 117.583 188.195 117.223 187.601C116.863 186.989 116.197 186.26 115.225 185.414C114.001 184.334 113.146 183.362 112.66 182.498C112.174 181.616 111.931 180.626 111.931 179.528C111.931 178.034 112.309 176.882 113.065 176.072C113.821 175.244 114.919 174.83 116.359 174.83C117.781 174.83 118.852 175.244 119.572 176.072C120.31 176.882 120.679 178.052 120.679 179.582V180.365H117.871V179.393C117.871 178.745 117.745 178.277 117.493 177.989C117.241 177.683 116.872 177.53 116.386 177.53C115.396 177.53 114.901 178.133 114.901 179.339C114.901 180.023 115.081 180.662 115.441 181.256C115.819 181.85 116.494 182.57 117.466 183.416C118.708 184.496 119.563 185.477 120.031 186.359C120.499 187.241 120.733 188.276 120.733 189.464C120.733 191.012 120.346 192.2 119.572 193.028C118.816 193.856 117.709 194.27 116.251 194.27ZM122.436 175.1H125.406V194H122.436V175.1ZM129.952 177.8H126.847V175.1H136.027V177.8H132.922V194H129.952V177.8ZM141.789 175.1H146.325C147.801 175.1 148.908 175.496 149.646 176.288C150.384 177.08 150.753 178.241 150.753 179.771V189.329C150.753 190.859 150.384 192.02 149.646 192.812C148.908 193.604 147.801 194 146.325 194H141.789V175.1ZM146.271 191.3C146.757 191.3 147.126 191.156 147.378 190.868C147.648 190.58 147.783 190.112 147.783 189.464V179.636C147.783 178.988 147.648 178.52 147.378 178.232C147.126 177.944 146.757 177.8 146.271 177.8H144.759V191.3H146.271ZM152.758 175.1H160.858V177.8H155.728V182.795H159.805V185.495H155.728V191.3H160.858V194H152.758V175.1ZM162.566 175.1H166.94C168.416 175.1 169.523 175.496 170.261 176.288C170.999 177.08 171.368 178.241 171.368 179.771V181.634C171.368 183.164 170.999 184.325 170.261 185.117C169.523 185.909 168.416 186.305 166.94 186.305H165.536V194H162.566V175.1ZM166.94 183.605C167.426 183.605 167.786 183.47 168.02 183.2C168.272 182.93 168.398 182.471 168.398 181.823V179.582C168.398 178.934 168.272 178.475 168.02 178.205C167.786 177.935 167.426 177.8 166.94 177.8H165.536V183.605H166.94ZM174.327 175.1H178.35L181.428 194H178.458L177.918 190.247V190.301H174.543L174.003 194H171.249L174.327 175.1ZM177.567 187.736L176.244 178.394H176.19L174.894 187.736H177.567ZM182.869 175.1H187.27C188.8 175.1 189.916 175.46 190.618 176.18C191.32 176.882 191.671 177.971 191.671 179.447V180.608C191.671 182.57 191.023 183.812 189.727 184.334V184.388C190.447 184.604 190.951 185.045 191.239 185.711C191.545 186.377 191.698 187.268 191.698 188.384V191.705C191.698 192.245 191.716 192.686 191.752 193.028C191.788 193.352 191.878 193.676 192.022 194H188.998C188.89 193.694 188.818 193.406 188.782 193.136C188.746 192.866 188.728 192.38 188.728 191.678V188.222C188.728 187.358 188.584 186.755 188.296 186.413C188.026 186.071 187.549 185.9 186.865 185.9H185.839V194H182.869V175.1ZM186.919 183.2C187.513 183.2 187.954 183.047 188.242 182.741C188.548 182.435 188.701 181.922 188.701 181.202V179.744C188.701 179.06 188.575 178.565 188.323 178.259C188.089 177.953 187.711 177.8 187.189 177.8H185.839V183.2H186.919ZM196.028 177.8H192.923V175.1H202.103V177.8H198.998V194H196.028V177.8ZM207.861 194.27C206.421 194.27 205.323 193.865 204.567 193.055C203.811 192.227 203.433 191.048 203.433 189.518V175.1H206.403V189.734C206.403 190.382 206.529 190.85 206.781 191.138C207.051 191.426 207.429 191.57 207.915 191.57C208.401 191.57 208.77 191.426 209.022 191.138C209.292 190.85 209.427 190.382 209.427 189.734V175.1H212.289V189.518C212.289 191.048 211.911 192.227 211.155 193.055C210.399 193.865 209.301 194.27 207.861 194.27ZM214.404 175.1H218.805C220.335 175.1 221.451 175.46 222.153 176.18C222.855 176.882 223.206 177.971 223.206 179.447V180.608C223.206 182.57 222.558 183.812 221.262 184.334V184.388C221.982 184.604 222.486 185.045 222.774 185.711C223.08 186.377 223.233 187.268 223.233 188.384V191.705C223.233 192.245 223.251 192.686 223.287 193.028C223.323 193.352 223.413 193.676 223.557 194H220.533C220.425 193.694 220.353 193.406 220.317 193.136C220.281 192.866 220.263 192.38 220.263 191.678V188.222C220.263 187.358 220.119 186.755 219.831 186.413C219.561 186.071 219.084 185.9 218.4 185.9H217.374V194H214.404V175.1ZM218.454 183.2C219.048 183.2 219.489 183.047 219.777 182.741C220.083 182.435 220.236 181.922 220.236 181.202V179.744C220.236 179.06 220.11 178.565 219.858 178.259C219.624 177.953 219.246 177.8 218.724 177.8H217.374V183.2H218.454ZM225.294 175.1H233.394V177.8H228.264V182.795H232.341V185.495H228.264V191.3H233.394V194H225.294V175.1ZM239.016 194.27C237.576 194.27 236.487 193.865 235.749 193.055C235.011 192.227 234.642 191.048 234.642 189.518V188.438H237.45V189.734C237.45 190.958 237.963 191.57 238.989 191.57C239.493 191.57 239.871 191.426 240.123 191.138C240.393 190.832 240.528 190.346 240.528 189.68C240.528 188.888 240.348 188.195 239.988 187.601C239.628 186.989 238.962 186.26 237.99 185.414C236.766 184.334 235.911 183.362 235.425 182.498C234.939 181.616 234.696 180.626 234.696 179.528C234.696 178.034 235.074 176.882 235.83 176.072C236.586 175.244 237.684 174.83 239.124 174.83C240.546 174.83 241.617 175.244 242.337 176.072C243.075 176.882 243.444 178.052 243.444 179.582V180.365H240.636V179.393C240.636 178.745 240.51 178.277 240.258 177.989C240.006 177.683 239.637 177.53 239.151 177.53C238.161 177.53 237.666 178.133 237.666 179.339C237.666 180.023 237.846 180.662 238.206 181.256C238.584 181.85 239.259 182.57 240.231 183.416C241.473 184.496 242.328 185.477 242.796 186.359C243.264 187.241 243.498 188.276 243.498 189.464C243.498 191.012 243.111 192.2 242.337 193.028C241.581 193.856 240.474 194.27 239.016 194.27ZM248.823 175.1H251.685L253.008 189.626H253.062L254.466 175.1H257.706L259.11 189.626H259.164L260.487 175.1H263.052L261.135 194H257.436L256.086 181.256H256.032L254.682 194H250.74L248.823 175.1ZM264.555 175.1H267.525V194H264.555V175.1ZM269.749 175.1H274.285C275.761 175.1 276.868 175.496 277.606 176.288C278.344 177.08 278.713 178.241 278.713 179.771V189.329C278.713 190.859 278.344 192.02 277.606 192.812C276.868 193.604 275.761 194 274.285 194H269.749V175.1ZM274.231 191.3C274.717 191.3 275.086 191.156 275.338 190.868C275.608 190.58 275.743 190.112 275.743 189.464V179.636C275.743 178.988 275.608 178.52 275.338 178.232C275.086 177.944 274.717 177.8 274.231 177.8H272.719V191.3H274.231ZM284.93 194.27C283.49 194.27 282.392 193.865 281.636 193.055C280.88 192.227 280.502 191.048 280.502 189.518V179.582C280.502 178.052 280.88 176.882 281.636 176.072C282.392 175.244 283.49 174.83 284.93 174.83C286.37 174.83 287.468 175.244 288.224 176.072C288.98 176.882 289.358 178.052 289.358 179.582V181.202H286.55V179.393C286.55 178.151 286.037 177.53 285.011 177.53C283.985 177.53 283.472 178.151 283.472 179.393V189.734C283.472 190.958 283.985 191.57 285.011 191.57C286.037 191.57 286.55 190.958 286.55 189.734V186.035H285.065V183.335H289.358V189.518C289.358 191.048 288.98 192.227 288.224 193.055C287.468 193.865 286.37 194.27 284.93 194.27ZM291.265 175.1H299.365V177.8H294.235V182.795H298.312V185.495H294.235V191.3H299.365V194H291.265V175.1ZM303.395 177.8H300.29V175.1H309.47V177.8H306.365V194H303.395V177.8Z" fill="white"/>
16
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M178.87 65.8803C178.87 64.6713 178.312 63.7413 177.289 63.0903C177.103 62.9973 176.824 62.8113 176.638 62.7183C176.638 59.6494 176.545 56.4875 176.359 53.3256C175.987 46.0718 172.174 42.5378 165.013 42.4448C158.782 42.4448 152.551 42.4448 146.32 42.4448C136.183 42.4448 126.139 42.3518 116.002 42.5378C106.702 42.7238 102.982 46.6297 102.982 55.9295C102.982 58.1614 102.982 60.3934 102.982 62.7183C102.424 62.9043 101.959 63.3693 101.587 63.8343C100.936 64.3923 100.75 65.2293 100.75 66.1592C100.75 70.4371 100.75 74.715 100.75 79.0859C100.75 80.3879 101.215 81.4109 102.331 82.0618C102.61 82.2478 102.796 82.3408 103.075 82.4338C103.075 91.6406 103.075 100.754 103.075 109.961C103.075 111.263 102.889 112.751 103.54 113.867C104.935 116.099 104.656 118.517 104.749 120.935C104.842 123.911 106.795 125.957 109.771 126.05C111.91 126.143 114.049 126.143 116.188 126.05C119.257 125.957 121.21 124.19 121.303 121.121C121.396 119.819 121.582 119.354 123.07 119.354C134.23 119.447 145.483 119.447 156.643 119.354C158.038 119.354 158.41 119.726 158.41 121.121C158.503 124.376 160.456 126.05 163.711 126.05C165.571 126.05 167.431 126.05 169.291 126.05C173.104 126.05 174.964 124.097 175.057 120.284C175.057 118.796 174.592 117.122 175.429 115.727C176.452 113.867 176.731 112.007 176.731 109.961C176.731 101.312 176.731 92.6636 176.731 82.4338C177.382 82.3408 177.94 81.7829 178.312 81.2249C178.777 80.6669 178.963 79.9229 178.963 79.1789C178.87 74.808 178.87 70.3441 178.87 65.8803ZM124.279 49.1407C129.859 49.1407 135.439 49.1407 140.926 49.1407C146.32 49.1407 151.714 49.1407 157.201 49.1407C159.619 49.1407 159.898 49.5127 159.991 52.3026C159.991 55.3715 159.712 55.8365 157.387 55.8365C146.32 55.8365 135.253 55.8365 124.279 55.8365C121.861 55.8365 121.396 55.2785 121.396 52.4886C121.303 49.6987 121.768 49.1407 124.279 49.1407ZM117.304 111.077C114.049 111.077 111.352 108.38 111.352 105.125C111.445 101.963 114.142 99.3594 117.211 99.3594C120.466 99.3594 122.884 101.87 122.884 105.218C122.977 108.473 120.466 111.077 117.304 111.077ZM116.467 90.9896C112.933 90.9896 111.352 89.3157 111.352 85.6888C111.352 79.1789 111.352 72.6691 111.352 66.1592C111.352 62.5323 112.84 61.0444 116.467 61.0444C124.279 61.0444 131.998 61.0444 139.81 61.0444C147.436 61.0444 155.062 61.0444 162.688 61.0444C166.78 61.0444 168.175 62.4393 168.175 66.4382C168.175 72.6691 168.175 78.8999 168.175 85.1308C168.175 88.8507 166.129 90.8966 162.409 90.9896C147.157 90.9896 131.812 90.9896 116.467 90.9896ZM162.409 111.077C159.247 111.077 156.736 108.566 156.643 105.311C156.643 101.963 159.061 99.4524 162.316 99.4524C165.571 99.4524 168.268 102.149 168.268 105.404C168.175 108.38 165.571 111.077 162.409 111.077Z" fill="white"/>
17
+ <path d="M22.6277 153.8H19.5227V151.1H28.7027V153.8H25.5977V170H22.6277V153.8ZM30.1407 151.1H34.5417C36.0717 151.1 37.1877 151.46 37.8897 152.18C38.5917 152.882 38.9427 153.971 38.9427 155.447V156.608C38.9427 158.57 38.2947 159.812 36.9987 160.334V160.388C37.7187 160.604 38.2227 161.045 38.5107 161.711C38.8167 162.377 38.9697 163.268 38.9697 164.384V167.705C38.9697 168.245 38.9877 168.686 39.0237 169.028C39.0597 169.352 39.1497 169.676 39.2937 170H36.2697C36.1617 169.694 36.0897 169.406 36.0537 169.136C36.0177 168.866 35.9997 168.38 35.9997 167.678V164.222C35.9997 163.358 35.8557 162.755 35.5677 162.413C35.2977 162.071 34.8207 161.9 34.1367 161.9H33.1107V170H30.1407V151.1ZM34.1907 159.2C34.7847 159.2 35.2257 159.047 35.5137 158.741C35.8197 158.435 35.9727 157.922 35.9727 157.202V155.744C35.9727 155.06 35.8467 154.565 35.5947 154.259C35.3607 153.953 34.9827 153.8 34.4607 153.8H33.1107V159.2H34.1907ZM43.3253 151.1H47.3483L50.4263 170H47.4563L46.9163 166.247V166.301H43.5413L43.0013 170H40.2473L43.3253 151.1ZM46.5653 163.736L45.2423 154.394H45.1883L43.8923 163.736H46.5653ZM51.8673 151.1H55.5933L58.4823 162.413H58.5363V151.1H61.1823V170H58.1313L54.5673 156.203H54.5133V170H51.8673V151.1ZM67.2507 170.27C65.8107 170.27 64.7217 169.865 63.9837 169.055C63.2457 168.227 62.8767 167.048 62.8767 165.518V164.438H65.6847V165.734C65.6847 166.958 66.1977 167.57 67.2237 167.57C67.7277 167.57 68.1057 167.426 68.3577 167.138C68.6277 166.832 68.7627 166.346 68.7627 165.68C68.7627 164.888 68.5827 164.195 68.2227 163.601C67.8627 162.989 67.1967 162.26 66.2247 161.414C65.0007 160.334 64.1457 159.362 63.6597 158.498C63.1737 157.616 62.9307 156.626 62.9307 155.528C62.9307 154.034 63.3087 152.882 64.0647 152.072C64.8207 151.244 65.9187 150.83 67.3587 150.83C68.7807 150.83 69.8517 151.244 70.5717 152.072C71.3097 152.882 71.6787 154.052 71.6787 155.582V156.365H68.8707V155.393C68.8707 154.745 68.7447 154.277 68.4927 153.989C68.2407 153.683 67.8717 153.53 67.3857 153.53C66.3957 153.53 65.9007 154.133 65.9007 155.339C65.9007 156.023 66.0807 156.662 66.4407 157.256C66.8187 157.85 67.4937 158.57 68.4657 159.416C69.7077 160.496 70.5627 161.477 71.0307 162.359C71.4987 163.241 71.7327 164.276 71.7327 165.464C71.7327 167.012 71.3457 168.2 70.5717 169.028C69.8157 169.856 68.7087 170.27 67.2507 170.27ZM73.4356 151.1H76.4056V170H73.4356V151.1ZM80.9519 153.8H77.8469V151.1H87.0269V153.8H83.9219V170H80.9519V153.8ZM92.7891 151.1H97.3251C98.8011 151.1 99.9081 151.496 100.646 152.288C101.384 153.08 101.753 154.241 101.753 155.771V165.329C101.753 166.859 101.384 168.02 100.646 168.812C99.9081 169.604 98.8011 170 97.3251 170H92.7891V151.1ZM97.2711 167.3C97.7571 167.3 98.1261 167.156 98.3781 166.868C98.6481 166.58 98.7831 166.112 98.7831 165.464V155.636C98.7831 154.988 98.6481 154.52 98.3781 154.232C98.1261 153.944 97.7571 153.8 97.2711 153.8H95.7591V167.3H97.2711ZM103.758 151.1H111.858V153.8H106.728V158.795H110.805V161.495H106.728V167.3H111.858V170H103.758V151.1ZM113.566 151.1H117.94C119.416 151.1 120.523 151.496 121.261 152.288C121.999 153.08 122.368 154.241 122.368 155.771V157.634C122.368 159.164 121.999 160.325 121.261 161.117C120.523 161.909 119.416 162.305 117.94 162.305H116.536V170H113.566V151.1ZM117.94 159.605C118.426 159.605 118.786 159.47 119.02 159.2C119.272 158.93 119.398 158.471 119.398 157.823V155.582C119.398 154.934 119.272 154.475 119.02 154.205C118.786 153.935 118.426 153.8 117.94 153.8H116.536V159.605H117.94ZM125.327 151.1H129.35L132.428 170H129.458L128.918 166.247V166.301H125.543L125.003 170H122.249L125.327 151.1ZM128.567 163.736L127.244 154.394H127.19L125.894 163.736H128.567ZM133.869 151.1H138.27C139.8 151.1 140.916 151.46 141.618 152.18C142.32 152.882 142.671 153.971 142.671 155.447V156.608C142.671 158.57 142.023 159.812 140.727 160.334V160.388C141.447 160.604 141.951 161.045 142.239 161.711C142.545 162.377 142.698 163.268 142.698 164.384V167.705C142.698 168.245 142.716 168.686 142.752 169.028C142.788 169.352 142.878 169.676 143.022 170H139.998C139.89 169.694 139.818 169.406 139.782 169.136C139.746 168.866 139.728 168.38 139.728 167.678V164.222C139.728 163.358 139.584 162.755 139.296 162.413C139.026 162.071 138.549 161.9 137.865 161.9H136.839V170H133.869V151.1ZM137.919 159.2C138.513 159.2 138.954 159.047 139.242 158.741C139.548 158.435 139.701 157.922 139.701 157.202V155.744C139.701 155.06 139.575 154.565 139.323 154.259C139.089 153.953 138.711 153.8 138.189 153.8H136.839V159.2H137.919ZM147.028 153.8H143.923V151.1H153.103V153.8H149.998V170H147.028V153.8ZM158.861 170.27C157.421 170.27 156.323 169.865 155.567 169.055C154.811 168.227 154.433 167.048 154.433 165.518V151.1H157.403V165.734C157.403 166.382 157.529 166.85 157.781 167.138C158.051 167.426 158.429 167.57 158.915 167.57C159.401 167.57 159.77 167.426 160.022 167.138C160.292 166.85 160.427 166.382 160.427 165.734V151.1H163.289V165.518C163.289 167.048 162.911 168.227 162.155 169.055C161.399 169.865 160.301 170.27 158.861 170.27ZM165.404 151.1H169.805C171.335 151.1 172.451 151.46 173.153 152.18C173.855 152.882 174.206 153.971 174.206 155.447V156.608C174.206 158.57 173.558 159.812 172.262 160.334V160.388C172.982 160.604 173.486 161.045 173.774 161.711C174.08 162.377 174.233 163.268 174.233 164.384V167.705C174.233 168.245 174.251 168.686 174.287 169.028C174.323 169.352 174.413 169.676 174.557 170H171.533C171.425 169.694 171.353 169.406 171.317 169.136C171.281 168.866 171.263 168.38 171.263 167.678V164.222C171.263 163.358 171.119 162.755 170.831 162.413C170.561 162.071 170.084 161.9 169.4 161.9H168.374V170H165.404V151.1ZM169.454 159.2C170.048 159.2 170.489 159.047 170.777 158.741C171.083 158.435 171.236 157.922 171.236 157.202V155.744C171.236 155.06 171.11 154.565 170.858 154.259C170.624 153.953 170.246 153.8 169.724 153.8H168.374V159.2H169.454ZM176.294 151.1H184.394V153.8H179.264V158.795H183.341V161.495H179.264V167.3H184.394V170H176.294V151.1ZM190.016 170.27C188.576 170.27 187.487 169.865 186.749 169.055C186.011 168.227 185.642 167.048 185.642 165.518V164.438H188.45V165.734C188.45 166.958 188.963 167.57 189.989 167.57C190.493 167.57 190.871 167.426 191.123 167.138C191.393 166.832 191.528 166.346 191.528 165.68C191.528 164.888 191.348 164.195 190.988 163.601C190.628 162.989 189.962 162.26 188.99 161.414C187.766 160.334 186.911 159.362 186.425 158.498C185.939 157.616 185.696 156.626 185.696 155.528C185.696 154.034 186.074 152.882 186.83 152.072C187.586 151.244 188.684 150.83 190.124 150.83C191.546 150.83 192.617 151.244 193.337 152.072C194.075 152.882 194.444 154.052 194.444 155.582V156.365H191.636V155.393C191.636 154.745 191.51 154.277 191.258 153.989C191.006 153.683 190.637 153.53 190.151 153.53C189.161 153.53 188.666 154.133 188.666 155.339C188.666 156.023 188.846 156.662 189.206 157.256C189.584 157.85 190.259 158.57 191.231 159.416C192.473 160.496 193.328 161.477 193.796 162.359C194.264 163.241 194.498 164.276 194.498 165.464C194.498 167.012 194.111 168.2 193.337 169.028C192.581 169.856 191.474 170.27 190.016 170.27ZM199.823 151.1H202.685L204.008 165.626H204.062L205.466 151.1H208.706L210.11 165.626H210.164L211.487 151.1H214.052L212.135 170H208.436L207.086 157.256H207.032L205.682 170H201.74L199.823 151.1ZM215.555 151.1H218.525V170H215.555V151.1ZM220.749 151.1H225.285C226.761 151.1 227.868 151.496 228.606 152.288C229.344 153.08 229.713 154.241 229.713 155.771V165.329C229.713 166.859 229.344 168.02 228.606 168.812C227.868 169.604 226.761 170 225.285 170H220.749V151.1ZM225.231 167.3C225.717 167.3 226.086 167.156 226.338 166.868C226.608 166.58 226.743 166.112 226.743 165.464V155.636C226.743 154.988 226.608 154.52 226.338 154.232C226.086 153.944 225.717 153.8 225.231 153.8H223.719V167.3H225.231ZM235.93 170.27C234.49 170.27 233.392 169.865 232.636 169.055C231.88 168.227 231.502 167.048 231.502 165.518V155.582C231.502 154.052 231.88 152.882 232.636 152.072C233.392 151.244 234.49 150.83 235.93 150.83C237.37 150.83 238.468 151.244 239.224 152.072C239.98 152.882 240.358 154.052 240.358 155.582V157.202H237.55V155.393C237.55 154.151 237.037 153.53 236.011 153.53C234.985 153.53 234.472 154.151 234.472 155.393V165.734C234.472 166.958 234.985 167.57 236.011 167.57C237.037 167.57 237.55 166.958 237.55 165.734V162.035H236.065V159.335H240.358V165.518C240.358 167.048 239.98 168.227 239.224 169.055C238.468 169.865 237.37 170.27 235.93 170.27ZM242.265 151.1H250.365V153.8H245.235V158.795H249.312V161.495H245.235V167.3H250.365V170H242.265V151.1ZM254.395 153.8H251.29V151.1H260.47V153.8H257.365V170H254.395V153.8Z" fill="white"/>
18
18
  </svg>
package/lib/file-utils.js CHANGED
@@ -89,6 +89,7 @@ export function copyStaticAssets(exportPath) {
89
89
  fileURLToPath(import.meta.url),
90
90
  '../../public',
91
91
  )
92
+ copydir.sync(path.join(staticAssetPath, 'img'), path.join(exportPath, 'img'))
92
93
  copydir.sync(path.join(staticAssetPath, 'css'), path.join(exportPath, 'css'))
93
94
  copydir.sync(path.join(staticAssetPath, 'js'), path.join(exportPath, 'js'))
94
95
  }
@@ -9,6 +9,7 @@ import { copyStaticAssets, prepDirectory } from './file-utils.js'
9
9
  import { log, logWarning, logError } from './log-utils.js'
10
10
  import {
11
11
  generateTransitDeparturesWidgetHtml,
12
+ generateTransitDeparturesWidgetJson,
12
13
  setDefaultConfig,
13
14
  } from './utils.js'
14
15
 
@@ -58,6 +59,7 @@ async function transitDeparturesWidget(initialConfig) {
58
59
  }
59
60
 
60
61
  await prepDirectory(exportPath)
62
+ await prepDirectory(path.join(exportPath, 'data'))
61
63
 
62
64
  if (config.noHead !== true) {
63
65
  copyStaticAssets(exportPath)
@@ -67,6 +69,17 @@ async function transitDeparturesWidget(initialConfig) {
67
69
 
68
70
  config.assetPath = ''
69
71
 
72
+ // Generate JSON of routes and stops
73
+ const { routes, stops } = generateTransitDeparturesWidgetJson(config)
74
+ await writeFile(
75
+ path.join(exportPath, 'data', 'routes.json'),
76
+ JSON.stringify(routes, null, 2),
77
+ )
78
+ await writeFile(
79
+ path.join(exportPath, 'data', 'stops.json'),
80
+ JSON.stringify(stops, null, 2),
81
+ )
82
+
70
83
  const html = await generateTransitDeparturesWidgetHtml(config)
71
84
  await writeFile(path.join(exportPath, 'index.html'), html)
72
85
 
package/lib/utils.js CHANGED
@@ -175,15 +175,26 @@ function getStopsForDirection(route, direction, config) {
175
175
  * Generate HTML for transit departures widget.
176
176
  */
177
177
  export function generateTransitDeparturesWidgetHtml(config) {
178
- const routes = getRoutes()
179
- const stops = []
180
- const filteredRoutes = []
181
178
  i18n.configure({
182
179
  directory: join(dirname(fileURLToPath(import.meta.url)), '..', 'locales'),
183
180
  defaultLocale: config.locale,
184
181
  updateFiles: false,
185
182
  })
186
183
 
184
+ const templateVars = {
185
+ __: i18n.__,
186
+ config,
187
+ }
188
+ return renderFile('widget', templateVars, config)
189
+ }
190
+
191
+ /*
192
+ * Generate JSON of routes and stops for transit departures widget.
193
+ */
194
+ export function generateTransitDeparturesWidgetJson(config) {
195
+ const routes = getRoutes()
196
+ const stops = []
197
+ const filteredRoutes = []
187
198
  const calendars = getCalendarsForDateRange(config)
188
199
 
189
200
  for (const route of routes) {
@@ -243,13 +254,31 @@ export function generateTransitDeparturesWidgetHtml(config) {
243
254
  // Sort unique list of stops
244
255
  const sortedStops = sortBy(uniqBy(stops, 'stop_id'), 'stop_name')
245
256
 
246
- const templateVars = {
247
- __: i18n.__,
248
- routes: sortedRoutes,
249
- stops: sortedStops,
250
- config,
257
+ return {
258
+ routes: removeNulls(sortedRoutes),
259
+ stops: removeNulls(sortedStops),
260
+ }
261
+ }
262
+
263
+ /*
264
+ * Remove null values from array or object
265
+ */
266
+ function removeNulls(data) {
267
+ if (Array.isArray(data)) {
268
+ return data
269
+ .map(removeNulls)
270
+ .filter((item) => item !== null && item !== undefined)
271
+ } else if (typeof data === 'object' && data !== null) {
272
+ return Object.entries(data).reduce((acc, [key, value]) => {
273
+ const cleanedValue = removeNulls(value)
274
+ if (cleanedValue !== null && cleanedValue !== undefined) {
275
+ acc[key] = cleanedValue
276
+ }
277
+ return acc
278
+ }, {})
279
+ } else {
280
+ return data
251
281
  }
252
- return renderFile('widget', templateVars, config)
253
282
  }
254
283
 
255
284
  /*
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "transit-departures-widget",
3
3
  "description": "Build a realtime transit departures tool from GTFS and GTFS-Realtime.",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "keywords": [
6
6
  "transit",
7
7
  "gtfs",
@@ -32,25 +32,25 @@
32
32
  "dependencies": {
33
33
  "copy-dir": "^1.3.0",
34
34
  "express": "^4.19.2",
35
- "gtfs": "^4.10.2",
35
+ "gtfs": "^4.12.0",
36
36
  "i18n": "^0.15.1",
37
37
  "js-beautify": "^1.15.1",
38
38
  "lodash-es": "^4.17.21",
39
39
  "morgan": "^1.10.0",
40
40
  "pretty-error": "^4.0.0",
41
- "pug": "^3.0.2",
41
+ "pug": "^3.0.3",
42
42
  "sanitize-filename": "^1.6.3",
43
43
  "sqlstring-sqlite": "^0.1.1",
44
44
  "timer-machine": "^1.1.0",
45
45
  "toposort": "^2.0.2",
46
46
  "untildify": "^5.0.0",
47
47
  "yargs": "^17.7.2",
48
- "yoctocolors": "^2.0.0"
48
+ "yoctocolors": "^2.1.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "husky": "^9.0.11",
52
- "lint-staged": "^15.2.2",
53
- "prettier": "^3.2.5"
52
+ "lint-staged": "^15.2.7",
53
+ "prettier": "^3.3.2"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">= 14.15.4"
@@ -38,7 +38,7 @@ function setupTransitDeparturesWidget(routes, stops, config) {
38
38
  }
39
39
 
40
40
  function formatDirectionId(directionId) {
41
- if (directionId === null) {
41
+ if (directionId === null || directionId === undefined) {
42
42
  return '0'
43
43
  }
44
44
 
@@ -622,7 +622,10 @@ function setupTransitDeparturesWidget(routes, stops, config) {
622
622
  source(query, populateResults) {
623
623
  const filteredResults = stops.filter((stop) => {
624
624
  // Don't list child stations
625
- if (stop.parent_station !== null) {
625
+ if (
626
+ stop.parent_station !== null &&
627
+ stop.parent_station !== undefined
628
+ ) {
626
629
  return false
627
630
  }
628
631
 
@@ -49,13 +49,12 @@
49
49
  .departure-results-error= __('Unable to fetch departures')
50
50
 
51
51
  script.
52
- (function() {
53
- const routes = !{JSON.stringify(routes)};
54
- const stops = !{JSON.stringify(stops)};
55
- const config = {
52
+ (async function() {
53
+ const routes = await fetch('data/routes.json').then(res => res.json())
54
+ const stops = await fetch('data/stops.json').then(res => res.json())
55
+ setupTransitDeparturesWidget(routes, stops, {
56
56
  gtfsRtTripupdatesUrl: '#{config.agency.gtfs_rt_tripupdates_url}',
57
57
  refreshIntervalSeconds: #{config.refreshIntervalSeconds},
58
58
  timeFormat: '#{config.timeFormat}'
59
- }
60
- setupTransitDeparturesWidget(routes, stops, config);
59
+ })
61
60
  })()