From 5688ed9e2c73deaa8c48d6fedae0f9ce95d3be8a 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 See hebcal/hebcal-es6#475 --- package-lock.json | 1 + package.json | 1 + src/calendar-model/generator.test.ts | 5 +++-- src/calendar-model/generator.ts | 14 ++++++-------- src/calendar-model/hebcal-conversions.ts | 3 ++- src/components/ParshaPicker.ts | 2 +- src/view-model/scroll-view-model.ts | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93e3922d..7c67d35b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@hebcal/core": "^5.6.1", + "@hebcal/hdate": "^0.11.5", "@hebcal/leyning": "^8.2.9", "normalize.css": "^8.0.1" }, diff --git a/package.json b/package.json index 52656de2..76403f47 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "homepage": "https://github.com/akivajgordon/tikkun.io#readme", "dependencies": { "@hebcal/core": "^5.6.1", + "@hebcal/hdate": "^0.11.5", "@hebcal/leyning": "^8.2.9", "normalize.css": "^8.0.1" }, diff --git a/src/calendar-model/generator.test.ts b/src/calendar-model/generator.test.ts index e914c00d..92533c00 100644 --- a/src/calendar-model/generator.test.ts +++ b/src/calendar-model/generator.test.ts @@ -1,12 +1,13 @@ 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 { HDate, Locale, 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/es/holidays' const testSettings: UserSettings = { ashkenazi: true, @@ -60,7 +61,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..878f024f 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, Locale, 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,8 @@ import { } from './utils.ts' import { toLeiningAliyah, toAliyahIndex } from './hebcal-conversions.ts' import { isSameRun } from './ref-utils.ts' +import { getSedra } from '@hebcal/core/dist/es/sedra' +import { getLeyningOnDate } from '@hebcal/leyning/dist/es/getLeyningOnDate' export function isSameLeiningDate(a: LeiningDate, b: LeiningDate) { return arrayEquals(a.leinings, b.leinings, isSameLeiningInstance) @@ -97,10 +98,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..dca14891 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/es/types' +import { BOOK, calculateNumVerses } from '@hebcal/leyning/dist/es/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 a5b10caf..f598ae9f 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,