1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.babel = babel;
|
7 | exports.previewAnnotations = void 0;
|
8 | exports.webpackFinal = webpackFinal;
|
9 |
|
10 | require("core-js/modules/es.promise.js");
|
11 |
|
12 | var _coreCommon = require("@storybook/core-common");
|
13 |
|
14 | var _reactDocgenTypescriptPlugin = _interopRequireDefault(require("@storybook/react-docgen-typescript-plugin"));
|
15 |
|
16 | var _docsTools = require("@storybook/docs-tools");
|
17 |
|
18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19 |
|
20 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
21 |
|
22 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
23 |
|
24 | 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; }
|
25 |
|
26 | async function babel(config, options) {
|
27 | if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
|
28 | var typescriptOptions = await options.presets.apply('typescript', {});
|
29 | var reactDocgen = typescriptOptions.reactDocgen;
|
30 |
|
31 | if (typeof reactDocgen !== 'string') {
|
32 | return config;
|
33 | }
|
34 |
|
35 | return _objectSpread(_objectSpread({}, config), {}, {
|
36 | overrides: [...((config === null || config === void 0 ? void 0 : config.overrides) || []), {
|
37 | test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
|
38 | plugins: [[require.resolve('babel-plugin-react-docgen'), {
|
39 | DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
|
40 | }]]
|
41 | }]
|
42 | });
|
43 | }
|
44 |
|
45 | async function webpackFinal(config, options) {
|
46 | if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
|
47 | var typescriptOptions = await options.presets.apply('typescript', {});
|
48 | var reactDocgen = typescriptOptions.reactDocgen,
|
49 | reactDocgenTypescriptOptions = typescriptOptions.reactDocgenTypescriptOptions;
|
50 |
|
51 | if (reactDocgen !== 'react-docgen-typescript') {
|
52 | return config;
|
53 | }
|
54 |
|
55 | return _objectSpread(_objectSpread({}, config), {}, {
|
56 | plugins: [...config.plugins, new _reactDocgenTypescriptPlugin.default(_objectSpread(_objectSpread({}, reactDocgenTypescriptOptions), {}, {
|
57 |
|
58 | savePropValueAsString: true
|
59 | }))]
|
60 | });
|
61 | }
|
62 |
|
63 | var previewAnnotations = function (entry = [], options) {
|
64 | if (!(0, _docsTools.hasDocsOrControls)(options)) return entry;
|
65 | return [...entry, (0, _coreCommon.findDistEsm)(__dirname, 'client/docs/config')];
|
66 | };
|
67 |
|
68 | exports.previewAnnotations = previewAnnotations; |
\ | No newline at end of file |