@lark-apaas/coding-preset-vite-react 0.1.0

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 (93) hide show
  1. package/LICENSE +13 -0
  2. package/lib/index.d.ts +52 -0
  3. package/lib/index.d.ts.map +1 -0
  4. package/lib/index.js +410 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/plugins/capabilities.d.ts +23 -0
  7. package/lib/plugins/capabilities.d.ts.map +1 -0
  8. package/lib/plugins/capabilities.js +151 -0
  9. package/lib/plugins/capabilities.js.map +1 -0
  10. package/lib/plugins/dev-logs.d.ts +44 -0
  11. package/lib/plugins/dev-logs.d.ts.map +1 -0
  12. package/lib/plugins/dev-logs.js +544 -0
  13. package/lib/plugins/dev-logs.js.map +1 -0
  14. package/lib/plugins/error-overlay.d.ts +19 -0
  15. package/lib/plugins/error-overlay.d.ts.map +1 -0
  16. package/lib/plugins/error-overlay.js +136 -0
  17. package/lib/plugins/error-overlay.js.map +1 -0
  18. package/lib/plugins/fonts-mirror.d.ts +14 -0
  19. package/lib/plugins/fonts-mirror.d.ts.map +1 -0
  20. package/lib/plugins/fonts-mirror.js +70 -0
  21. package/lib/plugins/fonts-mirror.js.map +1 -0
  22. package/lib/plugins/health.d.ts +19 -0
  23. package/lib/plugins/health.d.ts.map +1 -0
  24. package/lib/plugins/health.js +36 -0
  25. package/lib/plugins/health.js.map +1 -0
  26. package/lib/plugins/hmr-timing.d.ts +13 -0
  27. package/lib/plugins/hmr-timing.d.ts.map +1 -0
  28. package/lib/plugins/hmr-timing.js +93 -0
  29. package/lib/plugins/hmr-timing.js.map +1 -0
  30. package/lib/plugins/html-minify.d.ts +18 -0
  31. package/lib/plugins/html-minify.d.ts.map +1 -0
  32. package/lib/plugins/html-minify.js +100 -0
  33. package/lib/plugins/html-minify.js.map +1 -0
  34. package/lib/plugins/module-alias.d.ts +12 -0
  35. package/lib/plugins/module-alias.d.ts.map +1 -0
  36. package/lib/plugins/module-alias.js +78 -0
  37. package/lib/plugins/module-alias.js.map +1 -0
  38. package/lib/plugins/og-meta.d.ts +21 -0
  39. package/lib/plugins/og-meta.d.ts.map +1 -0
  40. package/lib/plugins/og-meta.js +60 -0
  41. package/lib/plugins/og-meta.js.map +1 -0
  42. package/lib/plugins/polyfill.d.ts +11 -0
  43. package/lib/plugins/polyfill.d.ts.map +1 -0
  44. package/lib/plugins/polyfill.js +140 -0
  45. package/lib/plugins/polyfill.js.map +1 -0
  46. package/lib/plugins/routes.d.ts +26 -0
  47. package/lib/plugins/routes.d.ts.map +1 -0
  48. package/lib/plugins/routes.js +265 -0
  49. package/lib/plugins/routes.js.map +1 -0
  50. package/lib/plugins/slardar.d.ts +24 -0
  51. package/lib/plugins/slardar.d.ts.map +1 -0
  52. package/lib/plugins/slardar.js +74 -0
  53. package/lib/plugins/slardar.js.map +1 -0
  54. package/lib/plugins/static-assets.d.ts +10 -0
  55. package/lib/plugins/static-assets.d.ts.map +1 -0
  56. package/lib/plugins/static-assets.js +297 -0
  57. package/lib/plugins/static-assets.js.map +1 -0
  58. package/lib/plugins/view-context.d.ts +22 -0
  59. package/lib/plugins/view-context.d.ts.map +1 -0
  60. package/lib/plugins/view-context.js +132 -0
  61. package/lib/plugins/view-context.js.map +1 -0
  62. package/lib/plugins/vite-client-patch.d.ts +4 -0
  63. package/lib/plugins/vite-client-patch.d.ts.map +1 -0
  64. package/lib/plugins/vite-client-patch.js +37 -0
  65. package/lib/plugins/vite-client-patch.js.map +1 -0
  66. package/lib/plugins/ws-watchdog.d.ts +22 -0
  67. package/lib/plugins/ws-watchdog.d.ts.map +1 -0
  68. package/lib/plugins/ws-watchdog.js +103 -0
  69. package/lib/plugins/ws-watchdog.js.map +1 -0
  70. package/lib/polyfills/index.d.ts +15 -0
  71. package/lib/polyfills/index.d.ts.map +1 -0
  72. package/lib/polyfills/index.js +36 -0
  73. package/lib/polyfills/index.js.map +1 -0
  74. package/lib/utils/normalize-base-path.d.ts +37 -0
  75. package/lib/utils/normalize-base-path.d.ts.map +1 -0
  76. package/lib/utils/normalize-base-path.js +57 -0
  77. package/lib/utils/normalize-base-path.js.map +1 -0
  78. package/lib/utils/snapdom-proxy.d.ts +12 -0
  79. package/lib/utils/snapdom-proxy.d.ts.map +1 -0
  80. package/lib/utils/snapdom-proxy.js +75 -0
  81. package/lib/utils/snapdom-proxy.js.map +1 -0
  82. package/package.json +63 -0
  83. package/src/empty.css +1 -0
  84. package/src/inspector-stub.js +6 -0
  85. package/src/module-alias/clsx.mjs +8 -0
  86. package/src/module-alias/echarts-for-react.mjs +130 -0
  87. package/src/module-alias/echarts.mjs +43 -0
  88. package/src/module-alias/registry_echarts_theme.mjs +390 -0
  89. package/src/overlay/components.js +94 -0
  90. package/src/overlay/index.js +443 -0
  91. package/src/overlay/vite-client.js +555 -0
  92. package/src/polyfills/index.ts +35 -0
  93. package/src/runtime/ws-watchdog-client.mjs +148 -0
@@ -0,0 +1,390 @@
1
+ import Color from 'colorjs.io';
2
+
3
+ /**
4
+ * Get the value of a CSS variable and convert it to sRGB color space hex string
5
+ * @param varName CSS variable name
6
+ * @param element Optional element, defaults to document.body
7
+ * @returns sRGB color space hex string
8
+ */
9
+ export function getCssVariable(varName, element = document.body) {
10
+ const value = window
11
+ .getComputedStyle(element)
12
+ .getPropertyValue(varName)
13
+ .trim();
14
+ if (!value) {
15
+ return '';
16
+ }
17
+ return new Color(value).to('srgb').toString({ format: 'hex' });
18
+ }
19
+
20
+ // Generate ECharts theme configuration
21
+ export function generateEChartsTheme(element = document.body) {
22
+ // Get chart colors
23
+ const chartColors = [
24
+ getCssVariable('--chart-1', element),
25
+ getCssVariable('--chart-2', element),
26
+ getCssVariable('--chart-3', element),
27
+ getCssVariable('--chart-4', element),
28
+ getCssVariable('--chart-5', element),
29
+ ];
30
+
31
+ // Get other color variables
32
+ const background = getCssVariable('--background', element);
33
+ const foreground = getCssVariable('--foreground', element);
34
+ const muted = getCssVariable('--muted', element);
35
+ const mutedForeground = getCssVariable('--muted-foreground', element);
36
+ const border = getCssVariable('--border', element);
37
+ const primary = getCssVariable('--primary', element);
38
+
39
+ const fullTheme = {
40
+ color: chartColors,
41
+ backgroundColor: 'transparent',
42
+ textStyle: {
43
+ // color: foreground,
44
+ },
45
+ title: {
46
+ textStyle: {
47
+ color: foreground,
48
+ },
49
+ subtextStyle: {
50
+ color: mutedForeground,
51
+ },
52
+ },
53
+ line: {
54
+ itemStyle: {
55
+ borderWidth: 1,
56
+ },
57
+ lineStyle: {
58
+ width: 2,
59
+ },
60
+ symbolSize: 4,
61
+ symbol: 'circle',
62
+ smooth: false,
63
+ },
64
+ radar: {
65
+ itemStyle: {
66
+ borderWidth: 1,
67
+ },
68
+ lineStyle: {
69
+ width: 2,
70
+ },
71
+ symbolSize: 4,
72
+ symbol: 'circle',
73
+ smooth: false,
74
+ },
75
+ bar: {
76
+ itemStyle: {
77
+ barBorderWidth: 0,
78
+ barBorderColor: border,
79
+ },
80
+ },
81
+ pie: {
82
+ itemStyle: {
83
+ borderWidth: 0,
84
+ borderColor: border,
85
+ },
86
+ },
87
+ scatter: {
88
+ itemStyle: {
89
+ borderWidth: 0,
90
+ borderColor: border,
91
+ },
92
+ },
93
+ boxplot: {
94
+ itemStyle: {
95
+ borderWidth: 0,
96
+ borderColor: border,
97
+ },
98
+ },
99
+ parallel: {
100
+ itemStyle: {
101
+ borderWidth: 0,
102
+ borderColor: border,
103
+ },
104
+ },
105
+ sankey: {
106
+ itemStyle: {
107
+ borderWidth: 0,
108
+ borderColor: border,
109
+ },
110
+ },
111
+ funnel: {
112
+ itemStyle: {
113
+ borderWidth: 0,
114
+ borderColor: border,
115
+ },
116
+ },
117
+ gauge: {
118
+ itemStyle: {
119
+ borderWidth: 0,
120
+ borderColor: border,
121
+ },
122
+ },
123
+ candlestick: {
124
+ itemStyle: {
125
+ color: chartColors[0],
126
+ color0: chartColors[1],
127
+ borderColor: chartColors[0],
128
+ borderColor0: chartColors[1],
129
+ borderWidth: 1,
130
+ },
131
+ },
132
+ graph: {
133
+ itemStyle: {
134
+ borderWidth: 0,
135
+ borderColor: border,
136
+ },
137
+ lineStyle: {
138
+ width: 1,
139
+ color: mutedForeground,
140
+ },
141
+ symbolSize: 4,
142
+ symbol: 'circle',
143
+ smooth: false,
144
+ color: chartColors,
145
+ label: {
146
+ color: foreground,
147
+ },
148
+ },
149
+ map: {
150
+ itemStyle: {
151
+ areaColor: muted,
152
+ borderColor: border,
153
+ borderWidth: 0.5,
154
+ },
155
+ label: {
156
+ color: foreground,
157
+ },
158
+ emphasis: {
159
+ itemStyle: {
160
+ areaColor: chartColors[0],
161
+ borderColor: chartColors[1],
162
+ borderWidth: 1,
163
+ },
164
+ label: {
165
+ color: foreground,
166
+ },
167
+ },
168
+ },
169
+ geo: {
170
+ itemStyle: {
171
+ areaColor: muted,
172
+ borderColor: border,
173
+ borderWidth: 0.5,
174
+ },
175
+ label: {
176
+ color: foreground,
177
+ },
178
+ emphasis: {
179
+ itemStyle: {
180
+ areaColor: chartColors[0],
181
+ borderColor: chartColors[1],
182
+ borderWidth: 1,
183
+ },
184
+ label: {
185
+ color: foreground,
186
+ },
187
+ },
188
+ },
189
+ categoryAxis: {
190
+ axisLine: {
191
+ show: true,
192
+ lineStyle: {
193
+ color: border,
194
+ },
195
+ },
196
+ axisTick: {
197
+ show: true,
198
+ lineStyle: {
199
+ color: border,
200
+ },
201
+ },
202
+ axisLabel: {
203
+ show: true,
204
+ color: mutedForeground,
205
+ },
206
+ splitLine: {
207
+ show: false,
208
+ lineStyle: {
209
+ color: [border],
210
+ },
211
+ },
212
+ splitArea: {
213
+ show: false,
214
+ },
215
+ },
216
+ valueAxis: {
217
+ axisLine: {
218
+ show: true,
219
+ lineStyle: {
220
+ color: border,
221
+ },
222
+ },
223
+ axisTick: {
224
+ show: true,
225
+ lineStyle: {
226
+ color: border,
227
+ },
228
+ },
229
+ axisLabel: {
230
+ show: true,
231
+ color: mutedForeground,
232
+ },
233
+ splitLine: {
234
+ show: true,
235
+ lineStyle: {
236
+ color: [border],
237
+ },
238
+ },
239
+ splitArea: {
240
+ show: false,
241
+ },
242
+ },
243
+ logAxis: {
244
+ axisLine: {
245
+ show: true,
246
+ lineStyle: {
247
+ color: border,
248
+ },
249
+ },
250
+ axisTick: {
251
+ show: true,
252
+ lineStyle: {
253
+ color: border,
254
+ },
255
+ },
256
+ axisLabel: {
257
+ show: true,
258
+ color: mutedForeground,
259
+ },
260
+ splitLine: {
261
+ show: true,
262
+ lineStyle: {
263
+ color: [border],
264
+ },
265
+ },
266
+ splitArea: {
267
+ show: false,
268
+ },
269
+ },
270
+ timeAxis: {
271
+ axisLine: {
272
+ show: true,
273
+ lineStyle: {
274
+ color: border,
275
+ },
276
+ },
277
+ axisTick: {
278
+ show: true,
279
+ lineStyle: {
280
+ color: border,
281
+ },
282
+ },
283
+ axisLabel: {
284
+ show: true,
285
+ color: mutedForeground,
286
+ },
287
+ splitLine: {
288
+ show: true,
289
+ lineStyle: {
290
+ color: [border],
291
+ },
292
+ },
293
+ splitArea: {
294
+ show: false,
295
+ },
296
+ },
297
+ toolbox: {
298
+ iconStyle: {
299
+ borderColor: mutedForeground,
300
+ },
301
+ emphasis: {
302
+ iconStyle: {
303
+ borderColor: primary,
304
+ },
305
+ },
306
+ },
307
+ legend: {
308
+ textStyle: {
309
+ color: foreground,
310
+ },
311
+ },
312
+ tooltip: {
313
+ axisPointer: {
314
+ lineStyle: {
315
+ color: border,
316
+ width: 1,
317
+ },
318
+ crossStyle: {
319
+ color: border,
320
+ width: 1,
321
+ },
322
+ },
323
+ },
324
+ timeline: {
325
+ lineStyle: {
326
+ color: primary,
327
+ width: 1,
328
+ },
329
+ itemStyle: {
330
+ color: primary,
331
+ borderWidth: 1,
332
+ },
333
+ controlStyle: {
334
+ color: primary,
335
+ borderColor: primary,
336
+ borderWidth: 0.5,
337
+ },
338
+ checkpointStyle: {
339
+ color: chartColors[1],
340
+ borderColor: chartColors[1],
341
+ },
342
+ label: {
343
+ color: mutedForeground,
344
+ },
345
+ emphasis: {
346
+ itemStyle: {
347
+ color: chartColors[1],
348
+ },
349
+ controlStyle: {
350
+ color: primary,
351
+ borderColor: primary,
352
+ borderWidth: 0.5,
353
+ },
354
+ label: {
355
+ color: mutedForeground,
356
+ },
357
+ },
358
+ },
359
+ visualMap: {
360
+ color: [chartColors[0], chartColors[2]],
361
+ },
362
+ dataZoom: {
363
+ backgroundColor: background,
364
+ dataBackgroundColor: border,
365
+ fillerColor: `${chartColors[0]}40`, // 25% opacity
366
+ handleColor: primary,
367
+ handleSize: '100%',
368
+ textStyle: {
369
+ color: foreground,
370
+ },
371
+ },
372
+ markPoint: {
373
+ label: {
374
+ color: foreground,
375
+ },
376
+ emphasis: {
377
+ label: {
378
+ color: foreground,
379
+ },
380
+ },
381
+ },
382
+ };
383
+ return fullTheme;
384
+ }
385
+
386
+ // Get current theme's ECharts configuration
387
+ export function getShadcnEChartsTheme() {
388
+ // body
389
+ return generateEChartsTheme(document.body);
390
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * 错误容器组件
3
+ * @param {*} document
4
+ * @param {*} root
5
+ * @param {string} errorTitle 错误标题
6
+ */
7
+ function ErrorContainer(document, root, errorTitle) {
8
+ // 创建容器元素
9
+ const container = document.createElement('div');
10
+ container.className = 'overlay-container';
11
+
12
+ // 创建内容元素
13
+ const content = document.createElement('div');
14
+ content.className = 'overlay-content';
15
+ container.appendChild(content);
16
+
17
+ // 创建图片元素
18
+ const img = document.createElement('img');
19
+ img.src =
20
+ 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg';
21
+ img.alt = 'Error';
22
+ // 图片占位
23
+ img.width = 100;
24
+ img.height = 100;
25
+ img.className = 'overlay-error-image';
26
+ content.appendChild(img);
27
+
28
+ // 创建标题元素
29
+ const title = document.createElement('p');
30
+ title.className = 'overlay-title';
31
+ title.textContent = errorTitle;
32
+ content.appendChild(title);
33
+
34
+ // 添加到根元素
35
+ root.appendChild(container);
36
+ }
37
+
38
+ function RootStyle(document, root) {
39
+ const style = document.createElement('style');
40
+ style.id = 'react-refresh-overlay-style';
41
+ style.textContent = `
42
+ * {
43
+ margin: 0;
44
+ padding: 0;
45
+ box-sizing: border-box;
46
+ }
47
+
48
+ body {
49
+ font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
50
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
51
+ sans-serif;
52
+ -webkit-font-smoothing: antialiased;
53
+ -moz-osx-font-smoothing: grayscale;
54
+ }
55
+
56
+ .overlay-container {
57
+ min-height: 100vh;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ background-color: #fff;
62
+ }
63
+
64
+ .overlay-content {
65
+ display: flex;
66
+ flex-direction: column;
67
+ justify-content: center;
68
+ align-items: center;
69
+ text-align: center;
70
+ }
71
+
72
+ .overlay-error-image {
73
+ margin-bottom: 12px; /* mb-3 */
74
+ width: 100px; /* w-[100px] */
75
+ height: auto;
76
+ }
77
+
78
+ .overlay-title {
79
+ color: #1F2329;
80
+ text-align: center;
81
+ font-size: 14px;
82
+ font-style: normal;
83
+ font-weight: 500;
84
+ line-height: 22px;
85
+ }
86
+
87
+ `;
88
+ root.appendChild(style);
89
+ }
90
+
91
+ module.exports = {
92
+ ErrorContainer,
93
+ RootStyle,
94
+ };