@agions/taroviz 1.1.1 → 1.2.1

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 (81) hide show
  1. package/README.md +324 -53
  2. package/dist/cjs/index.js +1 -0
  3. package/dist/esm/index.js +82979 -0
  4. package/package.json +160 -30
  5. package/src/__tests__/integration.test.tsx +168 -0
  6. package/src/adapters/__tests__/index.test.ts +91 -0
  7. package/src/adapters/h5/__tests__/index.test.ts +156 -0
  8. package/src/adapters/h5/index.ts +301 -0
  9. package/src/adapters/harmony/index.ts +274 -0
  10. package/src/adapters/index.ts +166 -0
  11. package/src/adapters/swan/index.ts +274 -0
  12. package/src/adapters/tt/index.ts +274 -0
  13. package/src/adapters/types.ts +162 -0
  14. package/src/adapters/weapp/index.ts +237 -0
  15. package/src/charts/bar/__tests__/index.test.tsx +113 -0
  16. package/src/charts/bar/index.tsx +18 -0
  17. package/src/charts/common/BaseChartWrapper.tsx +136 -0
  18. package/src/charts/funnel/index.tsx +18 -0
  19. package/src/charts/gauge/index.tsx +18 -0
  20. package/src/charts/heatmap/index.tsx +18 -0
  21. package/src/charts/index.ts +21 -0
  22. package/src/charts/line/__tests__/index.test.tsx +107 -0
  23. package/src/charts/line/index.tsx +18 -0
  24. package/src/charts/pie/__tests__/index.test.tsx +112 -0
  25. package/src/charts/pie/index.tsx +19 -0
  26. package/src/charts/radar/index.tsx +18 -0
  27. package/src/charts/scatter/index.tsx +18 -0
  28. package/src/charts/types.ts +619 -0
  29. package/src/charts/utils.ts +56 -0
  30. package/src/core/__tests__/platform.test.ts +48 -0
  31. package/src/core/animation/AnimationManager.ts +391 -0
  32. package/src/core/animation/index.ts +20 -0
  33. package/src/core/animation/types.ts +248 -0
  34. package/src/core/components/BaseChart.tsx +1313 -0
  35. package/src/core/components/ErrorBoundary.tsx +458 -0
  36. package/src/core/echarts.ts +58 -0
  37. package/src/core/index.ts +22 -0
  38. package/src/core/types/chart.ts +66 -0
  39. package/src/core/types/common.ts +224 -0
  40. package/src/core/types/index.ts +281 -0
  41. package/src/core/types/platform.ts +325 -0
  42. package/src/core/utils/__tests__/common.test.ts +52 -0
  43. package/src/core/utils/__tests__/environment.test.ts +94 -0
  44. package/src/core/utils/__tests__/i18n.test.ts +247 -0
  45. package/src/core/utils/__tests__/index.test.ts +219 -0
  46. package/src/core/utils/__tests__/uuid.test.ts +78 -0
  47. package/src/core/utils/chartInstances.ts +69 -0
  48. package/src/core/utils/codeGenerator/CodeGenerator.ts +655 -0
  49. package/src/core/utils/codeGenerator/index.ts +13 -0
  50. package/src/core/utils/codeGenerator/types.ts +198 -0
  51. package/src/core/utils/common.ts +58 -0
  52. package/src/core/utils/configGenerator/ConfigGenerator.ts +583 -0
  53. package/src/core/utils/configGenerator/index.ts +13 -0
  54. package/src/core/utils/configGenerator/types.ts +445 -0
  55. package/src/core/utils/debug/DebugPanel.tsx +637 -0
  56. package/src/core/utils/debug/debugger.ts +322 -0
  57. package/src/core/utils/debug/index.ts +21 -0
  58. package/src/core/utils/debug/types.ts +142 -0
  59. package/src/core/utils/i18n.ts +452 -0
  60. package/src/core/utils/index.ts +162 -0
  61. package/src/core/utils/performance/PerformanceAnalyzer.ts +586 -0
  62. package/src/core/utils/performance/index.ts +13 -0
  63. package/src/core/utils/performance/types.ts +180 -0
  64. package/src/core/utils/uuid.ts +30 -0
  65. package/src/editor/ThemeEditor.tsx +449 -0
  66. package/src/editor/index.ts +10 -0
  67. package/src/hooks/__tests__/index.test.tsx +333 -0
  68. package/src/hooks/index.ts +594 -0
  69. package/src/index.ts +75 -0
  70. package/src/main.tsx +247 -0
  71. package/src/react-dom.d.ts +7 -0
  72. package/src/themes/__tests__/index.test.ts +91 -0
  73. package/src/themes/index.ts +860 -0
  74. package/dist/389.index.esm.js +0 -1
  75. package/dist/389.index.js +0 -1
  76. package/dist/633.index.esm.js +0 -1
  77. package/dist/633.index.js +0 -1
  78. package/dist/967.index.esm.js +0 -1
  79. package/dist/967.index.js +0 -1
  80. package/dist/index.esm.js +0 -1
  81. package/dist/index.js +0 -1
@@ -0,0 +1,198 @@
1
+ /**
2
+ * TaroViz 代码示例生成器类型定义
3
+ */
4
+
5
+ /**
6
+ * 代码示例框架类型
7
+ */
8
+ export type FrameworkType = 'react' | 'vue' | 'vanilla' | 'angular';
9
+
10
+ /**
11
+ * 代码示例导入类型
12
+ */
13
+ export type ImportType = 'esm' | 'cjs' | 'umd';
14
+
15
+ /**
16
+ * 代码示例主题类型
17
+ */
18
+ export type ThemeType = 'light' | 'dark';
19
+
20
+ /**
21
+ * 代码示例选项
22
+ */
23
+ export interface CodeGeneratorOptions {
24
+ /**
25
+ * 框架类型
26
+ */
27
+ framework: FrameworkType;
28
+ /**
29
+ * 导入类型
30
+ */
31
+ importType?: ImportType;
32
+ /**
33
+ * 主题类型
34
+ */
35
+ theme?: ThemeType;
36
+ /**
37
+ * 是否包含样式
38
+ */
39
+ includeStyles?: boolean;
40
+ /**
41
+ * 是否包含数据
42
+ */
43
+ includeData?: boolean;
44
+ /**
45
+ * 是否包含注释
46
+ */
47
+ includeComments?: boolean;
48
+ /**
49
+ * 是否使用TypeScript
50
+ */
51
+ useTypeScript?: boolean;
52
+ /**
53
+ * 图表ID
54
+ */
55
+ chartId?: string;
56
+ /**
57
+ * 组件名称
58
+ */
59
+ componentName?: string;
60
+ /**
61
+ * 其他自定义选项
62
+ */
63
+ [key: string]: any;
64
+ }
65
+
66
+ /**
67
+ * 代码示例模板
68
+ */
69
+ export interface CodeExampleTemplate {
70
+ /**
71
+ * 模板名称
72
+ */
73
+ name: string;
74
+ /**
75
+ * 模板描述
76
+ */
77
+ description: string;
78
+ /**
79
+ * 模板适用的框架
80
+ */
81
+ frameworks: FrameworkType[];
82
+ /**
83
+ * 模板内容
84
+ */
85
+ content: string;
86
+ /**
87
+ * 模板变量
88
+ */
89
+ variables?: string[];
90
+ }
91
+
92
+ /**
93
+ * 代码示例生成结果
94
+ */
95
+ export interface CodeGeneratorResult {
96
+ /**
97
+ * 生成的代码
98
+ */
99
+ code: string;
100
+ /**
101
+ * 代码语言
102
+ */
103
+ language: string;
104
+ /**
105
+ * 代码框架
106
+ */
107
+ framework: FrameworkType;
108
+ /**
109
+ * 代码导入类型
110
+ */
111
+ importType: ImportType;
112
+ /**
113
+ * 代码主题
114
+ */
115
+ theme: ThemeType;
116
+ /**
117
+ * 生成时间
118
+ */
119
+ generatedAt: number;
120
+ /**
121
+ * 代码文件扩展名
122
+ */
123
+ extension: string;
124
+ }
125
+
126
+ /**
127
+ * 代码示例生成器事件类型
128
+ */
129
+ export enum CodeGeneratorEventType {
130
+ /**
131
+ * 代码生成开始事件
132
+ */
133
+ GENERATE_START = 'codeGenerateStart',
134
+ /**
135
+ * 代码生成完成事件
136
+ */
137
+ GENERATE_COMPLETE = 'codeGenerateComplete',
138
+ /**
139
+ * 代码生成失败事件
140
+ */
141
+ GENERATE_ERROR = 'codeGenerateError',
142
+ /**
143
+ * 模板应用事件
144
+ */
145
+ TEMPLATE_APPLY = 'templateApply',
146
+ }
147
+
148
+ /**
149
+ * 代码示例生成器事件处理器
150
+ */
151
+ export type CodeGeneratorEventHandler = (event: {
152
+ type: CodeGeneratorEventType;
153
+ data?: any;
154
+ }) => void;
155
+
156
+ /**
157
+ * 代码示例片段
158
+ */
159
+ export interface CodeSnippet {
160
+ /**
161
+ * 片段名称
162
+ */
163
+ name: string;
164
+ /**
165
+ * 片段内容
166
+ */
167
+ content: string;
168
+ /**
169
+ * 片段语言
170
+ */
171
+ language: string;
172
+ }
173
+
174
+ /**
175
+ * 完整代码示例
176
+ */
177
+ export interface CompleteCodeExample {
178
+ /**
179
+ * 主文件代码
180
+ */
181
+ main: string;
182
+ /**
183
+ * 依赖文件代码
184
+ */
185
+ dependencies?: Record<string, string>;
186
+ /**
187
+ * 配置文件代码
188
+ */
189
+ config?: Record<string, string>;
190
+ /**
191
+ * 示例说明
192
+ */
193
+ description?: string;
194
+ /**
195
+ * 示例标题
196
+ */
197
+ title?: string;
198
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * 获取DOM元素
3
+ * @param selector 选择器或DOM元素
4
+ * @returns DOM元素
5
+ */
6
+ export function getElement(selector: string | Element): Element | null {
7
+ if (typeof selector === 'string') {
8
+ return document.querySelector(selector);
9
+ }
10
+ return selector;
11
+ }
12
+
13
+ /**
14
+ * 是否为浏览器环境
15
+ * @returns 是否为浏览器环境
16
+ */
17
+ export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
18
+
19
+ /**
20
+ * 是否为NodeJS环境
21
+ * @returns 是否为NodeJS环境
22
+ */
23
+ export const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
24
+
25
+ /**
26
+ * 是否为React Native环境
27
+ * @returns 是否为React Native环境
28
+ */
29
+ export const isReactNative =
30
+ typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
31
+
32
+ /**
33
+ * 是否为小程序环境
34
+ * @returns 是否为小程序环境
35
+ */
36
+ export const isMiniApp = (): boolean => {
37
+ // 使用类型断言来安全地检查全局变量
38
+ const globalObj =
39
+ typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
40
+
41
+ if (typeof (globalObj as any).wx !== 'undefined') {
42
+ return true;
43
+ }
44
+ if (typeof (globalObj as any).my !== 'undefined') {
45
+ return true;
46
+ }
47
+ if (typeof (globalObj as any).swan !== 'undefined') {
48
+ return true;
49
+ }
50
+ if (typeof (globalObj as any).tt !== 'undefined') {
51
+ return true;
52
+ }
53
+ if (typeof (globalObj as any).jd !== 'undefined') {
54
+ return true;
55
+ }
56
+
57
+ return false;
58
+ };