@storybook/addon-docs 7.0.0-alpha.10 → 7.0.0-alpha.13
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.js +1 -1
- package/dist/cjs/preset.js +27 -8
- package/dist/esm/preset.js +9 -1
- package/dist/types/preset.d.ts +7 -2
- package/package.json +20 -18
- package/dist/cjs/manager.js +0 -20
- package/dist/esm/manager.js +0 -16
- package/dist/types/manager.d.ts +0 -1
- package/manager.js +0 -1
- package/register.js +0 -6
package/blocks.js
CHANGED
package/dist/cjs/preset.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.storyIndexers = void 0;
|
|
6
|
+
exports.storyIndexers = exports.docs = void 0;
|
|
7
7
|
exports.webpack = webpack;
|
|
8
8
|
|
|
9
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
@@ -29,7 +29,7 @@ function createBabelOptions({
|
|
|
29
29
|
mdxBabelOptions,
|
|
30
30
|
configureJSX
|
|
31
31
|
}) {
|
|
32
|
-
const babelPlugins = mdxBabelOptions
|
|
32
|
+
const babelPlugins = (mdxBabelOptions === null || mdxBabelOptions === void 0 ? void 0 : mdxBabelOptions.plugins) || (babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [];
|
|
33
33
|
const jsxPlugin = [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
34
34
|
pragma: 'React.createElement',
|
|
35
35
|
pragmaFrag: 'React.Fragment'
|
|
@@ -45,6 +45,8 @@ function createBabelOptions({
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async function webpack(webpackConfig = {}, options) {
|
|
48
|
+
var _global$FEATURES, _global$FEATURES2;
|
|
49
|
+
|
|
48
50
|
const resolvedBabelLoader = require.resolve('babel-loader');
|
|
49
51
|
|
|
50
52
|
const {
|
|
@@ -65,11 +67,11 @@ async function webpack(webpackConfig = {}, options) {
|
|
|
65
67
|
skipCsf: true,
|
|
66
68
|
remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
|
|
67
69
|
};
|
|
68
|
-
const mdxVersion = _global.default.FEATURES
|
|
70
|
+
const mdxVersion = (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
|
|
69
71
|
|
|
70
72
|
_nodeLogger.logger.info(`Addon-docs: using ${mdxVersion}`);
|
|
71
73
|
|
|
72
|
-
const mdxLoader = _global.default.FEATURES
|
|
74
|
+
const 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
|
|
73
75
|
|
|
74
76
|
const sourceLoader = sourceLoaderOptions ? [{
|
|
75
77
|
test: /\.(stories|story)\.[tj]sx?$/,
|
|
@@ -82,7 +84,11 @@ async function webpack(webpackConfig = {}, options) {
|
|
|
82
84
|
let rules = module.rules || [];
|
|
83
85
|
|
|
84
86
|
if (transcludeMarkdown) {
|
|
85
|
-
rules = [...rules.filter(rule =>
|
|
87
|
+
rules = [...rules.filter(rule => {
|
|
88
|
+
var _rule$test;
|
|
89
|
+
|
|
90
|
+
return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) !== '/\\.md$/';
|
|
91
|
+
}), {
|
|
86
92
|
test: /\.md$/,
|
|
87
93
|
use: [{
|
|
88
94
|
loader: resolvedBabelLoader,
|
|
@@ -134,11 +140,13 @@ async function webpack(webpackConfig = {}, options) {
|
|
|
134
140
|
|
|
135
141
|
const storyIndexers = async indexers => {
|
|
136
142
|
const mdxIndexer = async (fileName, opts) => {
|
|
143
|
+
var _global$FEATURES3;
|
|
144
|
+
|
|
137
145
|
let code = (await _fsExtra.default.readFile(fileName, 'utf-8')).toString(); // @ts-ignore
|
|
138
146
|
|
|
139
147
|
const {
|
|
140
148
|
compile
|
|
141
|
-
} = _global.default.FEATURES
|
|
149
|
+
} = (_global$FEATURES3 = _global.default.FEATURES) !== null && _global$FEATURES3 !== void 0 && _global$FEATURES3.previewMdx2 ? await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx2-csf'))) : await Promise.resolve().then(() => _interopRequireWildcard(require('@storybook/mdx1-csf')));
|
|
142
150
|
code = await compile(code, {});
|
|
143
151
|
return (0, _csfTools.loadCsf)(code, Object.assign({}, opts, {
|
|
144
152
|
fileName
|
|
@@ -147,8 +155,19 @@ const storyIndexers = async indexers => {
|
|
|
147
155
|
|
|
148
156
|
return [{
|
|
149
157
|
test: /(stories|story)\.mdx$/,
|
|
150
|
-
indexer: mdxIndexer
|
|
158
|
+
indexer: mdxIndexer,
|
|
159
|
+
addDocsTemplate: true
|
|
151
160
|
}, ...(indexers || [])];
|
|
152
161
|
};
|
|
153
162
|
|
|
154
|
-
exports.storyIndexers = storyIndexers;
|
|
163
|
+
exports.storyIndexers = storyIndexers;
|
|
164
|
+
|
|
165
|
+
const docs = docsOptions => {
|
|
166
|
+
return Object.assign({}, docsOptions, {
|
|
167
|
+
enabled: true,
|
|
168
|
+
defaultName: 'Docs',
|
|
169
|
+
docsPage: true
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
exports.docs = docs;
|
package/dist/esm/preset.js
CHANGED
|
@@ -127,6 +127,14 @@ export const storyIndexers = async indexers => {
|
|
|
127
127
|
|
|
128
128
|
return [{
|
|
129
129
|
test: /(stories|story)\.mdx$/,
|
|
130
|
-
indexer: mdxIndexer
|
|
130
|
+
indexer: mdxIndexer,
|
|
131
|
+
addDocsTemplate: true
|
|
131
132
|
}, ...(indexers || [])];
|
|
133
|
+
};
|
|
134
|
+
export const docs = docsOptions => {
|
|
135
|
+
return Object.assign({}, docsOptions, {
|
|
136
|
+
enabled: true,
|
|
137
|
+
defaultName: 'Docs',
|
|
138
|
+
docsPage: true
|
|
139
|
+
});
|
|
132
140
|
};
|
package/dist/types/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Options, StoryIndexer } from '@storybook/core-common';
|
|
1
|
+
import type { DocsOptions, Options, StoryIndexer } from '@storybook/core-common';
|
|
2
2
|
declare type BabelParams = {
|
|
3
3
|
babelOptions?: any;
|
|
4
4
|
mdxBabelOptions?: any;
|
|
@@ -8,5 +8,10 @@ export declare function webpack(webpackConfig: any, options: Options & BabelPara
|
|
|
8
8
|
sourceLoaderOptions: any;
|
|
9
9
|
transcludeMarkdown: boolean;
|
|
10
10
|
}): Promise<any>;
|
|
11
|
-
export declare const storyIndexers: (indexers
|
|
11
|
+
export declare const storyIndexers: (indexers: StoryIndexer[] | null) => Promise<StoryIndexer[]>;
|
|
12
|
+
export declare const docs: (docsOptions: DocsOptions) => {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
defaultName: string;
|
|
15
|
+
docsPage: boolean;
|
|
16
|
+
};
|
|
12
17
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.13",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"!__testfixtures__"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
+
"check": "tsc --noEmit",
|
|
48
49
|
"prepare": "node ../../scripts/prepare.js"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
@@ -52,25 +53,25 @@
|
|
|
52
53
|
"@babel/preset-env": "^7.12.11",
|
|
53
54
|
"@jest/transform": "^26.6.2",
|
|
54
55
|
"@mdx-js/react": "^1.6.22",
|
|
55
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
56
|
-
"@storybook/api": "7.0.0-alpha.
|
|
57
|
-
"@storybook/blocks": "7.0.0-alpha.
|
|
58
|
-
"@storybook/components": "7.0.0-alpha.
|
|
59
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
60
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
56
|
+
"@storybook/addons": "7.0.0-alpha.13",
|
|
57
|
+
"@storybook/api": "7.0.0-alpha.13",
|
|
58
|
+
"@storybook/blocks": "7.0.0-alpha.13",
|
|
59
|
+
"@storybook/components": "7.0.0-alpha.13",
|
|
60
|
+
"@storybook/core-common": "7.0.0-alpha.13",
|
|
61
|
+
"@storybook/core-events": "7.0.0-alpha.13",
|
|
61
62
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
62
|
-
"@storybook/csf-tools": "7.0.0-alpha.
|
|
63
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
63
|
+
"@storybook/csf-tools": "7.0.0-alpha.13",
|
|
64
|
+
"@storybook/docs-tools": "7.0.0-alpha.13",
|
|
64
65
|
"@storybook/mdx1-csf": "^0.0.1",
|
|
65
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
66
|
-
"@storybook/postinstall": "7.0.0-alpha.
|
|
67
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
68
|
-
"@storybook/source-loader": "7.0.0-alpha.
|
|
69
|
-
"@storybook/store": "7.0.0-alpha.
|
|
70
|
-
"@storybook/theming": "7.0.0-alpha.
|
|
66
|
+
"@storybook/node-logger": "7.0.0-alpha.13",
|
|
67
|
+
"@storybook/postinstall": "7.0.0-alpha.13",
|
|
68
|
+
"@storybook/preview-web": "7.0.0-alpha.13",
|
|
69
|
+
"@storybook/source-loader": "7.0.0-alpha.13",
|
|
70
|
+
"@storybook/store": "7.0.0-alpha.13",
|
|
71
|
+
"@storybook/theming": "7.0.0-alpha.13",
|
|
71
72
|
"babel-loader": "^8.2.5",
|
|
72
73
|
"core-js": "^3.8.2",
|
|
73
|
-
"
|
|
74
|
+
"dequal": "^2.0.2",
|
|
74
75
|
"global": "^4.4.0",
|
|
75
76
|
"lodash": "^4.17.21",
|
|
76
77
|
"remark-external-links": "^8.0.0",
|
|
@@ -81,7 +82,8 @@
|
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@babel/core": "^7.12.10",
|
|
83
84
|
"@storybook/mdx2-csf": "^0.0.3",
|
|
84
|
-
"@types/util-deprecate": "^1.0.0"
|
|
85
|
+
"@types/util-deprecate": "^1.0.0",
|
|
86
|
+
"typescript": "~4.6.3"
|
|
85
87
|
},
|
|
86
88
|
"peerDependencies": {
|
|
87
89
|
"@storybook/mdx2-csf": "^0.0.3",
|
|
@@ -102,7 +104,7 @@
|
|
|
102
104
|
"publishConfig": {
|
|
103
105
|
"access": "public"
|
|
104
106
|
},
|
|
105
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "9ac4d2e0a05eb945713a0e6689abc3b12359e181",
|
|
106
108
|
"storybook": {
|
|
107
109
|
"displayName": "Docs",
|
|
108
110
|
"icon": "https://user-images.githubusercontent.com/263385/101991672-48355c80-3c7c-11eb-82d9-95fa12438f64.png",
|
package/dist/cjs/manager.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _addons = require("@storybook/addons");
|
|
4
|
-
|
|
5
|
-
var _shared = require("./shared");
|
|
6
|
-
|
|
7
|
-
_addons.addons.register(_shared.ADDON_ID, () => {
|
|
8
|
-
_addons.addons.add(_shared.PANEL_ID, {
|
|
9
|
-
type: _addons.types.TAB,
|
|
10
|
-
title: 'Docs',
|
|
11
|
-
route: ({
|
|
12
|
-
storyId,
|
|
13
|
-
refId
|
|
14
|
-
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
15
|
-
match: ({
|
|
16
|
-
viewMode
|
|
17
|
-
}) => viewMode === 'docs',
|
|
18
|
-
render: () => null
|
|
19
|
-
});
|
|
20
|
-
});
|
package/dist/esm/manager.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { addons, types } from '@storybook/addons';
|
|
2
|
-
import { ADDON_ID, PANEL_ID } from './shared';
|
|
3
|
-
addons.register(ADDON_ID, () => {
|
|
4
|
-
addons.add(PANEL_ID, {
|
|
5
|
-
type: types.TAB,
|
|
6
|
-
title: 'Docs',
|
|
7
|
-
route: ({
|
|
8
|
-
storyId,
|
|
9
|
-
refId
|
|
10
|
-
}) => refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`,
|
|
11
|
-
match: ({
|
|
12
|
-
viewMode
|
|
13
|
-
}) => viewMode === 'docs',
|
|
14
|
-
render: () => null
|
|
15
|
-
});
|
|
16
|
-
});
|
package/dist/types/manager.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/manager.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './dist/esm/manager';
|