@modern-js/storybook 0.0.0-next-20230913035856

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/.eslintrc.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: ['@modern-js'],
3
+ ignorePatterns: ['compiled/', 'fixtures/**', 'tests/**', 'modern.config.ts'],
4
+ parserOptions: {
5
+ project: require.resolve('./tsconfig.json'),
6
+ },
7
+ };
@@ -0,0 +1,4 @@
1
+
2
+ > @modern-js/storybook@2.31.2 build /home/runner/work/modern.js/modern.js/packages/storybook/framework
3
+ > tsc
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @modern-js/storybook
2
+
3
+ ## 0.0.0-next-20230913035856
4
+
5
+ ### Patch Changes
6
+
7
+ - aec9975f8: feat: add storybook-framework
8
+ feat: 支持 storybook-framework
9
+ - Updated dependencies [aec9975f8]
10
+ - @modern-js/storybook-builder@0.0.0-next-20230913035856
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Modern.js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('storybook');
@@ -0,0 +1,2 @@
1
+ export * from './preset';
2
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./preset"), exports);
18
+ __exportStar(require("./types"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB"}
@@ -0,0 +1,8 @@
1
+ import type { Options } from '@storybook/types';
2
+ import type { BuilderConfig } from '@modern-js/storybook-builder/types';
3
+ export declare const frameworkOptions: (_: never, options: Options) => Promise<{
4
+ name: string;
5
+ options: any;
6
+ }>;
7
+ export declare const modern: (config: BuilderConfig, _options: Options) => BuilderConfig;
8
+ export declare const core: (config: any, options: any) => Promise<any>;
package/dist/preset.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.core = exports.modern = exports.frameworkOptions = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const frameworkOptions = async (_, options) => {
9
+ const config = await options.presets.apply('framework');
10
+ if (typeof config === 'string') {
11
+ return {
12
+ name: config,
13
+ options: {},
14
+ };
15
+ }
16
+ if (typeof config === 'undefined') {
17
+ return {
18
+ name: '@modern-js/storybook',
19
+ options: {},
20
+ };
21
+ }
22
+ return {
23
+ name: config.name,
24
+ options: {
25
+ ...config.options,
26
+ },
27
+ };
28
+ };
29
+ exports.frameworkOptions = frameworkOptions;
30
+ const modern = (config, _options) => {
31
+ // @ts-expect-error
32
+ return {
33
+ ...config,
34
+ source: {
35
+ ...config.source,
36
+ alias: {
37
+ ...config.source?.alias,
38
+ '@storybook/react': absPath('@storybook/react'),
39
+ },
40
+ },
41
+ };
42
+ };
43
+ exports.modern = modern;
44
+ const core = async (config, options) => {
45
+ const framework = await options.presets.apply('framework');
46
+ return {
47
+ ...config,
48
+ builder: {
49
+ name: absPath('@modern-js/storybook-builder'),
50
+ options: typeof framework === 'string' ? {} : framework?.options?.builder || {},
51
+ },
52
+ // FIXME: renderer: absPath('@storybook/react'),
53
+ renderer: '@storybook/react',
54
+ };
55
+ };
56
+ exports.core = core;
57
+ function absPath(pkg) {
58
+ return path_1.default.dirname(require.resolve(path_1.default.join(pkg, 'package.json')));
59
+ }
60
+ //# sourceMappingURL=preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAIjB,MAAM,gBAAgB,GAAG,KAAK,EAAE,CAAQ,EAAE,OAAgB,EAAE,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,W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,GAAW;IAC1B,OAAO,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { StorybookConfig as StorybookConfigBase } from '@storybook/types';
2
+ import { FrameworkOptions } from '.';
3
+ export { defineConfig, type FrameworkOptions, } from '@modern-js/storybook-builder';
4
+ export type FrameworkName = '@modern-js/storybook' | string;
5
+ export interface StorybookConfig extends StorybookConfigBase {
6
+ framework: FrameworkName | {
7
+ name: FrameworkName;
8
+ options: FrameworkOptions;
9
+ };
10
+ typescript?: {
11
+ reactDocgen?: 'react-docgen' | 'react-docgen-typescript' | false;
12
+ } & StorybookConfigBase['typescript'];
13
+ }
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineConfig = void 0;
4
+ var storybook_builder_1 = require("@modern-js/storybook-builder");
5
+ Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return storybook_builder_1.defineConfig; } });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAGA,kEAGsC;AAFpC,iHAAA,YAAY,OAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Old storybook:
3
+ * - `path/config/storybook` move to `path/.storybook/main.ts`
4
+ * - stories folder -> configure in `.storybook/main.ts`
5
+ */
6
+ export declare function upgrade(cwd: string): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.upgrade = void 0;
4
+ /**
5
+ * Old storybook:
6
+ * - `path/config/storybook` move to `path/.storybook/main.ts`
7
+ * - stories folder -> configure in `.storybook/main.ts`
8
+ */
9
+ function upgrade(cwd) {
10
+ console.log(cwd);
11
+ }
12
+ exports.upgrade = upgrade;
13
+ //# sourceMappingURL=upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../src/upgrade.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAFD,0BAEC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@modern-js/storybook",
3
+ "version": "0.0.0-next-20230913035856",
4
+ "description": "modern.js support for storybook",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/web-infra-dev/modern.js",
8
+ "directory": "packages/storybook/builder"
9
+ },
10
+ "jsnext:source": "./src/index.ts",
11
+ "main": "./dist/index.js",
12
+ "bin": {
13
+ "storybook": "./bin.js",
14
+ "sb": "./bin.js"
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "jsnext:source": "./src/index.ts",
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./preset": {
24
+ "jsnext:source": "./src/preset.ts",
25
+ "types": "./dist/preset.d.ts",
26
+ "default": "./dist/preset.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "engines": {
31
+ "node": ">=16.0.0"
32
+ },
33
+ "keywords": [],
34
+ "author": "",
35
+ "license": "MIT",
36
+ "dependencies": {
37
+ "@storybook/react": "^7.4.0",
38
+ "storybook": "^7.4.0",
39
+ "@modern-js/storybook-builder": "0.0.0-next-20230913035856"
40
+ },
41
+ "devDependencies": {
42
+ "@storybook/types": "^7.4.0",
43
+ "@types/node": "^20.5.6"
44
+ },
45
+ "publishConfig": {
46
+ "registry": "https://registry.npmjs.org/",
47
+ "access": "public",
48
+ "provenance": true
49
+ },
50
+ "scripts": {
51
+ "build": "tsc",
52
+ "dev": "tsc --watch --incremental",
53
+ "test": "vitest run"
54
+ }
55
+ }
package/preset.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/preset');
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './preset';
2
+ export * from './types';
package/src/preset.ts ADDED
@@ -0,0 +1,63 @@
1
+ import path from 'path';
2
+ import type { Options } from '@storybook/types';
3
+ import type { BuilderConfig } from '@modern-js/storybook-builder/types';
4
+
5
+ export const frameworkOptions = async (_: never, options: Options) => {
6
+ const config = await options.presets.apply('framework');
7
+
8
+ if (typeof config === 'string') {
9
+ return {
10
+ name: config,
11
+ options: {},
12
+ };
13
+ }
14
+ if (typeof config === 'undefined') {
15
+ return {
16
+ name: '@modern-js/storybook',
17
+ options: {},
18
+ };
19
+ }
20
+
21
+ return {
22
+ name: config.name,
23
+ options: {
24
+ ...config.options,
25
+ },
26
+ };
27
+ };
28
+
29
+ export const modern = (
30
+ config: BuilderConfig,
31
+ _options: Options,
32
+ ): BuilderConfig => {
33
+ // @ts-expect-error
34
+ return {
35
+ ...config,
36
+ source: {
37
+ ...config.source,
38
+ alias: {
39
+ ...config.source?.alias,
40
+ '@storybook/react': absPath('@storybook/react'),
41
+ },
42
+ },
43
+ };
44
+ };
45
+
46
+ export const core = async (config: any, options: any) => {
47
+ const framework = await options.presets.apply('framework');
48
+
49
+ return {
50
+ ...config,
51
+ builder: {
52
+ name: absPath('@modern-js/storybook-builder'),
53
+ options:
54
+ typeof framework === 'string' ? {} : framework?.options?.builder || {},
55
+ },
56
+ // FIXME: renderer: absPath('@storybook/react'),
57
+ renderer: '@storybook/react',
58
+ };
59
+ };
60
+
61
+ function absPath(pkg: string) {
62
+ return path.dirname(require.resolve(path.join(pkg, 'package.json')));
63
+ }
package/src/types.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { StorybookConfig as StorybookConfigBase } from '@storybook/types';
2
+ import { FrameworkOptions } from '.';
3
+
4
+ export {
5
+ defineConfig,
6
+ type FrameworkOptions,
7
+ } from '@modern-js/storybook-builder';
8
+
9
+ export type FrameworkName = '@modern-js/storybook' | string;
10
+
11
+ export interface StorybookConfig extends StorybookConfigBase {
12
+ framework:
13
+ | FrameworkName
14
+ | {
15
+ name: FrameworkName;
16
+ options: FrameworkOptions;
17
+ };
18
+ typescript?: {
19
+ reactDocgen?: 'react-docgen' | 'react-docgen-typescript' | false;
20
+ } & StorybookConfigBase['typescript'];
21
+ }
package/src/upgrade.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Old storybook:
3
+ * - `path/config/storybook` move to `path/.storybook/main.ts`
4
+ * - stories folder -> configure in `.storybook/main.ts`
5
+ */
6
+ export function upgrade(cwd: string) {
7
+ console.log(cwd);
8
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "@modern-js/tsconfig/base",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "declaration": true,
6
+ "outDir": "dist",
7
+ "isolatedModules": true,
8
+ "noImplicitAny": true,
9
+ "skipLibCheck": true,
10
+ "sourceMap": true,
11
+ "moduleResolution": "NodeNext",
12
+ "module": "NodeNext",
13
+ "esModuleInterop": true
14
+ },
15
+ "include": ["./src"]
16
+ }