Skip to content

Commit

Permalink
chore: deprecate core (#439)
Browse files Browse the repository at this point in the history
* chore: remove core dependency from midi

* chore: remove core dependency in key

* feat: cleanup chord-type dependencies

* chore: update mode dependencies

* chore: cleanup dependencies

* chore: update dependencies
  • Loading branch information
danigb authored Jul 23, 2024
1 parent 3cd5f16 commit b113754
Show file tree
Hide file tree
Showing 32 changed files with 1,313 additions and 3,071 deletions.
31 changes: 31 additions & 0 deletions .changeset/afraid-buttons-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
"@tonaljs/roman-numeral": patch
"@tonaljs/chord-detect": patch
"@tonaljs/progression": patch
"@tonaljs/chord-type": patch
"@tonaljs/scale-type": patch
"@tonaljs/pcset": patch
"@tonaljs/range": patch
"@tonaljs/scale": patch
"tonal": patch
"@tonaljs/midi": patch
"@tonaljs/mode": patch
"@tonaljs/note": patch
"@tonaljs/key": patch
---

#### `default` export is deprecated for @tonaljs modules

Using default exports for single packages are deprecated, so instead of:

```js
import Note from "@tonaljs/note";
```

You should do this:

```js
import * as Note from "@tonaljs/note";
```

The same for all modules.
14 changes: 0 additions & 14 deletions .changeset/curly-adults-move.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@ Now you can do:
import { Note } from "tonal";
Note.distance("c4", "e7"); // => "24M"
```

#### Note `default` export is deprecated

Using default exports for single packages are discouraged. For `note` module is now deprecated, so instead of:

```js
import Note from "@tonaljs/note";
```

You should do this:

```js
import * as Note from "@tonaljs/note";
```
4,081 changes: 1,137 additions & 2,944 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,24 @@
"testEnvironment": "node"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@changesets/cli": "^2.27.7",
"@types/jest": "^29.5.2",
"@types/node": "^20.10.1",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"esbuild": "^0.20.0",
"esbuild": "^0.23.0",
"eslint": "^8.54.0",
"jest": "^29.5.0",
"jest-config": "^29.5.0",
"lint-staged": "^15.1.0",
"lodash": "^4.17.15",
"prettier": "^3.1.0",
"ts-jest": "^29.1.0",
"tsup": "^8.0.0",
"turbo": "^1.10.3",
"tsup": "^8.2.2",
"turbo": "^2.0.0",
"typedoc": "^0.26.5",
"typedoc-plugin-markdown": "^4.2.2",
"typescript": "^5.2.2"
}
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
}
3 changes: 2 additions & 1 deletion packages/chord-detect/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { all, ChordType } from "@tonaljs/chord-type";
import { note } from "@tonaljs/core";
import { modes } from "@tonaljs/pcset";
import { note } from "@tonaljs/pitch-note";

interface FoundChord {
readonly weight: number;
Expand Down Expand Up @@ -124,4 +124,5 @@ function findMatches(
return found;
}

/** @deprecated */
export default { detect };
5 changes: 3 additions & 2 deletions packages/chord-detect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"chord-detect",
"music",
"theory",
"tonal"
"tonal",
"music-theory"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -16,7 +17,7 @@
"types": "dist/index.d.ts",
"dependencies": {
"@tonaljs/chord-type": "5.0.5",
"@tonaljs/core": "5.0.0",
"@tonaljs/pitch-note": "6.0.0",
"@tonaljs/pcset": "4.9.2"
},
"author": "[email protected]",
Expand Down
8 changes: 5 additions & 3 deletions packages/chord-type/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deprecate } from "@tonaljs/core";
import {
EmptyPcset,
get as pcset,
Expand Down Expand Up @@ -44,7 +43,8 @@ export function get(type: ChordTypeName): ChordType {
return index[type] || NoChordType;
}

export const chordType = deprecate("ChordType.chordType", "ChordType.get", get);
/** @deprecated */
export const chordType = get;

/**
* Get all chord (long) names
Expand Down Expand Up @@ -74,7 +74,8 @@ export function all(): ChordType[] {
return dictionary.slice();
}

export const entries = deprecate("ChordType.entries", "ChordType.all", all);
/** @deprecated */
export const entries = all;

/**
* Clear the dictionary
Expand Down Expand Up @@ -130,6 +131,7 @@ data.forEach(([ivls, fullName, names]: string[]) =>
);
dictionary.sort((a, b) => a.setNum - b.setNum);

/** @deprecated */
export default {
names,
symbols,
Expand Down
3 changes: 1 addition & 2 deletions packages/chord-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"chords",
"music",
"theory",
"@tonaljs/core"
"music-theory"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -17,7 +17,6 @@
],
"types": "dist/index.d.ts",
"dependencies": {
"@tonaljs/core": "5.0.0",
"@tonaljs/pcset": "4.9.2"
},
"author": "[email protected]",
Expand Down
5 changes: 3 additions & 2 deletions packages/key/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { accToAlt, altToAcc, note, transpose } from "@tonaljs/core";
import { transposeFifths } from "@tonaljs/note";
import { transpose, transposeFifths } from "@tonaljs/note";
import { accToAlt, altToAcc, note } from "@tonaljs/pitch-note";
import { get as roman } from "@tonaljs/roman-numeral";

const Empty: readonly string[] = Object.freeze([] as string[]);
Expand Down Expand Up @@ -219,4 +219,5 @@ export function majorTonicFromKeySignature(
return null;
}

/** @deprecated */
export default { majorKey, majorTonicFromKeySignature, minorKey };
4 changes: 2 additions & 2 deletions packages/key/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"key",
"music",
"theory",
"@tonaljs/core"
"music-theory"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -15,7 +15,7 @@
],
"types": "dist/index.d.ts",
"dependencies": {
"@tonaljs/core": "5.0.0",
"@tonaljs/pitch-note": "6.0.0",
"@tonaljs/note": "4.10.3",
"@tonaljs/roman-numeral": "4.8.3"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/midi/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NoteName, note as props } from "@tonaljs/core";
import { NoteName, note as props } from "@tonaljs/pitch-note";

type Midi = number;

Expand Down Expand Up @@ -158,6 +158,7 @@ export function pcsetDegrees(notes: number[] | string, tonic: number) {
};
}

/** @deprecated */
export default {
chroma,
freqToMidi,
Expand Down
4 changes: 2 additions & 2 deletions packages/midi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"midi",
"music",
"theory",
"@tonaljs/core"
"tonal"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -16,7 +16,7 @@
],
"types": "dist/index.d.ts",
"dependencies": {
"@tonaljs/core": "5.0.0"
"@tonaljs/pitch-note": "6.0.0"
},
"author": "[email protected]",
"license": "MIT",
Expand Down
12 changes: 8 additions & 4 deletions packages/mode/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { rotate } from "@tonaljs/collection";
import { deprecate, NamedPitch, NoteName, transpose } from "@tonaljs/core";
import { simplify, transposeFifths } from "@tonaljs/interval";
import { EmptyPcset, Pcset } from "@tonaljs/pcset";
import { transpose } from "@tonaljs/pitch-distance";
import { NoteName } from "@tonaljs/pitch-note";
import { get as getType } from "@tonaljs/scale-type";

const MODES = [
Expand Down Expand Up @@ -44,7 +45,7 @@ modes.forEach((mode) => {
});
});

type ModeLiteral = string | NamedPitch;
type ModeLiteral = string | { name: string };

/**
* Get a Mode by it's name
Expand Down Expand Up @@ -73,15 +74,18 @@ export function get(name: ModeLiteral): Mode {
: NoMode;
}

export const mode = deprecate("Mode.mode", "Mode.get", get);
/** @deprecated */
export const mode = get;

/**
* Get a list of all modes
*/
export function all() {
return modes.slice();
}
export const entries = deprecate("Mode.mode", "Mode.all", all);

/** @deprecated */
export const entries = all;

/**
* Get a list of all mode names
Expand Down
5 changes: 3 additions & 2 deletions packages/mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"mode",
"music",
"theory",
"@tonaljs/core"
"music-theory"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -16,7 +16,8 @@
"types": "dist/index.d.ts",
"dependencies": {
"@tonaljs/collection": "4.8.1",
"@tonaljs/core": "5.0.0",
"@tonaljs/pitch-note": "6.0.0",
"@tonaljs/pitch-distance": "5.0.3",
"@tonaljs/interval": "5.0.0",
"@tonaljs/pcset": "4.9.2",
"@tonaljs/scale-type": "4.8.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/note/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"note",
"music",
"theory",
"@tonaljs/core"
"music-theory"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
31 changes: 12 additions & 19 deletions packages/pcset/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { compact, range, rotate } from "@tonaljs/collection";
import {
Interval,
IntervalName,
NotFound,
Note,
NoteName,
deprecate,
interval,
note,
transpose,
} from "@tonaljs/core";
import { NotFound } from "@tonaljs/pitch";
import { transpose } from "@tonaljs/pitch-distance";
import { Interval, IntervalName, interval } from "@tonaljs/pitch-interval";
import { Note, NoteName, note } from "@tonaljs/pitch-note";

/**
* The properties of a pitch class set
Expand Down Expand Up @@ -97,11 +90,10 @@ export function get(src: Set): Pcset {
}

/**
* Use Pcset.properties
* @function
* @use Pcset.get
* @deprecated
*/
export const pcset = deprecate("Pcset.pcset", "Pcset.get", get);
export const pcset = get;

/**
* Get pitch class set chroma
Expand All @@ -117,15 +109,15 @@ export const chroma = (set: Set) => get(set).chroma;
* @example
* Pcset.intervals(["c", "d", "e"]); //=>
*/
const intervals = (set: Set) => get(set).intervals;
export const intervals = (set: Set) => get(set).intervals;

/**
* Get pitch class set number
* @function
* @example
* Pcset.num(["c", "d", "e"]); //=> 2192
*/
const num = (set: Set) => get(set).setNum;
export const num = (set: Set) => get(set).setNum;

const IVLS = [
"1P",
Expand All @@ -143,13 +135,13 @@ const IVLS = [
];

/**
* @private
* Get the intervals of a pcset *starting from C*
* @private
* @param {Set} set - the pitch class set
* @return {IntervalName[]} an array of interval names or an empty array
* if not a valid pitch class set
*/
export function chromaToIntervals(chroma: PcsetChroma): IntervalName[] {
function chromaToIntervals(chroma: PcsetChroma): IntervalName[] {
const intervals = [];
for (let i = 0; i < 12; i++) {
// tslint:disable-next-line:curly
Expand Down Expand Up @@ -201,7 +193,7 @@ export function modes(set: Set, normalize = true): PcsetChroma[] {
}

/**
* Test if two pitch class sets are numentical
* Test if two pitch class sets are equal
*
* @param {Array|string} set1 - one of the pitch class sets
* @param {Array|string} set2 - the other pitch class set
Expand Down Expand Up @@ -303,6 +295,7 @@ export function filter(set: Set) {
};
}

/** @deprecated */
export default {
get,
chroma,
Expand Down
Loading

0 comments on commit b113754

Please sign in to comment.