@storybook/addon-docs 6.5.9 → 7.0.0-alpha.10
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/blocks.d.ts +1 -1
- package/dist/cjs/blocks/index.js +5 -359
- package/dist/cjs/index.js +1 -7
- package/dist/cjs/manager.js +9 -15
- package/dist/cjs/preset.js +121 -193
- package/dist/cjs/preview.js +9 -87
- package/dist/cjs/shared.js +5 -5
- package/dist/esm/blocks/index.js +1 -24
- package/dist/esm/manager.js +9 -14
- package/dist/esm/preset.js +114 -179
- package/dist/esm/preview.js +7 -61
- package/dist/esm/shared.js +5 -5
- package/dist/types/blocks/index.d.ts +1 -0
- package/dist/{ts3.9 → types}/index.d.ts +0 -0
- package/dist/{ts3.9 → types}/manager.d.ts +0 -0
- package/dist/{ts3.9 → types}/preset.d.ts +2 -1
- package/dist/types/preview.d.ts +1 -0
- package/dist/{ts3.9 → types}/shared.d.ts +0 -0
- package/package.json +18 -25
- package/dist/cjs/blocks/Anchor.js +0 -26
- package/dist/cjs/blocks/ArgsTable.js +0 -400
- package/dist/cjs/blocks/Canvas.js +0 -144
- package/dist/cjs/blocks/Description.js +0 -153
- package/dist/cjs/blocks/DocsContainer.js +0 -155
- package/dist/cjs/blocks/DocsContext.js +0 -25
- package/dist/cjs/blocks/DocsPage.js +0 -32
- package/dist/cjs/blocks/DocsStory.js +0 -78
- package/dist/cjs/blocks/Heading.js +0 -35
- package/dist/cjs/blocks/Meta.js +0 -72
- package/dist/cjs/blocks/Preview.js +0 -29
- package/dist/cjs/blocks/Primary.js +0 -67
- package/dist/cjs/blocks/Props.js +0 -35
- package/dist/cjs/blocks/Source.js +0 -197
- package/dist/cjs/blocks/SourceContainer.js +0 -116
- package/dist/cjs/blocks/Stories.js +0 -82
- package/dist/cjs/blocks/Story.js +0 -263
- package/dist/cjs/blocks/Subheading.js +0 -35
- package/dist/cjs/blocks/Subtitle.js +0 -59
- package/dist/cjs/blocks/Title.js +0 -68
- package/dist/cjs/blocks/Wrapper.js +0 -21
- package/dist/cjs/blocks/enhanceSource.js +0 -129
- package/dist/cjs/blocks/mdx.js +0 -245
- package/dist/cjs/blocks/types.js +0 -10
- package/dist/cjs/blocks/useStory.js +0 -108
- package/dist/cjs/blocks/utils.js +0 -61
- package/dist/esm/blocks/Anchor.js +0 -11
- package/dist/esm/blocks/ArgsTable.js +0 -341
- package/dist/esm/blocks/Canvas.js +0 -95
- package/dist/esm/blocks/Description.js +0 -113
- package/dist/esm/blocks/DocsContainer.js +0 -106
- package/dist/esm/blocks/DocsContext.js +0 -16
- package/dist/esm/blocks/DocsPage.js +0 -13
- package/dist/esm/blocks/DocsStory.js +0 -55
- package/dist/esm/blocks/Heading.js +0 -19
- package/dist/esm/blocks/Meta.js +0 -35
- package/dist/esm/blocks/Preview.js +0 -14
- package/dist/esm/blocks/Primary.js +0 -29
- package/dist/esm/blocks/Props.js +0 -19
- package/dist/esm/blocks/Source.js +0 -150
- package/dist/esm/blocks/SourceContainer.js +0 -77
- package/dist/esm/blocks/Stories.js +0 -42
- package/dist/esm/blocks/Story.js +0 -207
- package/dist/esm/blocks/Subheading.js +0 -19
- package/dist/esm/blocks/Subtitle.js +0 -23
- package/dist/esm/blocks/Title.js +0 -25
- package/dist/esm/blocks/Wrapper.js +0 -9
- package/dist/esm/blocks/enhanceSource.js +0 -111
- package/dist/esm/blocks/mdx.js +0 -207
- package/dist/esm/blocks/types.js +0 -2
- package/dist/esm/blocks/useStory.js +0 -84
- package/dist/esm/blocks/utils.js +0 -43
- package/dist/modern/blocks/Anchor.js +0 -8
- package/dist/modern/blocks/ArgsTable.js +0 -292
- package/dist/modern/blocks/Canvas.js +0 -83
- package/dist/modern/blocks/Description.js +0 -107
- package/dist/modern/blocks/DocsContainer.js +0 -98
- package/dist/modern/blocks/DocsContext.js +0 -16
- package/dist/modern/blocks/DocsPage.js +0 -11
- package/dist/modern/blocks/DocsStory.js +0 -48
- package/dist/modern/blocks/Heading.js +0 -17
- package/dist/modern/blocks/Meta.js +0 -31
- package/dist/modern/blocks/Preview.js +0 -9
- package/dist/modern/blocks/Primary.js +0 -23
- package/dist/modern/blocks/Props.js +0 -14
- package/dist/modern/blocks/Source.js +0 -154
- package/dist/modern/blocks/SourceContainer.js +0 -44
- package/dist/modern/blocks/Stories.js +0 -34
- package/dist/modern/blocks/Story.js +0 -168
- package/dist/modern/blocks/Subheading.js +0 -17
- package/dist/modern/blocks/Subtitle.js +0 -23
- package/dist/modern/blocks/Title.js +0 -24
- package/dist/modern/blocks/Wrapper.js +0 -8
- package/dist/modern/blocks/enhanceSource.js +0 -89
- package/dist/modern/blocks/index.js +0 -24
- package/dist/modern/blocks/mdx.js +0 -204
- package/dist/modern/blocks/types.js +0 -2
- package/dist/modern/blocks/useStory.js +0 -28
- package/dist/modern/blocks/utils.js +0 -29
- package/dist/modern/index.js +0 -1
- package/dist/modern/manager.js +0 -16
- package/dist/modern/preset.js +0 -130
- package/dist/modern/preview.js +0 -6
- package/dist/modern/shared.js +0 -11
- package/dist/ts3.4/blocks/Anchor.d.ts +0 -6
- package/dist/ts3.4/blocks/ArgsTable.d.ts +0 -33
- package/dist/ts3.4/blocks/Canvas.d.ts +0 -9
- package/dist/ts3.4/blocks/Description.d.ts +0 -20
- package/dist/ts3.4/blocks/DocsContainer.d.ts +0 -7
- package/dist/ts3.4/blocks/DocsContext.d.ts +0 -5
- package/dist/ts3.4/blocks/DocsPage.d.ts +0 -2
- package/dist/ts3.4/blocks/DocsStory.d.ts +0 -3
- package/dist/ts3.4/blocks/Heading.d.ts +0 -6
- package/dist/ts3.4/blocks/Meta.d.ts +0 -9
- package/dist/ts3.4/blocks/Preview.d.ts +0 -3
- package/dist/ts3.4/blocks/Primary.d.ts +0 -6
- package/dist/ts3.4/blocks/Props.d.ts +0 -3
- package/dist/ts3.4/blocks/Source.d.ts +0 -38
- package/dist/ts3.4/blocks/SourceContainer.d.ts +0 -14
- package/dist/ts3.4/blocks/Stories.d.ts +0 -7
- package/dist/ts3.4/blocks/Story.d.ts +0 -28
- package/dist/ts3.4/blocks/Subheading.d.ts +0 -3
- package/dist/ts3.4/blocks/Subtitle.d.ts +0 -6
- package/dist/ts3.4/blocks/Title.d.ts +0 -8
- package/dist/ts3.4/blocks/Wrapper.d.ts +0 -2
- package/dist/ts3.4/blocks/enhanceSource.d.ts +0 -3
- package/dist/ts3.4/blocks/index.d.ts +0 -24
- package/dist/ts3.4/blocks/mdx.d.ts +0 -20
- package/dist/ts3.4/blocks/types.d.ts +0 -13
- package/dist/ts3.4/blocks/useStory.d.ts +0 -5
- package/dist/ts3.4/blocks/utils.d.ts +0 -3
- package/dist/ts3.4/index.d.ts +0 -1
- package/dist/ts3.4/manager.d.ts +0 -1
- package/dist/ts3.4/preset.d.ts +0 -11
- package/dist/ts3.4/preview.d.ts +0 -6
- package/dist/ts3.4/shared.d.ts +0 -24
- package/dist/ts3.9/blocks/Anchor.d.ts +0 -6
- package/dist/ts3.9/blocks/ArgsTable.d.ts +0 -33
- package/dist/ts3.9/blocks/Canvas.d.ts +0 -9
- package/dist/ts3.9/blocks/Description.d.ts +0 -20
- package/dist/ts3.9/blocks/DocsContainer.d.ts +0 -7
- package/dist/ts3.9/blocks/DocsContext.d.ts +0 -5
- package/dist/ts3.9/blocks/DocsPage.d.ts +0 -2
- package/dist/ts3.9/blocks/DocsStory.d.ts +0 -3
- package/dist/ts3.9/blocks/Heading.d.ts +0 -6
- package/dist/ts3.9/blocks/Meta.d.ts +0 -9
- package/dist/ts3.9/blocks/Preview.d.ts +0 -3
- package/dist/ts3.9/blocks/Primary.d.ts +0 -6
- package/dist/ts3.9/blocks/Props.d.ts +0 -3
- package/dist/ts3.9/blocks/Source.d.ts +0 -38
- package/dist/ts3.9/blocks/SourceContainer.d.ts +0 -14
- package/dist/ts3.9/blocks/Stories.d.ts +0 -7
- package/dist/ts3.9/blocks/Story.d.ts +0 -28
- package/dist/ts3.9/blocks/Subheading.d.ts +0 -3
- package/dist/ts3.9/blocks/Subtitle.d.ts +0 -6
- package/dist/ts3.9/blocks/Title.d.ts +0 -8
- package/dist/ts3.9/blocks/Wrapper.d.ts +0 -2
- package/dist/ts3.9/blocks/enhanceSource.d.ts +0 -3
- package/dist/ts3.9/blocks/index.d.ts +0 -24
- package/dist/ts3.9/blocks/mdx.d.ts +0 -20
- package/dist/ts3.9/blocks/types.d.ts +0 -13
- package/dist/ts3.9/blocks/useStory.d.ts +0 -5
- package/dist/ts3.9/blocks/utils.d.ts +0 -3
- package/dist/ts3.9/preview.d.ts +0 -6
package/dist/cjs/preset.js
CHANGED
|
@@ -1,47 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.array.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.string.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.from.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.slice.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.function.name.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.promise.js");
|
|
22
|
-
|
|
23
3
|
Object.defineProperty(exports, "__esModule", {
|
|
24
4
|
value: true
|
|
25
5
|
});
|
|
6
|
+
exports.storyIndexers = void 0;
|
|
26
7
|
exports.webpack = webpack;
|
|
27
8
|
|
|
28
|
-
require("
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.array.concat.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.object.assign.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.array.filter.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.object.to-string.js");
|
|
37
|
-
|
|
38
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
41
|
-
|
|
42
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
43
|
-
|
|
44
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
45
10
|
|
|
46
11
|
var _remarkSlug = _interopRequireDefault(require("remark-slug"));
|
|
47
12
|
|
|
@@ -51,176 +16,139 @@ var _global = _interopRequireDefault(require("global"));
|
|
|
51
16
|
|
|
52
17
|
var _nodeLogger = require("@storybook/node-logger");
|
|
53
18
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
19
|
+
var _csfTools = require("@storybook/csf-tools");
|
|
57
20
|
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
61
|
-
|
|
62
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
63
|
-
|
|
64
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
65
|
-
|
|
66
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
67
22
|
|
|
68
|
-
function
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
69
24
|
|
|
70
|
-
function
|
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
71
26
|
|
|
72
|
-
function createBabelOptions(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
27
|
+
function createBabelOptions({
|
|
28
|
+
babelOptions,
|
|
29
|
+
mdxBabelOptions,
|
|
30
|
+
configureJSX
|
|
31
|
+
}) {
|
|
32
|
+
const babelPlugins = mdxBabelOptions?.plugins || babelOptions?.plugins || [];
|
|
33
|
+
const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
78
34
|
pragma: 'React.createElement',
|
|
79
35
|
pragmaFrag: 'React.Fragment'
|
|
80
36
|
}];
|
|
81
|
-
|
|
37
|
+
const plugins = configureJSX ? [...babelPlugins, jsxPlugin] : babelPlugins;
|
|
82
38
|
return Object.assign({
|
|
83
39
|
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
|
|
84
40
|
babelrc: false,
|
|
85
41
|
configFile: false
|
|
86
42
|
}, babelOptions, mdxBabelOptions, {
|
|
87
|
-
plugins
|
|
43
|
+
plugins
|
|
88
44
|
});
|
|
89
45
|
}
|
|
90
46
|
|
|
91
|
-
function webpack() {
|
|
92
|
-
|
|
47
|
+
async function webpack(webpackConfig = {}, options) {
|
|
48
|
+
const resolvedBabelLoader = require.resolve('babel-loader');
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
module = {}
|
|
52
|
+
} = webpackConfig; // it will reuse babel options that are already in use in storybook
|
|
53
|
+
// also, these babel options are chained with other presets.
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
babelOptions,
|
|
57
|
+
mdxBabelOptions,
|
|
58
|
+
configureJSX = true,
|
|
59
|
+
sourceLoaderOptions = {
|
|
60
|
+
injectStoryParameters: true
|
|
61
|
+
},
|
|
62
|
+
transcludeMarkdown = false
|
|
63
|
+
} = options;
|
|
64
|
+
const mdxLoaderOptions = {
|
|
65
|
+
skipCsf: true,
|
|
66
|
+
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
67
|
+
};
|
|
68
|
+
const mdxVersion = _global.default.FEATURES?.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
69
|
+
|
|
70
|
+
_nodeLogger.logger.info(`Addon-docs: using ${mdxVersion}`);
|
|
71
|
+
|
|
72
|
+
const mdxLoader = _global.default.FEATURES?.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
73
|
+
|
|
74
|
+
const sourceLoader = sourceLoaderOptions ? [{
|
|
75
|
+
test: /\.(stories|story)\.[tj]sx?$/,
|
|
76
|
+
loader: require.resolve('@storybook/source-loader'),
|
|
77
|
+
options: Object.assign({}, sourceLoaderOptions, {
|
|
78
|
+
inspectLocalDependencies: true
|
|
79
|
+
}),
|
|
80
|
+
enforce: 'pre'
|
|
81
|
+
}] : [];
|
|
82
|
+
let rules = module.rules || [];
|
|
83
|
+
|
|
84
|
+
if (transcludeMarkdown) {
|
|
85
|
+
rules = [...rules.filter(rule => rule.test?.toString() !== '/\\.md$/'), {
|
|
86
|
+
test: /\.md$/,
|
|
87
|
+
use: [{
|
|
88
|
+
loader: resolvedBabelLoader,
|
|
89
|
+
options: createBabelOptions({
|
|
90
|
+
babelOptions,
|
|
91
|
+
mdxBabelOptions,
|
|
92
|
+
configureJSX
|
|
93
|
+
})
|
|
94
|
+
}, {
|
|
95
|
+
loader: mdxLoader,
|
|
96
|
+
options: mdxLoaderOptions
|
|
97
|
+
}]
|
|
98
|
+
}];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = Object.assign({}, webpackConfig, {
|
|
102
|
+
module: Object.assign({}, module, {
|
|
103
|
+
rules: [...rules, {
|
|
104
|
+
test: /(stories|story)\.mdx$/,
|
|
105
|
+
use: [{
|
|
106
|
+
loader: resolvedBabelLoader,
|
|
107
|
+
options: createBabelOptions({
|
|
108
|
+
babelOptions,
|
|
109
|
+
mdxBabelOptions,
|
|
110
|
+
configureJSX
|
|
111
|
+
})
|
|
112
|
+
}, {
|
|
113
|
+
loader: mdxLoader
|
|
114
|
+
}]
|
|
115
|
+
}, {
|
|
116
|
+
test: /\.mdx$/,
|
|
117
|
+
exclude: /(stories|story)\.mdx$/,
|
|
118
|
+
use: [{
|
|
119
|
+
loader: resolvedBabelLoader,
|
|
120
|
+
options: createBabelOptions({
|
|
121
|
+
babelOptions,
|
|
122
|
+
mdxBabelOptions,
|
|
123
|
+
configureJSX
|
|
124
|
+
})
|
|
125
|
+
}, {
|
|
126
|
+
loader: mdxLoader,
|
|
127
|
+
options: mdxLoaderOptions
|
|
128
|
+
}]
|
|
129
|
+
}, ...sourceLoader]
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
return result;
|
|
93
133
|
}
|
|
94
134
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
sourceLoader,
|
|
116
|
-
rules,
|
|
117
|
-
result,
|
|
118
|
-
_args = arguments;
|
|
119
|
-
|
|
120
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
121
|
-
while (1) {
|
|
122
|
-
switch (_context.prev = _context.next) {
|
|
123
|
-
case 0:
|
|
124
|
-
webpackConfig = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
125
|
-
options = _args.length > 1 ? _args[1] : undefined;
|
|
126
|
-
resolvedBabelLoader = require.resolve('babel-loader');
|
|
127
|
-
_webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
|
|
128
|
-
// also, these babel options are chained with other presets.
|
|
129
|
-
|
|
130
|
-
babelOptions = options.babelOptions, mdxBabelOptions = options.mdxBabelOptions, _options$configureJSX = options.configureJSX, configureJSX = _options$configureJSX === void 0 ? true : _options$configureJSX, _options$sourceLoader = options.sourceLoaderOptions, sourceLoaderOptions = _options$sourceLoader === void 0 ? {
|
|
131
|
-
injectStoryParameters: true
|
|
132
|
-
} : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
|
|
133
|
-
mdxLoaderOptions = {
|
|
134
|
-
skipCsf: true,
|
|
135
|
-
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
136
|
-
};
|
|
137
|
-
mdxVersion = (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
138
|
-
|
|
139
|
-
_nodeLogger.logger.info("Addon-docs: using ".concat(mdxVersion));
|
|
140
|
-
|
|
141
|
-
mdxLoader = (_global$FEATURES2 = _global.default.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
|
|
142
|
-
|
|
143
|
-
sourceLoader = sourceLoaderOptions ? [{
|
|
144
|
-
test: /\.(stories|story)\.[tj]sx?$/,
|
|
145
|
-
loader: require.resolve('@storybook/source-loader'),
|
|
146
|
-
options: Object.assign({}, sourceLoaderOptions, {
|
|
147
|
-
inspectLocalDependencies: true
|
|
148
|
-
}),
|
|
149
|
-
enforce: 'pre'
|
|
150
|
-
}] : [];
|
|
151
|
-
rules = module.rules || [];
|
|
152
|
-
|
|
153
|
-
if (transcludeMarkdown) {
|
|
154
|
-
rules = [].concat(_toConsumableArray(rules.filter(function (rule) {
|
|
155
|
-
var _rule$test;
|
|
156
|
-
|
|
157
|
-
return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
|
|
158
|
-
})), [{
|
|
159
|
-
test: /\.md$/,
|
|
160
|
-
use: [{
|
|
161
|
-
loader: resolvedBabelLoader,
|
|
162
|
-
options: createBabelOptions({
|
|
163
|
-
babelOptions: babelOptions,
|
|
164
|
-
mdxBabelOptions: mdxBabelOptions,
|
|
165
|
-
configureJSX: configureJSX
|
|
166
|
-
})
|
|
167
|
-
}, {
|
|
168
|
-
loader: mdxLoader,
|
|
169
|
-
options: mdxLoaderOptions
|
|
170
|
-
}]
|
|
171
|
-
}]);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
result = Object.assign({}, webpackConfig, {
|
|
175
|
-
module: Object.assign({}, module, {
|
|
176
|
-
rules: [].concat(_toConsumableArray(rules), [{
|
|
177
|
-
test: /\.js$/,
|
|
178
|
-
include: new RegExp("node_modules\\".concat(_path.default.sep, "acorn-jsx")),
|
|
179
|
-
use: [{
|
|
180
|
-
loader: resolvedBabelLoader,
|
|
181
|
-
options: {
|
|
182
|
-
presets: [[require.resolve('@babel/preset-env'), {
|
|
183
|
-
modules: 'commonjs'
|
|
184
|
-
}]]
|
|
185
|
-
}
|
|
186
|
-
}]
|
|
187
|
-
}, {
|
|
188
|
-
test: /(stories|story)\.mdx$/,
|
|
189
|
-
use: [{
|
|
190
|
-
loader: resolvedBabelLoader,
|
|
191
|
-
options: createBabelOptions({
|
|
192
|
-
babelOptions: babelOptions,
|
|
193
|
-
mdxBabelOptions: mdxBabelOptions,
|
|
194
|
-
configureJSX: configureJSX
|
|
195
|
-
})
|
|
196
|
-
}, {
|
|
197
|
-
loader: mdxLoader
|
|
198
|
-
}]
|
|
199
|
-
}, {
|
|
200
|
-
test: /\.mdx$/,
|
|
201
|
-
exclude: /(stories|story)\.mdx$/,
|
|
202
|
-
use: [{
|
|
203
|
-
loader: resolvedBabelLoader,
|
|
204
|
-
options: createBabelOptions({
|
|
205
|
-
babelOptions: babelOptions,
|
|
206
|
-
mdxBabelOptions: mdxBabelOptions,
|
|
207
|
-
configureJSX: configureJSX
|
|
208
|
-
})
|
|
209
|
-
}, {
|
|
210
|
-
loader: mdxLoader,
|
|
211
|
-
options: mdxLoaderOptions
|
|
212
|
-
}]
|
|
213
|
-
}], sourceLoader)
|
|
214
|
-
})
|
|
215
|
-
});
|
|
216
|
-
return _context.abrupt("return", result);
|
|
217
|
-
|
|
218
|
-
case 14:
|
|
219
|
-
case "end":
|
|
220
|
-
return _context.stop();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}, _callee);
|
|
224
|
-
}));
|
|
225
|
-
return _webpack.apply(this, arguments);
|
|
226
|
-
}
|
|
135
|
+
const storyIndexers = async indexers => {
|
|
136
|
+
const mdxIndexer = async (fileName, opts) => {
|
|
137
|
+
let code = (await _fsExtra.default.readFile(fileName, 'utf-8')).toString(); // @ts-ignore
|
|
138
|
+
|
|
139
|
+
const {
|
|
140
|
+
compile
|
|
141
|
+
} = _global.default.FEATURES?.previewMdx2 ? await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx2-csf'))) : await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx1-csf')));
|
|
142
|
+
code = await compile(code, {});
|
|
143
|
+
return (0, _csfTools.loadCsf)(code, Object.assign({}, opts, {
|
|
144
|
+
fileName
|
|
145
|
+
})).parse();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return [{
|
|
149
|
+
test: /(stories|story)\.mdx$/,
|
|
150
|
+
indexer: mdxIndexer
|
|
151
|
+
}, ...(indexers || [])];
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
exports.storyIndexers = storyIndexers;
|
package/dist/cjs/preview.js
CHANGED
|
@@ -1,100 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.string.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.weak-map.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.symbol.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.symbol.description.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
20
|
-
|
|
21
3
|
Object.defineProperty(exports, "__esModule", {
|
|
22
4
|
value: true
|
|
23
5
|
});
|
|
24
6
|
exports.parameters = void 0;
|
|
25
7
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.object.to-string.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.promise.js");
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
9
|
|
|
32
|
-
function
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
11
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
37
|
-
|
|
38
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
39
|
-
|
|
40
|
-
var parameters = {
|
|
12
|
+
const parameters = {
|
|
41
13
|
docs: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_context.next = 2;
|
|
49
|
-
return Promise.resolve().then(function () {
|
|
50
|
-
return _interopRequireWildcard(require('./blocks'));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
case 2:
|
|
54
|
-
return _context.abrupt("return", _context.sent.DocsContainer);
|
|
55
|
-
|
|
56
|
-
case 3:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}, _callee);
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
function getContainer() {
|
|
65
|
-
return _getContainer.apply(this, arguments);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return getContainer;
|
|
69
|
-
}(),
|
|
70
|
-
getPage: function () {
|
|
71
|
-
var _getPage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
72
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
73
|
-
while (1) {
|
|
74
|
-
switch (_context2.prev = _context2.next) {
|
|
75
|
-
case 0:
|
|
76
|
-
_context2.next = 2;
|
|
77
|
-
return Promise.resolve().then(function () {
|
|
78
|
-
return _interopRequireWildcard(require('./blocks'));
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
case 2:
|
|
82
|
-
return _context2.abrupt("return", _context2.sent.DocsPage);
|
|
83
|
-
|
|
84
|
-
case 3:
|
|
85
|
-
case "end":
|
|
86
|
-
return _context2.stop();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, _callee2);
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
function getPage() {
|
|
93
|
-
return _getPage.apply(this, arguments);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return getPage;
|
|
97
|
-
}()
|
|
14
|
+
renderer: async () => {
|
|
15
|
+
const {
|
|
16
|
+
DocsRenderer
|
|
17
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('./blocks')));
|
|
18
|
+
return new DocsRenderer();
|
|
19
|
+
}
|
|
98
20
|
}
|
|
99
21
|
};
|
|
100
22
|
exports.parameters = parameters;
|
package/dist/cjs/shared.js
CHANGED
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SourceType = exports.SNIPPET_RENDERED = exports.PARAM_KEY = exports.PANEL_ID = exports.ADDON_ID = void 0;
|
|
7
|
-
|
|
7
|
+
const ADDON_ID = 'storybook/docs';
|
|
8
8
|
exports.ADDON_ID = ADDON_ID;
|
|
9
|
-
|
|
9
|
+
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
10
10
|
exports.PANEL_ID = PANEL_ID;
|
|
11
|
-
|
|
11
|
+
const PARAM_KEY = `docs`;
|
|
12
12
|
exports.PARAM_KEY = PARAM_KEY;
|
|
13
|
-
|
|
13
|
+
const SNIPPET_RENDERED = `${ADDON_ID}/snippet-rendered`;
|
|
14
14
|
exports.SNIPPET_RENDERED = SNIPPET_RENDERED;
|
|
15
|
-
|
|
15
|
+
let SourceType;
|
|
16
16
|
exports.SourceType = SourceType;
|
|
17
17
|
|
|
18
18
|
(function (SourceType) {
|
package/dist/esm/blocks/index.js
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './Anchor';
|
|
3
|
-
export * from './ArgsTable';
|
|
4
|
-
export * from './Canvas';
|
|
5
|
-
export * from './Description';
|
|
6
|
-
export * from './DocsContext';
|
|
7
|
-
export * from './DocsPage';
|
|
8
|
-
export * from './DocsContainer';
|
|
9
|
-
export * from './DocsStory';
|
|
10
|
-
export * from './Heading';
|
|
11
|
-
export * from './Meta';
|
|
12
|
-
export * from './Preview';
|
|
13
|
-
export * from './Primary';
|
|
14
|
-
export * from './Props';
|
|
15
|
-
export * from './Source';
|
|
16
|
-
export * from './SourceContainer';
|
|
17
|
-
export * from './Stories';
|
|
18
|
-
export * from './Story';
|
|
19
|
-
export * from './Subheading';
|
|
20
|
-
export * from './Subtitle';
|
|
21
|
-
export * from './Title';
|
|
22
|
-
export * from './Wrapper';
|
|
23
|
-
export * from './types';
|
|
24
|
-
export * from './mdx';
|
|
1
|
+
export * from '@storybook/blocks';
|
package/dist/esm/manager.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import "core-js/modules/es.array.concat.js";
|
|
2
1
|
import { addons, types } from '@storybook/addons';
|
|
3
2
|
import { ADDON_ID, PANEL_ID } from './shared';
|
|
4
|
-
addons.register(ADDON_ID,
|
|
3
|
+
addons.register(ADDON_ID, () => {
|
|
5
4
|
addons.add(PANEL_ID, {
|
|
6
5
|
type: types.TAB,
|
|
7
6
|
title: 'Docs',
|
|
8
|
-
route:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
render: function render() {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
7
|
+
route: ({
|
|
8
|
+
storyId,
|
|
9
|
+
refId
|
|
10
|
+
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
11
|
+
match: ({
|
|
12
|
+
viewMode
|
|
13
|
+
}) => viewMode === 'docs',
|
|
14
|
+
render: () => null
|
|
20
15
|
});
|
|
21
16
|
});
|