@storybook/core-server 6.4.9 → 6.5.0-alpha.4

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.
@@ -131,11 +131,11 @@ async function buildDevStandalone(options) {
131
131
  if (options.smokeTest) {
132
132
  // @ts-ignore
133
133
  var managerWarnings = managerStats && managerStats.toJson().warnings || [];
134
- if (managerWarnings.length > 0) _nodeLogger.logger.warn(`manager: ${managerWarnings}`); // I'm a little reticent to import webpack types in this file :shrug:
134
+ if (managerWarnings.length > 0) _nodeLogger.logger.warn(`manager: ${JSON.stringify(managerWarnings, null, 2)}`); // I'm a little reticent to import webpack types in this file :shrug:
135
135
  // @ts-ignore
136
136
 
137
137
  var previewWarnings = previewStats && previewStats.toJson().warnings || [];
138
- if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${previewWarnings}`);
138
+ if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`);
139
139
  process.exit(managerWarnings.length > 0 || previewWarnings.length > 0 && !options.ignorePreview ? 1 : 0);
140
140
  return;
141
141
  } // Get package name and capitalize it e.g. @storybook/react -> React
@@ -200,8 +200,7 @@ class StoryIndexGenerator {
200
200
  }
201
201
 
202
202
  invalidate(specifier, importPath, removed) {
203
- var absolutePath = _path.default.resolve(this.options.workingDir, importPath);
204
-
203
+ var absolutePath = (0, _slash.default)(_path.default.resolve(this.options.workingDir, importPath));
205
204
  var pathToEntries = this.storyIndexEntries.get(specifier);
206
205
 
207
206
  if (removed) {
@@ -5,22 +5,37 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.openInBrowser = openInBrowser;
7
7
 
8
+ require("core-js/modules/es.promise.js");
9
+
8
10
  var _nodeLogger = require("@storybook/node-logger");
9
11
 
10
12
  var _betterOpn = _interopRequireDefault(require("better-opn"));
11
13
 
14
+ var _open = _interopRequireDefault(require("open"));
15
+
16
+ var _xDefaultBrowser = _interopRequireDefault(require("x-default-browser"));
17
+
12
18
  var _tsDedent = _interopRequireDefault(require("ts-dedent"));
13
19
 
14
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
21
 
22
+ // betterOpn alias used because also loading open
16
23
  function openInBrowser(address) {
17
- try {
18
- (0, _betterOpn.default)(address);
19
- } catch (error) {
20
- _nodeLogger.logger.error((0, _tsDedent.default)`
21
- Could not open ${address} inside a browser. If you're running this command inside a
22
- docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
23
- browser by default.
24
- `);
25
- }
24
+ (0, _xDefaultBrowser.default)(async function (err, res) {
25
+ try {
26
+ if (res.isChrome || res.isChromium) {
27
+ // We use betterOpn for Chrome because it is better at handling which chrome tab
28
+ // or window the preview loads in.
29
+ (0, _betterOpn.default)(address);
30
+ } else {
31
+ await (0, _open.default)(address);
32
+ }
33
+ } catch (error) {
34
+ _nodeLogger.logger.error((0, _tsDedent.default)`
35
+ Could not open ${address} inside a browser. If you're running this command inside a
36
+ docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
37
+ browser by default.
38
+ `);
39
+ }
40
+ });
26
41
  }
@@ -79,11 +79,13 @@ function watchStorySpecifiers(specifiers, options, onInvalidate) {
79
79
  // (where the last bit depends on `files`).
80
80
  var dirGlob = _path.default.join(options.workingDir, importPath, '**', // files can be e.g. '**/foo/*/*.js' so we just want the last bit,
81
81
  // because the directoru could already be within the files part (e.g. './x/foo/bar')
82
- _path.default.basename(specifier.files));
82
+ _path.default.basename(specifier.files)); // glob only supports forward slashes
83
83
 
84
- var files = await (0, _globby.default)(dirGlob);
84
+
85
+ var files = await (0, _globby.default)(dirGlob.replace(/\\/g, '/'));
85
86
  files.forEach(function (filePath) {
86
- var fileImportPath = toImportPath(_path.default.relative(options.workingDir, filePath));
87
+ var fileImportPath = toImportPath( // use posix path separators even on windows
88
+ _path.default.relative(options.workingDir, filePath).replace(/\\/g, '/'));
87
89
 
88
90
  if (specifier.importPathMatcher.exec(fileImportPath)) {
89
91
  onInvalidate(specifier, fileImportPath, removed);
@@ -105,11 +105,11 @@ export async function buildDevStandalone(options) {
105
105
  if (options.smokeTest) {
106
106
  // @ts-ignore
107
107
  var managerWarnings = managerStats && managerStats.toJson().warnings || [];
108
- if (managerWarnings.length > 0) logger.warn(`manager: ${managerWarnings}`); // I'm a little reticent to import webpack types in this file :shrug:
108
+ if (managerWarnings.length > 0) logger.warn(`manager: ${JSON.stringify(managerWarnings, null, 2)}`); // I'm a little reticent to import webpack types in this file :shrug:
109
109
  // @ts-ignore
110
110
 
111
111
  var previewWarnings = previewStats && previewStats.toJson().warnings || [];
112
- if (previewWarnings.length > 0) logger.warn(`preview: ${previewWarnings}`);
112
+ if (previewWarnings.length > 0) logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`);
113
113
  process.exit(managerWarnings.length > 0 || previewWarnings.length > 0 && !options.ignorePreview ? 1 : 0);
114
114
  return;
115
115
  } // Get package name and capitalize it e.g. @storybook/react -> React
@@ -175,7 +175,7 @@ export class StoryIndexGenerator {
175
175
  }
176
176
 
177
177
  invalidate(specifier, importPath, removed) {
178
- var absolutePath = path.resolve(this.options.workingDir, importPath);
178
+ var absolutePath = slash(path.resolve(this.options.workingDir, importPath));
179
179
  var pathToEntries = this.storyIndexEntries.get(specifier);
180
180
 
181
181
  if (removed) {
@@ -1,14 +1,26 @@
1
+ import "core-js/modules/es.promise.js";
1
2
  import { logger } from '@storybook/node-logger';
2
- import open from 'better-opn';
3
+ import betterOpn from 'better-opn'; // betterOpn alias used because also loading open
4
+
5
+ import open from 'open';
6
+ import getDefaultBrowser from 'x-default-browser';
3
7
  import dedent from 'ts-dedent';
4
8
  export function openInBrowser(address) {
5
- try {
6
- open(address);
7
- } catch (error) {
8
- logger.error(dedent`
9
- Could not open ${address} inside a browser. If you're running this command inside a
10
- docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
11
- browser by default.
12
- `);
13
- }
9
+ getDefaultBrowser(async function (err, res) {
10
+ try {
11
+ if (res.isChrome || res.isChromium) {
12
+ // We use betterOpn for Chrome because it is better at handling which chrome tab
13
+ // or window the preview loads in.
14
+ betterOpn(address);
15
+ } else {
16
+ await open(address);
17
+ }
18
+ } catch (error) {
19
+ logger.error(dedent`
20
+ Could not open ${address} inside a browser. If you're running this command inside a
21
+ docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
22
+ browser by default.
23
+ `);
24
+ }
25
+ });
14
26
  }
@@ -65,10 +65,12 @@ export function watchStorySpecifiers(specifiers, options, onInvalidate) {
65
65
  // (where the last bit depends on `files`).
66
66
  var dirGlob = path.join(options.workingDir, importPath, '**', // files can be e.g. '**/foo/*/*.js' so we just want the last bit,
67
67
  // because the directoru could already be within the files part (e.g. './x/foo/bar')
68
- path.basename(specifier.files));
69
- var files = await glob(dirGlob);
68
+ path.basename(specifier.files)); // glob only supports forward slashes
69
+
70
+ var files = await glob(dirGlob.replace(/\\/g, '/'));
70
71
  files.forEach(function (filePath) {
71
- var fileImportPath = toImportPath(path.relative(options.workingDir, filePath));
72
+ var fileImportPath = toImportPath( // use posix path separators even on windows
73
+ path.relative(options.workingDir, filePath).replace(/\\/g, '/'));
72
74
 
73
75
  if (specifier.importPathMatcher.exec(fileImportPath)) {
74
76
  onInvalidate(specifier, fileImportPath, removed);
@@ -105,11 +105,11 @@ export async function buildDevStandalone(options) {
105
105
  if (options.smokeTest) {
106
106
  // @ts-ignore
107
107
  var managerWarnings = managerStats && managerStats.toJson().warnings || [];
108
- if (managerWarnings.length > 0) logger.warn(`manager: ${managerWarnings}`); // I'm a little reticent to import webpack types in this file :shrug:
108
+ if (managerWarnings.length > 0) logger.warn(`manager: ${JSON.stringify(managerWarnings, null, 2)}`); // I'm a little reticent to import webpack types in this file :shrug:
109
109
  // @ts-ignore
110
110
 
111
111
  var previewWarnings = previewStats && previewStats.toJson().warnings || [];
112
- if (previewWarnings.length > 0) logger.warn(`preview: ${previewWarnings}`);
112
+ if (previewWarnings.length > 0) logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`);
113
113
  process.exit(managerWarnings.length > 0 || previewWarnings.length > 0 && !options.ignorePreview ? 1 : 0);
114
114
  return;
115
115
  } // Get package name and capitalize it e.g. @storybook/react -> React
@@ -175,7 +175,7 @@ export class StoryIndexGenerator {
175
175
  }
176
176
 
177
177
  invalidate(specifier, importPath, removed) {
178
- var absolutePath = path.resolve(this.options.workingDir, importPath);
178
+ var absolutePath = slash(path.resolve(this.options.workingDir, importPath));
179
179
  var pathToEntries = this.storyIndexEntries.get(specifier);
180
180
 
181
181
  if (removed) {
@@ -1,14 +1,26 @@
1
+ import "core-js/modules/es.promise.js";
1
2
  import { logger } from '@storybook/node-logger';
2
- import open from 'better-opn';
3
+ import betterOpn from 'better-opn'; // betterOpn alias used because also loading open
4
+
5
+ import open from 'open';
6
+ import getDefaultBrowser from 'x-default-browser';
3
7
  import dedent from 'ts-dedent';
4
8
  export function openInBrowser(address) {
5
- try {
6
- open(address);
7
- } catch (error) {
8
- logger.error(dedent`
9
- Could not open ${address} inside a browser. If you're running this command inside a
10
- docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
11
- browser by default.
12
- `);
13
- }
9
+ getDefaultBrowser(async function (err, res) {
10
+ try {
11
+ if (res.isChrome || res.isChromium) {
12
+ // We use betterOpn for Chrome because it is better at handling which chrome tab
13
+ // or window the preview loads in.
14
+ betterOpn(address);
15
+ } else {
16
+ await open(address);
17
+ }
18
+ } catch (error) {
19
+ logger.error(dedent`
20
+ Could not open ${address} inside a browser. If you're running this command inside a
21
+ docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
22
+ browser by default.
23
+ `);
24
+ }
25
+ });
14
26
  }
@@ -65,10 +65,12 @@ export function watchStorySpecifiers(specifiers, options, onInvalidate) {
65
65
  // (where the last bit depends on `files`).
66
66
  var dirGlob = path.join(options.workingDir, importPath, '**', // files can be e.g. '**/foo/*/*.js' so we just want the last bit,
67
67
  // because the directoru could already be within the files part (e.g. './x/foo/bar')
68
- path.basename(specifier.files));
69
- var files = await glob(dirGlob);
68
+ path.basename(specifier.files)); // glob only supports forward slashes
69
+
70
+ var files = await glob(dirGlob.replace(/\\/g, '/'));
70
71
  files.forEach(function (filePath) {
71
- var fileImportPath = toImportPath(path.relative(options.workingDir, filePath));
72
+ var fileImportPath = toImportPath( // use posix path separators even on windows
73
+ path.relative(options.workingDir, filePath).replace(/\\/g, '/'));
72
74
 
73
75
  if (specifier.importPathMatcher.exec(fileImportPath)) {
74
76
  onInvalidate(specifier, fileImportPath, removed);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/core-server",
3
- "version": "6.4.9",
3
+ "version": "6.5.0-alpha.4",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -41,17 +41,17 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@discoveryjs/json-ext": "^0.5.3",
44
- "@storybook/builder-webpack4": "6.4.9",
45
- "@storybook/core-client": "6.4.9",
46
- "@storybook/core-common": "6.4.9",
47
- "@storybook/core-events": "6.4.9",
44
+ "@storybook/builder-webpack4": "6.5.0-alpha.4",
45
+ "@storybook/core-client": "6.5.0-alpha.4",
46
+ "@storybook/core-common": "6.5.0-alpha.4",
47
+ "@storybook/core-events": "6.5.0-alpha.4",
48
48
  "@storybook/csf": "0.0.2--canary.87bc651.0",
49
- "@storybook/csf-tools": "6.4.9",
50
- "@storybook/manager-webpack4": "6.4.9",
51
- "@storybook/node-logger": "6.4.9",
49
+ "@storybook/csf-tools": "6.5.0-alpha.4",
50
+ "@storybook/manager-webpack4": "6.5.0-alpha.4",
51
+ "@storybook/node-logger": "6.5.0-alpha.4",
52
52
  "@storybook/semver": "^7.3.2",
53
- "@storybook/store": "6.4.9",
54
- "@types/node": "^14.0.10",
53
+ "@storybook/store": "6.5.0-alpha.4",
54
+ "@types/node": "^14.0.10 || ^16.0.0",
55
55
  "@types/node-fetch": "^2.5.7",
56
56
  "@types/pretty-hrtime": "^1.0.0",
57
57
  "@types/webpack": "^4.41.26",
@@ -71,6 +71,7 @@
71
71
  "ip": "^1.1.5",
72
72
  "lodash": "^4.17.21",
73
73
  "node-fetch": "^2.6.1",
74
+ "open": "^8.4.0",
74
75
  "pretty-hrtime": "^1.0.3",
75
76
  "prompts": "^2.4.0",
76
77
  "regenerator-runtime": "^0.13.7",
@@ -81,10 +82,11 @@
81
82
  "util-deprecate": "^1.0.2",
82
83
  "watchpack": "^2.2.0",
83
84
  "webpack": "4",
84
- "ws": "^8.2.3"
85
+ "ws": "^8.2.3",
86
+ "x-default-browser": "^0.4.0"
85
87
  },
86
88
  "devDependencies": {
87
- "@storybook/builder-webpack5": "6.4.9",
89
+ "@storybook/builder-webpack5": "6.5.0-alpha.4",
88
90
  "@types/compression": "^1.7.0",
89
91
  "@types/ip": "^1.1.0",
90
92
  "@types/serve-favicon": "^2.5.2",
@@ -92,8 +94,8 @@
92
94
  "jest-specific-snapshot": "^4.0.0"
93
95
  },
94
96
  "peerDependencies": {
95
- "@storybook/builder-webpack5": "6.4.9",
96
- "@storybook/manager-webpack5": "6.4.9",
97
+ "@storybook/builder-webpack5": "6.5.0-alpha.4",
98
+ "@storybook/manager-webpack5": "6.5.0-alpha.4",
97
99
  "react": "^16.8.0 || ^17.0.0",
98
100
  "react-dom": "^16.8.0 || ^17.0.0"
99
101
  },
@@ -111,6 +113,6 @@
111
113
  "publishConfig": {
112
114
  "access": "public"
113
115
  },
114
- "gitHead": "7d354c89322080b241454eff2cd3adf9c11306cd",
116
+ "gitHead": "9a73995d6a5cfa36c5a5ce60cb33259ff40e2fe6",
115
117
  "sbmodern": "dist/modern/index.js"
116
118
  }
package/typings.d.ts CHANGED
@@ -6,6 +6,8 @@ declare module 'pnp-webpack-plugin';
6
6
  declare module '@storybook/theming/paths';
7
7
  declare module '@storybook/ui/paths';
8
8
  declare module 'better-opn';
9
+ declare module 'open';
10
+ declare module 'x-default-browser';
9
11
  declare module '@storybook/ui';
10
12
  declare module '@discoveryjs/json-ext';
11
13
  declare module 'watchpack';