Skip to content

Commit

Permalink
Switch to modular imports of @hdate libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
SLaks committed Nov 8, 2024
1 parent 32b5434 commit 4a712ae
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 36 deletions.
75 changes: 54 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions src/calendar-model/generator.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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

Expand Down
15 changes: 7 additions & 8 deletions src/calendar-model/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HDate, HebrewCalendar, Locale, months } from '@hebcal/core'
import { HDate, months } from '@hebcal/hdate'
import type {
LeiningAliyah,
LeiningDate,
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/calendar-model/hebcal-conversions.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/components/ParshaPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/view-model/scroll-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4a712ae

Please sign in to comment.