@storybook/addon-docs 6.4.0-rc.6 → 6.4.0

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.
@@ -6,16 +6,8 @@ require("core-js/modules/es.symbol.js");
6
6
 
7
7
  require("core-js/modules/es.symbol.description.js");
8
8
 
9
- require("core-js/modules/es.object.to-string.js");
10
-
11
9
  require("core-js/modules/es.symbol.iterator.js");
12
10
 
13
- require("core-js/modules/es.string.iterator.js");
14
-
15
- require("core-js/modules/es.array.iterator.js");
16
-
17
- require("core-js/modules/web.dom-collections.iterator.js");
18
-
19
11
  require("core-js/modules/es.array.slice.js");
20
12
 
21
13
  require("core-js/modules/es.array.from.js");
@@ -33,6 +25,16 @@ require("core-js/modules/es.function.name.js");
33
25
 
34
26
  require("core-js/modules/es.object.assign.js");
35
27
 
28
+ require("core-js/modules/es.promise.js");
29
+
30
+ require("core-js/modules/es.object.to-string.js");
31
+
32
+ require("core-js/modules/es.string.iterator.js");
33
+
34
+ require("core-js/modules/es.array.iterator.js");
35
+
36
+ require("core-js/modules/web.dom-collections.iterator.js");
37
+
36
38
  require("core-js/modules/es.array.concat.js");
37
39
 
38
40
  var _react = _interopRequireWildcard(require("react"));
@@ -151,8 +153,16 @@ var getStoryProps = function getStoryProps(_ref4, story, context, onStoryFnCalle
151
153
 
152
154
  exports.getStoryProps = getStoryProps;
153
155
 
156
+ function makeGate() {
157
+ var open;
158
+ var gate = new Promise(function (r) {
159
+ open = r;
160
+ });
161
+ return [gate, open];
162
+ }
163
+
154
164
  var Story = function Story(props) {
155
- var _global$FEATURES;
165
+ var _global$FEATURES, _global$FEATURES2;
156
166
 
157
167
  var context = (0, _react.useContext)(_DocsContext.DocsContext);
158
168
 
@@ -200,22 +210,44 @@ var Story = function Story(props) {
200
210
  };
201
211
  }, [story]);
202
212
 
203
- if (!story) {
204
- return /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null);
205
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
213
+ var _makeGate = makeGate(),
214
+ _makeGate2 = _slicedToArray(_makeGate, 2),
215
+ storyFnRan = _makeGate2[0],
216
+ onStoryFnRan = _makeGate2[1];
217
+
218
+ var _makeGate3 = makeGate(),
219
+ _makeGate4 = _slicedToArray(_makeGate3, 2),
220
+ rendered = _makeGate4[0],
221
+ onRendered = _makeGate4[1];
222
+
223
+ (0, _react.useEffect)(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
206
224
  // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
207
225
  // `Preview.renderStoryToDom()` which itself emits the event.
208
226
 
227
+ if (story && !(_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
228
+ // We need to wait for two things before we can consider the story rendered:
229
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
230
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
231
+ // call to the story function.
232
+ // (b) The story function needs to actually have been called.
233
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
234
+ // React render cycle, so we need to wait for the framework to actually do that
235
+ Promise.all([storyFnRan, rendered]).then(function () {
236
+ channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
237
+ });
238
+ }
209
239
 
210
- var storyProps = getStoryProps(props, story, context, function () {
211
- return channel.emit(_coreEvents.default.STORY_RENDERED, storyId);
212
- });
240
+ if (!story) {
241
+ return /*#__PURE__*/_react.default.createElement(_components.StorySkeleton, null);
242
+ }
243
+
244
+ var storyProps = getStoryProps(props, story, context, onStoryFnRan);
213
245
 
214
246
  if (!storyProps) {
215
247
  return null;
216
248
  }
217
249
 
218
- if (_global.default !== null && _global.default !== void 0 && (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
250
+ if (_global.default !== null && _global.default !== void 0 && (_global$FEATURES2 = _global.default.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
219
251
  // We do this so React doesn't complain when we replace the span in a secondary render
220
252
  var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
221
253
 
@@ -12,14 +12,15 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import "core-js/modules/es.function.name.js";
14
14
  import "core-js/modules/es.object.assign.js";
15
- import "core-js/modules/es.array.concat.js";
16
- import "core-js/modules/es.symbol.js";
17
- import "core-js/modules/es.symbol.description.js";
15
+ import "core-js/modules/es.promise.js";
18
16
  import "core-js/modules/es.object.to-string.js";
19
- import "core-js/modules/es.symbol.iterator.js";
20
17
  import "core-js/modules/es.string.iterator.js";
21
18
  import "core-js/modules/es.array.iterator.js";
22
19
  import "core-js/modules/web.dom-collections.iterator.js";
20
+ import "core-js/modules/es.array.concat.js";
21
+ import "core-js/modules/es.symbol.js";
22
+ import "core-js/modules/es.symbol.description.js";
23
+ import "core-js/modules/es.symbol.iterator.js";
23
24
  import "core-js/modules/es.array.slice.js";
24
25
  import "core-js/modules/es.array.from.js";
25
26
  import React, { useContext, useRef, useEffect, useState } from 'react';
@@ -99,8 +100,16 @@ export var getStoryProps = function getStoryProps(_ref4, story, context, onStory
99
100
  });
100
101
  };
101
102
 
103
+ function makeGate() {
104
+ var open;
105
+ var gate = new Promise(function (r) {
106
+ open = r;
107
+ });
108
+ return [gate, open];
109
+ }
110
+
102
111
  var Story = function Story(props) {
103
- var _global$FEATURES;
112
+ var _global$FEATURES, _global$FEATURES2;
104
113
 
105
114
  var context = useContext(DocsContext);
106
115
  var channel = addons.getChannel();
@@ -146,22 +155,44 @@ var Story = function Story(props) {
146
155
  };
147
156
  }, [story]);
148
157
 
149
- if (!story) {
150
- return /*#__PURE__*/React.createElement(StorySkeleton, null);
151
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
158
+ var _makeGate = makeGate(),
159
+ _makeGate2 = _slicedToArray(_makeGate, 2),
160
+ storyFnRan = _makeGate2[0],
161
+ onStoryFnRan = _makeGate2[1];
162
+
163
+ var _makeGate3 = makeGate(),
164
+ _makeGate4 = _slicedToArray(_makeGate3, 2),
165
+ rendered = _makeGate4[0],
166
+ onRendered = _makeGate4[1];
167
+
168
+ useEffect(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
152
169
  // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
153
170
  // `Preview.renderStoryToDom()` which itself emits the event.
154
171
 
172
+ if (story && !(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
173
+ // We need to wait for two things before we can consider the story rendered:
174
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
175
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
176
+ // call to the story function.
177
+ // (b) The story function needs to actually have been called.
178
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
179
+ // React render cycle, so we need to wait for the framework to actually do that
180
+ Promise.all([storyFnRan, rendered]).then(function () {
181
+ channel.emit(Events.STORY_RENDERED, storyId);
182
+ });
183
+ }
184
+
185
+ if (!story) {
186
+ return /*#__PURE__*/React.createElement(StorySkeleton, null);
187
+ }
155
188
 
156
- var storyProps = getStoryProps(props, story, context, function () {
157
- return channel.emit(Events.STORY_RENDERED, storyId);
158
- });
189
+ var storyProps = getStoryProps(props, story, context, onStoryFnRan);
159
190
 
160
191
  if (!storyProps) {
161
192
  return null;
162
193
  }
163
194
 
164
- if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
195
+ if (global !== null && global !== void 0 && (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
165
196
  // We do this so React doesn't complain when we replace the span in a secondary render
166
197
  var htmlContents = "<span></span>"; // FIXME: height/style/etc. lifted from PureStory
167
198
 
@@ -76,8 +76,16 @@ export const getStoryProps = ({
76
76
  });
77
77
  };
78
78
 
79
+ function makeGate() {
80
+ let open;
81
+ const gate = new Promise(r => {
82
+ open = r;
83
+ });
84
+ return [gate, open];
85
+ }
86
+
79
87
  const Story = props => {
80
- var _global$FEATURES;
88
+ var _global$FEATURES, _global$FEATURES2;
81
89
 
82
90
  const context = useContext(DocsContext);
83
91
  const channel = addons.getChannel();
@@ -117,21 +125,36 @@ const Story = props => {
117
125
 
118
126
  return () => cleanup && cleanup();
119
127
  }, [story]);
120
-
121
- if (!story) {
122
- return /*#__PURE__*/React.createElement(StorySkeleton, null);
123
- } // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
128
+ const [storyFnRan, onStoryFnRan] = makeGate();
129
+ const [rendered, onRendered] = makeGate();
130
+ useEffect(onRendered); // If we are rendering a old-style inline Story via `PureStory` below, we want to emit
124
131
  // the `STORY_RENDERED` event when it renders. The modern mode below calls out to
125
132
  // `Preview.renderStoryToDom()` which itself emits the event.
126
133
 
134
+ if (story && !(global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender)) {
135
+ // We need to wait for two things before we can consider the story rendered:
136
+ // (a) React's `useEffect` hook needs to fire. This is needed for React stories, as
137
+ // decorators of the form `<A><B/></A>` will not actually execute `B` in the first
138
+ // call to the story function.
139
+ // (b) The story function needs to actually have been called.
140
+ // Certain frameworks (i.e.angular) don't actually render the component in the very first
141
+ // React render cycle, so we need to wait for the framework to actually do that
142
+ Promise.all([storyFnRan, rendered]).then(() => {
143
+ channel.emit(Events.STORY_RENDERED, storyId);
144
+ });
145
+ }
146
+
147
+ if (!story) {
148
+ return /*#__PURE__*/React.createElement(StorySkeleton, null);
149
+ }
127
150
 
128
- const storyProps = getStoryProps(props, story, context, () => channel.emit(Events.STORY_RENDERED, storyId));
151
+ const storyProps = getStoryProps(props, story, context, onStoryFnRan);
129
152
 
130
153
  if (!storyProps) {
131
154
  return null;
132
155
  }
133
156
 
134
- if (global !== null && global !== void 0 && (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.modernInlineRender) {
157
+ if (global !== null && global !== void 0 && (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.modernInlineRender) {
135
158
  // We do this so React doesn't complain when we replace the span in a secondary render
136
159
  const htmlContents = `<span></span>`; // FIXME: height/style/etc. lifted from PureStory
137
160
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.4.0-rc.6",
3
+ "version": "6.4.0",
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-rc.6",
67
- "@storybook/api": "6.4.0-rc.6",
68
- "@storybook/builder-webpack4": "6.4.0-rc.6",
69
- "@storybook/client-logger": "6.4.0-rc.6",
70
- "@storybook/components": "6.4.0-rc.6",
71
- "@storybook/core": "6.4.0-rc.6",
72
- "@storybook/core-events": "6.4.0-rc.6",
66
+ "@storybook/addons": "6.4.0",
67
+ "@storybook/api": "6.4.0",
68
+ "@storybook/builder-webpack4": "6.4.0",
69
+ "@storybook/client-logger": "6.4.0",
70
+ "@storybook/components": "6.4.0",
71
+ "@storybook/core": "6.4.0",
72
+ "@storybook/core-events": "6.4.0",
73
73
  "@storybook/csf": "0.0.2--canary.87bc651.0",
74
- "@storybook/csf-tools": "6.4.0-rc.6",
75
- "@storybook/node-logger": "6.4.0-rc.6",
76
- "@storybook/postinstall": "6.4.0-rc.6",
77
- "@storybook/preview-web": "6.4.0-rc.6",
78
- "@storybook/source-loader": "6.4.0-rc.6",
79
- "@storybook/store": "6.4.0-rc.6",
80
- "@storybook/theming": "6.4.0-rc.6",
74
+ "@storybook/csf-tools": "6.4.0",
75
+ "@storybook/node-logger": "6.4.0",
76
+ "@storybook/postinstall": "6.4.0",
77
+ "@storybook/preview-web": "6.4.0",
78
+ "@storybook/source-loader": "6.4.0",
79
+ "@storybook/store": "6.4.0",
80
+ "@storybook/theming": "6.4.0",
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-rc.6",
110
- "@storybook/html": "6.4.0-rc.6",
111
- "@storybook/react": "6.4.0-rc.6",
112
- "@storybook/vue": "6.4.0-rc.6",
113
- "@storybook/web-components": "6.4.0-rc.6",
109
+ "@storybook/angular": "6.4.0",
110
+ "@storybook/html": "6.4.0",
111
+ "@storybook/react": "6.4.0",
112
+ "@storybook/vue": "6.4.0",
113
+ "@storybook/web-components": "6.4.0",
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-rc.6",
144
- "@storybook/html": "6.4.0-rc.6",
145
- "@storybook/react": "6.4.0-rc.6",
146
- "@storybook/vue": "6.4.0-rc.6",
147
- "@storybook/vue3": "6.4.0-rc.6",
148
- "@storybook/web-components": "6.4.0-rc.6",
143
+ "@storybook/angular": "6.4.0",
144
+ "@storybook/html": "6.4.0",
145
+ "@storybook/react": "6.4.0",
146
+ "@storybook/vue": "6.4.0",
147
+ "@storybook/vue3": "6.4.0",
148
+ "@storybook/web-components": "6.4.0",
149
149
  "lit": "^2.0.0",
150
150
  "lit-html": "^1.4.1 || ^2.0.0",
151
151
  "react": "^16.8.0 || ^17.0.0",
@@ -202,7 +202,7 @@
202
202
  "publishConfig": {
203
203
  "access": "public"
204
204
  },
205
- "gitHead": "b2afbb87f07d81f5c3830748490f6dca84d8e470",
205
+ "gitHead": "7d4d6ab38a9c4ef18968fa3964b5084d87a82b71",
206
206
  "sbmodern": "dist/modern/index.js",
207
207
  "storybook": {
208
208
  "displayName": "Docs",