@storybook/server 6.5.7 → 7.0.0-alpha.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.
Files changed (79) hide show
  1. package/README.md +1 -317
  2. package/dist/cjs/{client/index.js → index.js} +4 -3
  3. package/dist/cjs/{client/preview → preview}/config.js +0 -0
  4. package/dist/cjs/{client/preview → preview}/globals.js +0 -0
  5. package/dist/cjs/{client/preview → preview}/index.js +2 -2
  6. package/dist/cjs/preview/render.js +210 -0
  7. package/dist/cjs/{client/preview → preview}/types.js +0 -0
  8. package/dist/esm/index.js +3 -0
  9. package/dist/{modern/client → esm}/preview/config.js +0 -0
  10. package/dist/{modern/client → esm}/preview/globals.js +0 -0
  11. package/dist/{modern/client → esm}/preview/index.js +1 -1
  12. package/dist/{modern/client → esm}/preview/render.js +0 -0
  13. package/dist/esm/{client/preview → preview}/types.js +0 -0
  14. package/dist/{ts3.9/client → types}/index.d.ts +0 -0
  15. package/dist/{ts3.9/client → types}/preview/config.d.ts +0 -0
  16. package/dist/{ts3.9/client → types}/preview/globals.d.ts +0 -0
  17. package/dist/{ts3.9/client → types}/preview/index.d.ts +1 -2
  18. package/dist/{ts3.9/client → types}/preview/render.d.ts +0 -0
  19. package/dist/{ts3.9/client → types}/preview/types.d.ts +1 -1
  20. package/package.json +13 -40
  21. package/preview.js +1 -0
  22. package/bin/build.js +0 -4
  23. package/bin/index.js +0 -3
  24. package/dist/cjs/client/preview/render.js +0 -192
  25. package/dist/cjs/lib/compiler/index.js +0 -21
  26. package/dist/cjs/lib/compiler/stringifier.js +0 -175
  27. package/dist/cjs/lib/compiler/types.js +0 -1
  28. package/dist/cjs/server/build.js +0 -9
  29. package/dist/cjs/server/framework-preset-server.js +0 -33
  30. package/dist/cjs/server/index.js +0 -9
  31. package/dist/cjs/server/loader.js +0 -14
  32. package/dist/cjs/server/options.js +0 -17
  33. package/dist/esm/client/index.js +0 -5
  34. package/dist/esm/client/preview/config.js +0 -4
  35. package/dist/esm/client/preview/globals.js +0 -3
  36. package/dist/esm/client/preview/index.js +0 -30
  37. package/dist/esm/client/preview/render.js +0 -161
  38. package/dist/esm/lib/compiler/index.js +0 -13
  39. package/dist/esm/lib/compiler/stringifier.js +0 -137
  40. package/dist/esm/lib/compiler/types.js +0 -0
  41. package/dist/esm/server/build.js +0 -3
  42. package/dist/esm/server/framework-preset-server.js +0 -18
  43. package/dist/esm/server/index.js +0 -3
  44. package/dist/esm/server/loader.js +0 -4
  45. package/dist/esm/server/options.js +0 -8
  46. package/dist/modern/client/index.js +0 -5
  47. package/dist/modern/client/preview/types.js +0 -1
  48. package/dist/modern/lib/compiler/index.js +0 -12
  49. package/dist/modern/lib/compiler/stringifier.js +0 -83
  50. package/dist/modern/lib/compiler/types.js +0 -0
  51. package/dist/modern/server/build.js +0 -3
  52. package/dist/modern/server/framework-preset-server.js +0 -18
  53. package/dist/modern/server/index.js +0 -3
  54. package/dist/modern/server/loader.js +0 -4
  55. package/dist/modern/server/options.js +0 -8
  56. package/dist/ts3.4/client/index.d.ts +0 -1
  57. package/dist/ts3.4/client/preview/config.d.ts +0 -4
  58. package/dist/ts3.4/client/preview/globals.d.ts +0 -1
  59. package/dist/ts3.4/client/preview/index.d.ts +0 -21
  60. package/dist/ts3.4/client/preview/render.d.ts +0 -5
  61. package/dist/ts3.4/client/preview/types.d.ts +0 -20
  62. package/dist/ts3.4/lib/compiler/index.d.ts +0 -2
  63. package/dist/ts3.4/lib/compiler/stringifier.d.ts +0 -7
  64. package/dist/ts3.4/lib/compiler/types.d.ts +0 -24
  65. package/dist/ts3.4/server/build.d.ts +0 -1
  66. package/dist/ts3.4/server/framework-preset-server.d.ts +0 -4
  67. package/dist/ts3.4/server/index.d.ts +0 -1
  68. package/dist/ts3.4/server/loader.d.ts +0 -2
  69. package/dist/ts3.4/server/options.d.ts +0 -3
  70. package/dist/ts3.9/lib/compiler/index.d.ts +0 -2
  71. package/dist/ts3.9/lib/compiler/stringifier.d.ts +0 -7
  72. package/dist/ts3.9/lib/compiler/types.d.ts +0 -24
  73. package/dist/ts3.9/server/build.d.ts +0 -1
  74. package/dist/ts3.9/server/framework-preset-server.d.ts +0 -4
  75. package/dist/ts3.9/server/index.d.ts +0 -1
  76. package/dist/ts3.9/server/loader.d.ts +0 -2
  77. package/dist/ts3.9/server/options.d.ts +0 -3
  78. package/preset.js +0 -1
  79. package/standalone.js +0 -8
@@ -1,161 +0,0 @@
1
- var _templateObject;
2
-
3
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
4
-
5
- import "regenerator-runtime/runtime.js";
6
-
7
- 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); } }
8
-
9
- 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); }); }; }
10
-
11
- import "core-js/modules/es.object.to-string.js";
12
- import "core-js/modules/es.promise.js";
13
- import "core-js/modules/es.array.iterator.js";
14
- import "core-js/modules/es.string.iterator.js";
15
- import "core-js/modules/web.dom-collections.iterator.js";
16
- import "core-js/modules/web.url.js";
17
- import "core-js/modules/web.url-search-params.js";
18
- import "core-js/modules/es.array.concat.js";
19
- import "core-js/modules/es.regexp.exec.js";
20
- import "core-js/modules/es.string.search.js";
21
- import "core-js/modules/es.regexp.to-string.js";
22
- import "core-js/modules/es.object.assign.js";
23
- import "core-js/modules/web.dom-collections.for-each.js";
24
- import "core-js/modules/es.object.keys.js";
25
- import "core-js/modules/es.function.name.js";
26
- import "core-js/modules/es.array.slice.js";
27
- import "core-js/modules/es.object.freeze.js";
28
-
29
- /* eslint-disable no-param-reassign */
30
- import global from 'global';
31
- import dedent from 'ts-dedent';
32
- import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web';
33
- var fetch = global.fetch,
34
- Node = global.Node;
35
-
36
- var defaultFetchStoryHtml = /*#__PURE__*/function () {
37
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, path, params, storyContext) {
38
- var fetchUrl, response;
39
- return regeneratorRuntime.wrap(function _callee$(_context) {
40
- while (1) {
41
- switch (_context.prev = _context.next) {
42
- case 0:
43
- fetchUrl = new URL("".concat(url, "/").concat(path));
44
- fetchUrl.search = new URLSearchParams(Object.assign({}, storyContext.globals, params)).toString();
45
- _context.next = 4;
46
- return fetch(fetchUrl);
47
-
48
- case 4:
49
- response = _context.sent;
50
- return _context.abrupt("return", response.text());
51
-
52
- case 6:
53
- case "end":
54
- return _context.stop();
55
- }
56
- }
57
- }, _callee);
58
- }));
59
-
60
- return function defaultFetchStoryHtml(_x, _x2, _x3, _x4) {
61
- return _ref.apply(this, arguments);
62
- };
63
- }();
64
-
65
- var buildStoryArgs = function buildStoryArgs(args, argTypes) {
66
- var storyArgs = Object.assign({}, args);
67
- Object.keys(argTypes).forEach(function (key) {
68
- var argType = argTypes[key];
69
- var control = argType.control;
70
- var controlType = control && control.type.toLowerCase();
71
- var argValue = storyArgs[key];
72
-
73
- switch (controlType) {
74
- case 'date':
75
- // For cross framework & language support we pick a consistent representation of Dates as strings
76
- storyArgs[key] = new Date(argValue).toISOString();
77
- break;
78
-
79
- case 'object':
80
- // send objects as JSON strings
81
- storyArgs[key] = JSON.stringify(argValue);
82
- break;
83
-
84
- default:
85
- }
86
- });
87
- return storyArgs;
88
- };
89
-
90
- export var render = function render(args) {};
91
- export function renderToDOM(_x5, _x6) {
92
- return _renderToDOM.apply(this, arguments);
93
- }
94
-
95
- function _renderToDOM() {
96
- _renderToDOM = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2, domElement) {
97
- var id, title, name, showMain, showError, forceRemount, storyFn, storyContext, _ref2$storyContext, parameters, args, argTypes, storyArgs, _parameters$server, url, storyId, _parameters$server$fe, fetchStoryHtml, params, fetchId, storyParams, element;
98
-
99
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
100
- while (1) {
101
- switch (_context2.prev = _context2.next) {
102
- case 0:
103
- id = _ref2.id, title = _ref2.title, name = _ref2.name, showMain = _ref2.showMain, showError = _ref2.showError, forceRemount = _ref2.forceRemount, storyFn = _ref2.storyFn, storyContext = _ref2.storyContext, _ref2$storyContext = _ref2.storyContext, parameters = _ref2$storyContext.parameters, args = _ref2$storyContext.args, argTypes = _ref2$storyContext.argTypes;
104
- // Some addons wrap the storyFn so we need to call it even though Server doesn't need the answer
105
- storyFn();
106
- storyArgs = buildStoryArgs(args, argTypes);
107
- _parameters$server = parameters.server, url = _parameters$server.url, storyId = _parameters$server.id, _parameters$server$fe = _parameters$server.fetchStoryHtml, fetchStoryHtml = _parameters$server$fe === void 0 ? defaultFetchStoryHtml : _parameters$server$fe, params = _parameters$server.params;
108
- fetchId = storyId || id;
109
- storyParams = Object.assign({}, params, storyArgs);
110
- _context2.next = 8;
111
- return fetchStoryHtml(url, fetchId, storyParams, storyContext);
112
-
113
- case 8:
114
- element = _context2.sent;
115
- showMain();
116
-
117
- if (!(typeof element === 'string')) {
118
- _context2.next = 15;
119
- break;
120
- }
121
-
122
- domElement.innerHTML = element;
123
- simulatePageLoad(domElement);
124
- _context2.next = 24;
125
- break;
126
-
127
- case 15:
128
- if (!(element instanceof Node)) {
129
- _context2.next = 23;
130
- break;
131
- }
132
-
133
- if (!(domElement.firstChild === element && forceRemount === false)) {
134
- _context2.next = 18;
135
- break;
136
- }
137
-
138
- return _context2.abrupt("return");
139
-
140
- case 18:
141
- domElement.innerHTML = '';
142
- domElement.appendChild(element);
143
- simulateDOMContentLoaded();
144
- _context2.next = 24;
145
- break;
146
-
147
- case 23:
148
- showError({
149
- title: "Expecting an HTML snippet or DOM node from the story: \"".concat(name, "\" of \"").concat(title, "\"."),
150
- description: dedent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Did you forget to return the HTML snippet from the story?\n Use \"() => <your snippet or node>\" or when defining the story.\n "])))
151
- });
152
-
153
- case 24:
154
- case "end":
155
- return _context2.stop();
156
- }
157
- }
158
- }, _callee2);
159
- }));
160
- return _renderToDOM.apply(this, arguments);
161
- }
@@ -1,13 +0,0 @@
1
- import "core-js/modules/es.object.assign.js";
2
- import { stringifySection } from './stringifier';
3
-
4
- function createSection(args) {
5
- return Object.assign({
6
- imports: {},
7
- decorators: []
8
- }, args);
9
- }
10
-
11
- export function compileCsfModule(args) {
12
- return stringifySection(createSection(args));
13
- }
@@ -1,137 +0,0 @@
1
- import "core-js/modules/es.symbol.js";
2
- import "core-js/modules/es.symbol.description.js";
3
- import "core-js/modules/es.object.to-string.js";
4
- import "core-js/modules/es.symbol.iterator.js";
5
- import "core-js/modules/es.array.iterator.js";
6
- import "core-js/modules/es.string.iterator.js";
7
- import "core-js/modules/web.dom-collections.iterator.js";
8
- import "core-js/modules/es.array.slice.js";
9
- import "core-js/modules/es.array.from.js";
10
- import "core-js/modules/es.regexp.exec.js";
11
- import "core-js/modules/es.object.freeze.js";
12
-
13
- var _templateObject;
14
-
15
- var _excluded = ["title", "imports", "decorators", "stories"],
16
- _excluded2 = ["name"];
17
-
18
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
19
-
20
- 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."); }
21
-
22
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
-
24
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
-
26
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
27
-
28
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
-
30
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
-
32
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
-
34
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
-
36
- 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); }
37
-
38
- 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; }
39
-
40
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
41
-
42
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
-
44
- 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); }
45
-
46
- import "core-js/modules/es.string.repeat.js";
47
- import "core-js/modules/es.array.map.js";
48
- import "core-js/modules/es.array.join.js";
49
- import "core-js/modules/es.array.concat.js";
50
- import "core-js/modules/es.object.keys.js";
51
- import "core-js/modules/es.object.entries.js";
52
- import "core-js/modules/es.array.sort.js";
53
- import "core-js/modules/es.function.name.js";
54
- import "core-js/modules/es.object.assign.js";
55
- import dedent from 'ts-dedent';
56
-
57
- var _require = require('safe-identifier'),
58
- identifier = _require.identifier;
59
-
60
- export function stringifyObject(object) {
61
- var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
62
- var excludeOuterParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
63
-
64
- if (typeof object === 'string') {
65
- return JSON.stringify(object);
66
- }
67
-
68
- var indent = ' '.repeat(level);
69
-
70
- if (Array.isArray(object)) {
71
- var arrayStrings = object.map(function (item) {
72
- return stringifyObject(item, level + 1);
73
- });
74
- var arrayString = arrayStrings.join(",\n".concat(indent, " "));
75
- if (excludeOuterParams) return arrayString;
76
- return "[\n".concat(indent, " ").concat(arrayString, "\n").concat(indent, "]");
77
- }
78
-
79
- if (_typeof(object) === 'object') {
80
- var objectString = '';
81
-
82
- if (Object.keys(object).length > 0) {
83
- var objectStrings = Object.keys(object).map(function (key) {
84
- var value = stringifyObject(object[key], level + 1);
85
- return "\n".concat(indent, " ").concat(key, ": ").concat(value);
86
- });
87
- objectString = objectStrings.join(',');
88
- }
89
-
90
- if (excludeOuterParams) return objectString;
91
- if (objectString.length === 0) return '{}';
92
- return "{".concat(objectString, "\n").concat(indent, "}");
93
- }
94
-
95
- return object;
96
- }
97
- export function stringifyImports(imports) {
98
- if (Object.keys(imports).length === 0) return '';
99
- return Object.entries(imports).map(function (_ref) {
100
- var _ref2 = _slicedToArray(_ref, 2),
101
- module = _ref2[0],
102
- names = _ref2[1];
103
-
104
- return "import { ".concat(names.sort().join(', '), " } from '").concat(module, "';\n");
105
- }).join('');
106
- }
107
- export function stringifyDecorators(decorators) {
108
- return decorators && decorators.length > 0 ? "\n decorators: [\n ".concat(decorators.join(',\n '), "\n ],") : '';
109
- }
110
- export function stringifyDefault(section) {
111
- var title = section.title,
112
- imports = section.imports,
113
- decorators = section.decorators,
114
- stories = section.stories,
115
- options = _objectWithoutProperties(section, _excluded);
116
-
117
- var decoratorsString = stringifyDecorators(decorators);
118
- var optionsString = stringifyObject(options, 0, true);
119
- return dedent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n export default {\n title: ", ",", "", "\n };\n \n "])), JSON.stringify(title), decoratorsString, optionsString);
120
- }
121
- export function stringifyStory(story) {
122
- var name = story.name,
123
- options = _objectWithoutProperties(story, _excluded2);
124
-
125
- var storyId = identifier(name);
126
- var exportedStory = Object.assign({
127
- name: name
128
- }, options);
129
- var storyStrings = ["export const ".concat(storyId, " = ").concat(stringifyObject(exportedStory), ";"), ''];
130
- return storyStrings.join('\n');
131
- }
132
- export function stringifySection(section) {
133
- var sectionString = [stringifyImports(section.imports), stringifyDefault(section)].concat(_toConsumableArray(section.stories.map(function (story) {
134
- return stringifyStory(story);
135
- }))).join('\n');
136
- return sectionString;
137
- }
File without changes
@@ -1,3 +0,0 @@
1
- import { buildStatic } from '@storybook/core/server';
2
- import options from './options';
3
- buildStatic(options);
@@ -1,18 +0,0 @@
1
- import path from 'path';
2
- import { findDistEsm } from '@storybook/core-common';
3
- export function webpack(config) {
4
- config.module.rules.push({
5
- type: 'javascript/auto',
6
- test: /\.stories\.json$/,
7
- use: path.resolve(__dirname, './loader.js')
8
- });
9
- config.module.rules.push({
10
- type: 'javascript/auto',
11
- test: /\.stories\.ya?ml/,
12
- use: [path.resolve(__dirname, './loader.js'), 'yaml-loader']
13
- });
14
- return config;
15
- }
16
- export var previewAnnotations = function (entry = []) {
17
- return [...entry, findDistEsm(__dirname, 'client/preview/config')];
18
- };
@@ -1,3 +0,0 @@
1
- import { buildDev } from '@storybook/core/server';
2
- import options from './options';
3
- buildDev(options);
@@ -1,4 +0,0 @@
1
- import { compileCsfModule } from '../lib/compiler';
2
- export default (function (content) {
3
- return compileCsfModule(JSON.parse(content));
4
- });
@@ -1,8 +0,0 @@
1
- import { sync } from 'read-pkg-up';
2
- export default {
3
- packageJson: sync({
4
- cwd: __dirname
5
- }).packageJson,
6
- framework: 'server',
7
- frameworkPresets: [require.resolve('./framework-preset-server.js')]
8
- };
@@ -1,5 +0,0 @@
1
- export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw } from './preview';
2
-
3
- if (module && module.hot && module.hot.decline) {
4
- module.hot.decline();
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import { stringifySection } from './stringifier';
2
-
3
- function createSection(args) {
4
- return Object.assign({
5
- imports: {},
6
- decorators: []
7
- }, args);
8
- }
9
-
10
- export function compileCsfModule(args) {
11
- return stringifySection(createSection(args));
12
- }
@@ -1,83 +0,0 @@
1
- const _excluded = ["title", "imports", "decorators", "stories"],
2
- _excluded2 = ["name"];
3
-
4
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
-
6
- import dedent from 'ts-dedent';
7
-
8
- const {
9
- identifier
10
- } = require('safe-identifier');
11
-
12
- export function stringifyObject(object, level = 0, excludeOuterParams = false) {
13
- if (typeof object === 'string') {
14
- return JSON.stringify(object);
15
- }
16
-
17
- const indent = ' '.repeat(level);
18
-
19
- if (Array.isArray(object)) {
20
- const arrayStrings = object.map(item => stringifyObject(item, level + 1));
21
- const arrayString = arrayStrings.join(`,\n${indent} `);
22
- if (excludeOuterParams) return arrayString;
23
- return `[\n${indent} ${arrayString}\n${indent}]`;
24
- }
25
-
26
- if (typeof object === 'object') {
27
- let objectString = '';
28
-
29
- if (Object.keys(object).length > 0) {
30
- const objectStrings = Object.keys(object).map(key => {
31
- const value = stringifyObject(object[key], level + 1);
32
- return `\n${indent} ${key}: ${value}`;
33
- });
34
- objectString = objectStrings.join(',');
35
- }
36
-
37
- if (excludeOuterParams) return objectString;
38
- if (objectString.length === 0) return '{}';
39
- return `{${objectString}\n${indent}}`;
40
- }
41
-
42
- return object;
43
- }
44
- export function stringifyImports(imports) {
45
- if (Object.keys(imports).length === 0) return '';
46
- return Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(', ')} } from '${module}';\n`).join('');
47
- }
48
- export function stringifyDecorators(decorators) {
49
- return decorators && decorators.length > 0 ? `\n decorators: [\n ${decorators.join(',\n ')}\n ],` : '';
50
- }
51
- export function stringifyDefault(section) {
52
- const {
53
- title,
54
- decorators
55
- } = section,
56
- options = _objectWithoutPropertiesLoose(section, _excluded);
57
-
58
- const decoratorsString = stringifyDecorators(decorators);
59
- const optionsString = stringifyObject(options, 0, true);
60
- return dedent`
61
- export default {
62
- title: ${JSON.stringify(title)},${decoratorsString}${optionsString}
63
- };
64
-
65
- `;
66
- }
67
- export function stringifyStory(story) {
68
- const {
69
- name
70
- } = story,
71
- options = _objectWithoutPropertiesLoose(story, _excluded2);
72
-
73
- const storyId = identifier(name);
74
- const exportedStory = Object.assign({
75
- name
76
- }, options);
77
- const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ''];
78
- return storyStrings.join('\n');
79
- }
80
- export function stringifySection(section) {
81
- const sectionString = [stringifyImports(section.imports), stringifyDefault(section), ...section.stories.map(story => stringifyStory(story))].join('\n');
82
- return sectionString;
83
- }
File without changes
@@ -1,3 +0,0 @@
1
- import { buildStatic } from '@storybook/core/server';
2
- import options from './options';
3
- buildStatic(options);
@@ -1,18 +0,0 @@
1
- import path from 'path';
2
- import { findDistEsm } from '@storybook/core-common';
3
- export function webpack(config) {
4
- config.module.rules.push({
5
- type: 'javascript/auto',
6
- test: /\.stories\.json$/,
7
- use: path.resolve(__dirname, './loader.js')
8
- });
9
- config.module.rules.push({
10
- type: 'javascript/auto',
11
- test: /\.stories\.ya?ml/,
12
- use: [path.resolve(__dirname, './loader.js'), 'yaml-loader']
13
- });
14
- return config;
15
- }
16
- export var previewAnnotations = function (entry = []) {
17
- return [...entry, findDistEsm(__dirname, 'client/preview/config')];
18
- };
@@ -1,3 +0,0 @@
1
- import { buildDev } from '@storybook/core/server';
2
- import options from './options';
3
- buildDev(options);
@@ -1,4 +0,0 @@
1
- import { compileCsfModule } from '../lib/compiler';
2
- export default (function (content) {
3
- return compileCsfModule(JSON.parse(content));
4
- });
@@ -1,8 +0,0 @@
1
- import { sync } from 'read-pkg-up';
2
- export default {
3
- packageJson: sync({
4
- cwd: __dirname
5
- }).packageJson,
6
- framework: 'server',
7
- frameworkPresets: [require.resolve('./framework-preset-server.js')]
8
- };
@@ -1 +0,0 @@
1
- export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, } from './preview';
@@ -1,4 +0,0 @@
1
- export { render, renderToDOM } from './render';
2
- export declare const parameters: {
3
- framework: string;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- /// <reference types="webpack-env" />
2
- /// <reference types="node" />
3
- import { ClientStoryApi, Loadable } from '@storybook/addons';
4
- import './globals';
5
- import { IStorybookSection, ServerFramework } from './types';
6
- interface ClientApi extends ClientStoryApi<ServerFramework['storyResult']> {
7
- setAddon(addon: any): void;
8
- configure(loader: Loadable, module: NodeModule): void;
9
- getStorybook(): IStorybookSection[];
10
- clearDecorators(): void;
11
- forceReRender(): void;
12
- raw: () => any;
13
- }
14
- export declare const storiesOf: ClientApi['storiesOf'];
15
- export declare const configure: ClientApi['configure'];
16
- export declare const addDecorator: (() => never) | ((decorator: import("@storybook/csf").DecoratorFunction<ServerFramework, import("@storybook/addons").Args>) => void), addParameters: (({ globals, globalTypes, ...parameters }: import("@storybook/csf").Parameters & {
17
- globals?: import("@storybook/csf").Globals;
18
- globalTypes?: import("@storybook/csf").GlobalTypes;
19
- }) => void) | (() => never), clearDecorators: (() => void) | (() => never), setAddon: ((addon: any) => void) | (() => never), getStorybook: (() => never) | (() => import("@storybook/client-api/dist/ts3.9/ClientApi").GetStorybookKind<ServerFramework>[]), raw: (() => never) | (() => import("@storybook/store").BoundStory<ServerFramework>[]);
20
- export declare const forceReRender: (() => never) | (() => void);
21
- export {};
@@ -1,5 +0,0 @@
1
- import { RenderContext } from '@storybook/store';
2
- import { StoryFn } from '@storybook/csf';
3
- import { ServerFramework } from './types';
4
- export declare const render: StoryFn<ServerFramework>;
5
- export declare function renderToDOM({ id, title, name, showMain, showError, forceRemount, storyFn, storyContext, storyContext: { parameters, args, argTypes }, }: RenderContext<ServerFramework>, domElement: HTMLElement): Promise<void>;
@@ -1,20 +0,0 @@
1
- import { StoryContext } from '@storybook/csf';
2
- export { RenderContext } from '@storybook/core';
3
- export declare type StoryFnServerReturnType = any;
4
- export declare type ServerFramework = {
5
- component: string;
6
- storyResult: StoryFnServerReturnType;
7
- };
8
- export declare type FetchStoryHtmlType = (url: string, id: string, params: any, context: StoryContext<ServerFramework>) => Promise<string | Node>;
9
- export interface IStorybookStory {
10
- name: string;
11
- render: (context: any) => any;
12
- }
13
- export interface IStorybookSection {
14
- kind: string;
15
- stories: IStorybookStory[];
16
- }
17
- export interface ShowErrorArgs {
18
- title: string;
19
- description: string;
20
- }
@@ -1,2 +0,0 @@
1
- import { CompileCsfModuleArgs } from './types';
2
- export declare function compileCsfModule(args: CompileCsfModuleArgs): string;
@@ -1,7 +0,0 @@
1
- import { StorybookStory, StorybookSection } from './types';
2
- export declare function stringifyObject(object: any, level?: number, excludeOuterParams?: boolean): string;
3
- export declare function stringifyImports(imports: Record<string, string[]>): string;
4
- export declare function stringifyDecorators(decorators: string[]): string;
5
- export declare function stringifyDefault(section: StorybookSection): string;
6
- export declare function stringifyStory(story: StorybookStory): string;
7
- export declare function stringifySection(section: StorybookSection): string;
@@ -1,24 +0,0 @@
1
- export interface CompileStorybookStoryArgs {
2
- name: string;
3
- [x: string]: any;
4
- }
5
- export interface CompileStorybookSectionArgs {
6
- title: string;
7
- stories: CompileStorybookStoryArgs[];
8
- [x: string]: any;
9
- }
10
- export interface CompileCsfModuleArgs extends CompileStorybookSectionArgs {
11
- addons?: string[];
12
- }
13
- export interface StorybookStory {
14
- name: string;
15
- decorators?: string[];
16
- [x: string]: any;
17
- }
18
- export interface StorybookSection {
19
- imports: Record<string, string[]>;
20
- decorators?: string[];
21
- title: string;
22
- stories: StorybookStory[];
23
- [x: string]: any;
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { StorybookConfig } from '@storybook/core-common';
2
- import { Configuration } from 'webpack';
3
- export declare function webpack(config: Configuration): Configuration;
4
- export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: (content: string) => string;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import { LoadOptions } from '@storybook/core-common';
2
- declare const _default: LoadOptions;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- import { CompileCsfModuleArgs } from './types';
2
- export declare function compileCsfModule(args: CompileCsfModuleArgs): string;
@@ -1,7 +0,0 @@
1
- import { StorybookStory, StorybookSection } from './types';
2
- export declare function stringifyObject(object: any, level?: number, excludeOuterParams?: boolean): string;
3
- export declare function stringifyImports(imports: Record<string, string[]>): string;
4
- export declare function stringifyDecorators(decorators: string[]): string;
5
- export declare function stringifyDefault(section: StorybookSection): string;
6
- export declare function stringifyStory(story: StorybookStory): string;
7
- export declare function stringifySection(section: StorybookSection): string;