@storybook/html-webpack5 7.2.0 → 7.2.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/preset.d.ts +87 -2
  2. package/package.json +5 -5
package/dist/preset.d.ts CHANGED
@@ -720,11 +720,17 @@ PackageJson$1.NonStandardEntryPoints &
720
720
  PackageJson$1.TypeScriptConfiguration &
721
721
  PackageJson$1.YarnConfiguration &
722
722
  PackageJson$1.JSPMConfiguration;
723
+
724
+ type StoryId = string;
725
+ type ComponentTitle = string;
726
+ type StoryName = string;
723
727
  type Tag = string;
724
728
  interface Parameters {
725
729
  [name: string]: any;
726
730
  }
727
731
 
732
+ type ExportName = string;
733
+ type MetaId = string;
728
734
  interface StoriesSpecifier {
729
735
  /**
730
736
  * When auto-titling, what to prefix all generated titles with (default: '')
@@ -753,15 +759,89 @@ interface IndexedStory {
753
759
  }
754
760
  interface IndexedCSFFile {
755
761
  meta: {
762
+ id?: string;
756
763
  title?: string;
757
764
  tags?: Tag[];
758
765
  };
759
766
  stories: IndexedStory[];
760
767
  }
761
- interface StoryIndexer {
768
+ /**
769
+ * FIXME: This is a temporary type to allow us to deprecate the old indexer API.
770
+ * We should remove this type and the deprecated indexer API in 8.0.
771
+ */
772
+ type BaseIndexer = {
773
+ /**
774
+ * A regular expression that should match all files to be handled by this indexer
775
+ */
762
776
  test: RegExp;
777
+ };
778
+ /**
779
+ * An indexer describes which filenames it handles, and how to index each individual file - turning it into an entry in the index.
780
+ */
781
+ type Indexer = BaseIndexer & {
782
+ /**
783
+ * Indexes a file containing stories or docs.
784
+ * @param fileName The name of the file to index.
785
+ * @param options {@link IndexerOptions} for indexing the file.
786
+ * @returns A promise that resolves to an array of {@link IndexInput} objects.
787
+ */
788
+ index: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
789
+ /**
790
+ * @soonDeprecated Use {@link index} instead
791
+ */
792
+ indexer?: never;
793
+ };
794
+ type DeprecatedIndexer = BaseIndexer & {
763
795
  indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
764
- }
796
+ index?: never;
797
+ };
798
+ /**
799
+ * @soonDeprecated Use {@link Indexer} instead
800
+ */
801
+ type StoryIndexer = Indexer | DeprecatedIndexer;
802
+ /**
803
+ * The base input for indexing a story or docs entry.
804
+ */
805
+ type BaseIndexInput = {
806
+ /** The file to import from e.g. the story file. */
807
+ importPath: Path;
808
+ /** The name of the export to import. */
809
+ exportName: ExportName;
810
+ /** The name of the entry, auto-generated from {@link exportName} if unspecified. */
811
+ name?: StoryName;
812
+ /** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
813
+ title?: ComponentTitle;
814
+ /**
815
+ * The custom id optionally set at `meta.id` if it needs to differ from the id generated via {@link title}.
816
+ * If unspecified, the meta id will be auto-generated from {@link title}.
817
+ * If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
818
+ */
819
+ metaId?: MetaId;
820
+ /** Tags for filtering entries in Storybook and its tools. */
821
+ tags?: Tag[];
822
+ /**
823
+ * The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if unspecified.
824
+ * If specified, the story in the CSF file _must_ have a matching id set at `parameters.__id`, to be correctly matched.
825
+ * Only use this if you need to override the auto-generated id.
826
+ */
827
+ __id?: StoryId;
828
+ };
829
+ /**
830
+ * The input for indexing a story entry.
831
+ */
832
+ type StoryIndexInput = BaseIndexInput & {
833
+ type: 'story';
834
+ };
835
+ /**
836
+ * The input for indexing a docs entry.
837
+ */
838
+ type DocsIndexInput = BaseIndexInput & {
839
+ type: 'docs';
840
+ /** Paths to story files that must be pre-loaded for this docs entry. */
841
+ storiesImports?: Path[];
842
+ };
843
+ type IndexInput = StoryIndexInput | DocsIndexInput;
844
+ type Path = string;
765
845
 
766
846
  interface Options$1 {
767
847
  allowRegExp: boolean;
@@ -1037,8 +1117,13 @@ interface StorybookConfig {
1037
1117
  previewAnnotations?: PresetValue<Entry[]>;
1038
1118
  /**
1039
1119
  * Process CSF files for the story index.
1120
+ * @soonDeprecated use {@link experimental_indexers} instead
1040
1121
  */
1041
1122
  storyIndexers?: PresetValue<StoryIndexer[]>;
1123
+ /**
1124
+ * Process CSF files for the story index.
1125
+ */
1126
+ experimental_indexers?: PresetValue<Indexer[]>;
1042
1127
  /**
1043
1128
  * Docs related features in index generation
1044
1129
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/html-webpack5",
3
- "version": "7.2.0",
3
+ "version": "7.2.2-alpha.0",
4
4
  "description": "Storybook for HTML: View HTML snippets in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -47,11 +47,11 @@
47
47
  "prep": "../../../scripts/prepare/bundle.ts"
48
48
  },
49
49
  "dependencies": {
50
- "@storybook/builder-webpack5": "7.2.0",
51
- "@storybook/core-common": "7.2.0",
50
+ "@storybook/builder-webpack5": "7.2.2-alpha.0",
51
+ "@storybook/core-common": "7.2.2-alpha.0",
52
52
  "@storybook/global": "^5.0.0",
53
- "@storybook/html": "7.2.0",
54
- "@storybook/preset-html-webpack": "7.2.0",
53
+ "@storybook/html": "7.2.2-alpha.0",
54
+ "@storybook/preset-html-webpack": "7.2.2-alpha.0",
55
55
  "@types/node": "^16.0.0"
56
56
  },
57
57
  "devDependencies": {