@storybook/server 7.0.0-alpha.1 → 7.0.0-alpha.4
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
|
@@ -5,49 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "addDecorator", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _preview.addDecorator;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "addParameters", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _preview.addParameters;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "configure", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _preview.configure;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "forceReRender", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _preview.forceReRender;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "getStorybook", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _preview.getStorybook;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "raw", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _preview.raw;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "setAddon", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function
|
|
44
|
+
get: function () {
|
|
45
45
|
return _preview.setAddon;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "storiesOf", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function
|
|
50
|
+
get: function () {
|
|
51
51
|
return _preview.storiesOf;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.parameters = void 0;
|
|
7
7
|
Object.defineProperty(exports, "render", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function
|
|
9
|
+
get: function () {
|
|
10
10
|
return _render.render;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "renderToDOM", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function
|
|
15
|
+
get: function () {
|
|
16
16
|
return _render.renderToDOM;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
var _render = require("./render");
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const parameters = {
|
|
23
23
|
framework: 'server'
|
|
24
24
|
};
|
|
25
25
|
exports.parameters = parameters;
|
|
@@ -4,5 +4,7 @@ var _global = _interopRequireDefault(require("global"));
|
|
|
4
4
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const {
|
|
8
|
+
window: globalWindow
|
|
9
|
+
} = _global.default;
|
|
8
10
|
globalWindow.STORYBOOK_ENV = 'SERVER';
|
|
@@ -5,48 +5,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clearDecorators = exports.addParameters = exports.addDecorator = void 0;
|
|
7
7
|
|
|
8
|
-
require("core-js/modules/es.array.concat.js");
|
|
9
|
-
|
|
10
8
|
var _coreClient = require("@storybook/core-client");
|
|
11
9
|
|
|
12
10
|
require("./globals");
|
|
13
11
|
|
|
14
12
|
var _render = require("./render");
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const framework = 'server';
|
|
15
|
+
const api = (0, _coreClient.start)(_render.renderToDOM, {
|
|
18
16
|
render: _render.render
|
|
19
17
|
});
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
const storiesOf = (kind, m) => {
|
|
22
20
|
return api.clientApi.storiesOf(kind, m).addParameters({
|
|
23
|
-
framework
|
|
21
|
+
framework
|
|
24
22
|
});
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
exports.storiesOf = storiesOf;
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
-
args[_key] = arguments[_key];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return api.configure.apply(api, [framework].concat(args));
|
|
35
|
-
};
|
|
27
|
+
const configure = (...args) => api.configure(framework, ...args);
|
|
36
28
|
|
|
37
29
|
exports.configure = configure;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
const {
|
|
31
|
+
addDecorator,
|
|
32
|
+
addParameters,
|
|
33
|
+
clearDecorators,
|
|
34
|
+
setAddon,
|
|
35
|
+
getStorybook,
|
|
36
|
+
raw
|
|
37
|
+
} = api.clientApi;
|
|
45
38
|
exports.raw = raw;
|
|
46
39
|
exports.getStorybook = getStorybook;
|
|
47
40
|
exports.setAddon = setAddon;
|
|
48
41
|
exports.clearDecorators = clearDecorators;
|
|
49
42
|
exports.addParameters = addParameters;
|
|
50
43
|
exports.addDecorator = addDecorator;
|
|
51
|
-
|
|
44
|
+
const {
|
|
45
|
+
forceReRender
|
|
46
|
+
} = api;
|
|
52
47
|
exports.forceReRender = forceReRender;
|
|
@@ -1,120 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.array.slice.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.object.freeze.js");
|
|
24
|
-
|
|
25
3
|
Object.defineProperty(exports, "__esModule", {
|
|
26
4
|
value: true
|
|
27
5
|
});
|
|
28
6
|
exports.render = void 0;
|
|
29
7
|
exports.renderToDOM = renderToDOM;
|
|
30
8
|
|
|
31
|
-
require("core-js/modules/es.object.to-string.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.promise.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/es.array.iterator.js");
|
|
36
|
-
|
|
37
|
-
require("core-js/modules/es.string.iterator.js");
|
|
38
|
-
|
|
39
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
40
|
-
|
|
41
|
-
require("core-js/modules/web.url.js");
|
|
42
|
-
|
|
43
|
-
require("core-js/modules/web.url-search-params.js");
|
|
44
|
-
|
|
45
|
-
require("core-js/modules/es.array.concat.js");
|
|
46
|
-
|
|
47
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
48
|
-
|
|
49
|
-
require("core-js/modules/es.string.search.js");
|
|
50
|
-
|
|
51
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
52
|
-
|
|
53
|
-
require("core-js/modules/es.object.assign.js");
|
|
54
|
-
|
|
55
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
56
|
-
|
|
57
|
-
require("core-js/modules/es.object.keys.js");
|
|
58
|
-
|
|
59
|
-
require("core-js/modules/es.function.name.js");
|
|
60
|
-
|
|
61
9
|
var _global = _interopRequireDefault(require("global"));
|
|
62
10
|
|
|
63
11
|
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
64
12
|
|
|
65
13
|
var _previewWeb = require("@storybook/preview-web");
|
|
66
14
|
|
|
67
|
-
var _templateObject;
|
|
68
|
-
|
|
69
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
70
16
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
case 4:
|
|
95
|
-
response = _context.sent;
|
|
96
|
-
return _context.abrupt("return", response.text());
|
|
97
|
-
|
|
98
|
-
case 6:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context.stop();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, _callee);
|
|
104
|
-
}));
|
|
105
|
-
|
|
106
|
-
return function defaultFetchStoryHtml(_x, _x2, _x3, _x4) {
|
|
107
|
-
return _ref.apply(this, arguments);
|
|
108
|
-
};
|
|
109
|
-
}();
|
|
110
|
-
|
|
111
|
-
var buildStoryArgs = function buildStoryArgs(args, argTypes) {
|
|
112
|
-
var storyArgs = Object.assign({}, args);
|
|
113
|
-
Object.keys(argTypes).forEach(function (key) {
|
|
114
|
-
var argType = argTypes[key];
|
|
115
|
-
var control = argType.control;
|
|
116
|
-
var controlType = control && control.type.toLowerCase();
|
|
117
|
-
var argValue = storyArgs[key];
|
|
17
|
+
/* eslint-disable no-param-reassign */
|
|
18
|
+
const {
|
|
19
|
+
fetch,
|
|
20
|
+
Node
|
|
21
|
+
} = _global.default;
|
|
22
|
+
|
|
23
|
+
const defaultFetchStoryHtml = async (url, path, params, storyContext) => {
|
|
24
|
+
const fetchUrl = new URL(`${url}/${path}`);
|
|
25
|
+
fetchUrl.search = new URLSearchParams(Object.assign({}, storyContext.globals, params)).toString();
|
|
26
|
+
const response = await fetch(fetchUrl);
|
|
27
|
+
return response.text();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const buildStoryArgs = (args, argTypes) => {
|
|
31
|
+
const storyArgs = Object.assign({}, args);
|
|
32
|
+
Object.keys(argTypes).forEach(key => {
|
|
33
|
+
const argType = argTypes[key];
|
|
34
|
+
const {
|
|
35
|
+
control
|
|
36
|
+
} = argType;
|
|
37
|
+
const controlType = control && control.type.toLowerCase();
|
|
38
|
+
const argValue = storyArgs[key];
|
|
118
39
|
|
|
119
40
|
switch (controlType) {
|
|
120
41
|
case 'date':
|
|
@@ -133,78 +54,60 @@ var buildStoryArgs = function buildStoryArgs(args, argTypes) {
|
|
|
133
54
|
return storyArgs;
|
|
134
55
|
};
|
|
135
56
|
|
|
136
|
-
|
|
57
|
+
const render = args => {};
|
|
137
58
|
|
|
138
59
|
exports.render = render;
|
|
139
60
|
|
|
140
|
-
function renderToDOM(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
(0, _previewWeb.simulateDOMContentLoaded)();
|
|
193
|
-
_context2.next = 24;
|
|
194
|
-
break;
|
|
195
|
-
|
|
196
|
-
case 23:
|
|
197
|
-
showError({
|
|
198
|
-
title: "Expecting an HTML snippet or DOM node from the story: \"".concat(name, "\" of \"").concat(title, "\"."),
|
|
199
|
-
description: (0, _tsDedent.default)(_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 "])))
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
case 24:
|
|
203
|
-
case "end":
|
|
204
|
-
return _context2.stop();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}, _callee2);
|
|
208
|
-
}));
|
|
209
|
-
return _renderToDOM.apply(this, arguments);
|
|
61
|
+
async function renderToDOM({
|
|
62
|
+
id,
|
|
63
|
+
title,
|
|
64
|
+
name,
|
|
65
|
+
showMain,
|
|
66
|
+
showError,
|
|
67
|
+
forceRemount,
|
|
68
|
+
storyFn,
|
|
69
|
+
storyContext,
|
|
70
|
+
storyContext: {
|
|
71
|
+
parameters,
|
|
72
|
+
args,
|
|
73
|
+
argTypes
|
|
74
|
+
}
|
|
75
|
+
}, domElement) {
|
|
76
|
+
// Some addons wrap the storyFn so we need to call it even though Server doesn't need the answer
|
|
77
|
+
storyFn();
|
|
78
|
+
const storyArgs = buildStoryArgs(args, argTypes);
|
|
79
|
+
const {
|
|
80
|
+
server: {
|
|
81
|
+
url,
|
|
82
|
+
id: storyId,
|
|
83
|
+
fetchStoryHtml = defaultFetchStoryHtml,
|
|
84
|
+
params
|
|
85
|
+
}
|
|
86
|
+
} = parameters;
|
|
87
|
+
const fetchId = storyId || id;
|
|
88
|
+
const storyParams = Object.assign({}, params, storyArgs);
|
|
89
|
+
const element = await fetchStoryHtml(url, fetchId, storyParams, storyContext);
|
|
90
|
+
showMain();
|
|
91
|
+
|
|
92
|
+
if (typeof element === 'string') {
|
|
93
|
+
domElement.innerHTML = element;
|
|
94
|
+
(0, _previewWeb.simulatePageLoad)(domElement);
|
|
95
|
+
} else if (element instanceof Node) {
|
|
96
|
+
// Don't re-mount the element if it didn't change and neither did the story
|
|
97
|
+
if (domElement.firstChild === element && forceRemount === false) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
domElement.innerHTML = '';
|
|
102
|
+
domElement.appendChild(element);
|
|
103
|
+
(0, _previewWeb.simulateDOMContentLoaded)();
|
|
104
|
+
} else {
|
|
105
|
+
showError({
|
|
106
|
+
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${title}".`,
|
|
107
|
+
description: (0, _tsDedent.default)`
|
|
108
|
+
Did you forget to return the HTML snippet from the story?
|
|
109
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
110
|
+
`
|
|
111
|
+
});
|
|
112
|
+
}
|
|
210
113
|
}
|
|
@@ -2,4 +2,4 @@ import type { RenderContext } from '@storybook/store';
|
|
|
2
2
|
import type { StoryFn } from '@storybook/csf';
|
|
3
3
|
import type { ServerFramework } from './types';
|
|
4
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:
|
|
5
|
+
export declare function renderToDOM({ id, title, name, showMain, showError, forceRemount, storyFn, storyContext, storyContext: { parameters, args, argTypes }, }: RenderContext<ServerFramework>, domElement: Element): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/server",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
4
4
|
"description": "Storybook Server renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -32,16 +32,15 @@
|
|
|
32
32
|
"prepare": "node ../../scripts/prepare.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
36
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
35
|
+
"@storybook/addons": "7.0.0-alpha.4",
|
|
36
|
+
"@storybook/core-client": "7.0.0-alpha.4",
|
|
37
37
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
38
|
-
"@storybook/preview-web": "7.0.0-alpha.
|
|
39
|
-
"@storybook/store": "7.0.0-alpha.
|
|
38
|
+
"@storybook/preview-web": "7.0.0-alpha.4",
|
|
39
|
+
"@storybook/store": "7.0.0-alpha.4",
|
|
40
40
|
"core-js": "^3.8.2",
|
|
41
41
|
"global": "^4.4.0",
|
|
42
42
|
"react": "16.14.0",
|
|
43
43
|
"react-dom": "16.14.0",
|
|
44
|
-
"regenerator-runtime": "^0.13.7",
|
|
45
44
|
"ts-dedent": "^2.0.0"
|
|
46
45
|
},
|
|
47
46
|
"engines": {
|
|
@@ -50,5 +49,5 @@
|
|
|
50
49
|
"publishConfig": {
|
|
51
50
|
"access": "public"
|
|
52
51
|
},
|
|
53
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "006ed54452dd7c37a8cbe91a84f5312182f7ca00"
|
|
54
53
|
}
|