@tramvai/storybook-addon 0.0.2

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 (38) hide show
  1. package/README.md +3 -0
  2. package/lib/babel/babelConfigFactory.d.ts +71 -0
  3. package/lib/babel/babelConfigFactory.js +12 -0
  4. package/lib/babel/babelConfigFactory.js.map +1 -0
  5. package/lib/decorators/actionsDecorator.d.ts +7 -0
  6. package/lib/decorators/actionsDecorator.js +22 -0
  7. package/lib/decorators/actionsDecorator.js.map +1 -0
  8. package/lib/decorators/reactQueryDecorator.d.ts +7 -0
  9. package/lib/decorators/reactQueryDecorator.js +20 -0
  10. package/lib/decorators/reactQueryDecorator.js.map +1 -0
  11. package/lib/decorators/routerDecorator.d.ts +9 -0
  12. package/lib/decorators/routerDecorator.js +15 -0
  13. package/lib/decorators/routerDecorator.js.map +1 -0
  14. package/lib/decorators/tramvaiCoreDecorator.d.ts +12 -0
  15. package/lib/decorators/tramvaiCoreDecorator.js +50 -0
  16. package/lib/decorators/tramvaiCoreDecorator.js.map +1 -0
  17. package/lib/preset.d.ts +10 -0
  18. package/lib/preset.js +30 -0
  19. package/lib/preset.js.map +1 -0
  20. package/lib/preview.d.ts +9 -0
  21. package/lib/preview.js +14 -0
  22. package/lib/preview.js.map +1 -0
  23. package/lib/tramvai/buildConfigManager.d.ts +2 -0
  24. package/lib/tramvai/buildConfigManager.js +23 -0
  25. package/lib/tramvai/buildConfigManager.js.map +1 -0
  26. package/lib/webpack/addEnvVariables.d.ts +6 -0
  27. package/lib/webpack/addEnvVariables.js +15 -0
  28. package/lib/webpack/addEnvVariables.js.map +1 -0
  29. package/lib/webpack/addFilesRules.d.ts +8 -0
  30. package/lib/webpack/addFilesRules.js +12 -0
  31. package/lib/webpack/addFilesRules.js.map +1 -0
  32. package/lib/webpack/addStylesRules.d.ts +8 -0
  33. package/lib/webpack/addStylesRules.js +15 -0
  34. package/lib/webpack/addStylesRules.js.map +1 -0
  35. package/lib/webpack/removeRules.d.ts +5 -0
  36. package/lib/webpack/removeRules.js +9 -0
  37. package/lib/webpack/removeRules.js.map +1 -0
  38. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @tramvai/storybook-addon
2
+
3
+ Storybook addon for tramvai apps
@@ -0,0 +1,71 @@
1
+ export declare const babelConfigFactory: () => {
2
+ cwd: string;
3
+ compact: boolean;
4
+ sourceType: "unambiguous";
5
+ presets: (string | (string | {
6
+ modules: string | boolean;
7
+ useBuiltIns: string;
8
+ corejs: string;
9
+ loose: boolean;
10
+ targets: string[];
11
+ browserslistEnv: import("@tramvai/cli/lib/typings/target").Target;
12
+ bugfixes: boolean;
13
+ exclude: string[];
14
+ })[] | (string | {
15
+ runtime: string;
16
+ useSpread: boolean;
17
+ development: boolean;
18
+ })[])[];
19
+ plugins: (string | (string | {
20
+ useESModules: boolean;
21
+ })[] | (string | {
22
+ id: string[];
23
+ })[] | (string | {
24
+ root: string[];
25
+ extensions: string[];
26
+ alias: Record<string, any>;
27
+ })[] | (string | {
28
+ legacy: boolean;
29
+ })[] | (string | {
30
+ loose: boolean;
31
+ })[] | (string | {
32
+ 'typeof window': string;
33
+ })[] | (string | {
34
+ skipEnvCheck: boolean;
35
+ })[])[];
36
+ } | {
37
+ cwd?: undefined;
38
+ compact?: undefined;
39
+ sourceType: "unambiguous";
40
+ presets: (string | (string | {
41
+ modules: string | boolean;
42
+ useBuiltIns: string;
43
+ corejs: string;
44
+ loose: boolean;
45
+ targets: string[];
46
+ browserslistEnv: import("@tramvai/cli/lib/typings/target").Target;
47
+ bugfixes: boolean;
48
+ exclude: string[];
49
+ })[] | (string | {
50
+ runtime: string;
51
+ useSpread: boolean;
52
+ development: boolean;
53
+ })[])[];
54
+ plugins: (string | (string | {
55
+ useESModules: boolean;
56
+ })[] | (string | {
57
+ id: string[];
58
+ })[] | (string | {
59
+ root: string[];
60
+ extensions: string[];
61
+ alias: Record<string, any>;
62
+ })[] | (string | {
63
+ legacy: boolean;
64
+ })[] | (string | {
65
+ loose: boolean;
66
+ })[] | (string | {
67
+ 'typeof window': string;
68
+ })[] | (string | {
69
+ skipEnvCheck: boolean;
70
+ })[])[];
71
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.babelConfigFactory = void 0;
4
+ const cli_1 = require("@tramvai/cli");
5
+ const babelConfigFactory = () => cli_1.babelConfigFactory({
6
+ modules: 'commonjs',
7
+ typescript: true,
8
+ generateDataQaTag: false,
9
+ removeTypeofWindow: true,
10
+ });
11
+ exports.babelConfigFactory = babelConfigFactory;
12
+ //# sourceMappingURL=babelConfigFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babelConfigFactory.js","sourceRoot":"","sources":["../../src/babel/babelConfigFactory.ts"],"names":[],"mappings":";;;AAAA,sCAA+E;AAExE,MAAM,kBAAkB,GAAG,GAAG,EAAE,CACrC,wBAAyB,CAAC;IACxB,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAC;AANQ,QAAA,kBAAkB,sBAM1B"}
@@ -0,0 +1,7 @@
1
+ import type { Action } from '@tramvai/core';
2
+ export interface ActionsDecoratorParameters {
3
+ actions?: Action[];
4
+ }
5
+ export declare const ActionsDecorator: (Story: any, { parameters }: {
6
+ parameters: ActionsDecoratorParameters;
7
+ }) => JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionsDecorator = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_2 = require("@tramvai/react");
7
+ const tokens_common_1 = require("@tramvai/tokens-common");
8
+ const ActionsDecorator = (Story, { parameters }) => {
9
+ const actionExecution = react_2.useDi(tokens_common_1.ACTION_EXECUTION_TOKEN);
10
+ react_1.useEffect(() => {
11
+ if (parameters.actions) {
12
+ parameters.actions.forEach((action) => {
13
+ // @ts-expect-error
14
+ actionExecution.run(action, undefined, 'global');
15
+ });
16
+ }
17
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18
+ }, []);
19
+ return jsx_runtime_1.jsx(Story, {}, void 0);
20
+ };
21
+ exports.ActionsDecorator = ActionsDecorator;
22
+ //# sourceMappingURL=actionsDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionsDecorator.js","sourceRoot":"","sources":["../../src/decorators/actionsDecorator.tsx"],"names":[],"mappings":";;;;AAAA,iCAAkC;AAElC,0CAAuC;AACvC,0DAAgE;AAMzD,MAAM,gBAAgB,GAAG,CAC9B,KAAK,EACL,EAAE,UAAU,EAA8C,EAC1D,EAAE;IACF,MAAM,eAAe,GAAG,aAAK,CAAC,sCAAsB,CAAC,CAAC;IAEtD,iBAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACpC,mBAAmB;gBACnB,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;SACJ;QACD,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,kBAAC,KAAK,aAAG,CAAC;AACnB,CAAC,CAAC;AAjBW,QAAA,gBAAgB,oBAiB3B"}
@@ -0,0 +1,7 @@
1
+ import type { DefaultOptions } from 'react-query';
2
+ export interface ReactQueryDecoratorParameters {
3
+ reactQueryDefaultOptions?: DefaultOptions;
4
+ }
5
+ export declare const ReactQueryDecorator: (Story: any, { parameters }: {
6
+ parameters: ReactQueryDecoratorParameters;
7
+ }) => JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactQueryDecorator = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_query_1 = require("react-query");
6
+ const ReactQueryDecorator = (Story, { parameters }) => {
7
+ var _a;
8
+ const queryClient = new react_query_1.QueryClient({
9
+ defaultOptions: (_a = parameters.reactQueryDefaultOptions) !== null && _a !== void 0 ? _a : {
10
+ queries: {
11
+ refetchOnMount: false,
12
+ refetchOnReconnect: false,
13
+ refetchOnWindowFocus: false,
14
+ },
15
+ },
16
+ });
17
+ return (jsx_runtime_1.jsx(react_query_1.QueryClientProvider, Object.assign({ client: queryClient }, { children: jsx_runtime_1.jsx(Story, {}, void 0) }), void 0));
18
+ };
19
+ exports.ReactQueryDecorator = ReactQueryDecorator;
20
+ //# sourceMappingURL=reactQueryDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactQueryDecorator.js","sourceRoot":"","sources":["../../src/decorators/reactQueryDecorator.tsx"],"names":[],"mappings":";;;;AAAA,6CAA+D;AAOxD,MAAM,mBAAmB,GAAG,CACjC,KAAK,EACL,EAAE,UAAU,EAAiD,EAC7D,EAAE;;IACF,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC;QAClC,cAAc,EAAE,MAAA,UAAU,CAAC,wBAAwB,mCAAI;YACrD,OAAO,EAAE;gBACP,cAAc,EAAE,KAAK;gBACrB,kBAAkB,EAAE,KAAK;gBACzB,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF,CAAC,CAAC;IAEH,OAAO,CACL,kBAAC,iCAAmB,kBAAC,MAAM,EAAE,WAAW,gBACtC,kBAAC,KAAK,aAAG,YACW,CACvB,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B"}
@@ -0,0 +1,9 @@
1
+ import type { Route } from '@tinkoff/router';
2
+ import type { Url } from '@tinkoff/url';
3
+ export interface RouterDecoratorParameters {
4
+ currentRoute?: Route;
5
+ currentUrl?: Url;
6
+ }
7
+ export declare const RouterDecorator: (Story: any, { parameters }: {
8
+ parameters: RouterDecoratorParameters;
9
+ }) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouterDecorator = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const router_1 = require("@tinkoff/router");
6
+ const test_mocks_1 = require("@tramvai/test-mocks");
7
+ const RouterDecorator = (Story, { parameters }) => {
8
+ const routerMock = test_mocks_1.createMockRouter({
9
+ currentRoute: parameters.currentRoute,
10
+ currentUrl: parameters.currentUrl,
11
+ });
12
+ return (jsx_runtime_1.jsx(router_1.Provider, Object.assign({ router: routerMock }, { children: jsx_runtime_1.jsx(Story, {}, void 0) }), void 0));
13
+ };
14
+ exports.RouterDecorator = RouterDecorator;
15
+ //# sourceMappingURL=routerDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerDecorator.js","sourceRoot":"","sources":["../../src/decorators/routerDecorator.tsx"],"names":[],"mappings":";;;;AAAA,4CAA6D;AAG7D,oDAAuD;AAOhD,MAAM,eAAe,GAAG,CAC7B,KAAK,EACL,EAAE,UAAU,EAA6C,EACzD,EAAE;IACF,MAAM,UAAU,GAAG,6BAAgB,CAAC;QAClC,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC,CAAC;IAEH,OAAO,CACL,kBAAC,iBAAc,kBAAC,MAAM,EAAE,UAAU,gBAChC,kBAAC,KAAK,aAAG,YACM,CAClB,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,eAAe,mBAc1B"}
@@ -0,0 +1,12 @@
1
+ import type { StoreClass } from '@tramvai/state';
2
+ import type { ExtendedModule, ModuleType } from '@tramvai/core';
3
+ import type { Provider as DiProvider } from '@tinkoff/dippy';
4
+ export interface TramvaiCoreDecoratorParameters {
5
+ stores?: StoreClass[];
6
+ initialState?: Record<string, any>;
7
+ providers?: DiProvider[];
8
+ modules?: Array<ModuleType | ExtendedModule>;
9
+ }
10
+ export declare const TramvaiCoreDecorator: (Story: any, { parameters }: {
11
+ parameters: TramvaiCoreDecoratorParameters;
12
+ }) => JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TramvaiCoreDecorator = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const state_1 = require("@tramvai/state");
6
+ const react_1 = require("@tramvai/react");
7
+ const tokens_common_1 = require("@tramvai/tokens-common");
8
+ const core_1 = require("@tramvai/core");
9
+ const test_mocks_1 = require("@tramvai/test-mocks");
10
+ const TramvaiCoreDecorator = (Story, { parameters }) => {
11
+ var _a, _b;
12
+ const storeMock = test_mocks_1.createMockStore({
13
+ stores: parameters.stores,
14
+ initialState: parameters.initialState,
15
+ });
16
+ const diMock = test_mocks_1.createMockDi({
17
+ modules: [...((_a = parameters.modules) !== null && _a !== void 0 ? _a : [])],
18
+ providers: [
19
+ {
20
+ provide: tokens_common_1.LOGGER_TOKEN,
21
+ useValue: test_mocks_1.createMockLogger(),
22
+ },
23
+ {
24
+ provide: tokens_common_1.ENV_MANAGER_TOKEN,
25
+ useValue: test_mocks_1.createMockEnvManager(),
26
+ },
27
+ {
28
+ provide: core_1.APP_INFO_TOKEN,
29
+ useValue: test_mocks_1.createMockAppInfo(),
30
+ },
31
+ {
32
+ provide: tokens_common_1.REQUEST_MANAGER_TOKEN,
33
+ useValue: test_mocks_1.createMockRequestManager(),
34
+ },
35
+ {
36
+ provide: tokens_common_1.CREATE_CACHE_TOKEN,
37
+ useValue: () => test_mocks_1.createMockCache(),
38
+ },
39
+ ...((_b = parameters.providers) !== null && _b !== void 0 ? _b : []),
40
+ ],
41
+ });
42
+ const contextMock = test_mocks_1.createMockContext({
43
+ di: diMock,
44
+ store: storeMock,
45
+ useTramvaiActionsConditionals: true,
46
+ });
47
+ return (jsx_runtime_1.jsx(state_1.Provider, Object.assign({ context: contextMock, serverState: parameters.initialState }, { children: jsx_runtime_1.jsx(react_1.DIContext.Provider, Object.assign({ value: diMock }, { children: jsx_runtime_1.jsx(Story, {}, void 0) }), void 0) }), void 0));
48
+ };
49
+ exports.TramvaiCoreDecorator = TramvaiCoreDecorator;
50
+ //# sourceMappingURL=tramvaiCoreDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tramvaiCoreDecorator.js","sourceRoot":"","sources":["../../src/decorators/tramvaiCoreDecorator.tsx"],"names":[],"mappings":";;;;AAAA,0CAA0C;AAE1C,0CAA2C;AAC3C,0DAKgC;AAEhC,wCAA+C;AAE/C,oDAS6B;AAStB,MAAM,oBAAoB,GAAG,CAClC,KAAK,EACL,EAAE,UAAU,EAAkD,EAC9D,EAAE;;IACF,MAAM,SAAS,GAAG,4BAAe,CAAC;QAChC,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,YAAY,EAAE,UAAU,CAAC,YAAY;KACtC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,yBAAY,CAAC;QAC1B,OAAO,EAAE,CAAC,GAAG,CAAC,MAAA,UAAU,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;QACxC,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,4BAAY;gBACrB,QAAQ,EAAE,6BAAgB,EAAE;aAC7B;YACD;gBACE,OAAO,EAAE,iCAAiB;gBAC1B,QAAQ,EAAE,iCAAoB,EAAE;aACjC;YACD;gBACE,OAAO,EAAE,qBAAc;gBACvB,QAAQ,EAAE,8BAAiB,EAAE;aAC9B;YACD;gBACE,OAAO,EAAE,qCAAqB;gBAC9B,QAAQ,EAAE,qCAAwB,EAAE;aACrC;YACD;gBACE,OAAO,EAAE,kCAAkB;gBAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,4BAAe,EAAE;aAClC;YACD,GAAG,CAAC,MAAA,UAAU,CAAC,SAAS,mCAAI,EAAE,CAAC;SAChC;KACF,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,8BAAiB,CAAC;QACpC,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,SAAS;QAChB,6BAA6B,EAAE,IAAI;KACpC,CAAC,CAAC;IAEH,OAAO,CACL,kBAAC,gBAAQ,kBAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,YAAY,gBAClE,kBAAC,iBAAS,CAAC,QAAQ,kBAAC,KAAK,EAAE,MAAM,gBAC/B,kBAAC,KAAK,aAAG,YACU,YACZ,CACZ,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,oBAAoB,wBA+C/B"}
@@ -0,0 +1,10 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type { TransformOptions } from '@babel/core';
3
+ import type { TramvaiCoreDecoratorParameters } from './decorators/tramvaiCoreDecorator';
4
+ import type { RouterDecoratorParameters } from './decorators/routerDecorator';
5
+ import type { ReactQueryDecoratorParameters } from './decorators/reactQueryDecorator';
6
+ import type { ActionsDecoratorParameters } from './decorators/actionsDecorator';
7
+ export declare type TramvaiStoriesParameters = TramvaiCoreDecoratorParameters & RouterDecoratorParameters & ReactQueryDecoratorParameters & ActionsDecoratorParameters;
8
+ export declare const config: (entry: string[]) => string[];
9
+ export declare const babel: (cfg: TransformOptions) => TransformOptions;
10
+ export declare const webpackFinal: (baseConfig: Configuration, options: any) => Promise<Configuration>;
package/lib/preset.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // https://storybook.js.org/docs/react/addons/writing-presets
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.webpackFinal = exports.babel = exports.config = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const webpack_chain_1 = tslib_1.__importDefault(require("webpack-chain"));
7
+ const webpack_merge_1 = require("webpack-merge");
8
+ const buildConfigManager_1 = require("./tramvai/buildConfigManager");
9
+ const babelConfigFactory_1 = require("./babel/babelConfigFactory");
10
+ const addEnvVariables_1 = require("./webpack/addEnvVariables");
11
+ const addFilesRules_1 = require("./webpack/addFilesRules");
12
+ const addStylesRules_1 = require("./webpack/addStylesRules");
13
+ const config = (entry) => {
14
+ return [...entry, require.resolve('./preview')];
15
+ };
16
+ exports.config = config;
17
+ const babel = (cfg) => {
18
+ return babelConfigFactory_1.babelConfigFactory();
19
+ };
20
+ exports.babel = babel;
21
+ const webpackFinal = (baseConfig, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
22
+ const configManager = buildConfigManager_1.buildConfigManager(options);
23
+ const webpackConfig = new webpack_chain_1.default();
24
+ addEnvVariables_1.addEnvVariables({ webpackConfig, configManager });
25
+ addFilesRules_1.addFilesRules({ baseConfig, webpackConfig, configManager });
26
+ addStylesRules_1.addStylesRules({ baseConfig, webpackConfig, configManager });
27
+ return webpack_merge_1.merge(baseConfig, webpackConfig.toConfig());
28
+ });
29
+ exports.webpackFinal = webpackFinal;
30
+ //# sourceMappingURL=preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;;AAG7D,0EAAmC;AACnC,iDAAsC;AAEtC,qEAAkE;AAClE,mEAAgE;AAChE,+DAA4D;AAC5D,2DAAwD;AACxD,6DAA0D;AAWnD,MAAM,MAAM,GAAG,CAAC,KAAe,EAAY,EAAE;IAClD,OAAO,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,MAAM,UAEjB;AAEK,MAAM,KAAK,GAAG,CAAC,GAAqB,EAAoB,EAAE;IAC/D,OAAO,uCAAkB,EAAE,CAAC;AAC9B,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEK,MAAM,YAAY,GAAG,CAAO,UAAyB,EAAE,OAAO,EAA0B,EAAE;IAC/F,MAAM,aAAa,GAAG,uCAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,uBAAM,EAAE,CAAC;IAEnC,iCAAe,CAAC,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC;IAClD,6BAAa,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC;IAC5D,+BAAc,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC;IAE7D,OAAO,qBAAK,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC,CAAA,CAAC;AATW,QAAA,YAAY,gBASvB"}
@@ -0,0 +1,9 @@
1
+ export declare const decorators: (((Story: any, { parameters }: {
2
+ parameters: import("./decorators/tramvaiCoreDecorator").TramvaiCoreDecoratorParameters;
3
+ }) => JSX.Element) | ((Story: any, { parameters }: {
4
+ parameters: import("./decorators/routerDecorator").RouterDecoratorParameters;
5
+ }) => JSX.Element) | ((Story: any, { parameters }: {
6
+ parameters: import("./decorators/reactQueryDecorator").ReactQueryDecoratorParameters;
7
+ }) => JSX.Element) | ((Story: any, { parameters }: {
8
+ parameters: import("./decorators/actionsDecorator").ActionsDecoratorParameters;
9
+ }) => JSX.Element))[];
package/lib/preview.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decorators = void 0;
4
+ const tramvaiCoreDecorator_1 = require("./decorators/tramvaiCoreDecorator");
5
+ const routerDecorator_1 = require("./decorators/routerDecorator");
6
+ const actionsDecorator_1 = require("./decorators/actionsDecorator");
7
+ const reactQueryDecorator_1 = require("./decorators/reactQueryDecorator");
8
+ exports.decorators = [
9
+ reactQueryDecorator_1.ReactQueryDecorator,
10
+ actionsDecorator_1.ActionsDecorator,
11
+ routerDecorator_1.RouterDecorator,
12
+ tramvaiCoreDecorator_1.TramvaiCoreDecorator,
13
+ ];
14
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":";;;AAAA,4EAAyE;AACzE,kEAA+D;AAC/D,oEAAiE;AACjE,0EAAuE;AAE1D,QAAA,UAAU,GAAG;IACxB,yCAAmB;IACnB,mCAAgB;IAChB,iCAAe;IACf,2CAAoB;CACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ConfigManager } from '@tramvai/cli';
2
+ export declare const buildConfigManager: (options: any) => ConfigManager;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildConfigManager = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const cli_1 = require("@tramvai/cli");
7
+ const buildConfigManager = (options) => {
8
+ const rootDir = options.tramvaiDir || path_1.default.resolve(process.cwd(), '..');
9
+ const { content, isSuccessful } = cli_1.getTramvaiConfig(rootDir);
10
+ if (!isSuccessful) {
11
+ throw Error(`tramvai.json not found inside ${rootDir} folder`);
12
+ }
13
+ const configManagerValidator = new cli_1.ConfigManagerValidator({
14
+ config: content,
15
+ syncConfigFile: cli_1.syncJsonFile,
16
+ });
17
+ const { projects } = content;
18
+ const defaultProject = Object.keys(projects)[0];
19
+ const configManager = new cli_1.ConfigManager(configManagerValidator.getProject(options.tramvaiAppName || defaultProject), { rootDir, buildType: 'client', env: process.env.NODE_ENV });
20
+ return configManager;
21
+ };
22
+ exports.buildConfigManager = buildConfigManager;
23
+ //# sourceMappingURL=buildConfigManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildConfigManager.js","sourceRoot":"","sources":["../../src/tramvai/buildConfigManager.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,sCAKsB;AAEf,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAiB,EAAE;IAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IACxE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,sBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,KAAK,CAAC,iCAAiC,OAAO,SAAS,CAAC,CAAC;KAChE;IAED,MAAM,sBAAsB,GAAG,IAAI,4BAAsB,CAAC;QACxD,MAAM,EAAE,OAAO;QACf,cAAc,EAAE,kBAAY;KAC7B,CAAC,CAAC;IAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,IAAI,mBAAa,CACrC,sBAAsB,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,IAAI,cAAc,CAAC,EAC3E,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAe,EAAE,CACnE,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B"}
@@ -0,0 +1,6 @@
1
+ import type Config from 'webpack-chain';
2
+ import type { ConfigManager } from '@tramvai/cli';
3
+ export declare function addEnvVariables({ webpackConfig, configManager, }: {
4
+ webpackConfig: Config;
5
+ configManager: ConfigManager;
6
+ }): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addEnvVariables = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
6
+ const cli_1 = require("@tramvai/cli");
7
+ function addEnvVariables({ webpackConfig, configManager, }) {
8
+ const env = configManager.env === 'development' ? 'dev' : 'prod';
9
+ webpackConfig.plugin('define').use(webpack_1.default.DefinePlugin, [
10
+ Object.assign(Object.assign({}, configManager.build.configurations.definePlugin[env]), { 'process.env.NODE_ENV': JSON.stringify(configManager.env), 'process.env.APP_ID': JSON.stringify(configManager.name), 'process.env.BROWSER': true, 'process.env.SERVER': false }),
11
+ ]);
12
+ cli_1.configToEnv(configManager)(webpackConfig);
13
+ }
14
+ exports.addEnvVariables = addEnvVariables;
15
+ //# sourceMappingURL=addEnvVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addEnvVariables.js","sourceRoot":"","sources":["../../src/webpack/addEnvVariables.ts"],"names":[],"mappings":";;;;AAAA,8DAA8B;AAG9B,sCAA2C;AAE3C,SAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,aAAa,GAId;IACC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAEjE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,iBAAO,CAAC,YAAY,EAAE;wCAElD,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CAAC,KACvD,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,EACzD,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,EACxD,qBAAqB,EAAE,IAAI,EAC3B,oBAAoB,EAAE,KAAK;KAE9B,CAAC,CAAC;IAEH,iBAAW,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC;AApBD,0CAoBC"}
@@ -0,0 +1,8 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type Config from 'webpack-chain';
3
+ import type { ConfigManager } from '@tramvai/cli';
4
+ export declare function addFilesRules({ baseConfig, webpackConfig, configManager, }: {
5
+ baseConfig: Configuration;
6
+ webpackConfig: Config;
7
+ configManager: ConfigManager;
8
+ }): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addFilesRules = void 0;
4
+ const cli_1 = require("@tramvai/cli");
5
+ const removeRules_1 = require("./removeRules");
6
+ function addFilesRules({ baseConfig, webpackConfig, configManager, }) {
7
+ // remove existed files loaders
8
+ removeRules_1.removeRules({ baseConfig, extensions: /(woff|svg|png|jpe?g|gif|webp|mp4|webm|avif)/ });
9
+ cli_1.filesClientWebackRulesFactory(configManager)(webpackConfig);
10
+ }
11
+ exports.addFilesRules = addFilesRules;
12
+ //# sourceMappingURL=addFilesRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addFilesRules.js","sourceRoot":"","sources":["../../src/webpack/addFilesRules.ts"],"names":[],"mappings":";;;AAGA,sCAA6D;AAC7D,+CAA4C;AAE5C,SAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,aAAa,EACb,aAAa,GAKd;IACC,+BAA+B;IAC/B,yBAAW,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,6CAA6C,EAAE,CAAC,CAAC;IAEvF,mCAA6B,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;AAC9D,CAAC;AAbD,sCAaC"}
@@ -0,0 +1,8 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type Config from 'webpack-chain';
3
+ import type { ConfigManager } from '@tramvai/cli';
4
+ export declare function addStylesRules({ baseConfig, webpackConfig, configManager, }: {
5
+ baseConfig: Configuration;
6
+ webpackConfig: Config;
7
+ configManager: ConfigManager;
8
+ }): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addStylesRules = void 0;
4
+ const cli_1 = require("@tramvai/cli");
5
+ const removeRules_1 = require("./removeRules");
6
+ function addStylesRules({ baseConfig, webpackConfig, configManager, }) {
7
+ // remove existed styles loaders
8
+ removeRules_1.removeRules({ baseConfig, extensions: /(css|less)/ });
9
+ cli_1.extractCssPluginFactory(configManager)(webpackConfig);
10
+ cli_1.cssWebpackRulesFactory(configManager)(webpackConfig);
11
+ cli_1.lessWebpackRulesFactory(configManager)(webpackConfig);
12
+ cli_1.postcssAssetsWebpackRulesFactory(configManager)(webpackConfig);
13
+ }
14
+ exports.addStylesRules = addStylesRules;
15
+ //# sourceMappingURL=addStylesRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addStylesRules.js","sourceRoot":"","sources":["../../src/webpack/addStylesRules.ts"],"names":[],"mappings":";;;AAGA,sCAKsB;AACtB,+CAA4C;AAE5C,SAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,aAAa,EACb,aAAa,GAKd;IACC,gCAAgC;IAChC,yBAAW,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IAEtD,6BAAuB,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;IACtD,4BAAsB,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;IACrD,6BAAuB,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;IACtD,sCAAgC,CAAC,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC;AACjE,CAAC;AAhBD,wCAgBC"}
@@ -0,0 +1,5 @@
1
+ import type { Configuration } from 'webpack';
2
+ export declare function removeRules({ baseConfig, extensions, }: {
3
+ baseConfig: Configuration;
4
+ extensions: RegExp;
5
+ }): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeRules = void 0;
4
+ function removeRules({ baseConfig, extensions, }) {
5
+ // eslint-disable-next-line no-param-reassign
6
+ baseConfig.module.rules = baseConfig.module.rules.filter((rule) => { var _a; return typeof rule !== 'string' && !String((_a = rule.test) === null || _a === void 0 ? void 0 : _a.toString()).match(extensions); });
7
+ }
8
+ exports.removeRules = removeRules;
9
+ //# sourceMappingURL=removeRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeRules.js","sourceRoot":"","sources":["../../src/webpack/removeRules.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,EAC1B,UAAU,EACV,UAAU,GAIX;IACC,6CAA6C;IAC7C,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CACtD,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAA,IAAI,CAAC,IAAI,0CAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA,EAAA,CACvF,CAAC;AACJ,CAAC;AAXD,kCAWC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@tramvai/storybook-addon",
3
+ "version": "0.0.2",
4
+ "description": "",
5
+ "main": "lib/preset.js",
6
+ "typings": "lib/preset.d.ts",
7
+ "files": [
8
+ "lib"
9
+ ],
10
+ "sideEffects": false,
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git@github.com:Tinkoff/tramvai.git"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "watch": "tsc -w"
18
+ },
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org/"
21
+ },
22
+ "dependencies": {
23
+ "@tramvai/test-mocks": "1.95.1",
24
+ "webpack-chain": "^6.5.1",
25
+ "webpack-merge": "^5.8.0",
26
+ "react-query": "^3.35.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/webpack": ">=5.28",
30
+ "@babel/core": "^7.16.0",
31
+ "webpack": "5.64.4"
32
+ },
33
+ "peerDependencies": {
34
+ "@tramvai/cli": "1.95.1",
35
+ "@tramvai/core": "1.95.1",
36
+ "@tramvai/state": "1.95.1",
37
+ "@tramvai/react": "1.95.1",
38
+ "@tramvai/tokens-common": "1.95.1",
39
+ "@tinkoff/dippy": "0.7.39",
40
+ "@tinkoff/router": "0.1.72",
41
+ "@tinkoff/url": "0.7.37",
42
+ "react": ">=16.8.0"
43
+ }
44
+ }