diff --git a/code/lib/addons/src/types.ts b/code/lib/addons/src/types.ts index 5ce1726388b5..b33a88e39438 100644 --- a/code/lib/addons/src/types.ts +++ b/code/lib/addons/src/types.ts @@ -77,7 +77,8 @@ export type IndexEntry = StoryIndexEntry | DocsIndexEntry; // The `any` here is the story store's `StoreItem` record. Ideally we should probably only // pass a defined subset of that full data, but we pass it all so far :shrug: -export type StorySortComparator = Comparator<[StoryId, any, Parameters, Parameters]>; +export type IndexEntryLegacy = [StoryId, any, Parameters, Parameters]; +export type StorySortComparator = Comparator; export type StorySortParameter = StorySortComparator | StorySortObjectParameter; export type StorySortComparatorV7 = Comparator; export type StorySortParameterV7 = StorySortComparatorV7 | StorySortObjectParameter; diff --git a/code/lib/builder-vite/src/optimizeDeps.ts b/code/lib/builder-vite/src/optimizeDeps.ts index 09df4ba81c8c..1ee4070dff6a 100644 --- a/code/lib/builder-vite/src/optimizeDeps.ts +++ b/code/lib/builder-vite/src/optimizeDeps.ts @@ -84,7 +84,6 @@ const INCLUDE_CANDIDATES = [ 'refractor/lang/yaml.js', 'regenerator-runtime/runtime.js', 'slash', - 'stable', 'store2', 'synchronous-promise', 'telejson', diff --git a/code/lib/builder-webpack5/package.json b/code/lib/builder-webpack5/package.json index 3c955d317110..f4aa7c596118 100644 --- a/code/lib/builder-webpack5/package.json +++ b/code/lib/builder-webpack5/package.json @@ -65,7 +65,6 @@ "html-webpack-plugin": "^5.5.0", "path-browserify": "^1.0.1", "process": "^0.11.10", - "stable": "^0.1.8", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.3.1", "ts-dedent": "^2.0.0", diff --git a/code/lib/store/package.json b/code/lib/store/package.json index 5749685d5b5e..779bba95a8f4 100644 --- a/code/lib/store/package.json +++ b/code/lib/store/package.json @@ -44,7 +44,6 @@ "lodash": "^4.17.21", "memoizerific": "^1.11.3", "slash": "^3.0.0", - "stable": "^0.1.8", "synchronous-promise": "^2.0.15", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2" diff --git a/code/lib/store/src/sortStories.ts b/code/lib/store/src/sortStories.ts index bcc8a7222b6a..f817fca96bcf 100644 --- a/code/lib/store/src/sortStories.ts +++ b/code/lib/store/src/sortStories.ts @@ -1,6 +1,10 @@ -import stable from 'stable'; import { dedent } from 'ts-dedent'; -import type { Comparator, StorySortParameter, StorySortParameterV7 } from '@storybook/addons'; +import type { + Comparator, + IndexEntryLegacy, + StorySortParameter, + StorySortParameterV7, +} from '@storybook/addons'; import { storySort } from './storySort'; import type { Story, StoryIndexEntry, IndexEntry, Path, Parameters } from './types'; @@ -16,10 +20,9 @@ const sortStoriesCommon = ( } else { sortFn = storySort(storySortParameter); } - stable.inplace(stories, sortFn); + stories.sort(sortFn as (a: IndexEntry, b: IndexEntry) => number); } else { - stable.inplace( - stories, + stories.sort( (s1, s2) => fileNameOrder.indexOf(s1.importPath) - fileNameOrder.indexOf(s2.importPath) ); } @@ -57,7 +60,7 @@ export const sortStoriesV6 = ( fileNameOrder: Path[] ) => { if (storySortParameter && typeof storySortParameter === 'function') { - stable.inplace(stories, storySortParameter); + stories.sort(storySortParameter as (a: IndexEntryLegacy, b: IndexEntryLegacy) => number); return stories.map((s) => toIndexEntry(s[1])); } diff --git a/code/yarn.lock b/code/yarn.lock index 419c3fe5f3ad..0cee90fdc740 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7777,7 +7777,6 @@ __metadata: html-webpack-plugin: ^5.5.0 path-browserify: ^1.0.1 process: ^0.11.10 - stable: ^0.1.8 style-loader: ^3.3.1 terser-webpack-plugin: ^5.3.1 ts-dedent: ^2.0.0 @@ -9440,7 +9439,6 @@ __metadata: lodash: ^4.17.21 memoizerific: ^1.11.3 slash: ^3.0.0 - stable: ^0.1.8 synchronous-promise: ^2.0.15 ts-dedent: ^2.0.0 typescript: ~4.6.3