liftie 3.56.4 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/Makefile +2 -2
  2. package/app.js +33 -25
  3. package/lib/checker.js +1 -1
  4. package/lib/cli/curl.js +8 -8
  5. package/lib/cli/dirs.js +8 -6
  6. package/lib/cli/fetch.js +9 -9
  7. package/lib/cli/for-each-resort.js +3 -4
  8. package/lib/cli/generate.js +10 -10
  9. package/lib/cli/noaa.js +7 -12
  10. package/lib/client/about/index.js +2 -6
  11. package/lib/client/boot/height.js +2 -6
  12. package/lib/client/boot/index.js +8 -11
  13. package/lib/client/boot/service-worker.js +1 -5
  14. package/lib/client/minimax/index.js +1 -3
  15. package/lib/client/resort/dom.js +2 -7
  16. package/lib/client/resort/index.js +7 -10
  17. package/lib/client/resort/lifts.js +4 -5
  18. package/lib/client/resort/snow.js +3 -4
  19. package/lib/client/resort/weather.js +3 -4
  20. package/lib/client/resort/webcams.js +5 -8
  21. package/lib/client/state/index.js +4 -7
  22. package/lib/client/stats/index.js +1 -5
  23. package/lib/client/tag/index.js +1 -3
  24. package/lib/embed/index.js +0 -2
  25. package/lib/lifts/index.js +12 -12
  26. package/lib/lifts/parse.js +5 -5
  27. package/lib/lifts/parser.js +6 -10
  28. package/lib/lifts/pipe.js +3 -3
  29. package/lib/lifts/request.js +1 -3
  30. package/lib/lifts/rest.js +2 -4
  31. package/lib/lifts/stats.js +2 -5
  32. package/lib/loader.js +9 -12
  33. package/lib/loaders.js +7 -8
  34. package/lib/opening.js +6 -5
  35. package/lib/plugins.js +3 -8
  36. package/lib/resorts/3cime/index.js +1 -1
  37. package/lib/resorts/3cime/resort.json +1 -1
  38. package/lib/resorts/49-degrees-north/index.js +1 -1
  39. package/lib/resorts/abasin/index.js +13 -6
  40. package/lib/resorts/abasin/resort.json +1 -1
  41. package/lib/resorts/alpe-lusia-san-pellegrino/index.js +1 -1
  42. package/lib/resorts/alpe-lusia-san-pellegrino/resort.json +1 -1
  43. package/lib/resorts/alpine/index.js +1 -1
  44. package/lib/resorts/alta/index.js +6 -7
  45. package/lib/resorts/alta-badia/index.js +1 -1
  46. package/lib/resorts/alta-badia/resort.json +1 -1
  47. package/lib/resorts/alyeska/index.js +1 -1
  48. package/lib/resorts/angel-fire/index.js +1 -1
  49. package/lib/resorts/arabba/index.js +1 -1
  50. package/lib/resorts/arabba/resort.json +1 -1
  51. package/lib/resorts/aspen-highlands/index.js +1 -1
  52. package/lib/resorts/aspen-mountain/index.js +1 -1
  53. package/lib/resorts/attitash/index.js +1 -1
  54. package/lib/resorts/beavercreek/index.js +1 -1
  55. package/lib/resorts/berkshire-east/index.js +1 -1
  56. package/lib/resorts/big-sky/index.js +1 -1
  57. package/lib/resorts/big-white/index.js +1 -1
  58. package/lib/resorts/big-white/resort.json +1 -1
  59. package/lib/resorts/blue-mountain-pa/index.js +1 -1
  60. package/lib/resorts/bluemountain/index.js +1 -1
  61. package/lib/resorts/bogusbasin/index.js +5 -4
  62. package/lib/resorts/bolton-valley/index.js +2 -3
  63. package/lib/resorts/boreal/index.js +1 -1
  64. package/lib/resorts/breck/index.js +1 -1
  65. package/lib/resorts/brettonwoods/index.js +7 -5
  66. package/lib/resorts/brianhead/index.js +1 -1
  67. package/lib/resorts/bridger-bowl/index.js +4 -3
  68. package/lib/resorts/brighton/index.js +1 -1
  69. package/lib/resorts/bromley-mountain/index.js +1 -1
  70. package/lib/resorts/burke-mountain/index.js +1 -1
  71. package/lib/resorts/buttermilk/index.js +1 -1
  72. package/lib/resorts/caberfae-peaks/index.js +1 -1
  73. package/lib/resorts/camelback/index.js +1 -1
  74. package/lib/resorts/campo-felice/index.js +1 -1
  75. package/lib/resorts/campo-felice/resort.json +1 -1
  76. package/lib/resorts/canada-olympic-park/index.js +1 -1
  77. package/lib/resorts/cannon/index.js +1 -1
  78. package/lib/resorts/cataloochee/index.js +1 -1
  79. package/lib/resorts/catedral/index.js +1 -1
  80. package/lib/resorts/cervino/index.js +2 -2
  81. package/lib/resorts/chamonix/index.js +2 -2
  82. package/lib/resorts/chamonix/resort.json +1 -1
  83. package/lib/resorts/chinapeak/index.js +1 -1
  84. package/lib/resorts/civetta/index.js +1 -1
  85. package/lib/resorts/civetta/resort.json +1 -1
  86. package/lib/resorts/claviere/index.js +1 -1
  87. package/lib/resorts/copper/index.js +1 -1
  88. package/lib/resorts/coronetpeak/index.js +1 -1
  89. package/lib/resorts/coronetpeak/resort.json +1 -1
  90. package/lib/resorts/cortina-d-ampezzo/index.js +1 -1
  91. package/lib/resorts/cortina-d-ampezzo/resort.json +1 -1
  92. package/lib/resorts/courchevel/index.js +1 -1
  93. package/lib/resorts/courchevel/resort.json +2 -1
  94. package/lib/resorts/cranmore-mountain/index.js +1 -1
  95. package/lib/resorts/cransmontana/index.js +2 -2
  96. package/lib/resorts/crested-butte/index.js +1 -1
  97. package/lib/resorts/crystal-mountain/index.js +1 -1
  98. package/lib/resorts/cypress-mountain/index.js +1 -1
  99. package/lib/resorts/deer-valley/index.js +1 -1
  100. package/lib/resorts/devils-head/index.js +1 -1
  101. package/lib/resorts/diamondpeak/index.js +1 -1
  102. package/lib/resorts/falls-creek/index.js +5 -3
  103. package/lib/resorts/falls-creek/resort.json +1 -1
  104. package/lib/resorts/flims-laax-falera/index.js +1 -1
  105. package/lib/resorts/flims-laax-falera/resort.json +1 -1
  106. package/lib/resorts/folgaria/index.js +1 -1
  107. package/lib/resorts/folgaria/resort.json +1 -1
  108. package/lib/resorts/folgarida-marilleva/index.js +2 -1
  109. package/lib/resorts/forni/index.js +1 -1
  110. package/lib/resorts/forni/resort.json +1 -1
  111. package/lib/resorts/gore-mountain/index.js +1 -1
  112. package/lib/resorts/grand-targhee/index.js +1 -1
  113. package/lib/resorts/grouse/index.js +1 -1
  114. package/lib/resorts/gunstock/index.js +1 -1
  115. package/lib/resorts/heavenly/index.js +1 -1
  116. package/lib/resorts/hochfuegen/index.js +2 -2
  117. package/lib/resorts/homewood/index.js +1 -1
  118. package/lib/resorts/hoodoo/index.js +1 -1
  119. package/lib/resorts/hunter/index.js +1 -1
  120. package/lib/resorts/ischgl-silvretta-arena/index.js +1 -1
  121. package/lib/resorts/jackson-hole/index.js +5 -3
  122. package/lib/resorts/jay-peak/index.js +1 -1
  123. package/lib/resorts/jiminypeak/index.js +1 -1
  124. package/lib/resorts/june-mountain/index.js +1 -1
  125. package/lib/resorts/keystone/index.js +1 -1
  126. package/lib/resorts/killington/index.js +1 -1
  127. package/lib/resorts/king-pine/index.js +5 -3
  128. package/lib/resorts/kirkwood/index.js +1 -1
  129. package/lib/resorts/kitzbuehel/index.js +1 -1
  130. package/lib/resorts/lamolina/index.js +1 -1
  131. package/lib/resorts/lamolina/resort.json +1 -1
  132. package/lib/resorts/laplagne/index.js +1 -1
  133. package/lib/resorts/laplagne/resort.json +2 -1
  134. package/lib/resorts/larosiere/index.js +1 -1
  135. package/lib/resorts/lavarone/index.js +1 -1
  136. package/lib/resorts/lavarone/resort.json +1 -1
  137. package/lib/resorts/lesarcs/index.js +1 -1
  138. package/lib/resorts/lesmenuires/index.js +1 -1
  139. package/lib/resorts/lesmenuires/resort.json +2 -1
  140. package/lib/resorts/loon/index.js +1 -1
  141. package/lib/resorts/loveland/index.js +5 -5
  142. package/lib/resorts/mad-river-glen/index.js +2 -2
  143. package/lib/resorts/madonna-di-campiglio/index.js +2 -1
  144. package/lib/resorts/mammoth-lakes/index.js +1 -1
  145. package/lib/resorts/manning-park/index.js +1 -1
  146. package/lib/resorts/manning-park/resort.json +1 -1
  147. package/lib/resorts/megeve/index.js +1 -1
  148. package/lib/resorts/megeve/resort.json +2 -1
  149. package/lib/resorts/meribel/index.js +1 -1
  150. package/lib/resorts/meribel/resort.json +2 -1
  151. package/lib/resorts/monarch/index.js +17 -4
  152. package/lib/resorts/monarch/resort.json +1 -5
  153. package/lib/resorts/monte-amiata/index.js +1 -1
  154. package/lib/resorts/monte-amiata/resort.json +1 -1
  155. package/lib/resorts/monte-bondone/index.js +1 -1
  156. package/lib/resorts/montegenevre/index.js +1 -1
  157. package/lib/resorts/monterosa/index.js +1 -1
  158. package/lib/resorts/morzine/index.js +1 -1
  159. package/lib/resorts/morzine/resort.json +6 -2
  160. package/lib/resorts/mount-sunapee/index.js +1 -1
  161. package/lib/resorts/mountsnow/index.js +1 -1
  162. package/lib/resorts/mt-buller/index.js +1 -1
  163. package/lib/resorts/mt-hotham/index.js +5 -3
  164. package/lib/resorts/mt-seymour/index.js +1 -1
  165. package/lib/resorts/mt-spokane/index.js +1 -1
  166. package/lib/resorts/mtbachelor/index.js +1 -1
  167. package/lib/resorts/mtbrighton/index.js +1 -1
  168. package/lib/resorts/mthigh/index.js +1 -1
  169. package/lib/resorts/mthood/index.js +1 -1
  170. package/lib/resorts/mtpeter/index.js +1 -1
  171. package/lib/resorts/mtpeter/resort.json +1 -1
  172. package/lib/resorts/mtrose/index.js +1 -1
  173. package/lib/resorts/niseko/index.js +1 -1
  174. package/lib/resorts/niseko/resort.json +1 -1
  175. package/lib/resorts/northstar/index.js +1 -1
  176. package/lib/resorts/okemo/index.js +1 -1
  177. package/lib/resorts/ovindoli/index.js +1 -1
  178. package/lib/resorts/ovindoli/resort.json +1 -1
  179. package/lib/resorts/owlshead/index.js +1 -1
  180. package/lib/resorts/paganella/index.js +1 -1
  181. package/lib/resorts/paganella/resort.json +1 -1
  182. package/lib/resorts/palisades/index.js +1 -1
  183. package/lib/resorts/parkcity/index.js +1 -1
  184. package/lib/resorts/pats-peak/index.js +4 -2
  185. package/lib/resorts/peio/index.js +2 -2
  186. package/lib/resorts/perisher/index.js +1 -1
  187. package/lib/resorts/perisher/resort.json +1 -1
  188. package/lib/resorts/piancavallo/index.js +1 -1
  189. package/lib/resorts/piancavallo/resort.json +1 -1
  190. package/lib/resorts/pico/index.js +1 -1
  191. package/lib/resorts/pinzolo/index.js +2 -1
  192. package/lib/resorts/plan-de-corones/index.js +1 -1
  193. package/lib/resorts/plan-de-corones/resort.json +1 -1
  194. package/lib/resorts/pleasant-mountain/index.js +1 -1
  195. package/lib/resorts/pontedilegno-tonale/index.js +1 -1
  196. package/lib/resorts/ragged-mountain/index.js +1 -1
  197. package/lib/resorts/ravascletto-zoncolan/index.js +1 -1
  198. package/lib/resorts/ravascletto-zoncolan/resort.json +1 -1
  199. package/lib/resorts/red-lodge-mountain/index.js +1 -1
  200. package/lib/resorts/red-mountain/index.js +2 -3
  201. package/lib/resorts/rio-pusteria-bressanone/index.js +1 -1
  202. package/lib/resorts/rio-pusteria-bressanone/resort.json +1 -1
  203. package/lib/resorts/roccaraso/index.js +1 -1
  204. package/lib/resorts/roccaraso/resort.json +1 -1
  205. package/lib/resorts/saddleback/index.js +1 -1
  206. package/lib/resorts/san-martino-di-castrozza-passo-rolle/index.js +1 -1
  207. package/lib/resorts/san-martino-di-castrozza-passo-rolle/resort.json +1 -1
  208. package/lib/resorts/sansicario/index.js +1 -1
  209. package/lib/resorts/sappada/index.js +1 -1
  210. package/lib/resorts/sappada/resort.json +1 -1
  211. package/lib/resorts/sasquatch-mountain/index.js +1 -1
  212. package/lib/resorts/sauris/index.js +1 -1
  213. package/lib/resorts/sauris/resort.json +1 -1
  214. package/lib/resorts/sauze/index.js +1 -1
  215. package/lib/resorts/schweitzer/index.js +1 -1
  216. package/lib/resorts/sella/index.js +1 -1
  217. package/lib/resorts/sella/resort.json +1 -1
  218. package/lib/resorts/serfaus-fiss-ladis/index.js +1 -1
  219. package/lib/resorts/sestriere/index.js +1 -1
  220. package/lib/resorts/sestriere/resort.json +1 -1
  221. package/lib/resorts/shawnee-mountain/index.js +4 -2
  222. package/lib/resorts/sierra/index.js +1 -1
  223. package/lib/resorts/silver-star/index.js +2 -2
  224. package/lib/resorts/skiwelt/index.js +1 -1
  225. package/lib/resorts/smuggs/index.js +1 -1
  226. package/lib/resorts/snow-valley/index.js +2 -2
  227. package/lib/resorts/snowbasin/index.js +1 -1
  228. package/lib/resorts/snowbird/index.js +2 -3
  229. package/lib/resorts/snowmass/index.js +1 -1
  230. package/lib/resorts/snowshoe/index.js +1 -1
  231. package/lib/resorts/soelden/index.js +1 -1
  232. package/lib/resorts/solitude/index.js +1 -1
  233. package/lib/resorts/st-anton-am-arlberg/index.js +1 -1
  234. package/lib/resorts/steamboat/index.js +1 -1
  235. package/lib/resorts/stevens/index.js +1 -1
  236. package/lib/resorts/stowe/index.js +1 -1
  237. package/lib/resorts/stratton/index.js +1 -1
  238. package/lib/resorts/sugarbowl/index.js +1 -1
  239. package/lib/resorts/sugarbush/index.js +1 -1
  240. package/lib/resorts/sugarloaf/index.js +1 -1
  241. package/lib/resorts/sun-peaks/index.js +1 -1
  242. package/lib/resorts/sun-peaks/resort.json +1 -1
  243. package/lib/resorts/sunday-river/index.js +1 -1
  244. package/lib/resorts/sunshine-village/index.js +6 -3
  245. package/lib/resorts/sunvalley/index.js +1 -1
  246. package/lib/resorts/tahoe-donner/index.js +1 -1
  247. package/lib/resorts/taos/index.js +1 -1
  248. package/lib/resorts/tarvisio/index.js +1 -1
  249. package/lib/resorts/tarvisio/resort.json +1 -1
  250. package/lib/resorts/telluride/index.js +1 -1
  251. package/lib/resorts/thredbo/index.js +1 -1
  252. package/lib/resorts/tignes/index.js +1 -1
  253. package/lib/resorts/tignes/resort.json +1 -1
  254. package/lib/resorts/timberline-lodge/index.js +1 -1
  255. package/lib/resorts/tremblant/index.js +1 -1
  256. package/lib/resorts/vail/index.js +1 -1
  257. package/lib/resorts/val-di-fassa/index.js +1 -1
  258. package/lib/resorts/val-di-fassa/resort.json +1 -1
  259. package/lib/resorts/val-di-fiemme/index.js +1 -1
  260. package/lib/resorts/val-di-fiemme/resort.json +1 -1
  261. package/lib/resorts/val-gardena/index.js +1 -1
  262. package/lib/resorts/val-gardena/resort.json +1 -1
  263. package/lib/resorts/valdisere/index.js +1 -1
  264. package/lib/resorts/valdisere/resort.json +1 -1
  265. package/lib/resorts/verbier/index.js +1 -1
  266. package/lib/resorts/waterville/index.js +1 -1
  267. package/lib/resorts/whistler-blackcomb/index.js +2 -2
  268. package/lib/resorts/whistler-blackcomb/resort.json +1 -1
  269. package/lib/resorts/whiteface/index.js +1 -1
  270. package/lib/resorts/whitefish/index.js +1 -1
  271. package/lib/resorts/wildcat/index.js +1 -1
  272. package/lib/resorts/windham/index.js +1 -1
  273. package/lib/resorts/winter-park/index.js +1 -1
  274. package/lib/resorts/winterplace/index.js +1 -1
  275. package/lib/routes/cache.js +4 -4
  276. package/lib/routes/canonical.js +1 -3
  277. package/lib/routes/data.js +10 -12
  278. package/lib/routes/database.js +6 -7
  279. package/lib/routes/headers.js +2 -2
  280. package/lib/routes/index.js +9 -11
  281. package/lib/routes/plan.js +2 -4
  282. package/lib/routes/service-worker.js +6 -7
  283. package/lib/routes/sorter.js +2 -4
  284. package/lib/routes/tags.js +2 -4
  285. package/lib/select.js +3 -5
  286. package/lib/tools/aspen.js +4 -4
  287. package/lib/tools/boyne.js +4 -4
  288. package/lib/tools/campiglio-dolomiti.js +1 -1
  289. package/lib/tools/coerce.js +4 -4
  290. package/lib/tools/dolomitisuperski.js +1 -1
  291. package/lib/tools/domutil.js +11 -18
  292. package/lib/tools/infosnow.js +6 -6
  293. package/lib/tools/intrawest.js +3 -3
  294. package/lib/tools/limiter.js +2 -4
  295. package/lib/tools/lumiplan.js +2 -2
  296. package/lib/tools/millis.js +4 -11
  297. package/lib/tools/powdr.js +4 -4
  298. package/lib/tools/prism.js +5 -5
  299. package/lib/tools/skiplan.js +1 -1
  300. package/lib/tools/turismofvg.js +2 -2
  301. package/lib/tools/vail.js +8 -10
  302. package/lib/tools/vialattea.js +1 -1
  303. package/lib/weather/icons.js +3 -8
  304. package/lib/weather/index.js +5 -6
  305. package/lib/weather/noaa.js +5 -3
  306. package/lib/weather/openweather.js +6 -7
  307. package/lib/webcams.js +6 -6
  308. package/package.json +3 -2
  309. package/public/scripts/liftie-embed.js.map +2 -2
  310. package/public/scripts/liftie.js +615 -695
  311. package/public/scripts/liftie.js.map +4 -4
package/Makefile CHANGED
@@ -77,10 +77,10 @@ node_modules: package.json pnpm-lock.yaml
77
77
  .NOTPARALLEL: node_modules
78
78
 
79
79
  lint: | node_modules
80
- $(NODE_BIN)/biome check $(LINT_SRC)
80
+ $(NODE_BIN)/biome ci $(LINT_SRC)
81
81
 
82
82
  format: | node_modules
83
- $(NODE_BIN)/biome format --write $(LINT_SRC)
83
+ $(NODE_BIN)/biome check --write $(LINT_SRC)
84
84
 
85
85
  test: | node_modules
86
86
  node --test $(TESTS)
package/app.js CHANGED
@@ -1,23 +1,31 @@
1
- const connect = require('@pirxpilot/connect');
2
- const cachifyStatic = require('connect-cachify-static');
3
- const gzip = require('connect-gzip-static');
4
- const http = require('node:http');
5
- const path = require('node:path');
6
- const loaders = require('./lib/loaders');
7
- const plugins = require('./lib/plugins');
8
-
9
- const cookieParser = require('@pirxpilot/cookie-parser');
10
- const logger = require('morgan');
11
- const errorHandler = require('errorhandler');
12
- const renderer = require('connect-renderer');
13
-
14
- const app = (module.exports = connect());
1
+ import http from 'node:http';
2
+ import path from 'node:path';
3
+ import connect from '@pirxpilot/connect';
4
+ import cookieParser from '@pirxpilot/cookie-parser';
5
+ import { compile } from '@pirxpilot/jade-core';
6
+ import cachifyStatic from 'connect-cachify-static';
7
+ import gzip from 'connect-gzip-static';
8
+ import renderer from 'connect-renderer';
9
+ import errorHandler from 'errorhandler';
10
+ import logger from 'morgan';
11
+ import lifts from './lib/lifts/index.js';
12
+ import loader from './lib/loader.js';
13
+ import * as loaders from './lib/loaders.js';
14
+ import opening from './lib/opening.js';
15
+ import * as plugins from './lib/plugins.js';
16
+ import dataRoutes from './lib/routes/data.js';
17
+ import routes from './lib/routes/index.js';
18
+ import weather from './lib/weather/index.js';
19
+ import webcams from './lib/webcams.js';
20
+
21
+ const app = connect();
22
+ export default app;
15
23
 
16
24
  process.env.PORT ??= 3000;
17
25
  process.env.SITE_URL ??= `http://localhost:${process.env.PORT}`;
18
26
  process.env.NODE_ENV ??= 'development';
19
27
 
20
- const root = path.join(__dirname, 'public');
28
+ const root = path.join(path.dirname(new URL(import.meta.url).pathname), 'public');
21
29
  const { SITE_URL: siteUrl, LIFTIE_STATIC_HOST: staticHost = '' } = process.env;
22
30
 
23
31
  const cachify = cachifyStatic(root);
@@ -34,8 +42,8 @@ app.locals = {
34
42
  };
35
43
 
36
44
  app.use(
37
- renderer(`${__dirname}/views`).engine('jade', {
38
- compile: require('@pirxpilot/jade-core').compile,
45
+ renderer(`${path.dirname(new URL(import.meta.url).pathname)}/views`).engine('jade', {
46
+ compile,
39
47
  options: { compileDebug: process.env.NODE_ENV !== 'production' }
40
48
  })
41
49
  );
@@ -59,17 +67,17 @@ if (process.env.NODE_ENV === 'development') {
59
67
  }
60
68
 
61
69
  app.loaders = loaders;
62
- app.loaders.register(require('./lib/loader'));
70
+ app.loaders.register(loader);
63
71
 
64
72
  app.plugins = plugins;
65
- app.plugins.register('lifts', require('./lib/lifts'));
66
- app.plugins.register('opening', require('./lib/opening'));
67
- app.plugins.register('weather', require('./lib/weather'));
68
- app.plugins.register('webcams', require('./lib/webcams'));
73
+ app.plugins.register('lifts', lifts);
74
+ app.plugins.register('opening', opening);
75
+ app.plugins.register('weather', weather);
76
+ app.plugins.register('webcams', webcams);
69
77
 
70
- app.data = require('./lib/routes/data')();
78
+ app.data = dataRoutes();
71
79
 
72
- require('./lib/routes')(app);
80
+ routes(app);
73
81
 
74
82
  app.run = function run() {
75
83
  app.data.init(err => {
@@ -84,6 +92,6 @@ app.run = function run() {
84
92
  });
85
93
  };
86
94
 
87
- if (!module.parent) {
95
+ if (import.meta.main) {
88
96
  app.run();
89
97
  }
package/lib/checker.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = checkNames;
1
+ export default checkNames;
2
2
 
3
3
  /**
4
4
  * Converts comma separated list of resort names to an array of valid resort names
package/lib/cli/curl.js CHANGED
@@ -1,14 +1,14 @@
1
- const path = require('node:path');
2
- const fs = require('node:fs');
3
- const request = require('../lifts/request');
4
- const dirs = require('./dirs');
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { pipeline } from 'node:stream/promises';
4
+ import request from '../lifts/request.js';
5
+ import * as dirs from './dirs.js';
5
6
 
6
- module.exports = curl;
7
-
8
- function curl(url, resortId) {
7
+ export default async function curl(url, resortId) {
9
8
  const dst = path.join(dirs.test, 'example', `${resortId}.html`);
10
9
  const dstStream = fs.createWriteStream(dst);
11
10
 
12
11
  console.log('Fetching %s to %s...', url.host + url.pathname, dst);
13
- request(url).pipe(dstStream);
12
+ const res = await request(url);
13
+ return pipeline(res.body, dstStream);
14
14
  }
package/lib/cli/dirs.js CHANGED
@@ -1,7 +1,9 @@
1
- const path = require('node:path');
1
+ import { resolve } from 'node:path';
2
2
 
3
- module.exports = {
4
- templates: path.resolve(__dirname, '../../templates'),
5
- lib: path.resolve(__dirname, '../resorts'),
6
- test: path.resolve(__dirname, '../../test/resorts')
7
- };
3
+ export const templates = resolve(import.meta.dirname, '../../templates');
4
+ export const lib = resolve(import.meta.dirname, '../resorts');
5
+ export const test = resolve(import.meta.dirname, '../../test/resorts');
6
+
7
+ export function descriptorPath(resortId) {
8
+ return resolve(import.meta.dirname, '..', 'resorts', resortId, 'resort.json');
9
+ }
package/lib/cli/fetch.js CHANGED
@@ -1,17 +1,17 @@
1
- const { program } = require('commander');
2
- const curl = require('./curl');
1
+ import { readFileSync } from 'node:fs';
2
+ import { program } from 'commander';
3
+ import curl from './curl.js';
4
+ import { descriptorPath } from './dirs.js';
3
5
 
4
6
  let done;
5
7
 
6
- function fetchExample(resortId) {
7
- let resort;
8
-
8
+ async function fetchExample(resortId) {
9
9
  try {
10
- resort = require(`../resorts/${resortId}/resort.json`);
11
- curl(resort.dataUrl || resort.api || resort.url, resortId);
10
+ const resort = JSON.parse(readFileSync(descriptorPath(resortId), 'utf8'));
12
11
  done = true;
13
- } catch {
14
- console.error(resortId, 'is not a valid resort ID');
12
+ await curl(resort.dataUrl || resort.api || resort.url, resortId);
13
+ } catch (e) {
14
+ console.error(resortId, 'is not a valid resort ID', e);
15
15
  process.exit(1);
16
16
  }
17
17
  }
@@ -1,7 +1,6 @@
1
- const { readdir } = require('node:fs');
2
- const { lib } = require('./dirs');
3
-
4
- module.exports = forEachResort;
1
+ import { readdir } from 'node:fs';
2
+ import { lib } from './dirs.js';
3
+ export default forEachResort;
5
4
 
6
5
  function forEachResort(fn) {
7
6
  console.log('Reading:', lib);
@@ -1,11 +1,11 @@
1
- const { program } = require('commander');
2
- const prompt = require('prompt');
3
- const url = require('node:url');
4
- const fs = require('node:fs');
5
- const path = require('node:path');
6
- const template = require('lodash').template;
7
- const curl = require('./curl');
8
- const dirs = require('./dirs');
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+ import { program } from 'commander';
5
+ import _ from 'lodash';
6
+ import prompt from 'prompt';
7
+ import curl from './curl.js';
8
+ import * as dirs from './dirs.js';
9
9
 
10
10
  let fname;
11
11
  const schema = [
@@ -84,7 +84,7 @@ if (program.json) {
84
84
 
85
85
  function generate(resort) {
86
86
  console.log('Generating files for %s', resort.name);
87
- const resortDir = path.join(dirs.lib, resort.id);
87
+ const resortDir = path.resolve(import.meta.dirname, '..', 'resorts', resort.id);
88
88
 
89
89
  fs.mkdirSync(resortDir);
90
90
  copy(path.join(dirs.templates, 'index.js'), path.join(resortDir, 'index.js'), resort);
@@ -113,7 +113,7 @@ function write(dst, json) {
113
113
  function copy(src, dst, params) {
114
114
  console.log('Generating %s...', dst);
115
115
  fs.readFile(src, 'utf8', (_err, data) => {
116
- data = template(data)(params);
116
+ data = _.template(data)(params);
117
117
  fs.writeFileSync(dst, data);
118
118
  });
119
119
  }
package/lib/cli/noaa.js CHANGED
@@ -1,8 +1,7 @@
1
- const { program } = require('commander');
2
- const { writeFileSync } = require('node:fs');
3
- const { resolve } = require('node:path');
4
-
5
- const forEachResort = require('./for-each-resort');
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { program } from 'commander';
3
+ import { descriptorPath } from './dirs.js';
4
+ import forEachResort from './for-each-resort.js';
6
5
 
7
6
  let done = false;
8
7
 
@@ -51,19 +50,15 @@ function noaaForResort(resortId, { overwrite }) {
51
50
  .catch(e => console.error('Cannot find NOAA station for:', resortId, e));
52
51
  }
53
52
 
54
- function descriptorPath(resortId, absolute) {
55
- const p = `../resorts/${resortId}/resort.json`;
56
- return absolute ? resolve(__dirname, p) : p;
57
- }
58
-
59
53
  function writeDescriptor(resortId, descriptor) {
60
- const filename = descriptorPath(resortId, true);
54
+ const filename = descriptorPath(resortId);
61
55
  writeFileSync(filename, `${JSON.stringify(descriptor, null, 2)}\n`);
62
56
  }
63
57
 
64
58
  function readDescriptor(resortId) {
65
59
  try {
66
- return require(`../resorts/${resortId}/resort.json`);
60
+ const filename = descriptorPath(resortId);
61
+ return JSON.parse(readFileSync(filename, 'utf8'));
67
62
  } catch {
68
63
  console.error(resortId, 'is not a valid resort ID');
69
64
  process.exit(1);
@@ -1,10 +1,6 @@
1
- const cookie = require('js-cookie');
1
+ import cookie from 'js-cookie';
2
2
 
3
- /*global document, window*/
4
-
5
- module.exports = about;
6
-
7
- function about() {
3
+ export default function about() {
8
4
  const s = document.querySelector('.hidden .about');
9
5
  if (!s) {
10
6
  // no hidden 'about' section - nothing to do
@@ -1,8 +1,4 @@
1
- const debounce = require('debounce');
2
-
3
- module.exports = postHeight;
4
-
5
- /*global window, document*/
1
+ import debounce from 'debounce';
6
2
 
7
3
  function notify() {
8
4
  const widget = document.querySelector('.widget');
@@ -18,7 +14,7 @@ function notify() {
18
14
  );
19
15
  }
20
16
 
21
- function postHeight() {
17
+ export default function postHeight() {
22
18
  if (window === window.parent) {
23
19
  // we are not embedded - nothing to do
24
20
  return;
@@ -1,14 +1,11 @@
1
- const minimax = require('../minimax');
2
- const resort = require('../resort');
3
- const state = require('../state');
4
- const tag = require('../tag');
5
- const about = require('../about');
6
- const stats = require('../stats');
7
- const height = require('./height');
8
- const serviceWorker = require('./service-worker');
9
-
10
- /*global document */
11
- /*global window */
1
+ import about from '../about/index.js';
2
+ import minimax from '../minimax/index.js';
3
+ import resort from '../resort/index.js';
4
+ import state from '../state/index.js';
5
+ import stats from '../stats/index.js';
6
+ import tag from '../tag/index.js';
7
+ import height from './height.js';
8
+ import serviceWorker from './service-worker.js';
12
9
 
13
10
  serviceWorker();
14
11
  init();
@@ -1,7 +1,3 @@
1
- module.exports = register;
2
-
3
- /* global navigator, console */
4
-
5
1
  function registrationHandler({ scope, installing, waiting, active }) {
6
2
  console.log('SW', scope);
7
3
 
@@ -16,7 +12,7 @@ function registrationHandler({ scope, installing, waiting, active }) {
16
12
  }
17
13
  }
18
14
 
19
- function register(url = '/sw.js') {
15
+ export default function register(url = '/sw.js') {
20
16
  if (navigator.serviceWorker && document.documentElement.hasAttribute('data-service-worker')) {
21
17
  return navigator.serviceWorker
22
18
  .register(url)
@@ -1,10 +1,8 @@
1
- module.exports = minimax;
2
-
3
1
  /**
4
2
  * @param {Array} elements list of affected element
5
3
  * @param {Element} trigger button|link that flips min, max state
6
4
  */
7
- function minimax(node, selector) {
5
+ export default function minimax(node, selector) {
8
6
  const my = {
9
7
  trigger: node.querySelector(selector),
10
8
  state: 'open', // by default trigger 'open' state
@@ -1,14 +1,9 @@
1
- function removeAllChildren(node) {
1
+ export function removeAllChildren(node) {
2
2
  while (node.hasChildNodes()) {
3
3
  node.removeChild(node.lastChild);
4
4
  }
5
5
  }
6
6
 
7
- function next({ nextElementSibling, nextSibling }) {
7
+ export function next({ nextElementSibling, nextSibling }) {
8
8
  return nextElementSibling || nextSibling;
9
9
  }
10
-
11
- module.exports = {
12
- next,
13
- removeAllChildren
14
- };
@@ -1,6 +1,8 @@
1
- const dom = require('./dom');
2
-
3
- module.exports = resort;
1
+ import * as dom from './dom.js';
2
+ import lifts from './lifts.js';
3
+ import snow from './snow.js';
4
+ import weather from './weather.js';
5
+ import webcams from './webcams.js';
4
6
 
5
7
  function renderOpening(node, opening) {
6
8
  if (opening) {
@@ -13,12 +15,7 @@ function renderOpening(node, opening) {
13
15
  }
14
16
  }
15
17
 
16
- const plugins = [
17
- require('../resort/lifts'),
18
- require('../resort/weather'),
19
- require('../resort/webcams'),
20
- require('../resort/snow')
21
- ];
18
+ const plugins = [lifts, weather, webcams, snow];
22
19
 
23
20
  function renderPlugins(node, getData) {
24
21
  const sec = dom.next(node); // extras section
@@ -60,7 +57,7 @@ function render(node, resort) {
60
57
 
61
58
  const MAX = 12; // update every 12th time
62
59
 
63
- function resort(node) {
60
+ export default function resort(node) {
64
61
  let updateCounter = MAX;
65
62
 
66
63
  function updateTimeToRefresh(counter) {
@@ -1,8 +1,7 @@
1
- const dom = require('./dom');
1
+ import * as dom from './dom.js';
2
2
 
3
- module.exports = render;
4
- module.exports.section = 0;
5
- module.exports.type = 'lifts';
3
+ render.section = 0;
4
+ render.type = 'lifts';
6
5
 
7
6
  const states = ['open', 'hold', 'scheduled', 'closed'];
8
7
 
@@ -29,7 +28,7 @@ function renderColorBar(node, percentage) {
29
28
  });
30
29
  }
31
30
 
32
- function render(node, { status, stats }) {
31
+ export default function render(node, { status, stats }) {
33
32
  renderStatus(node.querySelector('.lifts'), status);
34
33
  renderStats(node.querySelector('.summary'), stats);
35
34
  renderColorBar(node.querySelector('.summary-color-bar'), stats.percentage);
@@ -1,8 +1,7 @@
1
1
  const day = 24 * 60 * 60 * 1000;
2
2
 
3
- module.exports = render;
4
- module.exports.section = 1;
5
- module.exports.type = 'snow';
3
+ render.section = 1;
4
+ render.type = 'snow';
6
5
 
7
6
  // .snow
8
7
  // .snowfall= resort.snow.snowfall
@@ -17,7 +16,7 @@ function renderField(div, field, snow) {
17
16
  el.classList.toggle('hidden', !value);
18
17
  }
19
18
 
20
- function render(div, snow) {
19
+ export default function render(div, snow) {
21
20
  if (Date.now() - snow.timestamp > day) {
22
21
  return false;
23
22
  }
@@ -1,8 +1,7 @@
1
1
  const day = 24 * 60 * 60 * 1000;
2
2
 
3
- module.exports = render;
4
- module.exports.section = 1;
5
- module.exports.type = 'weather';
3
+ render.section = 1;
4
+ render.type = 'weather';
6
5
 
7
6
  // .weather
8
7
  // .weather-icon
@@ -37,7 +36,7 @@ function renderNotice(el, notice) {
37
36
  el.setAttribute('alt', notice.site);
38
37
  }
39
38
 
40
- function render(div, weather) {
39
+ export default function render(div, weather) {
41
40
  if (Date.now() - weather.timestamp > day) {
42
41
  return false;
43
42
  }
@@ -1,11 +1,8 @@
1
- const swipe = require('@pirxpilot/swipe');
2
- const pager = require('tiny-pager');
1
+ import swipe from '@pirxpilot/swipe';
2
+ import pager from 'tiny-pager';
3
3
 
4
- /*global setInterval,clearInterval */
5
-
6
- module.exports = render;
7
- module.exports.section = 1;
8
- module.exports.type = 'webcams';
4
+ render.section = 1;
5
+ render.type = 'webcams';
9
6
 
10
7
  const DELAY = 15 * 60 * 1000; // update every 15 minutes
11
8
 
@@ -44,7 +41,7 @@ function swiper(el) {
44
41
  };
45
42
  }
46
43
 
47
- function render(div, webcams) {
44
+ export default function render(div, webcams) {
48
45
  let cams;
49
46
  let timer;
50
47
  let ui;
@@ -1,12 +1,9 @@
1
- const cookie = require('js-cookie');
1
+ import K from '@pirxpilot/k';
2
+ import cookie from 'js-cookie';
2
3
 
3
- /*global window*/
4
+ const k = K(window);
4
5
 
5
- const k = require('@pirxpilot/k')(window);
6
-
7
- module.exports = state;
8
-
9
- function state(nodes, st, keys) {
6
+ export default function state(nodes, st, keys) {
10
7
  const cookieName = `resorts-${st}`;
11
8
 
12
9
  const self = {
@@ -1,8 +1,4 @@
1
- module.exports = stats;
2
-
3
- /* global document */
4
-
5
- function stats() {
1
+ export default function stats() {
6
2
  const pie = document.querySelector('.stats .pie');
7
3
  if (!pie) {
8
4
  return;
@@ -1,6 +1,4 @@
1
- module.exports = tag;
2
-
3
- function tag(node) {
1
+ export default function tag(node) {
4
2
  let count;
5
3
 
6
4
  function update(c) {
@@ -1,5 +1,3 @@
1
- /*global document, window */
2
-
3
1
  function el(attrs) {
4
2
  const attrStr = Object.keys(attrs)
5
3
  .map(attr => `${attr}="${attrs[attr]}"`)
@@ -1,16 +1,16 @@
1
- const debug = require('debug')('liftie:lifts');
1
+ import Debug from 'debug';
2
+ import getParseFn from './parse.js';
3
+ import pipe from './pipe.js';
4
+ import rest from './rest.js';
5
+ import stats from './stats.js';
2
6
 
3
- const pipe = require('./pipe');
4
- const rest = require('./rest');
5
- const stats = require('./stats');
6
- const getParseFn = require('./parse');
7
+ const debug = Debug('liftie:lifts');
7
8
 
8
- const interval = 60 * 1000; // once a minute - fetch status if there were requests
9
- const longInterval = 30 * interval; // once every 30 minutes - fetch even if there wasn't any requests
9
+ const shortInterval = 60 * 1000; // once a minute - fetch status if there were requests
10
+ const longInterval = 30 * shortInterval; // once every 30 minutes - fetch even if there wasn't any requests
10
11
 
11
- module.exports = fetch;
12
- module.exports.interval = {
13
- active: interval,
12
+ fetch.interval = {
13
+ active: shortInterval,
14
14
  inactive: longInterval
15
15
  };
16
16
 
@@ -39,12 +39,12 @@ function getRequestFnAndUrl(resort) {
39
39
  };
40
40
  }
41
41
 
42
- function fetch(resort, fn) {
42
+ export default async function fetch(resort, fn) {
43
43
  if (!resort._rfau) {
44
44
  resort._rfau = getRequestFnAndUrl(resort);
45
45
  }
46
46
  if (!resort._parseFn) {
47
- resort._parseFn = getParseFn(resort.id);
47
+ resort._parseFn = await getParseFn(resort.id);
48
48
  }
49
49
  debug('Fetch lift status for %s', resort.id);
50
50
  const rfau = resort._rfau;
@@ -1,13 +1,13 @@
1
- const domutil = require('../tools/domutil');
2
- const debug = require('debug')('liftie:lifts');
1
+ import Debug from 'debug';
2
+ import * as domutil from '../tools/domutil.js';
3
3
 
4
- module.exports = getParseFn;
4
+ const debug = Debug('liftie:lifts');
5
5
 
6
6
  /**
7
7
  * catch exceptions thrown by parse
8
8
  */
9
- function getParseFn(resortId) {
10
- const descriptor = require(`../resorts/${resortId}`);
9
+ export default async function getParseFn(resortId) {
10
+ const { default: descriptor } = await import(`../resorts/${resortId}/index.js`);
11
11
  const parse = typeof descriptor === 'function' ? descriptor : collectParse;
12
12
 
13
13
  wrappedParse.isAsync = parse.length > 1;
@@ -1,13 +1,9 @@
1
- const { nextTick } = require('node:process');
2
- const { DomHandler, Text } = require('domhandler');
3
- const { ElementType } = require('domelementtype');
4
- const { WritableStream } = require('htmlparser2/WritableStream');
1
+ import { nextTick } from 'node:process';
2
+ import { ElementType } from 'domelementtype';
3
+ import { DomHandler, Text } from 'domhandler';
4
+ import { WritableStream } from 'htmlparser2/WritableStream';
5
5
 
6
- module.exports = parserStream;
7
-
8
- parserStream.html = parseHtml;
9
-
10
- function parseHtml(html, parse, fn) {
6
+ export function parseHtml(html, parse, fn) {
11
7
  const stream = parserStream(parse, fn);
12
8
  stream.write(html);
13
9
  stream.end();
@@ -43,7 +39,7 @@ class IgnoreEmptiesDomHandler extends DomHandler {
43
39
  * @param fn(err, data) - callback that receives identified data pieces (or error),
44
40
  * first error should stop parsing
45
41
  */
46
- function parserStream(parse, fn) {
42
+ export default function parserStream(parse, fn) {
47
43
  function handle(err, dom) {
48
44
  return err ? fn(err) : nextTick(fn, null, parse(dom));
49
45
  }
package/lib/lifts/pipe.js CHANGED
@@ -1,7 +1,7 @@
1
- const request = require('./request');
2
- const { html: parseHtml } = require('./parser');
1
+ import { parseHtml } from './parser.js';
2
+ import request from './request.js';
3
3
 
4
- module.exports = (url, parse, fn) => {
4
+ export default (url, parse, fn) => {
5
5
  request(url)
6
6
  .then(async res => {
7
7
  if (res.status < 200 || res.status >= 300) {