@storybook/preset-server-webpack 7.0.0-alpha.0 → 7.0.0-alpha.3

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/dist/cjs/index.js CHANGED
@@ -9,7 +9,7 @@ var _path = _interopRequireDefault(require("path"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- var webpack = function webpack(config) {
12
+ const webpack = config => {
13
13
  config.module.rules.push({
14
14
  type: 'javascript/auto',
15
15
  test: /\.stories\.json$/,
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.compileCsfModule = compileCsfModule;
7
7
 
8
- require("core-js/modules/es.object.assign.js");
9
-
10
8
  var _stringifier = require("./stringifier");
11
9
 
12
10
  function createSection(args) {
@@ -1,27 +1,5 @@
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");
10
-
11
- require("core-js/modules/es.array.iterator.js");
12
-
13
- require("core-js/modules/es.string.iterator.js");
14
-
15
- require("core-js/modules/web.dom-collections.iterator.js");
16
-
17
- require("core-js/modules/es.array.slice.js");
18
-
19
- require("core-js/modules/es.array.from.js");
20
-
21
- require("core-js/modules/es.regexp.exec.js");
22
-
23
- require("core-js/modules/es.object.freeze.js");
24
-
25
3
  Object.defineProperty(exports, "__esModule", {
26
4
  value: true
27
5
  });
@@ -32,97 +10,47 @@ exports.stringifyObject = stringifyObject;
32
10
  exports.stringifySection = stringifySection;
33
11
  exports.stringifyStory = stringifyStory;
34
12
 
35
- require("core-js/modules/es.string.repeat.js");
36
-
37
- require("core-js/modules/es.array.map.js");
38
-
39
- require("core-js/modules/es.array.join.js");
40
-
41
- require("core-js/modules/es.array.concat.js");
42
-
43
- require("core-js/modules/es.object.keys.js");
44
-
45
- require("core-js/modules/es.object.entries.js");
46
-
47
- require("core-js/modules/es.array.sort.js");
48
-
49
- require("core-js/modules/es.function.name.js");
50
-
51
- require("core-js/modules/es.object.assign.js");
52
-
53
13
  var _tsDedent = _interopRequireDefault(require("ts-dedent"));
54
14
 
55
- var _templateObject;
56
-
57
- var _excluded = ["title", "imports", "decorators", "stories"],
58
- _excluded2 = ["name"];
15
+ const _excluded = ["title", "imports", "decorators", "stories"],
16
+ _excluded2 = ["name"];
59
17
 
60
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
19
 
62
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
63
-
64
- 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."); }
65
-
66
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
67
-
68
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
69
-
70
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
71
-
72
- 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; }
73
-
74
20
  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; }
75
21
 
76
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
77
-
78
- 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."); }
79
-
80
- 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); }
81
-
82
- 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; }
83
-
84
- 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; }
85
-
86
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
87
-
88
- 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); }
89
-
90
- var _require = require('safe-identifier'),
91
- identifier = _require.identifier;
92
-
93
- function stringifyObject(object) {
94
- var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
95
- var excludeOuterParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
22
+ const {
23
+ identifier
24
+ } = require('safe-identifier');
96
25
 
26
+ function stringifyObject(object, level = 0, excludeOuterParams = false) {
97
27
  if (typeof object === 'string') {
98
28
  return JSON.stringify(object);
99
29
  }
100
30
 
101
- var indent = ' '.repeat(level);
31
+ const indent = ' '.repeat(level);
102
32
 
103
33
  if (Array.isArray(object)) {
104
- var arrayStrings = object.map(function (item) {
105
- return stringifyObject(item, level + 1);
106
- });
107
- var arrayString = arrayStrings.join(",\n".concat(indent, " "));
34
+ const arrayStrings = object.map(item => stringifyObject(item, level + 1));
35
+ const arrayString = arrayStrings.join(`,\n${indent} `);
108
36
  if (excludeOuterParams) return arrayString;
109
- return "[\n".concat(indent, " ").concat(arrayString, "\n").concat(indent, "]");
37
+ return `[\n${indent} ${arrayString}\n${indent}]`;
110
38
  }
111
39
 
112
- if (_typeof(object) === 'object') {
113
- var objectString = '';
40
+ if (typeof object === 'object') {
41
+ let objectString = '';
114
42
 
115
43
  if (Object.keys(object).length > 0) {
116
- var objectStrings = Object.keys(object).map(function (key) {
117
- var value = stringifyObject(object[key], level + 1);
118
- return "\n".concat(indent, " ").concat(key, ": ").concat(value);
44
+ const objectStrings = Object.keys(object).map(key => {
45
+ const value = stringifyObject(object[key], level + 1);
46
+ return `\n${indent} ${key}: ${value}`;
119
47
  });
120
48
  objectString = objectStrings.join(',');
121
49
  }
122
50
 
123
51
  if (excludeOuterParams) return objectString;
124
52
  if (objectString.length === 0) return '{}';
125
- return "{".concat(objectString, "\n").concat(indent, "}");
53
+ return `{${objectString}\n${indent}}`;
126
54
  }
127
55
 
128
56
  return object;
@@ -130,46 +58,45 @@ function stringifyObject(object) {
130
58
 
131
59
  function stringifyImports(imports) {
132
60
  if (Object.keys(imports).length === 0) return '';
133
- return Object.entries(imports).map(function (_ref) {
134
- var _ref2 = _slicedToArray(_ref, 2),
135
- module = _ref2[0],
136
- names = _ref2[1];
137
-
138
- return "import { ".concat(names.sort().join(', '), " } from '").concat(module, "';\n");
139
- }).join('');
61
+ return Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(', ')} } from '${module}';\n`).join('');
140
62
  }
141
63
 
142
64
  function stringifyDecorators(decorators) {
143
- return decorators && decorators.length > 0 ? "\n decorators: [\n ".concat(decorators.join(',\n '), "\n ],") : '';
65
+ return decorators && decorators.length > 0 ? `\n decorators: [\n ${decorators.join(',\n ')}\n ],` : '';
144
66
  }
145
67
 
146
68
  function stringifyDefault(section) {
147
- var title = section.title,
148
- imports = section.imports,
149
- decorators = section.decorators,
150
- stories = section.stories,
151
- options = _objectWithoutProperties(section, _excluded);
152
-
153
- var decoratorsString = stringifyDecorators(decorators);
154
- var optionsString = stringifyObject(options, 0, true);
155
- return (0, _tsDedent.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n export default {\n title: ", ",", "", "\n };\n \n "])), JSON.stringify(title), decoratorsString, optionsString);
69
+ const {
70
+ title,
71
+ decorators
72
+ } = section,
73
+ options = _objectWithoutPropertiesLoose(section, _excluded);
74
+
75
+ const decoratorsString = stringifyDecorators(decorators);
76
+ const optionsString = stringifyObject(options, 0, true);
77
+ return (0, _tsDedent.default)`
78
+ export default {
79
+ title: ${JSON.stringify(title)},${decoratorsString}${optionsString}
80
+ };
81
+
82
+ `;
156
83
  }
157
84
 
158
85
  function stringifyStory(story) {
159
- var name = story.name,
160
- options = _objectWithoutProperties(story, _excluded2);
161
-
162
- var storyId = identifier(name);
163
- var exportedStory = Object.assign({
164
- name: name
86
+ const {
87
+ name
88
+ } = story,
89
+ options = _objectWithoutPropertiesLoose(story, _excluded2);
90
+
91
+ const storyId = identifier(name);
92
+ const exportedStory = Object.assign({
93
+ name
165
94
  }, options);
166
- var storyStrings = ["export const ".concat(storyId, " = ").concat(stringifyObject(exportedStory), ";"), ''];
95
+ const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ''];
167
96
  return storyStrings.join('\n');
168
97
  }
169
98
 
170
99
  function stringifySection(section) {
171
- var sectionString = [stringifyImports(section.imports), stringifyDefault(section)].concat(_toConsumableArray(section.stories.map(function (story) {
172
- return stringifyStory(story);
173
- }))).join('\n');
100
+ const sectionString = [stringifyImports(section.imports), stringifyDefault(section), ...section.stories.map(story => stringifyStory(story))].join('\n');
174
101
  return sectionString;
175
102
  }
@@ -7,9 +7,9 @@ exports.default = void 0;
7
7
 
8
8
  var _compiler = require("./lib/compiler");
9
9
 
10
- var _default = function _default(content) {
10
+ var _default = content => {
11
11
  try {
12
- var after = (0, _compiler.compileCsfModule)(JSON.parse(content));
12
+ const after = (0, _compiler.compileCsfModule)(JSON.parse(content));
13
13
  return after;
14
14
  } catch (e) {//
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preset-server-webpack",
3
- "version": "7.0.0-alpha.0",
3
+ "version": "7.0.0-alpha.3",
4
4
  "description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -32,9 +32,9 @@
32
32
  "prepare": "node ../../scripts/prepare.js"
33
33
  },
34
34
  "dependencies": {
35
- "@storybook/core-server": "7.0.0-alpha.0",
36
- "@storybook/core-webpack": "7.0.0-alpha.0",
37
- "@storybook/server": "7.0.0-alpha.0",
35
+ "@storybook/core-server": "7.0.0-alpha.3",
36
+ "@storybook/core-webpack": "7.0.0-alpha.3",
37
+ "@storybook/server": "7.0.0-alpha.3",
38
38
  "@types/node": "^14.14.20 || ^16.0.0",
39
39
  "core-js": "^3.8.2",
40
40
  "global": "^4.4.0",
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "c82d897ea765da8cf4fbbcc2af1f28c808a93e23"
59
+ "gitHead": "629b056190993bcee6445471b8cb27208eb401a9"
60
60
  }