@blocklet/component-studio-cli 0.4.134

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 (84) hide show
  1. package/README.md +84 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +11 -0
  4. package/dist/commands/add.d.ts +2 -0
  5. package/dist/commands/add.js +140 -0
  6. package/dist/commands/component-studio.d.ts +2 -0
  7. package/dist/commands/component-studio.js +70 -0
  8. package/dist/commands/dev.d.ts +2 -0
  9. package/dist/commands/dev.js +87 -0
  10. package/dist/commands/init.d.ts +2 -0
  11. package/dist/commands/init.js +114 -0
  12. package/dist/commands/migrate.d.ts +2 -0
  13. package/dist/commands/migrate.js +177 -0
  14. package/dist/commands/update.d.ts +2 -0
  15. package/dist/commands/update.js +22 -0
  16. package/dist/utils/display-logo.d.ts +2 -0
  17. package/dist/utils/display-logo.js +24 -0
  18. package/dist/utils/helper.d.ts +97 -0
  19. package/dist/utils/helper.js +479 -0
  20. package/package.json +58 -0
  21. package/templates/add/components/HelloWorld/@metadata.json +433 -0
  22. package/templates/add/components/HelloWorld/@template.json +4 -0
  23. package/templates/add/components/HelloWorld/index.tsx +560 -0
  24. package/templates/add/tools/cursor-rules/.cursor/rules/@metadata-json.mdc +549 -0
  25. package/templates/add/tools/cursor-rules/.cursor/rules/component-studio.mdc +138 -0
  26. package/templates/add/tools/cursor-rules/.cursor/rules/index-tsx.mdc +192 -0
  27. package/templates/add/tools/cursor-rules/@template.json +4 -0
  28. package/templates/init/0-basic/@template.json +4 -0
  29. package/templates/init/0-basic/README.md +30 -0
  30. package/templates/init/0-basic/package.json +26 -0
  31. package/templates/init/0-basic/src/HelloWorld/@metadata.json +433 -0
  32. package/templates/init/0-basic/src/HelloWorld/index.tsx +560 -0
  33. package/templates/init/1-professional/@template.json +4 -0
  34. package/templates/init/1-professional/README.md +75 -0
  35. package/templates/init/1-professional/biome.json +36 -0
  36. package/templates/init/1-professional/global.d.ts +131 -0
  37. package/templates/init/1-professional/package.json +73 -0
  38. package/templates/init/1-professional/scripts/bump-version.mjs +35 -0
  39. package/templates/init/1-professional/src/atoms/AnimationWrapper.tsx +95 -0
  40. package/templates/init/1-professional/src/atoms/ArrayTable.tsx +114 -0
  41. package/templates/init/1-professional/src/atoms/Card.tsx +52 -0
  42. package/templates/init/1-professional/src/atoms/ContentWrapper.tsx +72 -0
  43. package/templates/init/1-professional/src/atoms/CopyrightFooter.tsx +31 -0
  44. package/templates/init/1-professional/src/atoms/DataDisplays.tsx +157 -0
  45. package/templates/init/1-professional/src/atoms/GradientTitle.tsx +64 -0
  46. package/templates/init/1-professional/src/atoms/Logo.tsx +58 -0
  47. package/templates/init/1-professional/src/atoms/index.ts +27 -0
  48. package/templates/init/1-professional/src/components/HelloWorld/@metadata.json +433 -0
  49. package/templates/init/1-professional/src/components/HelloWorld/index.tsx +224 -0
  50. package/templates/init/1-professional/src/type.d.ts +42 -0
  51. package/templates/init/1-professional/src/utils/index.ts +1 -0
  52. package/templates/init/1-professional/tsconfig.json +102 -0
  53. package/templates/init/1-professional/version +1 -0
  54. package/templates/init/2-blank/@template.json +4 -0
  55. package/templates/init/2-blank/README.md +27 -0
  56. package/templates/init/2-blank/package.json +26 -0
  57. package/templates/workspace/.component-studio-runtime/_theme.tsx +4 -0
  58. package/templates/workspace/.editorconfig +23 -0
  59. package/templates/workspace/.env +1 -0
  60. package/templates/workspace/.init-component-studio +0 -0
  61. package/templates/workspace/LICENSE +13 -0
  62. package/templates/workspace/README.md +127 -0
  63. package/templates/workspace/api/dev.ts +21 -0
  64. package/templates/workspace/api/src/index.ts +50 -0
  65. package/templates/workspace/api/src/libs/auth.ts +17 -0
  66. package/templates/workspace/api/src/libs/env.ts +6 -0
  67. package/templates/workspace/api/src/libs/logger.ts +3 -0
  68. package/templates/workspace/api/src/routes/index.ts +12 -0
  69. package/templates/workspace/api/third.d.ts +17 -0
  70. package/templates/workspace/biome.json +36 -0
  71. package/templates/workspace/blocklet.md +8 -0
  72. package/templates/workspace/blocklet.yml +58 -0
  73. package/templates/workspace/index.html +15 -0
  74. package/templates/workspace/logo.png +0 -0
  75. package/templates/workspace/package.json +125 -0
  76. package/templates/workspace/pnpm-workspace.yaml +3 -0
  77. package/templates/workspace/scripts/build-clean.mjs +6 -0
  78. package/templates/workspace/scripts/bump-version.mjs +39 -0
  79. package/templates/workspace/scripts/init-component-studio.mjs +36 -0
  80. package/templates/workspace/tsconfig.api.json +12 -0
  81. package/templates/workspace/tsconfig.json +102 -0
  82. package/templates/workspace/version +1 -0
  83. package/templates/workspace/vite-server.config.ts +39 -0
  84. package/templates/workspace/vite.config.ts +68 -0
@@ -0,0 +1,157 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ import Card from './Card';
4
+
5
+ // NumberDisplay
6
+ export interface NumberDisplayProps {
7
+ integer?: number;
8
+ decimal?: number;
9
+ title?: string;
10
+ style?: CSSProperties;
11
+ className?: string;
12
+ background?: string;
13
+ transitionDelay?: string;
14
+ }
15
+
16
+ export const NumberDisplay: React.FC<NumberDisplayProps> = ({
17
+ integer,
18
+ decimal,
19
+ title = 'Number Values',
20
+ style,
21
+ className,
22
+ background = 'linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 248, 255, 0.9) 100%)',
23
+ transitionDelay = '0.1s',
24
+ }) => {
25
+ return (
26
+ <Card style={style} className={className} background={background} transitionDelay={transitionDelay}>
27
+ <h3
28
+ style={{
29
+ margin: '0 0 1rem 0',
30
+ color: '#4F46E5',
31
+ fontSize: '1.3rem',
32
+ fontWeight: 600,
33
+ }}>
34
+ {title}
35
+ </h3>
36
+ {integer !== undefined && (
37
+ <div style={{ margin: '0.8rem 0', fontSize: '1.1rem', color: '#1F2937' }}>
38
+ <span style={{ fontWeight: 500, marginRight: '0.5rem', color: '#6366F1' }}>Integer:</span>
39
+ <span style={{ fontSize: '1.5rem', fontWeight: 700 }}>{integer}</span>
40
+ </div>
41
+ )}
42
+ {decimal !== undefined && (
43
+ <div style={{ margin: '0.8rem 0', fontSize: '1.1rem', color: '#1F2937' }}>
44
+ <span style={{ fontWeight: 500, marginRight: '0.5rem', color: '#6366F1' }}>Decimal:</span>
45
+ <span style={{ fontSize: '1.5rem', fontWeight: 700 }}>{decimal.toFixed(2)}</span>
46
+ </div>
47
+ )}
48
+ </Card>
49
+ );
50
+ };
51
+
52
+ // JsonDisplay
53
+ export interface JsonDisplayProps {
54
+ data: Record<string, any>;
55
+ title?: string;
56
+ style?: CSSProperties;
57
+ className?: string;
58
+ background?: string;
59
+ transitionDelay?: string;
60
+ keyColor?: string;
61
+ }
62
+
63
+ export const JsonDisplay: React.FC<JsonDisplayProps> = ({
64
+ data,
65
+ title = 'JSON Data',
66
+ style,
67
+ className,
68
+ background = 'linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 248, 240, 0.9) 100%)',
69
+ transitionDelay = '0.2s',
70
+ keyColor = '#F59E0B',
71
+ }) => {
72
+ return (
73
+ <Card style={style} className={className} background={background} transitionDelay={transitionDelay}>
74
+ <h3
75
+ style={{
76
+ margin: '0 0 1rem 0',
77
+ color: keyColor,
78
+ fontSize: '1.3rem',
79
+ fontWeight: 600,
80
+ }}>
81
+ {title}
82
+ </h3>
83
+ {Object.entries(data).map(([key, value], index) => (
84
+ <div key={index} style={{ margin: '0.8rem 0', fontSize: '1.1rem', color: '#1F2937' }}>
85
+ <span style={{ fontWeight: 500, marginRight: '0.5rem', color: keyColor }}>{key}:</span>
86
+ <span style={{ fontSize: '1.15rem' }}>{String(value)}</span>
87
+ </div>
88
+ ))}
89
+ </Card>
90
+ );
91
+ };
92
+
93
+ // YamlDisplay
94
+ export interface YamlDisplayProps {
95
+ data: Record<string, any>;
96
+ title?: string;
97
+ style?: CSSProperties;
98
+ className?: string;
99
+ animate?: boolean;
100
+ delay?: string;
101
+ }
102
+
103
+ export const YamlDisplay: React.FC<YamlDisplayProps> = ({
104
+ data,
105
+ title = 'YAML to JSON Data',
106
+ style = {},
107
+ className,
108
+ animate = true,
109
+ delay = '0.4s',
110
+ }) => {
111
+ const containerStyle: CSSProperties = {
112
+ margin: '2.5rem 0',
113
+ ...(animate && {
114
+ opacity: 1,
115
+ transform: 'translateY(0)',
116
+ transition: 'transform 0.4s ease, opacity 0.4s ease',
117
+ transitionDelay: delay,
118
+ }),
119
+ ...style,
120
+ };
121
+
122
+ return (
123
+ <div style={containerStyle} className={className}>
124
+ <h3
125
+ style={{
126
+ textAlign: 'center',
127
+ margin: '0 0 1.5rem 0',
128
+ color: '#4F46E5',
129
+ fontSize: '1.5rem',
130
+ fontWeight: 600,
131
+ }}>
132
+ {title}
133
+ </h3>
134
+ <pre
135
+ style={{
136
+ background: 'linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.95) 100%)',
137
+ padding: '1.5rem',
138
+ borderRadius: '12px',
139
+ overflow: 'auto',
140
+ fontSize: '0.95rem',
141
+ color: '#E5E7EB',
142
+ boxShadow: '0 15px 30px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.05)',
143
+ fontFamily: '"Fira Code", "Menlo", monospace',
144
+ lineHeight: 1.6,
145
+ border: '1px solid rgba(55, 65, 81, 0.5)',
146
+ }}>
147
+ {JSON.stringify(data, null, 2)}
148
+ </pre>
149
+ </div>
150
+ );
151
+ };
152
+
153
+ export default {
154
+ NumberDisplay,
155
+ JsonDisplay,
156
+ YamlDisplay,
157
+ };
@@ -0,0 +1,64 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ export interface GradientTitleProps {
4
+ title: string;
5
+ level?: 1 | 2 | 3 | 4 | 5 | 6;
6
+ startColor?: string;
7
+ endColor?: string;
8
+ style?: CSSProperties;
9
+ className?: string;
10
+ animate?: boolean;
11
+ }
12
+
13
+ export const GradientTitle: React.FC<GradientTitleProps> = ({
14
+ title,
15
+ level = 1,
16
+ startColor = '#6366F1',
17
+ endColor = '#3773F2',
18
+ style = {},
19
+ className,
20
+ animate = false,
21
+ }) => {
22
+ const baseStyle: CSSProperties = {
23
+ borderRadius: '12px',
24
+ textAlign: 'center',
25
+ fontWeight: 800,
26
+ letterSpacing: '-0.03em',
27
+ margin: '0 0 1.5rem',
28
+ background: `linear-gradient(135deg, ${startColor} 0%, ${endColor} 100%)`,
29
+ WebkitBackgroundClip: 'text',
30
+ WebkitTextFillColor: 'transparent',
31
+ backgroundClip: 'text',
32
+ color: 'transparent',
33
+ // @ts-ignore
34
+ textFillColor: 'transparent',
35
+ ...(animate && { animation: 'fadeSlideDown 0.7s ease forwards' }),
36
+ ...style,
37
+ };
38
+
39
+ // 根据level设置不同的字体大小
40
+ const sizeMap = {
41
+ 1: '3.5rem',
42
+ 2: '2.5rem',
43
+ 3: '2rem',
44
+ 4: '1.5rem',
45
+ 5: '1.25rem',
46
+ 6: '1rem',
47
+ };
48
+
49
+ const combinedStyle = {
50
+ ...baseStyle,
51
+ fontSize: sizeMap[level],
52
+ };
53
+
54
+ // 根据level动态渲染对应的标题元素
55
+ const HeadingTag = `h${level}` as keyof JSX.IntrinsicElements;
56
+
57
+ return (
58
+ <HeadingTag key={title} className={className} style={combinedStyle}>
59
+ {title}
60
+ </HeadingTag>
61
+ );
62
+ };
63
+
64
+ export default GradientTitle;
@@ -0,0 +1,58 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ export interface LogoProps {
4
+ src: string;
5
+ width?: number;
6
+ height?: number;
7
+ alt?: string;
8
+ animated?: boolean;
9
+ style?: CSSProperties;
10
+ className?: string;
11
+ }
12
+
13
+ export const Logo: React.FC<LogoProps> = ({
14
+ src,
15
+ width,
16
+ height,
17
+ alt = 'logo',
18
+ animated = true,
19
+ style = {},
20
+ className,
21
+ }) => {
22
+ const baseStyle: CSSProperties = {
23
+ borderRadius: '4px',
24
+ maxWidth: '240px',
25
+ maxHeight: '120px',
26
+ filter: 'drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1))',
27
+ width: width ? `${width}px` : 'auto',
28
+ height: height ? `${height}px` : 'auto',
29
+ transition: 'transform 0.3s ease',
30
+ ...style,
31
+ };
32
+
33
+ const containerStyle: CSSProperties = {
34
+ textAlign: 'center',
35
+ margin: '1rem 0',
36
+ ...(animated && { animation: 'fadeIn 0.9s ease forwards' }),
37
+ };
38
+
39
+ const handleMouseOver = (e: React.MouseEvent<HTMLImageElement>) => {
40
+ if (animated) {
41
+ e.currentTarget.style.transform = 'scale(1.05)';
42
+ }
43
+ };
44
+
45
+ const handleMouseOut = (e: React.MouseEvent<HTMLImageElement>) => {
46
+ if (animated) {
47
+ e.currentTarget.style.transform = 'scale(1)';
48
+ }
49
+ };
50
+
51
+ return (
52
+ <div style={containerStyle} className={className}>
53
+ <img src={src} alt={alt} style={baseStyle} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut} />
54
+ </div>
55
+ );
56
+ };
57
+
58
+ export default Logo;
@@ -0,0 +1,27 @@
1
+ import AnimationWrapper, { useAnimationKeyframes } from './AnimationWrapper';
2
+ import ArrayTable from './ArrayTable';
3
+ import Card from './Card';
4
+ import ContentWrapper from './ContentWrapper';
5
+ import CopyrightFooter from './CopyrightFooter';
6
+ import { NumberDisplay, JsonDisplay, YamlDisplay } from './DataDisplays';
7
+ import GradientTitle from './GradientTitle';
8
+ import Logo from './Logo';
9
+
10
+ export {
11
+ // Basic
12
+ Card,
13
+ AnimationWrapper,
14
+ useAnimationKeyframes,
15
+ GradientTitle,
16
+ Logo,
17
+
18
+ // Data Display
19
+ NumberDisplay,
20
+ JsonDisplay,
21
+ YamlDisplay,
22
+ ArrayTable,
23
+
24
+ // Layout
25
+ ContentWrapper,
26
+ CopyrightFooter,
27
+ };