@storybook/addon-docs 6.4.0-beta.21 → 6.4.0-beta.25

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.
@@ -70,7 +70,8 @@ var DocsStory = function DocsStory(_ref) {
70
70
  }), /*#__PURE__*/_react.default.createElement(_Canvas.Canvas, {
71
71
  withToolbar: withToolbar
72
72
  }, /*#__PURE__*/_react.default.createElement(_Story.Story, {
73
- id: id
73
+ id: id,
74
+ parameters: parameters
74
75
  })));
75
76
  };
76
77
 
@@ -316,8 +316,10 @@ var extractDefaultValue = function extractDefaultValue(property) {
316
316
  };
317
317
 
318
318
  var resolveTypealias = function resolveTypealias(compodocType) {
319
+ var _compodocJson$miscell, _compodocJson$miscell2;
320
+
319
321
  var compodocJson = getCompodocJson();
320
- var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : compodocJson.miscellaneous.typealiases.find(function (x) {
322
+ var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : (_compodocJson$miscell = compodocJson.miscellaneous) === null || _compodocJson$miscell === void 0 ? void 0 : (_compodocJson$miscell2 = _compodocJson$miscell.typealiases) === null || _compodocJson$miscell2 === void 0 ? void 0 : _compodocJson$miscell2.find(function (x) {
321
323
  return x.name === compodocType;
322
324
  });
323
325
  return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
@@ -1,21 +1,47 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ require("core-js/modules/es.weak-map.js");
6
+
7
+ require("core-js/modules/es.string.iterator.js");
8
+
9
+ require("core-js/modules/es.array.iterator.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
+
3
21
  Object.defineProperty(exports, "__esModule", {
4
22
  value: true
5
23
  });
6
24
  exports.sourceDecorator = exports.skipSourceRender = void 0;
7
25
 
26
+ require("regenerator-runtime/runtime.js");
27
+
28
+ require("core-js/modules/es.promise.js");
29
+
30
+ require("core-js/modules/es.object.to-string.js");
31
+
8
32
  var _addons = require("@storybook/addons");
9
33
 
10
34
  var _renderer = require("@storybook/angular/renderer");
11
35
 
12
- var _parserHtml = _interopRequireDefault(require("prettier/parser-html"));
36
+ var _shared = require("../../shared");
13
37
 
14
- var _standalone = _interopRequireDefault(require("prettier/standalone"));
38
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
15
39
 
16
- var _shared = require("../../shared");
40
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
17
41
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
+ 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); } }
43
+
44
+ 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); }); }; }
19
45
 
20
46
  var skipSourceRender = function skipSourceRender(context) {
21
47
  var _context$parameters$d;
@@ -32,16 +58,62 @@ var skipSourceRender = function skipSourceRender(context) {
32
58
  };
33
59
 
34
60
  exports.skipSourceRender = skipSourceRender;
35
-
36
- var prettyUp = function prettyUp(source) {
37
- return _standalone.default.format(source, {
38
- parser: 'angular',
39
- plugins: [_parserHtml.default],
40
- htmlWhitespaceSensitivity: 'ignore'
41
- });
42
- };
61
+ var prettyUpInternal;
62
+
63
+ var makePrettyUp = /*#__PURE__*/function () {
64
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
65
+ var prettierHtml, prettier;
66
+ return regeneratorRuntime.wrap(function _callee$(_context) {
67
+ while (1) {
68
+ switch (_context.prev = _context.next) {
69
+ case 0:
70
+ if (!prettyUpInternal) {
71
+ _context.next = 2;
72
+ break;
73
+ }
74
+
75
+ return _context.abrupt("return", prettyUpInternal);
76
+
77
+ case 2:
78
+ _context.next = 4;
79
+ return Promise.resolve().then(function () {
80
+ return _interopRequireWildcard(require('prettier/parser-html'));
81
+ });
82
+
83
+ case 4:
84
+ prettierHtml = _context.sent;
85
+ _context.next = 7;
86
+ return Promise.resolve().then(function () {
87
+ return _interopRequireWildcard(require('prettier/standalone'));
88
+ });
89
+
90
+ case 7:
91
+ prettier = _context.sent;
92
+
93
+ prettyUpInternal = function prettyUpInternal(source) {
94
+ return prettier.format(source, {
95
+ parser: 'angular',
96
+ plugins: [prettierHtml],
97
+ htmlWhitespaceSensitivity: 'ignore'
98
+ });
99
+ };
100
+
101
+ return _context.abrupt("return", prettyUpInternal);
102
+
103
+ case 10:
104
+ case "end":
105
+ return _context.stop();
106
+ }
107
+ }
108
+ }, _callee);
109
+ }));
110
+
111
+ return function makePrettyUp() {
112
+ return _ref.apply(this, arguments);
113
+ };
114
+ }();
43
115
  /**
44
- * Svelte source decorator.
116
+ * Angular source decorator.
45
117
  * @param storyFn Fn
46
118
  * @param context StoryContext
47
119
  */
@@ -62,21 +134,25 @@ var sourceDecorator = function sourceDecorator(storyFn, context) {
62
134
  var component = context.component,
63
135
  argTypes = context.argTypes;
64
136
  var toEmit;
137
+ var prettyUpPromise = makePrettyUp();
65
138
  (0, _addons.useEffect)(function () {
66
- if (toEmit) channel.emit(_shared.SNIPPET_RENDERED, context.id, prettyUp(template));
139
+ prettyUpPromise.then(function (prettyUp) {
140
+ if (toEmit) channel.emit(_shared.SNIPPET_RENDERED, context.id, prettyUp(toEmit));
141
+ });
67
142
  });
143
+ prettyUpPromise.then(function (prettyUp) {
144
+ if (component && !userDefinedTemplate) {
145
+ var _source = (0, _renderer.computesTemplateSourceFromComponent)(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
146
+ // In these cases there might exist a template, even if we aren't able to create source from component
68
147
 
69
- if (component && !userDefinedTemplate) {
70
- var source = (0, _renderer.computesTemplateSourceFromComponent)(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
71
- // In these cases there might exist a template, even if we aren't able to create source from component
72
148
 
73
- if (source || template) {
74
- toEmit = prettyUp(source || template);
149
+ if (_source || template) {
150
+ toEmit = prettyUp(_source || template);
151
+ }
152
+ } else if (template) {
153
+ toEmit = prettyUp(template);
75
154
  }
76
- } else if (template) {
77
- toEmit = prettyUp(template);
78
- }
79
-
155
+ });
80
156
  return story;
81
157
  };
82
158
 
@@ -1,12 +1,6 @@
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.object.to-string.js");
8
-
9
- require("core-js/modules/es.symbol.iterator.js");
3
+ require("core-js/modules/es.weak-map.js");
10
4
 
11
5
  require("core-js/modules/es.string.iterator.js");
12
6
 
@@ -14,6 +8,14 @@ require("core-js/modules/es.array.iterator.js");
14
8
 
15
9
  require("core-js/modules/web.dom-collections.iterator.js");
16
10
 
11
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
12
+
13
+ require("core-js/modules/es.symbol.js");
14
+
15
+ require("core-js/modules/es.symbol.description.js");
16
+
17
+ require("core-js/modules/es.symbol.iterator.js");
18
+
17
19
  require("core-js/modules/es.array.from.js");
18
20
 
19
21
  require("core-js/modules/es.array.slice.js");
@@ -26,6 +28,12 @@ Object.defineProperty(exports, "__esModule", {
26
28
  exports.vnodeToString = vnodeToString;
27
29
  exports.sourceDecorator = exports.skipSourceRender = void 0;
28
30
 
31
+ require("regenerator-runtime/runtime.js");
32
+
33
+ require("core-js/modules/es.promise.js");
34
+
35
+ require("core-js/modules/es.object.to-string.js");
36
+
29
37
  require("core-js/modules/es.array.join.js");
30
38
 
31
39
  require("core-js/modules/es.array.filter.js");
@@ -52,14 +60,8 @@ var _addons = require("@storybook/addons");
52
60
 
53
61
  var _clientLogger = require("@storybook/client-logger");
54
62
 
55
- var _standalone = _interopRequireDefault(require("prettier/standalone"));
56
-
57
- var _parserHtml = _interopRequireDefault(require("prettier/parser-html"));
58
-
59
63
  var _shared = require("../../shared");
60
64
 
61
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
62
-
63
65
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
64
66
 
65
67
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -82,6 +84,14 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
82
84
 
83
85
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
84
86
 
87
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
88
+
89
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
90
+
91
+ 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); } }
92
+
93
+ 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); }); }; }
94
+
85
95
  var skipSourceRender = function skipSourceRender(context) {
86
96
  var _context$parameters$d;
87
97
 
@@ -125,13 +135,50 @@ var sourceDecorator = function sourceDecorator(storyFn, context) {
125
135
  try {
126
136
  var storyNode = lookupStoryInstance(this, storyComponent);
127
137
  var code = vnodeToString(storyNode._vnode);
128
- channel.emit(_shared.SNIPPET_RENDERED, (context || {}).id, _standalone.default.format("<template>".concat(code, "</template>"), {
129
- parser: 'vue',
130
- plugins: [_parserHtml.default],
131
- // Because the parsed vnode missing spaces right before/after the surround tag,
132
- // we always get weird wrapped code without this option.
133
- htmlWhitespaceSensitivity: 'ignore'
134
- }));
138
+
139
+ var emitFormattedTemplate = /*#__PURE__*/function () {
140
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
141
+ var prettier, prettierHtml;
142
+ return regeneratorRuntime.wrap(function _callee$(_context) {
143
+ while (1) {
144
+ switch (_context.prev = _context.next) {
145
+ case 0:
146
+ _context.next = 2;
147
+ return Promise.resolve().then(function () {
148
+ return _interopRequireWildcard(require('prettier/standalone'));
149
+ });
150
+
151
+ case 2:
152
+ prettier = _context.sent;
153
+ _context.next = 5;
154
+ return Promise.resolve().then(function () {
155
+ return _interopRequireWildcard(require('prettier/parser-html'));
156
+ });
157
+
158
+ case 5:
159
+ prettierHtml = _context.sent;
160
+ channel.emit(_shared.SNIPPET_RENDERED, (context || {}).id, prettier.format("<template>".concat(code, "</template>"), {
161
+ parser: 'vue',
162
+ plugins: [prettierHtml],
163
+ // Because the parsed vnode missing spaces right before/after the surround tag,
164
+ // we always get weird wrapped code without this option.
165
+ htmlWhitespaceSensitivity: 'ignore'
166
+ }));
167
+
168
+ case 7:
169
+ case "end":
170
+ return _context.stop();
171
+ }
172
+ }
173
+ }, _callee);
174
+ }));
175
+
176
+ return function emitFormattedTemplate() {
177
+ return _ref.apply(this, arguments);
178
+ };
179
+ }();
180
+
181
+ emitFormattedTemplate();
135
182
  } catch (e) {
136
183
  _clientLogger.logger.warn("Failed to generate dynamic story source: ".concat(e));
137
184
  }
@@ -145,17 +192,17 @@ exports.sourceDecorator = sourceDecorator;
145
192
  function vnodeToString(vnode) {
146
193
  var _vnode$data, _vnode$componentOptio, _vnode$data2;
147
194
 
148
- var attrString = [].concat(_toConsumableArray((_vnode$data = vnode.data) !== null && _vnode$data !== void 0 && _vnode$data.slot ? [['slot', vnode.data.slot]] : []), [['class', stringifyClassAttribute(vnode)]], _toConsumableArray((_vnode$componentOptio = vnode.componentOptions) !== null && _vnode$componentOptio !== void 0 && _vnode$componentOptio.propsData ? Object.entries(vnode.componentOptions.propsData) : []), _toConsumableArray((_vnode$data2 = vnode.data) !== null && _vnode$data2 !== void 0 && _vnode$data2.attrs ? Object.entries(vnode.data.attrs) : [])).filter(function (_ref, index, list) {
149
- var _ref2 = _slicedToArray(_ref, 1),
150
- name = _ref2[0];
195
+ var attrString = [].concat(_toConsumableArray((_vnode$data = vnode.data) !== null && _vnode$data !== void 0 && _vnode$data.slot ? [['slot', vnode.data.slot]] : []), [['class', stringifyClassAttribute(vnode)]], _toConsumableArray((_vnode$componentOptio = vnode.componentOptions) !== null && _vnode$componentOptio !== void 0 && _vnode$componentOptio.propsData ? Object.entries(vnode.componentOptions.propsData) : []), _toConsumableArray((_vnode$data2 = vnode.data) !== null && _vnode$data2 !== void 0 && _vnode$data2.attrs ? Object.entries(vnode.data.attrs) : [])).filter(function (_ref2, index, list) {
196
+ var _ref3 = _slicedToArray(_ref2, 1),
197
+ name = _ref3[0];
151
198
 
152
199
  return list.findIndex(function (item) {
153
200
  return item[0] === name;
154
201
  }) === index;
155
- }).map(function (_ref3) {
156
- var _ref4 = _slicedToArray(_ref3, 2),
157
- name = _ref4[0],
158
- value = _ref4[1];
202
+ }).map(function (_ref4) {
203
+ var _ref5 = _slicedToArray(_ref4, 2),
204
+ name = _ref5[0],
205
+ value = _ref5[1];
159
206
 
160
207
  return stringifyAttr(name, value);
161
208
  }).filter(Boolean).join(' ');
@@ -222,14 +269,14 @@ function normalizeClassBinding(binding) {
222
269
  }
223
270
 
224
271
  if (_typeof(binding) === 'object') {
225
- return Object.entries(binding).filter(function (_ref5) {
226
- var _ref6 = _slicedToArray(_ref5, 2),
227
- active = _ref6[1];
272
+ return Object.entries(binding).filter(function (_ref6) {
273
+ var _ref7 = _slicedToArray(_ref6, 2),
274
+ active = _ref7[1];
228
275
 
229
276
  return !!active;
230
- }).map(function (_ref7) {
231
- var _ref8 = _slicedToArray(_ref7, 1),
232
- className = _ref8[0];
277
+ }).map(function (_ref8) {
278
+ var _ref9 = _slicedToArray(_ref8, 1),
279
+ className = _ref9[0];
233
280
 
234
281
  return className;
235
282
  });
@@ -49,6 +49,7 @@ export var DocsStory = function DocsStory(_ref) {
49
49
  }), /*#__PURE__*/React.createElement(Canvas, {
50
50
  withToolbar: withToolbar
51
51
  }, /*#__PURE__*/React.createElement(Story, {
52
- id: id
52
+ id: id,
53
+ parameters: parameters
53
54
  })));
54
55
  };
@@ -274,8 +274,10 @@ var extractDefaultValue = function extractDefaultValue(property) {
274
274
  };
275
275
 
276
276
  var resolveTypealias = function resolveTypealias(compodocType) {
277
+ var _compodocJson$miscell, _compodocJson$miscell2;
278
+
277
279
  var compodocJson = getCompodocJson();
278
- var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : compodocJson.miscellaneous.typealiases.find(function (x) {
280
+ var typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : (_compodocJson$miscell = compodocJson.miscellaneous) === null || _compodocJson$miscell === void 0 ? void 0 : (_compodocJson$miscell2 = _compodocJson$miscell.typealiases) === null || _compodocJson$miscell2 === void 0 ? void 0 : _compodocJson$miscell2.find(function (x) {
279
281
  return x.name === compodocType;
280
282
  });
281
283
  return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
@@ -1,7 +1,13 @@
1
+ import "regenerator-runtime/runtime.js";
2
+ import "core-js/modules/es.promise.js";
3
+ import "core-js/modules/es.object.to-string.js";
4
+
5
+ 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); } }
6
+
7
+ 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); }); }; }
8
+
1
9
  import { addons, useEffect } from '@storybook/addons';
2
10
  import { computesTemplateSourceFromComponent } from '@storybook/angular/renderer';
3
- import prettierHtml from 'prettier/parser-html';
4
- import prettier from 'prettier/standalone';
5
11
  import { SNIPPET_RENDERED, SourceType } from '../../shared';
6
12
  export var skipSourceRender = function skipSourceRender(context) {
7
13
  var _context$parameters$d;
@@ -16,16 +22,58 @@ export var skipSourceRender = function skipSourceRender(context) {
16
22
 
17
23
  return (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.CODE;
18
24
  };
25
+ var prettyUpInternal;
19
26
 
20
- var prettyUp = function prettyUp(source) {
21
- return prettier.format(source, {
22
- parser: 'angular',
23
- plugins: [prettierHtml],
24
- htmlWhitespaceSensitivity: 'ignore'
25
- });
26
- };
27
+ var makePrettyUp = /*#__PURE__*/function () {
28
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
29
+ var prettierHtml, prettier;
30
+ return regeneratorRuntime.wrap(function _callee$(_context) {
31
+ while (1) {
32
+ switch (_context.prev = _context.next) {
33
+ case 0:
34
+ if (!prettyUpInternal) {
35
+ _context.next = 2;
36
+ break;
37
+ }
38
+
39
+ return _context.abrupt("return", prettyUpInternal);
40
+
41
+ case 2:
42
+ _context.next = 4;
43
+ return import('prettier/parser-html');
44
+
45
+ case 4:
46
+ prettierHtml = _context.sent;
47
+ _context.next = 7;
48
+ return import('prettier/standalone');
49
+
50
+ case 7:
51
+ prettier = _context.sent;
52
+
53
+ prettyUpInternal = function prettyUpInternal(source) {
54
+ return prettier.format(source, {
55
+ parser: 'angular',
56
+ plugins: [prettierHtml],
57
+ htmlWhitespaceSensitivity: 'ignore'
58
+ });
59
+ };
60
+
61
+ return _context.abrupt("return", prettyUpInternal);
62
+
63
+ case 10:
64
+ case "end":
65
+ return _context.stop();
66
+ }
67
+ }
68
+ }, _callee);
69
+ }));
70
+
71
+ return function makePrettyUp() {
72
+ return _ref.apply(this, arguments);
73
+ };
74
+ }();
27
75
  /**
28
- * Svelte source decorator.
76
+ * Angular source decorator.
29
77
  * @param storyFn Fn
30
78
  * @param context StoryContext
31
79
  */
@@ -45,20 +93,24 @@ export var sourceDecorator = function sourceDecorator(storyFn, context) {
45
93
  var component = context.component,
46
94
  argTypes = context.argTypes;
47
95
  var toEmit;
96
+ var prettyUpPromise = makePrettyUp();
48
97
  useEffect(function () {
49
- if (toEmit) channel.emit(SNIPPET_RENDERED, context.id, prettyUp(template));
98
+ prettyUpPromise.then(function (prettyUp) {
99
+ if (toEmit) channel.emit(SNIPPET_RENDERED, context.id, prettyUp(toEmit));
100
+ });
50
101
  });
102
+ prettyUpPromise.then(function (prettyUp) {
103
+ if (component && !userDefinedTemplate) {
104
+ var _source = computesTemplateSourceFromComponent(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
105
+ // In these cases there might exist a template, even if we aren't able to create source from component
51
106
 
52
- if (component && !userDefinedTemplate) {
53
- var source = computesTemplateSourceFromComponent(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
54
- // In these cases there might exist a template, even if we aren't able to create source from component
55
107
 
56
- if (source || template) {
57
- toEmit = prettyUp(source || template);
108
+ if (_source || template) {
109
+ toEmit = prettyUp(_source || template);
110
+ }
111
+ } else if (template) {
112
+ toEmit = prettyUp(template);
58
113
  }
59
- } else if (template) {
60
- toEmit = prettyUp(template);
61
- }
62
-
114
+ });
63
115
  return story;
64
116
  };
@@ -20,6 +20,9 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
20
20
 
21
21
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
22
 
23
+ import "regenerator-runtime/runtime.js";
24
+ import "core-js/modules/es.promise.js";
25
+ import "core-js/modules/es.object.to-string.js";
23
26
  import "core-js/modules/es.array.join.js";
24
27
  import "core-js/modules/es.array.filter.js";
25
28
  import "core-js/modules/es.array.map.js";
@@ -33,7 +36,6 @@ import "core-js/modules/es.array.includes.js";
33
36
  import "core-js/modules/es.string.includes.js";
34
37
  import "core-js/modules/es.symbol.js";
35
38
  import "core-js/modules/es.symbol.description.js";
36
- import "core-js/modules/es.object.to-string.js";
37
39
  import "core-js/modules/es.symbol.iterator.js";
38
40
  import "core-js/modules/es.string.iterator.js";
39
41
  import "core-js/modules/es.array.iterator.js";
@@ -42,11 +44,13 @@ import "core-js/modules/es.array.from.js";
42
44
  import "core-js/modules/es.array.slice.js";
43
45
  import "core-js/modules/es.function.name.js";
44
46
 
47
+ 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); } }
48
+
49
+ 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); }); }; }
50
+
45
51
  /* eslint no-underscore-dangle: ["error", { "allow": ["_vnode"] }] */
46
52
  import { addons } from '@storybook/addons';
47
53
  import { logger } from '@storybook/client-logger';
48
- import prettier from 'prettier/standalone';
49
- import prettierHtml from 'prettier/parser-html';
50
54
  import { SourceType, SNIPPET_RENDERED } from '../../shared';
51
55
  export var skipSourceRender = function skipSourceRender(context) {
52
56
  var _context$parameters$d;
@@ -87,13 +91,46 @@ export var sourceDecorator = function sourceDecorator(storyFn, context) {
87
91
  try {
88
92
  var storyNode = lookupStoryInstance(this, storyComponent);
89
93
  var code = vnodeToString(storyNode._vnode);
90
- channel.emit(SNIPPET_RENDERED, (context || {}).id, prettier.format("<template>".concat(code, "</template>"), {
91
- parser: 'vue',
92
- plugins: [prettierHtml],
93
- // Because the parsed vnode missing spaces right before/after the surround tag,
94
- // we always get weird wrapped code without this option.
95
- htmlWhitespaceSensitivity: 'ignore'
96
- }));
94
+
95
+ var emitFormattedTemplate = /*#__PURE__*/function () {
96
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
97
+ var prettier, prettierHtml;
98
+ return regeneratorRuntime.wrap(function _callee$(_context) {
99
+ while (1) {
100
+ switch (_context.prev = _context.next) {
101
+ case 0:
102
+ _context.next = 2;
103
+ return import('prettier/standalone');
104
+
105
+ case 2:
106
+ prettier = _context.sent;
107
+ _context.next = 5;
108
+ return import('prettier/parser-html');
109
+
110
+ case 5:
111
+ prettierHtml = _context.sent;
112
+ channel.emit(SNIPPET_RENDERED, (context || {}).id, prettier.format("<template>".concat(code, "</template>"), {
113
+ parser: 'vue',
114
+ plugins: [prettierHtml],
115
+ // Because the parsed vnode missing spaces right before/after the surround tag,
116
+ // we always get weird wrapped code without this option.
117
+ htmlWhitespaceSensitivity: 'ignore'
118
+ }));
119
+
120
+ case 7:
121
+ case "end":
122
+ return _context.stop();
123
+ }
124
+ }
125
+ }, _callee);
126
+ }));
127
+
128
+ return function emitFormattedTemplate() {
129
+ return _ref.apply(this, arguments);
130
+ };
131
+ }();
132
+
133
+ emitFormattedTemplate();
97
134
  } catch (e) {
98
135
  logger.warn("Failed to generate dynamic story source: ".concat(e));
99
136
  }
@@ -104,17 +141,17 @@ export var sourceDecorator = function sourceDecorator(storyFn, context) {
104
141
  export function vnodeToString(vnode) {
105
142
  var _vnode$data, _vnode$componentOptio, _vnode$data2;
106
143
 
107
- var attrString = [].concat(_toConsumableArray((_vnode$data = vnode.data) !== null && _vnode$data !== void 0 && _vnode$data.slot ? [['slot', vnode.data.slot]] : []), [['class', stringifyClassAttribute(vnode)]], _toConsumableArray((_vnode$componentOptio = vnode.componentOptions) !== null && _vnode$componentOptio !== void 0 && _vnode$componentOptio.propsData ? Object.entries(vnode.componentOptions.propsData) : []), _toConsumableArray((_vnode$data2 = vnode.data) !== null && _vnode$data2 !== void 0 && _vnode$data2.attrs ? Object.entries(vnode.data.attrs) : [])).filter(function (_ref, index, list) {
108
- var _ref2 = _slicedToArray(_ref, 1),
109
- name = _ref2[0];
144
+ var attrString = [].concat(_toConsumableArray((_vnode$data = vnode.data) !== null && _vnode$data !== void 0 && _vnode$data.slot ? [['slot', vnode.data.slot]] : []), [['class', stringifyClassAttribute(vnode)]], _toConsumableArray((_vnode$componentOptio = vnode.componentOptions) !== null && _vnode$componentOptio !== void 0 && _vnode$componentOptio.propsData ? Object.entries(vnode.componentOptions.propsData) : []), _toConsumableArray((_vnode$data2 = vnode.data) !== null && _vnode$data2 !== void 0 && _vnode$data2.attrs ? Object.entries(vnode.data.attrs) : [])).filter(function (_ref2, index, list) {
145
+ var _ref3 = _slicedToArray(_ref2, 1),
146
+ name = _ref3[0];
110
147
 
111
148
  return list.findIndex(function (item) {
112
149
  return item[0] === name;
113
150
  }) === index;
114
- }).map(function (_ref3) {
115
- var _ref4 = _slicedToArray(_ref3, 2),
116
- name = _ref4[0],
117
- value = _ref4[1];
151
+ }).map(function (_ref4) {
152
+ var _ref5 = _slicedToArray(_ref4, 2),
153
+ name = _ref5[0],
154
+ value = _ref5[1];
118
155
 
119
156
  return stringifyAttr(name, value);
120
157
  }).filter(Boolean).join(' ');
@@ -181,14 +218,14 @@ function normalizeClassBinding(binding) {
181
218
  }
182
219
 
183
220
  if (_typeof(binding) === 'object') {
184
- return Object.entries(binding).filter(function (_ref5) {
185
- var _ref6 = _slicedToArray(_ref5, 2),
186
- active = _ref6[1];
221
+ return Object.entries(binding).filter(function (_ref6) {
222
+ var _ref7 = _slicedToArray(_ref6, 2),
223
+ active = _ref7[1];
187
224
 
188
225
  return !!active;
189
- }).map(function (_ref7) {
190
- var _ref8 = _slicedToArray(_ref7, 1),
191
- className = _ref8[0];
226
+ }).map(function (_ref8) {
227
+ var _ref9 = _slicedToArray(_ref8, 1),
228
+ className = _ref9[0];
192
229
 
193
230
  return className;
194
231
  });
@@ -42,6 +42,7 @@ export const DocsStory = ({
42
42
  }), /*#__PURE__*/React.createElement(Canvas, {
43
43
  withToolbar: withToolbar
44
44
  }, /*#__PURE__*/React.createElement(Story, {
45
- id: id
45
+ id: id,
46
+ parameters: parameters
46
47
  })));
47
48
  };
@@ -225,8 +225,10 @@ const extractDefaultValue = property => {
225
225
  };
226
226
 
227
227
  const resolveTypealias = compodocType => {
228
+ var _compodocJson$miscell, _compodocJson$miscell2;
229
+
228
230
  const compodocJson = getCompodocJson();
229
- const typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : compodocJson.miscellaneous.typealiases.find(x => x.name === compodocType);
231
+ const typeAlias = compodocJson === null || compodocJson === void 0 ? void 0 : (_compodocJson$miscell = compodocJson.miscellaneous) === null || _compodocJson$miscell === void 0 ? void 0 : (_compodocJson$miscell2 = _compodocJson$miscell.typealiases) === null || _compodocJson$miscell2 === void 0 ? void 0 : _compodocJson$miscell2.find(x => x.name === compodocType);
230
232
  return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
231
233
  };
232
234
 
@@ -1,7 +1,5 @@
1
1
  import { addons, useEffect } from '@storybook/addons';
2
2
  import { computesTemplateSourceFromComponent } from '@storybook/angular/renderer';
3
- import prettierHtml from 'prettier/parser-html';
4
- import prettier from 'prettier/standalone';
5
3
  import { SNIPPET_RENDERED, SourceType } from '../../shared';
6
4
  export const skipSourceRender = context => {
7
5
  var _context$parameters$d;
@@ -16,16 +14,28 @@ export const skipSourceRender = context => {
16
14
 
17
15
  return (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.code) || (sourceParams === null || sourceParams === void 0 ? void 0 : sourceParams.type) === SourceType.CODE;
18
16
  };
17
+ let prettyUpInternal;
19
18
 
20
- const prettyUp = source => {
21
- return prettier.format(source, {
22
- parser: 'angular',
23
- plugins: [prettierHtml],
24
- htmlWhitespaceSensitivity: 'ignore'
25
- });
19
+ const makePrettyUp = async () => {
20
+ if (prettyUpInternal) {
21
+ return prettyUpInternal;
22
+ }
23
+
24
+ const prettierHtml = await import('prettier/parser-html');
25
+ const prettier = await import('prettier/standalone');
26
+
27
+ prettyUpInternal = source => {
28
+ return prettier.format(source, {
29
+ parser: 'angular',
30
+ plugins: [prettierHtml],
31
+ htmlWhitespaceSensitivity: 'ignore'
32
+ });
33
+ };
34
+
35
+ return prettyUpInternal;
26
36
  };
27
37
  /**
28
- * Svelte source decorator.
38
+ * Angular source decorator.
29
39
  * @param storyFn Fn
30
40
  * @param context StoryContext
31
41
  */
@@ -49,20 +59,23 @@ export const sourceDecorator = (storyFn, context) => {
49
59
  argTypes
50
60
  } = context;
51
61
  let toEmit;
62
+ const prettyUpPromise = makePrettyUp();
52
63
  useEffect(() => {
53
- if (toEmit) channel.emit(SNIPPET_RENDERED, context.id, prettyUp(template));
64
+ prettyUpPromise.then(prettyUp => {
65
+ if (toEmit) channel.emit(SNIPPET_RENDERED, context.id, prettyUp(toEmit));
66
+ });
54
67
  });
68
+ prettyUpPromise.then(prettyUp => {
69
+ if (component && !userDefinedTemplate) {
70
+ const source = computesTemplateSourceFromComponent(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
71
+ // In these cases there might exist a template, even if we aren't able to create source from component
55
72
 
56
- if (component && !userDefinedTemplate) {
57
- const source = computesTemplateSourceFromComponent(component, props, argTypes); // We might have a story with a Directive or Service defined as the component
58
- // In these cases there might exist a template, even if we aren't able to create source from component
59
-
60
- if (source || template) {
61
- toEmit = prettyUp(source || template);
73
+ if (source || template) {
74
+ toEmit = prettyUp(source || template);
75
+ }
76
+ } else if (template) {
77
+ toEmit = prettyUp(template);
62
78
  }
63
- } else if (template) {
64
- toEmit = prettyUp(template);
65
- }
66
-
79
+ });
67
80
  return story;
68
81
  };
@@ -3,8 +3,6 @@ import "core-js/modules/es.array.reduce.js";
3
3
  /* eslint no-underscore-dangle: ["error", { "allow": ["_vnode"] }] */
4
4
  import { addons } from '@storybook/addons';
5
5
  import { logger } from '@storybook/client-logger';
6
- import prettier from 'prettier/standalone';
7
- import prettierHtml from 'prettier/parser-html';
8
6
  import { SourceType, SNIPPET_RENDERED } from '../../shared';
9
7
  export const skipSourceRender = context => {
10
8
  var _context$parameters$d;
@@ -46,13 +44,20 @@ export const sourceDecorator = (storyFn, context) => {
46
44
  try {
47
45
  const storyNode = lookupStoryInstance(this, storyComponent);
48
46
  const code = vnodeToString(storyNode._vnode);
49
- channel.emit(SNIPPET_RENDERED, (context || {}).id, prettier.format(`<template>${code}</template>`, {
50
- parser: 'vue',
51
- plugins: [prettierHtml],
52
- // Because the parsed vnode missing spaces right before/after the surround tag,
53
- // we always get weird wrapped code without this option.
54
- htmlWhitespaceSensitivity: 'ignore'
55
- }));
47
+
48
+ const emitFormattedTemplate = async () => {
49
+ const prettier = await import('prettier/standalone');
50
+ const prettierHtml = await import('prettier/parser-html');
51
+ channel.emit(SNIPPET_RENDERED, (context || {}).id, prettier.format(`<template>${code}</template>`, {
52
+ parser: 'vue',
53
+ plugins: [prettierHtml],
54
+ // Because the parsed vnode missing spaces right before/after the surround tag,
55
+ // we always get weird wrapped code without this option.
56
+ htmlWhitespaceSensitivity: 'ignore'
57
+ }));
58
+ };
59
+
60
+ emitFormattedTemplate();
56
61
  } catch (e) {
57
62
  logger.warn(`Failed to generate dynamic story source: ${e}`);
58
63
  }
@@ -2,7 +2,7 @@ import { PartialStoryFn } from '@storybook/csf';
2
2
  import { StoryContext, AngularFramework } from '@storybook/angular';
3
3
  export declare const skipSourceRender: (context: StoryContext) => any;
4
4
  /**
5
- * Svelte source decorator.
5
+ * Angular source decorator.
6
6
  * @param storyFn Fn
7
7
  * @param context StoryContext
8
8
  */
@@ -2,7 +2,7 @@ import { PartialStoryFn } from '@storybook/csf';
2
2
  import { StoryContext, AngularFramework } from '@storybook/angular';
3
3
  export declare const skipSourceRender: (context: StoryContext) => any;
4
4
  /**
5
- * Svelte source decorator.
5
+ * Angular source decorator.
6
6
  * @param storyFn Fn
7
7
  * @param context StoryContext
8
8
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.4.0-beta.21",
3
+ "version": "6.4.0-beta.25",
4
4
  "description": "Document component usage and properties in Markdown",
5
5
  "keywords": [
6
6
  "addon",
@@ -63,21 +63,21 @@
63
63
  "@mdx-js/loader": "^1.6.22",
64
64
  "@mdx-js/mdx": "^1.6.22",
65
65
  "@mdx-js/react": "^1.6.22",
66
- "@storybook/addons": "6.4.0-beta.21",
67
- "@storybook/api": "6.4.0-beta.21",
68
- "@storybook/builder-webpack4": "6.4.0-beta.21",
69
- "@storybook/client-logger": "6.4.0-beta.21",
70
- "@storybook/components": "6.4.0-beta.21",
71
- "@storybook/core": "6.4.0-beta.21",
72
- "@storybook/core-events": "6.4.0-beta.21",
66
+ "@storybook/addons": "6.4.0-beta.25",
67
+ "@storybook/api": "6.4.0-beta.25",
68
+ "@storybook/builder-webpack4": "6.4.0-beta.25",
69
+ "@storybook/client-logger": "6.4.0-beta.25",
70
+ "@storybook/components": "6.4.0-beta.25",
71
+ "@storybook/core": "6.4.0-beta.25",
72
+ "@storybook/core-events": "6.4.0-beta.25",
73
73
  "@storybook/csf": "0.0.2--canary.87bc651.0",
74
- "@storybook/csf-tools": "6.4.0-beta.21",
75
- "@storybook/node-logger": "6.4.0-beta.21",
76
- "@storybook/postinstall": "6.4.0-beta.21",
77
- "@storybook/preview-web": "6.4.0-beta.21",
78
- "@storybook/source-loader": "6.4.0-beta.21",
79
- "@storybook/store": "6.4.0-beta.21",
80
- "@storybook/theming": "6.4.0-beta.21",
74
+ "@storybook/csf-tools": "6.4.0-beta.25",
75
+ "@storybook/node-logger": "6.4.0-beta.25",
76
+ "@storybook/postinstall": "6.4.0-beta.25",
77
+ "@storybook/preview-web": "6.4.0-beta.25",
78
+ "@storybook/source-loader": "6.4.0-beta.25",
79
+ "@storybook/store": "6.4.0-beta.25",
80
+ "@storybook/theming": "6.4.0-beta.25",
81
81
  "acorn": "^7.4.1",
82
82
  "acorn-jsx": "^5.3.1",
83
83
  "acorn-walk": "^7.2.0",
@@ -106,11 +106,11 @@
106
106
  "@babel/core": "^7.12.10",
107
107
  "@emotion/core": "^10.1.1",
108
108
  "@emotion/styled": "^10.0.27",
109
- "@storybook/angular": "6.4.0-beta.21",
110
- "@storybook/html": "6.4.0-beta.21",
111
- "@storybook/react": "6.4.0-beta.21",
112
- "@storybook/vue": "6.4.0-beta.21",
113
- "@storybook/web-components": "6.4.0-beta.21",
109
+ "@storybook/angular": "6.4.0-beta.25",
110
+ "@storybook/html": "6.4.0-beta.25",
111
+ "@storybook/react": "6.4.0-beta.25",
112
+ "@storybook/vue": "6.4.0-beta.25",
113
+ "@storybook/web-components": "6.4.0-beta.25",
114
114
  "@types/cross-spawn": "^6.0.2",
115
115
  "@types/doctrine": "^0.0.3",
116
116
  "@types/enzyme": "^3.10.8",
@@ -140,12 +140,12 @@
140
140
  "zone.js": "^0.11.3"
141
141
  },
142
142
  "peerDependencies": {
143
- "@storybook/angular": "6.4.0-beta.21",
144
- "@storybook/html": "6.4.0-beta.21",
145
- "@storybook/react": "6.4.0-beta.21",
146
- "@storybook/vue": "6.4.0-beta.21",
147
- "@storybook/vue3": "6.4.0-beta.21",
148
- "@storybook/web-components": "6.4.0-beta.21",
143
+ "@storybook/angular": "6.4.0-beta.25",
144
+ "@storybook/html": "6.4.0-beta.25",
145
+ "@storybook/react": "6.4.0-beta.25",
146
+ "@storybook/vue": "6.4.0-beta.25",
147
+ "@storybook/vue3": "6.4.0-beta.25",
148
+ "@storybook/web-components": "6.4.0-beta.25",
149
149
  "lit": "^2.0.0-rc.1",
150
150
  "lit-html": "^1.4.1 || ^2.0.0-rc.3",
151
151
  "react": "^16.8.0 || ^17.0.0",
@@ -202,7 +202,7 @@
202
202
  "publishConfig": {
203
203
  "access": "public"
204
204
  },
205
- "gitHead": "eb83ef6aefb6791324e2c70567bdc128cef09d92",
205
+ "gitHead": "5bf101067e5b9387ce092301bea6ab4ee432f777",
206
206
  "sbmodern": "dist/modern/index.js",
207
207
  "storybook": {
208
208
  "displayName": "Docs",