@storybook/core-common 6.5.9 → 7.0.0-alpha.2
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.
- package/dist/cjs/index.js +0 -84
- package/dist/cjs/presets.js +11 -51
- package/dist/cjs/test-typings.d.js +1 -0
- package/dist/cjs/utils/get-storybook-info.js +2 -1
- package/dist/esm/index.js +1 -6
- package/dist/esm/presets.js +11 -49
- package/dist/esm/test-typings.d.js +0 -0
- package/dist/esm/utils/envs.js +1 -0
- package/dist/esm/utils/get-storybook-info.js +2 -1
- package/dist/{ts3.9 → types}/index.d.ts +0 -6
- package/dist/{ts3.9 → types}/presets.d.ts +0 -1
- package/dist/{ts3.9 → types}/types.d.ts +41 -53
- package/dist/{ts3.9 → types}/utils/cache.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/check-addon-order.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/envs.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/file-cache.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/findDistEsm.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/get-storybook-configuration.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/get-storybook-info.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/glob-to-regexp.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/handlebars.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/interpolate.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/interpret-files.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/interpret-require.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/load-custom-presets.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/load-main-config.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/load-manager-or-addons-file.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/load-preview-or-config-file.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/log-config.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/normalize-stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/notify-telemetry.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/paths.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/print-duration.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/progress-reporting.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/readTemplate.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/resolve-path-in-sb-cache.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/safeResolve.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/template.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/to-importFn.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/to-require-context.d.ts +0 -0
- package/dist/{ts3.9 → types}/utils/validate-configuration-files.d.ts +0 -0
- package/package.json +10 -19
- package/dist/cjs/utils/babel.js +0 -59
- package/dist/cjs/utils/check-webpack-version.js +0 -34
- package/dist/cjs/utils/es6Transpiler.js +0 -43
- package/dist/cjs/utils/load-custom-babel-config.js +0 -113
- package/dist/cjs/utils/load-custom-webpack-config.js +0 -22
- package/dist/cjs/utils/merge-webpack-config.js +0 -87
- package/dist/esm/utils/babel.js +0 -47
- package/dist/esm/utils/check-webpack-version.js +0 -20
- package/dist/esm/utils/es6Transpiler.js +0 -33
- package/dist/esm/utils/load-custom-babel-config.js +0 -94
- package/dist/esm/utils/load-custom-webpack-config.js +0 -8
- package/dist/esm/utils/merge-webpack-config.js +0 -80
- package/dist/modern/index.js +0 -33
- package/dist/modern/presets.js +0 -341
- package/dist/modern/types.js +0 -1
- package/dist/modern/utils/babel.js +0 -47
- package/dist/modern/utils/cache.js +0 -7
- package/dist/modern/utils/check-addon-order.js +0 -45
- package/dist/modern/utils/check-webpack-version.js +0 -20
- package/dist/modern/utils/envs.js +0 -69
- package/dist/modern/utils/es6Transpiler.js +0 -33
- package/dist/modern/utils/file-cache.js +0 -57
- package/dist/modern/utils/findDistEsm.js +0 -8
- package/dist/modern/utils/get-storybook-configuration.js +0 -24
- package/dist/modern/utils/get-storybook-info.js +0 -115
- package/dist/modern/utils/glob-to-regexp.js +0 -24
- package/dist/modern/utils/handlebars.js +0 -5
- package/dist/modern/utils/interpolate.js +0 -14
- package/dist/modern/utils/interpret-files.js +0 -31
- package/dist/modern/utils/interpret-require.js +0 -95
- package/dist/modern/utils/load-custom-babel-config.js +0 -94
- package/dist/modern/utils/load-custom-presets.js +0 -16
- package/dist/modern/utils/load-custom-webpack-config.js +0 -8
- package/dist/modern/utils/load-main-config.js +0 -9
- package/dist/modern/utils/load-manager-or-addons-file.js +0 -21
- package/dist/modern/utils/load-preview-or-config-file.js +0 -16
- package/dist/modern/utils/log-config.js +0 -8
- package/dist/modern/utils/merge-webpack-config.js +0 -80
- package/dist/modern/utils/normalize-stories.js +0 -115
- package/dist/modern/utils/notify-telemetry.js +0 -22
- package/dist/modern/utils/paths.js +0 -40
- package/dist/modern/utils/print-duration.js +0 -4
- package/dist/modern/utils/progress-reporting.js +0 -75
- package/dist/modern/utils/readTemplate.js +0 -7
- package/dist/modern/utils/resolve-path-in-sb-cache.js +0 -24
- package/dist/modern/utils/safeResolve.js +0 -15
- package/dist/modern/utils/template.js +0 -49
- package/dist/modern/utils/to-importFn.js +0 -52
- package/dist/modern/utils/to-require-context.js +0 -22
- package/dist/modern/utils/validate-configuration-files.js +0 -67
- package/dist/ts3.4/index.d.ts +0 -33
- package/dist/ts3.4/presets.d.ts +0 -42
- package/dist/ts3.4/types.d.ts +0 -387
- package/dist/ts3.4/utils/babel.d.ts +0 -5
- package/dist/ts3.4/utils/cache.d.ts +0 -1
- package/dist/ts3.4/utils/check-addon-order.d.ts +0 -16
- package/dist/ts3.4/utils/check-webpack-version.d.ts +0 -3
- package/dist/ts3.4/utils/envs.d.ts +0 -8
- package/dist/ts3.4/utils/es6Transpiler.d.ts +0 -2
- package/dist/ts3.4/utils/file-cache.d.ts +0 -30
- package/dist/ts3.4/utils/findDistEsm.d.ts +0 -1
- package/dist/ts3.4/utils/get-storybook-configuration.d.ts +0 -1
- package/dist/ts3.4/utils/get-storybook-info.d.ts +0 -12
- package/dist/ts3.4/utils/glob-to-regexp.d.ts +0 -1
- package/dist/ts3.4/utils/handlebars.d.ts +0 -1
- package/dist/ts3.4/utils/interpolate.d.ts +0 -9
- package/dist/ts3.4/utils/interpret-files.d.ts +0 -6
- package/dist/ts3.4/utils/interpret-require.d.ts +0 -2
- package/dist/ts3.4/utils/load-custom-babel-config.d.ts +0 -2
- package/dist/ts3.4/utils/load-custom-presets.d.ts +0 -4
- package/dist/ts3.4/utils/load-custom-webpack-config.d.ts +0 -1
- package/dist/ts3.4/utils/load-main-config.d.ts +0 -4
- package/dist/ts3.4/utils/load-manager-or-addons-file.d.ts +0 -3
- package/dist/ts3.4/utils/load-preview-or-config-file.d.ts +0 -3
- package/dist/ts3.4/utils/log-config.d.ts +0 -1
- package/dist/ts3.4/utils/merge-webpack-config.d.ts +0 -2
- package/dist/ts3.4/utils/normalize-stories.d.ts +0 -11
- package/dist/ts3.4/utils/notify-telemetry.d.ts +0 -1
- package/dist/ts3.4/utils/paths.d.ts +0 -6
- package/dist/ts3.4/utils/print-duration.d.ts +0 -4
- package/dist/ts3.4/utils/progress-reporting.d.ts +0 -8
- package/dist/ts3.4/utils/readTemplate.d.ts +0 -1
- package/dist/ts3.4/utils/resolve-path-in-sb-cache.d.ts +0 -9
- package/dist/ts3.4/utils/safeResolve.d.ts +0 -2
- package/dist/ts3.4/utils/template.d.ts +0 -5
- package/dist/ts3.4/utils/to-importFn.d.ts +0 -4
- package/dist/ts3.4/utils/to-require-context.d.ts +0 -7
- package/dist/ts3.4/utils/validate-configuration-files.d.ts +0 -1
- package/dist/ts3.9/utils/babel.d.ts +0 -5
- package/dist/ts3.9/utils/check-webpack-version.d.ts +0 -3
- package/dist/ts3.9/utils/es6Transpiler.d.ts +0 -2
- package/dist/ts3.9/utils/load-custom-babel-config.d.ts +0 -2
- package/dist/ts3.9/utils/load-custom-webpack-config.d.ts +0 -1
- package/dist/ts3.9/utils/merge-webpack-config.d.ts +0 -2
- package/types/index.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -27,34 +27,6 @@ Object.keys(_presets).forEach(function (key) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
var _babel = require("./utils/babel");
|
|
31
|
-
|
|
32
|
-
Object.keys(_babel).forEach(function (key) {
|
|
33
|
-
if (key === "default" || key === "__esModule") return;
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
-
if (key in exports && exports[key] === _babel[key]) return;
|
|
36
|
-
Object.defineProperty(exports, key, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _babel[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
var _checkWebpackVersion = require("./utils/check-webpack-version");
|
|
45
|
-
|
|
46
|
-
Object.keys(_checkWebpackVersion).forEach(function (key) {
|
|
47
|
-
if (key === "default" || key === "__esModule") return;
|
|
48
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
49
|
-
if (key in exports && exports[key] === _checkWebpackVersion[key]) return;
|
|
50
|
-
Object.defineProperty(exports, key, {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return _checkWebpackVersion[key];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
30
|
var _checkAddonOrder = require("./utils/check-addon-order");
|
|
59
31
|
|
|
60
32
|
Object.keys(_checkAddonOrder).forEach(function (key) {
|
|
@@ -83,20 +55,6 @@ Object.keys(_envs).forEach(function (key) {
|
|
|
83
55
|
});
|
|
84
56
|
});
|
|
85
57
|
|
|
86
|
-
var _es6Transpiler = require("./utils/es6Transpiler");
|
|
87
|
-
|
|
88
|
-
Object.keys(_es6Transpiler).forEach(function (key) {
|
|
89
|
-
if (key === "default" || key === "__esModule") return;
|
|
90
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
91
|
-
if (key in exports && exports[key] === _es6Transpiler[key]) return;
|
|
92
|
-
Object.defineProperty(exports, key, {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return _es6Transpiler[key];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
58
|
var _handlebars = require("./utils/handlebars");
|
|
101
59
|
|
|
102
60
|
Object.keys(_handlebars).forEach(function (key) {
|
|
@@ -139,20 +97,6 @@ Object.keys(_interpretRequire).forEach(function (key) {
|
|
|
139
97
|
});
|
|
140
98
|
});
|
|
141
99
|
|
|
142
|
-
var _loadCustomBabelConfig = require("./utils/load-custom-babel-config");
|
|
143
|
-
|
|
144
|
-
Object.keys(_loadCustomBabelConfig).forEach(function (key) {
|
|
145
|
-
if (key === "default" || key === "__esModule") return;
|
|
146
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
147
|
-
if (key in exports && exports[key] === _loadCustomBabelConfig[key]) return;
|
|
148
|
-
Object.defineProperty(exports, key, {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
get: function () {
|
|
151
|
-
return _loadCustomBabelConfig[key];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
100
|
var _loadCustomPresets = require("./utils/load-custom-presets");
|
|
157
101
|
|
|
158
102
|
Object.keys(_loadCustomPresets).forEach(function (key) {
|
|
@@ -167,20 +111,6 @@ Object.keys(_loadCustomPresets).forEach(function (key) {
|
|
|
167
111
|
});
|
|
168
112
|
});
|
|
169
113
|
|
|
170
|
-
var _loadCustomWebpackConfig = require("./utils/load-custom-webpack-config");
|
|
171
|
-
|
|
172
|
-
Object.keys(_loadCustomWebpackConfig).forEach(function (key) {
|
|
173
|
-
if (key === "default" || key === "__esModule") return;
|
|
174
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
175
|
-
if (key in exports && exports[key] === _loadCustomWebpackConfig[key]) return;
|
|
176
|
-
Object.defineProperty(exports, key, {
|
|
177
|
-
enumerable: true,
|
|
178
|
-
get: function () {
|
|
179
|
-
return _loadCustomWebpackConfig[key];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
114
|
var _loadMainConfig = require("./utils/load-main-config");
|
|
185
115
|
|
|
186
116
|
Object.keys(_loadMainConfig).forEach(function (key) {
|
|
@@ -265,20 +195,6 @@ Object.keys(_logConfig).forEach(function (key) {
|
|
|
265
195
|
});
|
|
266
196
|
});
|
|
267
197
|
|
|
268
|
-
var _mergeWebpackConfig = require("./utils/merge-webpack-config");
|
|
269
|
-
|
|
270
|
-
Object.keys(_mergeWebpackConfig).forEach(function (key) {
|
|
271
|
-
if (key === "default" || key === "__esModule") return;
|
|
272
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
273
|
-
if (key in exports && exports[key] === _mergeWebpackConfig[key]) return;
|
|
274
|
-
Object.defineProperty(exports, key, {
|
|
275
|
-
enumerable: true,
|
|
276
|
-
get: function () {
|
|
277
|
-
return _mergeWebpackConfig[key];
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
|
|
282
198
|
var _paths = require("./utils/paths");
|
|
283
199
|
|
|
284
200
|
Object.keys(_paths).forEach(function (key) {
|
package/dist/cjs/presets.js
CHANGED
|
@@ -13,19 +13,15 @@ require("core-js/modules/es.promise.js");
|
|
|
13
13
|
|
|
14
14
|
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
15
15
|
|
|
16
|
-
var _path = require("path");
|
|
17
|
-
|
|
18
16
|
var _nodeLogger = require("@storybook/node-logger");
|
|
19
17
|
|
|
20
18
|
var _loadCustomPresets = require("./utils/load-custom-presets");
|
|
21
19
|
|
|
22
|
-
var _interpretRequire = require("./utils/interpret-require");
|
|
23
|
-
|
|
24
20
|
var _safeResolve = require("./utils/safeResolve");
|
|
25
21
|
|
|
26
22
|
var _excluded = ["type", "name"],
|
|
27
|
-
_excluded2 = ["addons", "presets"
|
|
28
|
-
_excluded3 = ["corePresets", "
|
|
23
|
+
_excluded2 = ["addons", "presets"],
|
|
24
|
+
_excluded3 = ["corePresets", "overridePresets"];
|
|
29
25
|
|
|
30
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
27
|
|
|
@@ -54,15 +50,13 @@ function filterPresetsConfig(presetsConfig) {
|
|
|
54
50
|
});
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
function resolvePresetFunction(input, presetOptions,
|
|
58
|
-
var prepend = [framework].filter(Boolean);
|
|
59
|
-
|
|
53
|
+
function resolvePresetFunction(input, presetOptions, storybookOptions) {
|
|
60
54
|
if (isFunction(input)) {
|
|
61
|
-
return [...
|
|
55
|
+
return [...input(_objectSpread(_objectSpread({}, storybookOptions), presetOptions))];
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
if (Array.isArray(input)) {
|
|
65
|
-
return [...
|
|
59
|
+
return [...input];
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
return [];
|
|
@@ -106,9 +100,9 @@ var resolveAddonName = function (configDir, name, options) {
|
|
|
106
100
|
|
|
107
101
|
var path = name; // when user provides full path, we don't need to do anything!
|
|
108
102
|
|
|
109
|
-
var managerFile = (
|
|
110
|
-
var registerFile = (
|
|
111
|
-
var previewFile = (
|
|
103
|
+
var managerFile = r(`${path}/manager`);
|
|
104
|
+
var registerFile = r(`${path}/register`) || r(`${path}/register-panel`);
|
|
105
|
+
var previewFile = r(`${path}/preview`);
|
|
112
106
|
var presetFile = r(`${path}/preset`);
|
|
113
107
|
|
|
114
108
|
if (!(managerFile || previewFile) && presetFile) {
|
|
@@ -216,12 +210,11 @@ function loadPreset(input, level, storybookOptions) {
|
|
|
216
210
|
var _contents = contents,
|
|
217
211
|
addonsInput = _contents.addons,
|
|
218
212
|
presetsInput = _contents.presets,
|
|
219
|
-
framework = _contents.framework,
|
|
220
213
|
rest = _objectWithoutProperties(_contents, _excluded2);
|
|
221
214
|
|
|
222
|
-
var _subPresets = resolvePresetFunction(presetsInput, presetOptions,
|
|
215
|
+
var _subPresets = resolvePresetFunction(presetsInput, presetOptions, storybookOptions);
|
|
223
216
|
|
|
224
|
-
var subAddons = resolvePresetFunction(addonsInput, presetOptions,
|
|
217
|
+
var subAddons = resolvePresetFunction(addonsInput, presetOptions, storybookOptions);
|
|
225
218
|
return [...loadPresets([..._subPresets], level + 1, storybookOptions), ...loadPresets([...subAddons.map(map(storybookOptions))].filter(Boolean), level + 1, storybookOptions), {
|
|
226
219
|
name: name,
|
|
227
220
|
preset: rest,
|
|
@@ -248,10 +241,6 @@ function loadPresets(presets, level, storybookOptions) {
|
|
|
248
241
|
return [];
|
|
249
242
|
}
|
|
250
243
|
|
|
251
|
-
if (!level) {
|
|
252
|
-
_nodeLogger.logger.info('=> Loading presets');
|
|
253
|
-
}
|
|
254
|
-
|
|
255
244
|
return presets.reduce(function (acc, preset) {
|
|
256
245
|
var loaded = loadPreset(preset, level, storybookOptions);
|
|
257
246
|
return acc.concat(loaded);
|
|
@@ -317,44 +306,15 @@ function getPresets(presets, storybookOptions) {
|
|
|
317
306
|
}
|
|
318
307
|
};
|
|
319
308
|
}
|
|
320
|
-
/**
|
|
321
|
-
* Get the `framework` provided in main.js and also do error checking up front
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
var getFrameworkPackage = function (configDir) {
|
|
326
|
-
var main = (0, _interpretRequire.serverRequire)((0, _path.resolve)(configDir, 'main'));
|
|
327
|
-
if (!main) return null;
|
|
328
|
-
var frameworkPackage = main.framework,
|
|
329
|
-
_main$features = main.features,
|
|
330
|
-
features = _main$features === void 0 ? {} : _main$features;
|
|
331
|
-
|
|
332
|
-
if (features.breakingChangesV7 && !frameworkPackage) {
|
|
333
|
-
throw new Error((0, _tsDedent.default)`
|
|
334
|
-
Expected 'framework' in your main.js, didn't find one.
|
|
335
|
-
|
|
336
|
-
You can fix this automatically by running:
|
|
337
|
-
|
|
338
|
-
npx sb@next automigrate
|
|
339
|
-
|
|
340
|
-
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field
|
|
341
|
-
`);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return frameworkPackage;
|
|
345
|
-
};
|
|
346
309
|
|
|
347
310
|
function loadAllPresets(options) {
|
|
348
311
|
var _options$corePresets = options.corePresets,
|
|
349
312
|
corePresets = _options$corePresets === void 0 ? [] : _options$corePresets,
|
|
350
|
-
_options$frameworkPre = options.frameworkPresets,
|
|
351
|
-
frameworkPresets = _options$frameworkPre === void 0 ? [] : _options$frameworkPre,
|
|
352
313
|
_options$overridePres = options.overridePresets,
|
|
353
314
|
overridePresets = _options$overridePres === void 0 ? [] : _options$overridePres,
|
|
354
315
|
restOptions = _objectWithoutProperties(options, _excluded3);
|
|
355
316
|
|
|
356
|
-
var
|
|
357
|
-
var presetsConfig = [...corePresets, ...(frameworkPackage ? [] : frameworkPresets), ...(0, _loadCustomPresets.loadCustomPresets)(options), ...overridePresets]; // Remove `@storybook/preset-typescript` and add a warning if in use.
|
|
317
|
+
var presetsConfig = [...corePresets, ...(0, _loadCustomPresets.loadCustomPresets)(options), ...overridePresets]; // Remove `@storybook/preset-typescript` and add a warning if in use.
|
|
358
318
|
|
|
359
319
|
var filteredPresetConfig = filterPresetsConfig(presetsConfig);
|
|
360
320
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
/// <reference types="@types/compression" />
|
|
1
2
|
export * from './presets';
|
|
2
|
-
export * from './utils/babel';
|
|
3
|
-
export * from './utils/check-webpack-version';
|
|
4
3
|
export * from './utils/check-addon-order';
|
|
5
4
|
export * from './utils/envs';
|
|
6
|
-
export * from './utils/es6Transpiler';
|
|
7
5
|
export * from './utils/handlebars';
|
|
8
6
|
export * from './utils/interpret-files';
|
|
9
7
|
export * from './utils/interpret-require';
|
|
10
|
-
export * from './utils/load-custom-babel-config';
|
|
11
8
|
export * from './utils/load-custom-presets';
|
|
12
|
-
export * from './utils/load-custom-webpack-config';
|
|
13
9
|
export * from './utils/load-main-config';
|
|
14
10
|
export * from './utils/get-storybook-configuration';
|
|
15
11
|
export * from './utils/get-storybook-info';
|
|
16
12
|
export * from './utils/load-manager-or-addons-file';
|
|
17
13
|
export * from './utils/load-preview-or-config-file';
|
|
18
14
|
export * from './utils/log-config';
|
|
19
|
-
export * from './utils/merge-webpack-config';
|
|
20
15
|
export * from './utils/paths';
|
|
21
16
|
export * from './utils/progress-reporting';
|
|
22
17
|
export * from './utils/resolve-path-in-sb-cache';
|
package/dist/esm/presets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _excluded = ["type", "name"],
|
|
2
|
-
_excluded2 = ["addons", "presets"
|
|
3
|
-
_excluded3 = ["corePresets", "
|
|
2
|
+
_excluded2 = ["addons", "presets"],
|
|
3
|
+
_excluded3 = ["corePresets", "overridePresets"];
|
|
4
4
|
import "core-js/modules/es.promise.js";
|
|
5
5
|
|
|
6
6
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
@@ -14,10 +14,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
14
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
15
|
|
|
16
16
|
import dedent from 'ts-dedent';
|
|
17
|
-
import { resolve } from 'path';
|
|
18
17
|
import { logger } from '@storybook/node-logger';
|
|
19
18
|
import { loadCustomPresets } from './utils/load-custom-presets';
|
|
20
|
-
import { serverRequire } from './utils/interpret-require';
|
|
21
19
|
import { safeResolve, safeResolveFrom } from './utils/safeResolve';
|
|
22
20
|
|
|
23
21
|
var isObject = function (val) {
|
|
@@ -35,15 +33,13 @@ export function filterPresetsConfig(presetsConfig) {
|
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
function resolvePresetFunction(input, presetOptions,
|
|
39
|
-
var prepend = [framework].filter(Boolean);
|
|
40
|
-
|
|
36
|
+
function resolvePresetFunction(input, presetOptions, storybookOptions) {
|
|
41
37
|
if (isFunction(input)) {
|
|
42
|
-
return [...
|
|
38
|
+
return [...input(_objectSpread(_objectSpread({}, storybookOptions), presetOptions))];
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
if (Array.isArray(input)) {
|
|
46
|
-
return [...
|
|
42
|
+
return [...input];
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
return [];
|
|
@@ -87,9 +83,9 @@ export var resolveAddonName = function (configDir, name, options) {
|
|
|
87
83
|
|
|
88
84
|
var path = name; // when user provides full path, we don't need to do anything!
|
|
89
85
|
|
|
90
|
-
var managerFile =
|
|
91
|
-
var registerFile =
|
|
92
|
-
var previewFile =
|
|
86
|
+
var managerFile = r(`${path}/manager`);
|
|
87
|
+
var registerFile = r(`${path}/register`) || r(`${path}/register-panel`);
|
|
88
|
+
var previewFile = r(`${path}/preview`);
|
|
93
89
|
var presetFile = r(`${path}/preset`);
|
|
94
90
|
|
|
95
91
|
if (!(managerFile || previewFile) && presetFile) {
|
|
@@ -195,12 +191,11 @@ export function loadPreset(input, level, storybookOptions) {
|
|
|
195
191
|
var _contents = contents,
|
|
196
192
|
addonsInput = _contents.addons,
|
|
197
193
|
presetsInput = _contents.presets,
|
|
198
|
-
framework = _contents.framework,
|
|
199
194
|
rest = _objectWithoutProperties(_contents, _excluded2);
|
|
200
195
|
|
|
201
|
-
var _subPresets = resolvePresetFunction(presetsInput, presetOptions,
|
|
196
|
+
var _subPresets = resolvePresetFunction(presetsInput, presetOptions, storybookOptions);
|
|
202
197
|
|
|
203
|
-
var subAddons = resolvePresetFunction(addonsInput, presetOptions,
|
|
198
|
+
var subAddons = resolvePresetFunction(addonsInput, presetOptions, storybookOptions);
|
|
204
199
|
return [...loadPresets([..._subPresets], level + 1, storybookOptions), ...loadPresets([...subAddons.map(map(storybookOptions))].filter(Boolean), level + 1, storybookOptions), {
|
|
205
200
|
name: name,
|
|
206
201
|
preset: rest,
|
|
@@ -224,10 +219,6 @@ function loadPresets(presets, level, storybookOptions) {
|
|
|
224
219
|
return [];
|
|
225
220
|
}
|
|
226
221
|
|
|
227
|
-
if (!level) {
|
|
228
|
-
logger.info('=> Loading presets');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
222
|
return presets.reduce(function (acc, preset) {
|
|
232
223
|
var loaded = loadPreset(preset, level, storybookOptions);
|
|
233
224
|
return acc.concat(loaded);
|
|
@@ -293,43 +284,14 @@ export function getPresets(presets, storybookOptions) {
|
|
|
293
284
|
}
|
|
294
285
|
};
|
|
295
286
|
}
|
|
296
|
-
/**
|
|
297
|
-
* Get the `framework` provided in main.js and also do error checking up front
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
var getFrameworkPackage = function (configDir) {
|
|
301
|
-
var main = serverRequire(resolve(configDir, 'main'));
|
|
302
|
-
if (!main) return null;
|
|
303
|
-
var frameworkPackage = main.framework,
|
|
304
|
-
_main$features = main.features,
|
|
305
|
-
features = _main$features === void 0 ? {} : _main$features;
|
|
306
|
-
|
|
307
|
-
if (features.breakingChangesV7 && !frameworkPackage) {
|
|
308
|
-
throw new Error(dedent`
|
|
309
|
-
Expected 'framework' in your main.js, didn't find one.
|
|
310
|
-
|
|
311
|
-
You can fix this automatically by running:
|
|
312
|
-
|
|
313
|
-
npx sb@next automigrate
|
|
314
|
-
|
|
315
|
-
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field
|
|
316
|
-
`);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return frameworkPackage;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
287
|
export function loadAllPresets(options) {
|
|
323
288
|
var _options$corePresets = options.corePresets,
|
|
324
289
|
corePresets = _options$corePresets === void 0 ? [] : _options$corePresets,
|
|
325
|
-
_options$frameworkPre = options.frameworkPresets,
|
|
326
|
-
frameworkPresets = _options$frameworkPre === void 0 ? [] : _options$frameworkPre,
|
|
327
290
|
_options$overridePres = options.overridePresets,
|
|
328
291
|
overridePresets = _options$overridePres === void 0 ? [] : _options$overridePres,
|
|
329
292
|
restOptions = _objectWithoutProperties(options, _excluded3);
|
|
330
293
|
|
|
331
|
-
var
|
|
332
|
-
var presetsConfig = [...corePresets, ...(frameworkPackage ? [] : frameworkPresets), ...loadCustomPresets(options), ...overridePresets]; // Remove `@storybook/preset-typescript` and add a warning if in use.
|
|
294
|
+
var presetsConfig = [...corePresets, ...loadCustomPresets(options), ...overridePresets]; // Remove `@storybook/preset-typescript` and add a warning if in use.
|
|
333
295
|
|
|
334
296
|
var filteredPresetConfig = filterPresetsConfig(presetsConfig);
|
|
335
297
|
|
|
File without changes
|
package/dist/esm/utils/envs.js
CHANGED
|
@@ -4,6 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
+
// @ts-ignore
|
|
7
8
|
import { getEnvironment } from 'lazy-universal-dotenv';
|
|
8
9
|
import { nodePathsToArray } from './paths'; // Load environment variables starts with STORYBOOK_ to the client side.
|
|
9
10
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
export * from './presets';
|
|
2
|
-
export * from './utils/babel';
|
|
3
|
-
export * from './utils/check-webpack-version';
|
|
4
2
|
export * from './utils/check-addon-order';
|
|
5
3
|
export * from './utils/envs';
|
|
6
|
-
export * from './utils/es6Transpiler';
|
|
7
4
|
export * from './utils/handlebars';
|
|
8
5
|
export * from './utils/interpret-files';
|
|
9
6
|
export * from './utils/interpret-require';
|
|
10
|
-
export * from './utils/load-custom-babel-config';
|
|
11
7
|
export * from './utils/load-custom-presets';
|
|
12
|
-
export * from './utils/load-custom-webpack-config';
|
|
13
8
|
export * from './utils/load-main-config';
|
|
14
9
|
export * from './utils/get-storybook-configuration';
|
|
15
10
|
export * from './utils/get-storybook-info';
|
|
16
11
|
export * from './utils/load-manager-or-addons-file';
|
|
17
12
|
export * from './utils/load-preview-or-config-file';
|
|
18
13
|
export * from './utils/log-config';
|
|
19
|
-
export * from './utils/merge-webpack-config';
|
|
20
14
|
export * from './utils/paths';
|
|
21
15
|
export * from './utils/progress-reporting';
|
|
22
16
|
export * from './utils/resolve-path-in-sb-cache';
|
|
@@ -37,6 +37,5 @@ export declare function getPresets(presets: PresetConfig[], storybookOptions: In
|
|
|
37
37
|
export declare function loadAllPresets(options: CLIOptions & LoadOptions & BuilderOptions & {
|
|
38
38
|
corePresets: string[];
|
|
39
39
|
overridePresets: string[];
|
|
40
|
-
frameworkPresets: string[];
|
|
41
40
|
}): Presets;
|
|
42
41
|
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
3
2
|
import type { Options as TelejsonOptions } from 'telejson';
|
|
4
|
-
import type { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
|
|
5
|
-
import type { Configuration, Stats } from 'webpack';
|
|
6
3
|
import type { TransformOptions } from '@babel/core';
|
|
7
4
|
import { Router } from 'express';
|
|
8
5
|
import { Server } from 'http';
|
|
@@ -10,33 +7,24 @@ import { FileSystemCache } from './utils/file-cache';
|
|
|
10
7
|
/**
|
|
11
8
|
* ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
|
|
12
9
|
*/
|
|
13
|
-
export
|
|
14
|
-
check: boolean;
|
|
15
|
-
reactDocgen: false | string;
|
|
16
|
-
reactDocgenTypescriptOptions: {
|
|
17
|
-
shouldExtractLiteralValuesFromEnum: boolean;
|
|
18
|
-
shouldRemoveUndefinedFromOptional: boolean;
|
|
19
|
-
propFilter: (prop: any) => boolean;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare type BuilderName = 'webpack4' | 'webpack5' | string;
|
|
10
|
+
export declare type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
|
|
23
11
|
export declare type BuilderConfigObject = {
|
|
24
12
|
name: BuilderName;
|
|
25
13
|
options?: Record<string, any>;
|
|
26
14
|
};
|
|
27
15
|
export interface Webpack5BuilderConfig extends BuilderConfigObject {
|
|
28
|
-
name: 'webpack5';
|
|
16
|
+
name: '@storybook/builder-webpack5';
|
|
29
17
|
options?: {
|
|
30
18
|
fsCache?: boolean;
|
|
31
19
|
lazyCompilation?: boolean;
|
|
32
20
|
};
|
|
33
21
|
}
|
|
34
22
|
export interface Webpack4BuilderConfig extends BuilderConfigObject {
|
|
35
|
-
name: '
|
|
23
|
+
name: '@storybook/builder-webpack5';
|
|
36
24
|
}
|
|
37
25
|
export declare type BuilderConfig = BuilderName | BuilderConfigObject | Webpack4BuilderConfig | Webpack5BuilderConfig;
|
|
38
26
|
export interface CoreConfig {
|
|
39
|
-
builder
|
|
27
|
+
builder?: BuilderConfig;
|
|
40
28
|
disableWebpackDefaults?: boolean;
|
|
41
29
|
channelOptions?: Partial<TelejsonOptions>;
|
|
42
30
|
/**
|
|
@@ -67,20 +55,14 @@ interface DirectoryMapping {
|
|
|
67
55
|
to: string;
|
|
68
56
|
}
|
|
69
57
|
export interface Presets {
|
|
70
|
-
apply(extension: 'typescript', config:
|
|
58
|
+
apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
|
|
71
59
|
apply(extension: 'babel', config: {}, args: any): Promise<TransformOptions>;
|
|
72
60
|
apply(extension: 'entries', config: [], args: any): Promise<unknown>;
|
|
73
61
|
apply(extension: 'stories', config: [], args: any): Promise<StoriesEntry[]>;
|
|
74
|
-
apply(extension: 'webpack', config: {}, args: {
|
|
75
|
-
babelOptions?: TransformOptions;
|
|
76
|
-
} & any): Promise<Configuration>;
|
|
77
62
|
apply(extension: 'managerEntries', config: [], args: any): Promise<string[]>;
|
|
78
63
|
apply(extension: 'refs', config: [], args: any): Promise<unknown>;
|
|
79
64
|
apply(extension: 'core', config: {}, args: any): Promise<CoreConfig>;
|
|
80
|
-
apply(extension:
|
|
81
|
-
babelOptions?: TransformOptions;
|
|
82
|
-
} & ManagerWebpackOptions): Promise<Configuration>;
|
|
83
|
-
apply<T extends unknown>(extension: string, config?: T, args?: unknown): Promise<T>;
|
|
65
|
+
apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
|
|
84
66
|
}
|
|
85
67
|
export interface LoadedPreset {
|
|
86
68
|
name: string;
|
|
@@ -114,9 +96,12 @@ export interface ReleaseNotesData {
|
|
|
114
96
|
currentVersion: string;
|
|
115
97
|
showOnFirstLaunch: boolean;
|
|
116
98
|
}
|
|
99
|
+
export interface Stats {
|
|
100
|
+
toJson: () => any;
|
|
101
|
+
}
|
|
117
102
|
export interface BuilderResult {
|
|
118
|
-
stats?: Stats;
|
|
119
103
|
totalTime?: ReturnType<typeof process.hrtime>;
|
|
104
|
+
stats?: Stats;
|
|
120
105
|
}
|
|
121
106
|
export interface PackageJson {
|
|
122
107
|
name: string;
|
|
@@ -131,8 +116,6 @@ export interface PackageJson {
|
|
|
131
116
|
}
|
|
132
117
|
export interface LoadOptions {
|
|
133
118
|
packageJson: PackageJson;
|
|
134
|
-
framework: string;
|
|
135
|
-
frameworkPresets: string[];
|
|
136
119
|
outputDir?: string;
|
|
137
120
|
configDir?: string;
|
|
138
121
|
ignorePreview?: boolean;
|
|
@@ -174,7 +157,6 @@ export interface CLIOptions {
|
|
|
174
157
|
debugWebpack?: boolean;
|
|
175
158
|
webpackStatsJson?: string | boolean;
|
|
176
159
|
outputDir?: string;
|
|
177
|
-
modern?: boolean;
|
|
178
160
|
}
|
|
179
161
|
export interface BuilderOptions {
|
|
180
162
|
configType?: 'DEVELOPMENT' | 'PRODUCTION';
|
|
@@ -213,6 +195,23 @@ export interface Builder<Config, Stats> {
|
|
|
213
195
|
corePresets?: string[];
|
|
214
196
|
overridePresets?: string[];
|
|
215
197
|
}
|
|
198
|
+
export interface IndexerOptions {
|
|
199
|
+
makeTitle: (userTitle?: string) => string;
|
|
200
|
+
}
|
|
201
|
+
export interface IndexedStory {
|
|
202
|
+
id: string;
|
|
203
|
+
name: string;
|
|
204
|
+
}
|
|
205
|
+
export interface StoryIndex {
|
|
206
|
+
meta: {
|
|
207
|
+
title?: string;
|
|
208
|
+
};
|
|
209
|
+
stories: IndexedStory[];
|
|
210
|
+
}
|
|
211
|
+
export interface StoryIndexer {
|
|
212
|
+
test: RegExp;
|
|
213
|
+
indexer: (fileName: string, options: IndexerOptions) => Promise<StoryIndex>;
|
|
214
|
+
}
|
|
216
215
|
/**
|
|
217
216
|
* Options for TypeScript usage within Storybook.
|
|
218
217
|
*/
|
|
@@ -224,22 +223,11 @@ export interface TypescriptOptions {
|
|
|
224
223
|
*/
|
|
225
224
|
check: boolean;
|
|
226
225
|
/**
|
|
227
|
-
*
|
|
228
|
-
*/
|
|
229
|
-
checkOptions?: ForkTsCheckerWebpackPlugin['options'];
|
|
230
|
-
/**
|
|
231
|
-
* Sets the type of Docgen when working with React and TypeScript
|
|
226
|
+
* Disable parsing typescript files through babel.
|
|
232
227
|
*
|
|
233
|
-
* @default `
|
|
234
|
-
*/
|
|
235
|
-
reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
|
|
236
|
-
/**
|
|
237
|
-
* Configures `react-docgen-typescript-plugin`
|
|
238
|
-
*
|
|
239
|
-
* @default
|
|
240
|
-
* @see https://github.com/storybookjs/storybook/blob/next/lib/builder-webpack5/src/config/defaults.js#L4-L6
|
|
228
|
+
* @default `false`
|
|
241
229
|
*/
|
|
242
|
-
|
|
230
|
+
skipBabel: boolean;
|
|
243
231
|
}
|
|
244
232
|
interface StoriesSpecifier {
|
|
245
233
|
/**
|
|
@@ -299,10 +287,6 @@ export interface StorybookConfig {
|
|
|
299
287
|
* Allows to disable deprecated implicit PostCSS loader. (will be removed in 7.0)
|
|
300
288
|
*/
|
|
301
289
|
postcss?: boolean;
|
|
302
|
-
/**
|
|
303
|
-
* Allows to disable emotion webpack alias for emotion packages. (will be removed in 7.0)
|
|
304
|
-
*/
|
|
305
|
-
emotionAlias?: boolean;
|
|
306
290
|
/**
|
|
307
291
|
* Build stories.json automatically on start/build
|
|
308
292
|
*/
|
|
@@ -313,10 +297,6 @@ export interface StorybookConfig {
|
|
|
313
297
|
* @deprecated This is always on now from 6.4 regardless of the setting
|
|
314
298
|
*/
|
|
315
299
|
previewCsfV3?: boolean;
|
|
316
|
-
/**
|
|
317
|
-
* Activate modern inline rendering
|
|
318
|
-
*/
|
|
319
|
-
modernInlineRender?: boolean;
|
|
320
300
|
/**
|
|
321
301
|
* Activate on demand story store
|
|
322
302
|
*/
|
|
@@ -364,11 +344,15 @@ export interface StorybookConfig {
|
|
|
364
344
|
/**
|
|
365
345
|
* References external Storybooks
|
|
366
346
|
*/
|
|
367
|
-
refs?: StorybookRefs | ((config:
|
|
347
|
+
refs?: StorybookRefs | ((config: any, options: Options) => StorybookRefs);
|
|
368
348
|
/**
|
|
369
|
-
* Modify or return
|
|
349
|
+
* Modify or return babel config.
|
|
370
350
|
*/
|
|
371
|
-
|
|
351
|
+
babel?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
|
|
352
|
+
/**
|
|
353
|
+
* Modify or return babel config.
|
|
354
|
+
*/
|
|
355
|
+
babelDefault?: (config: TransformOptions, options: Options) => TransformOptions | Promise<TransformOptions>;
|
|
372
356
|
/**
|
|
373
357
|
* Add additional scripts to run in the preview a la `.storybook/preview.js`
|
|
374
358
|
*
|
|
@@ -379,5 +363,9 @@ export interface StorybookConfig {
|
|
|
379
363
|
* Add additional scripts to run in the preview a la `.storybook/preview.js`
|
|
380
364
|
*/
|
|
381
365
|
previewAnnotations?: (entries: Entry[], options: Options) => Entry[];
|
|
366
|
+
/**
|
|
367
|
+
* Process CSF files for the story index.
|
|
368
|
+
*/
|
|
369
|
+
storyIndexers?: (indexers: StoryIndexer[], options: Options) => StoryIndexer[];
|
|
382
370
|
}
|
|
383
371
|
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|