@storybook/core-server 6.4.0-rc.3 → 6.4.0-rc.7

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.
@@ -127,7 +127,8 @@ async function buildStaticStandalone(options) {
127
127
  };
128
128
  var stories = (0, _coreCommon.normalizeStories)(await presets.apply('stories'), directories);
129
129
  await (0, _storiesJson.extractStoriesJson)(_path.default.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
130
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
130
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
131
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
131
132
  }));
132
133
  }
133
134
 
@@ -44,7 +44,7 @@ var warnDLLsDeprecated = warnDeprecatedFlag(`
44
44
  var warnStaticDirDeprecated = warnDeprecatedFlag(`
45
45
  --static-dir CLI flag is deprecated, see:
46
46
 
47
- https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-static-dir-flag
47
+ https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
48
48
  `);
49
49
 
50
50
  function checkDeprecatedFlags({
@@ -23,6 +23,8 @@ var _slash = _interopRequireDefault(require("slash"));
23
23
 
24
24
  var _store = require("@storybook/store");
25
25
 
26
+ var _coreCommon = require("@storybook/core-common");
27
+
26
28
  var _nodeLogger = require("@storybook/node-logger");
27
29
 
28
30
  var _csfTools = require("@storybook/csf-tools");
@@ -47,15 +49,6 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
47
49
 
48
50
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
51
 
50
- function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
51
- var sortableStories = Object.values(stories);
52
- (0, _store.sortStoriesV7)(sortableStories, storySortParameter, fileNameOrder);
53
- return sortableStories.reduce(function (acc, item) {
54
- acc[item.id] = item;
55
- return acc;
56
- }, {});
57
- }
58
-
59
52
  class StoryIndexGenerator {
60
53
  // An internal cache mapping specifiers to a set of path=><set of stories>
61
54
  // Later, we'll combine each of these subsets together to form the full index
@@ -117,7 +110,7 @@ class StoryIndexGenerator {
117
110
  var entry = this.storyIndexEntries.get(specifier);
118
111
 
119
112
  try {
120
- var importPath = (0, _slash.default)(relativePath[0] === '.' ? relativePath : `./${relativePath}`);
113
+ var importPath = (0, _slash.default)((0, _coreCommon.normalizeStoryPath)(relativePath));
121
114
  var defaultTitle = (0, _store.autoTitleFromSpecifier)(importPath, specifier);
122
115
  var csf = (await (0, _csfTools.readCsfOrMdx)(absolutePath, {
123
116
  defaultTitle: defaultTitle
@@ -152,8 +145,19 @@ class StoryIndexGenerator {
152
145
  storiesList.forEach(function (subStories) {
153
146
  Object.assign(stories, subStories);
154
147
  });
155
- var storySortParameter = await this.getStorySortParameter();
156
- return sortExtractedStories(stories, storySortParameter, this.storyFileNames());
148
+ var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
149
+ // all the info we need here
150
+
151
+ if (this.options.storyStoreV7) {
152
+ var storySortParameter = await this.getStorySortParameter();
153
+ var fileNameOrder = this.storyFileNames();
154
+ (0, _store.sortStoriesV7)(sortableStories, storySortParameter, fileNameOrder);
155
+ }
156
+
157
+ return sortableStories.reduce(function (acc, item) {
158
+ acc[item.id] = item;
159
+ return acc;
160
+ }, {});
157
161
  }
158
162
 
159
163
  async getIndex() {
@@ -42,7 +42,8 @@ async function useStoriesJson(router, serverChannel, options, workingDir = proce
42
42
  var generator = new _StoryIndexGenerator.StoryIndexGenerator(normalizedStories, {
43
43
  configDir: options.configDir,
44
44
  workingDir: workingDir,
45
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
45
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
46
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
46
47
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
47
48
  // This is mainly for testing purposes.
48
49
 
@@ -98,7 +98,8 @@ export async function buildStaticStandalone(options) {
98
98
  };
99
99
  var stories = normalizeStories(await presets.apply('stories'), directories);
100
100
  await extractStoriesJson(path.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
101
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
101
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
102
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
102
103
  }));
103
104
  }
104
105
 
@@ -30,7 +30,7 @@ var warnDLLsDeprecated = warnDeprecatedFlag(`
30
30
  var warnStaticDirDeprecated = warnDeprecatedFlag(`
31
31
  --static-dir CLI flag is deprecated, see:
32
32
 
33
- https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-static-dir-flag
33
+ https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
34
34
  `);
35
35
  export function checkDeprecatedFlags({
36
36
  dll: dll,
@@ -25,18 +25,9 @@ import fs from 'fs-extra';
25
25
  import glob from 'globby';
26
26
  import slash from 'slash';
27
27
  import { autoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store';
28
+ import { normalizeStoryPath } from '@storybook/core-common';
28
29
  import { logger } from '@storybook/node-logger';
29
30
  import { readCsfOrMdx, getStorySortParameter } from '@storybook/csf-tools';
30
-
31
- function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
32
- var sortableStories = Object.values(stories);
33
- sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
34
- return sortableStories.reduce(function (acc, item) {
35
- acc[item.id] = item;
36
- return acc;
37
- }, {});
38
- }
39
-
40
31
  export class StoryIndexGenerator {
41
32
  // An internal cache mapping specifiers to a set of path=><set of stories>
42
33
  // Later, we'll combine each of these subsets together to form the full index
@@ -95,7 +86,7 @@ export class StoryIndexGenerator {
95
86
  var entry = this.storyIndexEntries.get(specifier);
96
87
 
97
88
  try {
98
- var importPath = slash(relativePath[0] === '.' ? relativePath : `./${relativePath}`);
89
+ var importPath = slash(normalizeStoryPath(relativePath));
99
90
  var defaultTitle = autoTitleFromSpecifier(importPath, specifier);
100
91
  var csf = (await readCsfOrMdx(absolutePath, {
101
92
  defaultTitle: defaultTitle
@@ -129,8 +120,19 @@ export class StoryIndexGenerator {
129
120
  storiesList.forEach(function (subStories) {
130
121
  Object.assign(stories, subStories);
131
122
  });
132
- var storySortParameter = await this.getStorySortParameter();
133
- return sortExtractedStories(stories, storySortParameter, this.storyFileNames());
123
+ var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
124
+ // all the info we need here
125
+
126
+ if (this.options.storyStoreV7) {
127
+ var storySortParameter = await this.getStorySortParameter();
128
+ var fileNameOrder = this.storyFileNames();
129
+ sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
130
+ }
131
+
132
+ return sortableStories.reduce(function (acc, item) {
133
+ acc[item.id] = item;
134
+ return acc;
135
+ }, {});
134
136
  }
135
137
 
136
138
  async getIndex() {
@@ -21,7 +21,8 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
21
21
  var generator = new StoryIndexGenerator(normalizedStories, {
22
22
  configDir: options.configDir,
23
23
  workingDir: workingDir,
24
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
24
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
25
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
25
26
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
26
27
  // This is mainly for testing purposes.
27
28
 
@@ -98,7 +98,8 @@ export async function buildStaticStandalone(options) {
98
98
  };
99
99
  var stories = normalizeStories(await presets.apply('stories'), directories);
100
100
  await extractStoriesJson(path.join(options.outputDir, 'stories.json'), stories, _objectSpread(_objectSpread({}, directories), {}, {
101
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
101
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
102
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
102
103
  }));
103
104
  }
104
105
 
@@ -30,7 +30,7 @@ var warnDLLsDeprecated = warnDeprecatedFlag(`
30
30
  var warnStaticDirDeprecated = warnDeprecatedFlag(`
31
31
  --static-dir CLI flag is deprecated, see:
32
32
 
33
- https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-static-dir-flag
33
+ https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
34
34
  `);
35
35
  export function checkDeprecatedFlags({
36
36
  dll: dll,
@@ -25,18 +25,9 @@ import fs from 'fs-extra';
25
25
  import glob from 'globby';
26
26
  import slash from 'slash';
27
27
  import { autoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store';
28
+ import { normalizeStoryPath } from '@storybook/core-common';
28
29
  import { logger } from '@storybook/node-logger';
29
30
  import { readCsfOrMdx, getStorySortParameter } from '@storybook/csf-tools';
30
-
31
- function sortExtractedStories(stories, storySortParameter, fileNameOrder) {
32
- var sortableStories = Object.values(stories);
33
- sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
34
- return sortableStories.reduce(function (acc, item) {
35
- acc[item.id] = item;
36
- return acc;
37
- }, {});
38
- }
39
-
40
31
  export class StoryIndexGenerator {
41
32
  // An internal cache mapping specifiers to a set of path=><set of stories>
42
33
  // Later, we'll combine each of these subsets together to form the full index
@@ -95,7 +86,7 @@ export class StoryIndexGenerator {
95
86
  var entry = this.storyIndexEntries.get(specifier);
96
87
 
97
88
  try {
98
- var importPath = slash(relativePath[0] === '.' ? relativePath : `./${relativePath}`);
89
+ var importPath = slash(normalizeStoryPath(relativePath));
99
90
  var defaultTitle = autoTitleFromSpecifier(importPath, specifier);
100
91
  var csf = (await readCsfOrMdx(absolutePath, {
101
92
  defaultTitle: defaultTitle
@@ -129,8 +120,19 @@ export class StoryIndexGenerator {
129
120
  storiesList.forEach(function (subStories) {
130
121
  Object.assign(stories, subStories);
131
122
  });
132
- var storySortParameter = await this.getStorySortParameter();
133
- return sortExtractedStories(stories, storySortParameter, this.storyFileNames());
123
+ var sortableStories = Object.values(stories); // Skip sorting if we're in v6 mode because we don't have
124
+ // all the info we need here
125
+
126
+ if (this.options.storyStoreV7) {
127
+ var storySortParameter = await this.getStorySortParameter();
128
+ var fileNameOrder = this.storyFileNames();
129
+ sortStoriesV7(sortableStories, storySortParameter, fileNameOrder);
130
+ }
131
+
132
+ return sortableStories.reduce(function (acc, item) {
133
+ acc[item.id] = item;
134
+ return acc;
135
+ }, {});
134
136
  }
135
137
 
136
138
  async getIndex() {
@@ -21,7 +21,8 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
21
21
  var generator = new StoryIndexGenerator(normalizedStories, {
22
22
  configDir: options.configDir,
23
23
  workingDir: workingDir,
24
- storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7)
24
+ storiesV2Compatibility: !(features !== null && features !== void 0 && features.breakingChangesV7) && !(features !== null && features !== void 0 && features.storyStoreV7),
25
+ storyStoreV7: features === null || features === void 0 ? void 0 : features.storyStoreV7
25
26
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
26
27
  // This is mainly for testing purposes.
27
28
 
@@ -6,6 +6,7 @@ export declare class StoryIndexGenerator {
6
6
  workingDir: Path;
7
7
  configDir: Path;
8
8
  storiesV2Compatibility: boolean;
9
+ storyStoreV7: boolean;
9
10
  };
10
11
  private storyIndexEntries;
11
12
  private lastIndex?;
@@ -13,6 +14,7 @@ export declare class StoryIndexGenerator {
13
14
  workingDir: Path;
14
15
  configDir: Path;
15
16
  storiesV2Compatibility: boolean;
17
+ storyStoreV7: boolean;
16
18
  });
17
19
  initialize(): Promise<void>;
18
20
  ensureExtracted(): Promise<StoryIndex['stories'][]>;
@@ -6,5 +6,6 @@ export declare function extractStoriesJson(outputFile: string, normalizedStories
6
6
  configDir: string;
7
7
  workingDir: string;
8
8
  storiesV2Compatibility: boolean;
9
+ storyStoreV7: boolean;
9
10
  }): Promise<void>;
10
11
  export declare function useStoriesJson(router: Router, serverChannel: ServerChannel, options: Options, workingDir?: string): Promise<void>;
@@ -6,6 +6,7 @@ export declare class StoryIndexGenerator {
6
6
  workingDir: Path;
7
7
  configDir: Path;
8
8
  storiesV2Compatibility: boolean;
9
+ storyStoreV7: boolean;
9
10
  };
10
11
  private storyIndexEntries;
11
12
  private lastIndex?;
@@ -13,6 +14,7 @@ export declare class StoryIndexGenerator {
13
14
  workingDir: Path;
14
15
  configDir: Path;
15
16
  storiesV2Compatibility: boolean;
17
+ storyStoreV7: boolean;
16
18
  });
17
19
  initialize(): Promise<void>;
18
20
  ensureExtracted(): Promise<StoryIndex['stories'][]>;
@@ -6,5 +6,6 @@ export declare function extractStoriesJson(outputFile: string, normalizedStories
6
6
  configDir: string;
7
7
  workingDir: string;
8
8
  storiesV2Compatibility: boolean;
9
+ storyStoreV7: boolean;
9
10
  }): Promise<void>;
10
11
  export declare function useStoriesJson(router: Router, serverChannel: ServerChannel, options: Options, workingDir?: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/core-server",
3
- "version": "6.4.0-rc.3",
3
+ "version": "6.4.0-rc.7",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@discoveryjs/json-ext": "^0.5.3",
44
- "@storybook/builder-webpack4": "6.4.0-rc.3",
45
- "@storybook/core-client": "6.4.0-rc.3",
46
- "@storybook/core-common": "6.4.0-rc.3",
47
- "@storybook/core-events": "6.4.0-rc.3",
44
+ "@storybook/builder-webpack4": "6.4.0-rc.7",
45
+ "@storybook/core-client": "6.4.0-rc.7",
46
+ "@storybook/core-common": "6.4.0-rc.7",
47
+ "@storybook/core-events": "6.4.0-rc.7",
48
48
  "@storybook/csf": "0.0.2--canary.87bc651.0",
49
- "@storybook/csf-tools": "6.4.0-rc.3",
50
- "@storybook/manager-webpack4": "6.4.0-rc.3",
51
- "@storybook/node-logger": "6.4.0-rc.3",
49
+ "@storybook/csf-tools": "6.4.0-rc.7",
50
+ "@storybook/manager-webpack4": "6.4.0-rc.7",
51
+ "@storybook/node-logger": "6.4.0-rc.7",
52
52
  "@storybook/semver": "^7.3.2",
53
- "@storybook/store": "6.4.0-rc.3",
53
+ "@storybook/store": "6.4.0-rc.7",
54
54
  "@types/node": "^14.0.10",
55
55
  "@types/node-fetch": "^2.5.7",
56
56
  "@types/pretty-hrtime": "^1.0.0",
@@ -84,7 +84,7 @@
84
84
  "ws": "^8.2.3"
85
85
  },
86
86
  "devDependencies": {
87
- "@storybook/builder-webpack5": "6.4.0-rc.3",
87
+ "@storybook/builder-webpack5": "6.4.0-rc.7",
88
88
  "@types/compression": "^1.7.0",
89
89
  "@types/ip": "^1.1.0",
90
90
  "@types/serve-favicon": "^2.5.2",
@@ -92,8 +92,8 @@
92
92
  "jest-specific-snapshot": "^4.0.0"
93
93
  },
94
94
  "peerDependencies": {
95
- "@storybook/builder-webpack5": "6.4.0-rc.3",
96
- "@storybook/manager-webpack5": "6.4.0-rc.3",
95
+ "@storybook/builder-webpack5": "6.4.0-rc.7",
96
+ "@storybook/manager-webpack5": "6.4.0-rc.7",
97
97
  "react": "^16.8.0 || ^17.0.0",
98
98
  "react-dom": "^16.8.0 || ^17.0.0"
99
99
  },
@@ -111,6 +111,6 @@
111
111
  "publishConfig": {
112
112
  "access": "public"
113
113
  },
114
- "gitHead": "f23a6daa88a2f051e2a94d803431ab3b3d11e26b",
114
+ "gitHead": "7162286c0d8d122c7206265fab41c4c191c86d40",
115
115
  "sbmodern": "dist/modern/index.js"
116
116
  }