@storybook/preset-server-webpack 7.0.0-alpha.6 → 7.0.0-alpha.7
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/chunk-GWWZJCUF.mjs +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/{types/loader.d.ts → loader.d.ts} +2 -1
- package/dist/loader.js +18 -0
- package/dist/loader.mjs +18 -0
- package/package.json +36 -9
- package/preset.js +1 -1
- package/dist/cjs/index.js +0 -31
- package/dist/cjs/lib/compiler/index.js +0 -19
- package/dist/cjs/lib/compiler/stringifier.js +0 -102
- package/dist/cjs/lib/compiler/types.js +0 -1
- package/dist/cjs/loader.js +0 -20
- package/dist/esm/index.js +0 -17
- package/dist/esm/lib/compiler/index.js +0 -12
- package/dist/esm/lib/compiler/stringifier.js +0 -83
- package/dist/esm/lib/compiler/types.js +0 -0
- package/dist/esm/loader.js +0 -10
- package/dist/types/index.d.ts +0 -2
- package/dist/types/lib/compiler/index.d.ts +0 -2
- package/dist/types/lib/compiler/stringifier.d.ts +0 -7
- package/dist/types/lib/compiler/types.d.ts +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var e=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;var f=(a,b,c)=>b in a?g(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,j=(a,b)=>{for(var c in b||(b={}))h.call(b,c)&&f(a,c,b[c]);if(e)for(var c of e(b))i.call(b,c)&&f(a,c,b[c]);return a};var k=(a,b)=>g(a,"name",{value:b,configurable:!0}),l=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});var m=(a,b)=>{var c={};for(var d in a)h.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(a!=null&&e)for(var d of e(a))b.indexOf(d)<0&&i.call(a,d)&&(c[d]=a[d]);return c};export{j as a,k as b,l as c,m as d};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.create;var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var i=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var a=(e,r)=>u(e,"name",{value:r,configurable:!0});var q=(e,r)=>{for(var s in r)u(e,s,{get:r[s],enumerable:!0})},p=(e,r,s,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!j.call(e,t)&&t!==s&&u(e,t,{get:()=>r[t],enumerable:!(l=v(r,t))||l.enumerable});return e};var o=(e,r,s)=>(s=e!=null?m(i(e)):{},p(r||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),x=e=>p(u({},"__esModule",{value:!0}),e);var c={};q(c,{webpack:()=>b});module.exports=x(c);var b=a(e=>{var s;let r=[...((s=e.module)==null?void 0:s.rules)||[],{type:"javascript/auto",test:/\.stories\.json$/,use:require.resolve("@storybook/preset-server-webpack/dist/loader")},{type:"javascript/auto",test:/\.stories\.ya?ml/,use:[require.resolve("@storybook/preset-server-webpack/dist/loader"),require.resolve("yaml-loader")]}];return e.module=e.module||{},e.module.rules=r,e},"webpack");0&&(module.exports={webpack});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as t,c as r}from"./chunk-GWWZJCUF.mjs";var a=t(e=>{var s;let o=[...((s=e.module)==null?void 0:s.rules)||[],{type:"javascript/auto",test:/\.stories\.json$/,use:r.resolve("@storybook/preset-server-webpack/dist/loader")},{type:"javascript/auto",test:/\.stories\.ya?ml/,use:[r.resolve("@storybook/preset-server-webpack/dist/loader"),r.resolve("yaml-loader")]}];return e.module=e.module||{},e.module.rules=o,e},"webpack");export{a as webpack};
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var J=Object.create;var c=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,A=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var $=(t,r,n)=>r in t?c(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,p=(t,r)=>{for(var n in r||(r={}))y.call(r,n)&&$(t,n,r[n]);if(u)for(var n of u(r))d.call(r,n)&&$(t,n,r[n]);return t};var e=(t,r)=>c(t,"name",{value:r,configurable:!0});var S=(t,r)=>{var n={};for(var i in t)y.call(t,i)&&r.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&u)for(var i of u(t))r.indexOf(i)<0&&d.call(t,i)&&(n[i]=t[i]);return n};var C=(t,r)=>{for(var n in r)c(t,n,{get:r[n],enumerable:!0})},l=(t,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of k(r))!y.call(t,o)&&o!==n&&c(t,o,{get:()=>r[o],enumerable:!(i=N(r,o))||i.enumerable});return t};var D=(t,r,n)=>(n=t!=null?J(A(t)):{},l(r||!t||!t.__esModule?c(n,"default",{value:t,enumerable:!0}):n,t)),I=t=>l(c({},"__esModule",{value:!0}),t);var F={};C(F,{default:()=>E});module.exports=I(F);var j=D(require("ts-dedent")),{identifier:M}=require("safe-identifier");function g(t,r=0,n=!1){if(typeof t=="string")return JSON.stringify(t);let i=" ".repeat(r);if(Array.isArray(t)){let f=t.map(s=>g(s,r+1)).join(`,
|
|
2
|
+
${i} `);return n?f:`[
|
|
3
|
+
${i} ${f}
|
|
4
|
+
${i}]`}if(typeof t=="object"){let o="";return Object.keys(t).length>0&&(o=Object.keys(t).map(s=>{let a=g(t[s],r+1);return`
|
|
5
|
+
${i} ${s}: ${a}`}).join(",")),n?o:o.length===0?"{}":`{${o}
|
|
6
|
+
${i}}`}return t}e(g,"stringifyObject");function b(t){return Object.keys(t).length===0?"":Object.entries(t).map(([r,n])=>`import { ${n.sort().join(", ")} } from '${r}';
|
|
7
|
+
`).join("")}e(b,"stringifyImports");function q(t){return t&&t.length>0?`
|
|
8
|
+
decorators: [
|
|
9
|
+
${t.join(`,
|
|
10
|
+
`)}
|
|
11
|
+
],`:""}e(q,"stringifyDecorators");function w(t){let m=t,{title:r,imports:n,decorators:i,stories:o}=m,f=S(m,["title","imports","decorators","stories"]),s=q(i),a=g(f,0,!0);return j.default`
|
|
12
|
+
export default {
|
|
13
|
+
title: ${JSON.stringify(r)},${s}${a}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
`}e(w,"stringifyDefault");function z(t){let s=t,{name:r}=s,n=S(s,["name"]),i=M(r),o=p({name:r},n);return[`export const ${i} = ${g(o)};`,""].join(`
|
|
17
|
+
`)}e(z,"stringifyStory");function O(t){return[b(t.imports),w(t),...t.stories.map(n=>z(n))].join(`
|
|
18
|
+
`)}e(O,"stringifySection");function B(t){return p({imports:{},decorators:[]},t)}e(B,"createSection");function h(t){return O(B(t))}e(h,"compileCsfModule");var E=e(t=>{try{return h(JSON.parse(t))}catch{}return t},"default");0&&(module.exports={});
|
package/dist/loader.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{a as c,b as n,c as d,d as g}from"./chunk-GWWZJCUF.mjs";import l from"ts-dedent";var{identifier:x}=d("safe-identifier");function u(t,r=0,i=!1){if(typeof t=="string")return JSON.stringify(t);let o=" ".repeat(r);if(Array.isArray(t)){let f=t.map(e=>u(e,r+1)).join(`,
|
|
2
|
+
${o} `);return i?f:`[
|
|
3
|
+
${o} ${f}
|
|
4
|
+
${o}]`}if(typeof t=="object"){let s="";return Object.keys(t).length>0&&(s=Object.keys(t).map(e=>{let p=u(t[e],r+1);return`
|
|
5
|
+
${o} ${e}: ${p}`}).join(",")),i?s:s.length===0?"{}":`{${s}
|
|
6
|
+
${o}}`}return t}n(u,"stringifyObject");function j(t){return Object.keys(t).length===0?"":Object.entries(t).map(([r,i])=>`import { ${i.sort().join(", ")} } from '${r}';
|
|
7
|
+
`).join("")}n(j,"stringifyImports");function O(t){return t&&t.length>0?`
|
|
8
|
+
decorators: [
|
|
9
|
+
${t.join(`,
|
|
10
|
+
`)}
|
|
11
|
+
],`:""}n(O,"stringifyDecorators");function h(t){let a=t,{title:r,imports:i,decorators:o,stories:s}=a,f=g(a,["title","imports","decorators","stories"]),e=O(o),p=u(f,0,!0);return l`
|
|
12
|
+
export default {
|
|
13
|
+
title: ${JSON.stringify(r)},${e}${p}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
`}n(h,"stringifyDefault");function J(t){let e=t,{name:r}=e,i=g(e,["name"]),o=x(r),s=c({name:r},i);return[`export const ${o} = ${u(s)};`,""].join(`
|
|
17
|
+
`)}n(J,"stringifyStory");function m(t){return[j(t.imports),h(t),...t.stories.map(i=>J(i))].join(`
|
|
18
|
+
`)}n(m,"stringifySection");function N(t){return c({imports:{},decorators:[]},t)}n(N,"createSection");function $(t){return m(N(t))}n($,"compileCsfModule");var M=n(t=>{try{return $(JSON.parse(t))}catch{}return t},"default");export{M as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-server-webpack",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.7",
|
|
4
4
|
"description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -19,9 +19,31 @@
|
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./preset": {
|
|
29
|
+
"require": "./dist/index.js",
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./dist/loader": {
|
|
34
|
+
"require": "./dist/loader.js",
|
|
35
|
+
"import": "./dist/loader.mjs",
|
|
36
|
+
"types": "./dist/loader.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": {
|
|
39
|
+
"require": "./package.json",
|
|
40
|
+
"import": "./package.json",
|
|
41
|
+
"types": "./package.json"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"main": "dist/index.js",
|
|
45
|
+
"module": "dist/index.mjs",
|
|
46
|
+
"types": "dist/index.d.ts",
|
|
25
47
|
"files": [
|
|
26
48
|
"dist/**/*",
|
|
27
49
|
"README.md",
|
|
@@ -29,12 +51,12 @@
|
|
|
29
51
|
"*.d.ts"
|
|
30
52
|
],
|
|
31
53
|
"scripts": {
|
|
32
|
-
"prepare": "
|
|
54
|
+
"prepare": "esrun ../../scripts/prepare/bundle.ts"
|
|
33
55
|
},
|
|
34
56
|
"dependencies": {
|
|
35
|
-
"@storybook/core-server": "7.0.0-alpha.
|
|
36
|
-
"@storybook/core-webpack": "7.0.0-alpha.
|
|
37
|
-
"@storybook/server": "7.0.0-alpha.
|
|
57
|
+
"@storybook/core-server": "7.0.0-alpha.7",
|
|
58
|
+
"@storybook/core-webpack": "7.0.0-alpha.7",
|
|
59
|
+
"@storybook/server": "7.0.0-alpha.7",
|
|
38
60
|
"@types/node": "^14.14.20 || ^16.0.0",
|
|
39
61
|
"core-js": "^3.8.2",
|
|
40
62
|
"global": "^4.4.0",
|
|
@@ -45,6 +67,7 @@
|
|
|
45
67
|
"yaml-loader": "^0.8.0"
|
|
46
68
|
},
|
|
47
69
|
"devDependencies": {
|
|
70
|
+
"@digitak/esrun": "^3.2.2",
|
|
48
71
|
"fs-extra": "^9.0.1",
|
|
49
72
|
"jest-specific-snapshot": "^4.0.0",
|
|
50
73
|
"yaml": "^1.10.0"
|
|
@@ -55,5 +78,9 @@
|
|
|
55
78
|
"publishConfig": {
|
|
56
79
|
"access": "public"
|
|
57
80
|
},
|
|
58
|
-
"
|
|
81
|
+
"bundlerEntrypoint": [
|
|
82
|
+
"./src/index.ts",
|
|
83
|
+
"./src/loader.ts"
|
|
84
|
+
],
|
|
85
|
+
"gitHead": "d334cabd251cd0ed8b845a87707dc84f007d4074"
|
|
59
86
|
}
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
1
|
+
module.exports = require('./dist/index');
|
package/dist/cjs/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.webpack = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const webpack = config => {
|
|
13
|
-
var _config$module;
|
|
14
|
-
|
|
15
|
-
const rules = [...(((_config$module = config.module) === null || _config$module === void 0 ? void 0 : _config$module.rules) || []), {
|
|
16
|
-
type: 'javascript/auto',
|
|
17
|
-
test: /\.stories\.json$/,
|
|
18
|
-
use: _path.default.resolve(__dirname, './loader.js')
|
|
19
|
-
}, {
|
|
20
|
-
type: 'javascript/auto',
|
|
21
|
-
test: /\.stories\.ya?ml/,
|
|
22
|
-
use: [_path.default.resolve(__dirname, './loader.js'), 'yaml-loader']
|
|
23
|
-
}]; // eslint-disable-next-line no-param-reassign
|
|
24
|
-
|
|
25
|
-
config.module = config.module || {}; // eslint-disable-next-line no-param-reassign
|
|
26
|
-
|
|
27
|
-
config.module.rules = rules;
|
|
28
|
-
return config;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.webpack = webpack;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.compileCsfModule = compileCsfModule;
|
|
7
|
-
|
|
8
|
-
var _stringifier = require("./stringifier");
|
|
9
|
-
|
|
10
|
-
function createSection(args) {
|
|
11
|
-
return Object.assign({
|
|
12
|
-
imports: {},
|
|
13
|
-
decorators: []
|
|
14
|
-
}, args);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function compileCsfModule(args) {
|
|
18
|
-
return (0, _stringifier.stringifySection)(createSection(args));
|
|
19
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stringifyDecorators = stringifyDecorators;
|
|
7
|
-
exports.stringifyDefault = stringifyDefault;
|
|
8
|
-
exports.stringifyImports = stringifyImports;
|
|
9
|
-
exports.stringifyObject = stringifyObject;
|
|
10
|
-
exports.stringifySection = stringifySection;
|
|
11
|
-
exports.stringifyStory = stringifyStory;
|
|
12
|
-
|
|
13
|
-
var _tsDedent = _interopRequireDefault(require("ts-dedent"));
|
|
14
|
-
|
|
15
|
-
const _excluded = ["title", "imports", "decorators", "stories"],
|
|
16
|
-
_excluded2 = ["name"];
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
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; }
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
identifier
|
|
24
|
-
} = require('safe-identifier');
|
|
25
|
-
|
|
26
|
-
function stringifyObject(object, level = 0, excludeOuterParams = false) {
|
|
27
|
-
if (typeof object === 'string') {
|
|
28
|
-
return JSON.stringify(object);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const indent = ' '.repeat(level);
|
|
32
|
-
|
|
33
|
-
if (Array.isArray(object)) {
|
|
34
|
-
const arrayStrings = object.map(item => stringifyObject(item, level + 1));
|
|
35
|
-
const arrayString = arrayStrings.join(`,\n${indent} `);
|
|
36
|
-
if (excludeOuterParams) return arrayString;
|
|
37
|
-
return `[\n${indent} ${arrayString}\n${indent}]`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (typeof object === 'object') {
|
|
41
|
-
let objectString = '';
|
|
42
|
-
|
|
43
|
-
if (Object.keys(object).length > 0) {
|
|
44
|
-
const objectStrings = Object.keys(object).map(key => {
|
|
45
|
-
const value = stringifyObject(object[key], level + 1);
|
|
46
|
-
return `\n${indent} ${key}: ${value}`;
|
|
47
|
-
});
|
|
48
|
-
objectString = objectStrings.join(',');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (excludeOuterParams) return objectString;
|
|
52
|
-
if (objectString.length === 0) return '{}';
|
|
53
|
-
return `{${objectString}\n${indent}}`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return object;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function stringifyImports(imports) {
|
|
60
|
-
if (Object.keys(imports).length === 0) return '';
|
|
61
|
-
return Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(', ')} } from '${module}';\n`).join('');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function stringifyDecorators(decorators) {
|
|
65
|
-
return decorators && decorators.length > 0 ? `\n decorators: [\n ${decorators.join(',\n ')}\n ],` : '';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function stringifyDefault(section) {
|
|
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
|
-
`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function stringifyStory(story) {
|
|
86
|
-
const {
|
|
87
|
-
name
|
|
88
|
-
} = story,
|
|
89
|
-
options = _objectWithoutPropertiesLoose(story, _excluded2);
|
|
90
|
-
|
|
91
|
-
const storyId = identifier(name);
|
|
92
|
-
const exportedStory = Object.assign({
|
|
93
|
-
name
|
|
94
|
-
}, options);
|
|
95
|
-
const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ''];
|
|
96
|
-
return storyStrings.join('\n');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function stringifySection(section) {
|
|
100
|
-
const sectionString = [stringifyImports(section.imports), stringifyDefault(section), ...section.stories.map(story => stringifyStory(story))].join('\n');
|
|
101
|
-
return sectionString;
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/cjs/loader.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _compiler = require("./lib/compiler");
|
|
9
|
-
|
|
10
|
-
var _default = content => {
|
|
11
|
-
try {
|
|
12
|
-
const after = (0, _compiler.compileCsfModule)(JSON.parse(content));
|
|
13
|
-
return after;
|
|
14
|
-
} catch (e) {//
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return content;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
exports.default = _default;
|
package/dist/esm/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const webpack = config => {
|
|
3
|
-
const rules = [...(config.module?.rules || []), {
|
|
4
|
-
type: 'javascript/auto',
|
|
5
|
-
test: /\.stories\.json$/,
|
|
6
|
-
use: path.resolve(__dirname, './loader.js')
|
|
7
|
-
}, {
|
|
8
|
-
type: 'javascript/auto',
|
|
9
|
-
test: /\.stories\.ya?ml/,
|
|
10
|
-
use: [path.resolve(__dirname, './loader.js'), 'yaml-loader']
|
|
11
|
-
}]; // eslint-disable-next-line no-param-reassign
|
|
12
|
-
|
|
13
|
-
config.module = config.module || {}; // eslint-disable-next-line no-param-reassign
|
|
14
|
-
|
|
15
|
-
config.module.rules = rules;
|
|
16
|
-
return config;
|
|
17
|
-
};
|
|
@@ -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
|
package/dist/esm/loader.js
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -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[] | undefined): 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
|
-
}
|