From 4a712aed051089720f85900503ad421fe5e9c96f Mon Sep 17 00:00:00 2001 From: SLaks Date: Sun, 3 Nov 2024 21:30:17 -0500 Subject: [PATCH] Switch to modular imports of @hdate libraries See hebcal/hebcal-es6#475 --- package-lock.json | 75 +++++++++++++++++------- package.json | 5 +- src/calendar-model/generator.test.ts | 6 +- src/calendar-model/generator.ts | 15 +++-- src/calendar-model/hebcal-conversions.ts | 3 +- src/components/ParshaPicker.ts | 2 +- src/view-model/scroll-view-model.ts | 2 +- 7 files changed, 72 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63ccd1fa..aa1adef7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,9 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@hebcal/core": "^5.6.1", - "@hebcal/leyning": "^8.2.9", + "@hebcal/core": "^5.7.7", + "@hebcal/hdate": "^0.12.0", + "@hebcal/leyning": "^9.0.1", "normalize.css": "^8.0.1" }, "devDependencies": { @@ -26,6 +27,18 @@ "vite": "^5.4.7" } }, + "node_modules/@babel/runtime": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", + "integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==", + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -560,36 +573,40 @@ } }, "node_modules/@hebcal/core": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-5.6.1.tgz", - "integrity": "sha512-/QthSSaZn2htaB8RlBu4ft96bcQYzu7j0PDP516+Bip7B86cGZiC7BvRg7QnXG1Jo+voMBJrMtlE0CNikgIILw==", + "version": "5.7.7", + "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-5.7.7.tgz", + "integrity": "sha512-Tt+sfAsTi9NmZbtvz4Q86yJ/qCOE7NgImPiKgZiLifoCQ/XPfnRBFn0tZKXVyzIfF4Io/cpyL1rPg8xGsb/o2Q==", + "license": "GPL-2.0", "dependencies": { - "@hebcal/hdate": "^0.11.5", + "@babel/runtime": "^7.26.0", + "@hebcal/hdate": "^0.12.0", "@hebcal/noaa": "^0.8.14", + "quick-lru": "^6.1.2", + "temporal-polyfill": "^0.2.5", "tslib": "^2.8.1" }, "engines": { "node": ">= 16.0.0" - }, - "peerDependencies": { - "temporal-polyfill": "^0.2.5" } }, "node_modules/@hebcal/hdate": { - "version": "0.11.5", - "resolved": "https://registry.npmjs.org/@hebcal/hdate/-/hdate-0.11.5.tgz", - "integrity": "sha512-L/39A8hZXUdAIIv7vzZoPmmwlV9Ck+Zwl7dPl/6EnsRmZ6FCf9Y1PkFj8p4lOJD+vYSbo7DwACyUqMeKX3u7aA==" + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@hebcal/hdate/-/hdate-0.12.0.tgz", + "integrity": "sha512-C2oR2daoTcu3jG4e3xE8Net34w4Xf/52pzpDp03xR8vqLlO1UFJ3trLhto6/0uqSyWf4b7KeqWZxvDWjagEA4w==", + "license": "GPL-2.0" }, "node_modules/@hebcal/leyning": { - "version": "8.2.9", - "resolved": "https://registry.npmjs.org/@hebcal/leyning/-/leyning-8.2.9.tgz", - "integrity": "sha512-D6stHgYBtVr2QPimQHaDusb3DKzR8nlfJJjK6nG+o5vi1nLdTjTbKLToTYviF7i5Wx6YC9359nm9Da59+uBLYQ==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@hebcal/leyning/-/leyning-9.0.1.tgz", + "integrity": "sha512-0LUSniVLIR4HGAeuv+lrAlftLm7MolT+h46MajQC4ETW6iXm7bJYv5+xsJTiUFFkkydR+l+esRQxahF9KAeMcA==", + "license": "BSD-2-Clause", "dependencies": { - "@hebcal/core": "^5.6.1", + "@hebcal/core": "^5.7.7", + "@hebcal/hdate": "^0.12.0", "tslib": "^2.8.1" }, - "bin": { - "leyning-csv": "bin/leyning-csv" + "engines": { + "node": ">=18" } }, "node_modules/@hebcal/noaa": { @@ -3500,6 +3517,18 @@ } ] }, + "node_modules/quick-lru": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.2.tgz", + "integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -3522,6 +3551,12 @@ "node": ">=8.10.0" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "license": "MIT" + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3897,7 +3932,6 @@ "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.5.tgz", "integrity": "sha512-ye47xp8Cb0nDguAhrrDS1JT1SzwEV9e26sSsrWzVu+yPZ7LzceEcH0i2gci9jWfOfSCCgM3Qv5nOYShVUUFUXA==", "license": "MIT", - "peer": true, "dependencies": { "temporal-spec": "^0.2.4" } @@ -3906,8 +3940,7 @@ "version": "0.2.4", "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.2.4.tgz", "integrity": "sha512-lDMFv4nKQrSjlkHKAlHVqKrBG4DyFfa9F74cmBZ3Iy3ed8yvWnlWSIdi4IKfSqwmazAohBNwiN64qGx4y5Q3IQ==", - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/text-table": { "version": "0.2.0", diff --git a/package.json b/package.json index 60be7dbe..3cdb942f 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,9 @@ }, "homepage": "https://github.com/akivajgordon/tikkun.io#readme", "dependencies": { - "@hebcal/core": "^5.6.1", - "@hebcal/leyning": "^8.2.9", + "@hebcal/core": "^5.7.7", + "@hebcal/hdate": "^0.12.0", + "@hebcal/leyning": "^9.0.1", "normalize.css": "^8.0.1" }, "devDependencies": { diff --git a/src/calendar-model/generator.test.ts b/src/calendar-model/generator.test.ts index e914c00d..ef30c954 100644 --- a/src/calendar-model/generator.test.ts +++ b/src/calendar-model/generator.test.ts @@ -1,12 +1,14 @@ import test from 'ava' import type { UserSettings } from './user-settings.ts' import { LeiningGenerator } from './generator.ts' -import { HDate, HebrewCalendar, Locale, months } from '@hebcal/core' +import { Locale } from '@hebcal/leyning/dist/esm/locale' +import { HDate, months } from '@hebcal/hdate' import type { LeiningAliyah, LeiningDate, LeiningRun } from './model-types.ts' import hebrewNumeralFromInteger from '../hebrew-numeral.ts' import type { Ref } from '../ref.ts' import { getBookName } from './hebcal-conversions.ts' import { last, toISODateString } from './utils.ts' +import { getHolidaysOnDate } from '@hebcal/core/dist/esm/holidays' const testSettings: UserSettings = { ashkenazi: true, @@ -60,7 +62,7 @@ test('4 פרשיות always get separate runs', (t) => { const start = new HDate(20, months.SHVAT, year) for (let day = 0; day < 100; day++) { const date = start.add(day, 'days') - const events = HebrewCalendar.getHolidaysOnDate(date) + const events = getHolidaysOnDate(date) if (!events?.some((d) => fourParshaDescriptions.includes(d.desc))) continue diff --git a/src/calendar-model/generator.ts b/src/calendar-model/generator.ts index 6ac5bcf9..a169a672 100644 --- a/src/calendar-model/generator.ts +++ b/src/calendar-model/generator.ts @@ -1,4 +1,4 @@ -import { HDate, HebrewCalendar, Locale, months } from '@hebcal/core' +import { HDate, months } from '@hebcal/hdate' import type { LeiningAliyah, LeiningDate, @@ -7,14 +7,13 @@ import type { } from './model-types.ts' import { LeiningInstanceId, LeiningRunType } from './model-types.ts' import type { UserSettings } from './user-settings.ts' -import { +import type { Aliyah, AliyotMap, - getLeyningOnDate, LeyningBase, LeyningParshaHaShavua, LeyningShabbatHoliday, -} from '@hebcal/leyning' +} from '@hebcal/leyning/dist/types.d.ts' import { invert, fromISODateString, @@ -24,6 +23,9 @@ import { } from './utils.ts' import { toLeiningAliyah, toAliyahIndex } from './hebcal-conversions.ts' import { isSameRun } from './ref-utils.ts' +import { getSedra } from '@hebcal/core/dist/esm/sedra' +import { getLeyningOnDate } from '@hebcal/leyning/dist/esm/getLeyningOnDate' +import { Locale } from '@hebcal/leyning/dist/esm/locale' export function isSameLeiningDate(a: LeiningDate, b: LeiningDate) { return arrayEquals(a.leinings, b.leinings, isSameLeiningInstance) @@ -97,10 +99,7 @@ export class LeiningGenerator { until = new HDate(untilDay, months.TISHREI, 1 + containing.getFullYear()) // Get בראשית from the previous year. - const parshaFinder = HebrewCalendar.getSedra( - until.getFullYear() - 1, - this.settings.israel - ) + const parshaFinder = getSedra(until.getFullYear() - 1, this.settings.israel) return this.generateCalendar({ start: parshaFinder.find('Bereshit')!, until, diff --git a/src/calendar-model/hebcal-conversions.ts b/src/calendar-model/hebcal-conversions.ts index 5f01aa3b..9b1b83dd 100644 --- a/src/calendar-model/hebcal-conversions.ts +++ b/src/calendar-model/hebcal-conversions.ts @@ -1,6 +1,7 @@ /** @fileoverview Contains generic helpers to convert between @hebcal types and our model types. */ -import { Aliyah, BOOK, calculateNumVerses } from '@hebcal/leyning' +import type { Aliyah } from '@hebcal/leyning/dist/esm/types' +import { BOOK, calculateNumVerses } from '@hebcal/leyning/dist/esm/common' import type { RefWithScroll, ScrollName } from '../ref.ts' import type { LeiningAliyah } from './model-types.ts' diff --git a/src/components/ParshaPicker.ts b/src/components/ParshaPicker.ts index 6d3bf19c..8b81dc7b 100644 --- a/src/components/ParshaPicker.ts +++ b/src/components/ParshaPicker.ts @@ -4,7 +4,7 @@ import ParshaResult, { NoResults } from './ParshaResult.ts' import Search, { SearchEmitter } from './Search.ts' import EventEmitter from '../event-emitter.ts' import { LeiningGenerator } from '../calendar-model/generator.ts' -import { HDate, Locale } from '@hebcal/core' +import { HDate, Locale } from '@hebcal/hdate' import { LeiningInstance, LeiningInstanceId, diff --git a/src/view-model/scroll-view-model.ts b/src/view-model/scroll-view-model.ts index 25b08550..08862d4a 100644 --- a/src/view-model/scroll-view-model.ts +++ b/src/view-model/scroll-view-model.ts @@ -10,7 +10,7 @@ import { LeiningRunType, } from '../calendar-model/model-types.ts' import IntegerIterator from '../integer-iterator.ts' -import { HDate } from '@hebcal/core' +import { HDate } from '@hebcal/hdate' import { containsRef } from '../calendar-model/ref-utils.ts' import { fromISODateString,