@lark-apaas/coding-vite-preset 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 (108) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +68 -0
  3. package/lib/index.d.ts +37 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +69 -0
  6. package/lib/index.js.map +1 -0
  7. package/lib/module-alias/clsx.d.ts +4 -0
  8. package/lib/module-alias/clsx.d.ts.map +1 -0
  9. package/lib/module-alias/clsx.js +13 -0
  10. package/lib/module-alias/clsx.js.map +1 -0
  11. package/lib/module-alias/echarts-for-react.d.ts +14 -0
  12. package/lib/module-alias/echarts-for-react.d.ts.map +1 -0
  13. package/lib/module-alias/echarts-for-react.js +142 -0
  14. package/lib/module-alias/echarts-for-react.js.map +1 -0
  15. package/lib/module-alias/echarts.d.ts +9 -0
  16. package/lib/module-alias/echarts.d.ts.map +1 -0
  17. package/lib/module-alias/echarts.js +84 -0
  18. package/lib/module-alias/echarts.js.map +1 -0
  19. package/lib/module-alias/registry_echarts_theme.d.ts +692 -0
  20. package/lib/module-alias/registry_echarts_theme.d.ts.map +1 -0
  21. package/lib/module-alias/registry_echarts_theme.js +394 -0
  22. package/lib/module-alias/registry_echarts_theme.js.map +1 -0
  23. package/lib/polyfills/index.d.ts +15 -0
  24. package/lib/polyfills/index.d.ts.map +1 -0
  25. package/lib/polyfills/index.js +36 -0
  26. package/lib/polyfills/index.js.map +1 -0
  27. package/lib/preset.d.ts +14 -0
  28. package/lib/preset.d.ts.map +1 -0
  29. package/lib/preset.js +452 -0
  30. package/lib/preset.js.map +1 -0
  31. package/lib/utils/hmr-timing.d.ts +10 -0
  32. package/lib/utils/hmr-timing.d.ts.map +1 -0
  33. package/lib/utils/hmr-timing.js +102 -0
  34. package/lib/utils/hmr-timing.js.map +1 -0
  35. package/lib/utils/normalize-base-path.d.ts +12 -0
  36. package/lib/utils/normalize-base-path.d.ts.map +1 -0
  37. package/lib/utils/normalize-base-path.js +24 -0
  38. package/lib/utils/normalize-base-path.js.map +1 -0
  39. package/lib/utils/snapdom-proxy.d.ts +8 -0
  40. package/lib/utils/snapdom-proxy.d.ts.map +1 -0
  41. package/lib/utils/snapdom-proxy.js +52 -0
  42. package/lib/utils/snapdom-proxy.js.map +1 -0
  43. package/lib/vite-plugins/banner-plugin.d.ts +3 -0
  44. package/lib/vite-plugins/banner-plugin.d.ts.map +1 -0
  45. package/lib/vite-plugins/banner-plugin.js +26 -0
  46. package/lib/vite-plugins/banner-plugin.js.map +1 -0
  47. package/lib/vite-plugins/css-legacy-plugin.d.ts +12 -0
  48. package/lib/vite-plugins/css-legacy-plugin.d.ts.map +1 -0
  49. package/lib/vite-plugins/css-legacy-plugin.js +205 -0
  50. package/lib/vite-plugins/css-legacy-plugin.js.map +1 -0
  51. package/lib/vite-plugins/error-overlay-plugin.d.ts +33 -0
  52. package/lib/vite-plugins/error-overlay-plugin.d.ts.map +1 -0
  53. package/lib/vite-plugins/error-overlay-plugin.js +129 -0
  54. package/lib/vite-plugins/error-overlay-plugin.js.map +1 -0
  55. package/lib/vite-plugins/html-output-plugin.d.ts +21 -0
  56. package/lib/vite-plugins/html-output-plugin.d.ts.map +1 -0
  57. package/lib/vite-plugins/html-output-plugin.js +171 -0
  58. package/lib/vite-plugins/html-output-plugin.js.map +1 -0
  59. package/lib/vite-plugins/module-alias-plugin.d.ts +10 -0
  60. package/lib/vite-plugins/module-alias-plugin.d.ts.map +1 -0
  61. package/lib/vite-plugins/module-alias-plugin.js +40 -0
  62. package/lib/vite-plugins/module-alias-plugin.js.map +1 -0
  63. package/lib/vite-plugins/og-meta-plugin.d.ts +17 -0
  64. package/lib/vite-plugins/og-meta-plugin.d.ts.map +1 -0
  65. package/lib/vite-plugins/og-meta-plugin.js +80 -0
  66. package/lib/vite-plugins/og-meta-plugin.js.map +1 -0
  67. package/lib/vite-plugins/polyfill-plugin.d.ts +12 -0
  68. package/lib/vite-plugins/polyfill-plugin.d.ts.map +1 -0
  69. package/lib/vite-plugins/polyfill-plugin.js +132 -0
  70. package/lib/vite-plugins/polyfill-plugin.js.map +1 -0
  71. package/lib/vite-plugins/route-parser-plugin.d.ts +13 -0
  72. package/lib/vite-plugins/route-parser-plugin.d.ts.map +1 -0
  73. package/lib/vite-plugins/route-parser-plugin.js +120 -0
  74. package/lib/vite-plugins/route-parser-plugin.js.map +1 -0
  75. package/lib/vite-plugins/runtime-injection-plugin.d.ts +23 -0
  76. package/lib/vite-plugins/runtime-injection-plugin.d.ts.map +1 -0
  77. package/lib/vite-plugins/runtime-injection-plugin.js +93 -0
  78. package/lib/vite-plugins/runtime-injection-plugin.js.map +1 -0
  79. package/lib/vite-plugins/slardar-plugin.d.ts +10 -0
  80. package/lib/vite-plugins/slardar-plugin.d.ts.map +1 -0
  81. package/lib/vite-plugins/slardar-plugin.js +102 -0
  82. package/lib/vite-plugins/slardar-plugin.js.map +1 -0
  83. package/lib/vite-plugins/source-map-upload-plugin.d.ts +7 -0
  84. package/lib/vite-plugins/source-map-upload-plugin.d.ts.map +1 -0
  85. package/lib/vite-plugins/source-map-upload-plugin.js +85 -0
  86. package/lib/vite-plugins/source-map-upload-plugin.js.map +1 -0
  87. package/lib/vite-plugins/static-assets-plugin.d.ts +27 -0
  88. package/lib/vite-plugins/static-assets-plugin.d.ts.map +1 -0
  89. package/lib/vite-plugins/static-assets-plugin.js +393 -0
  90. package/lib/vite-plugins/static-assets-plugin.js.map +1 -0
  91. package/lib/vite-plugins/view-context-plugin.d.ts +4 -0
  92. package/lib/vite-plugins/view-context-plugin.d.ts.map +1 -0
  93. package/lib/vite-plugins/view-context-plugin.js +40 -0
  94. package/lib/vite-plugins/view-context-plugin.js.map +1 -0
  95. package/lib/vite-plugins/vite-client-patch-plugin.d.ts +23 -0
  96. package/lib/vite-plugins/vite-client-patch-plugin.d.ts.map +1 -0
  97. package/lib/vite-plugins/vite-client-patch-plugin.js +53 -0
  98. package/lib/vite-plugins/vite-client-patch-plugin.js.map +1 -0
  99. package/package.json +61 -0
  100. package/src/empty.css +1 -0
  101. package/src/inspector-stub.js +6 -0
  102. package/src/module-alias/clsx.mjs +8 -0
  103. package/src/module-alias/echarts-for-react.mjs +129 -0
  104. package/src/module-alias/echarts.mjs +43 -0
  105. package/src/module-alias/registry_echarts_theme.mjs +390 -0
  106. package/src/overlay/components.js +94 -0
  107. package/src/overlay/index.js +443 -0
  108. package/src/overlay/vite-client.js +554 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Lark Technologies Pte. Ltd. and/or its affiliates
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @lark-apaas/coding-vite-preset
2
+
3
+ Vite 8 preset for OpenClaw projects. Provides a batteries-included Vite configuration with React, TypeScript, and production optimizations.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @lark-apaas/coding-vite-preset
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ // vite.config.ts
15
+ import { defineConfig } from '@lark-apaas/coding-vite-preset';
16
+
17
+ export default defineConfig({
18
+ // your overrides
19
+ });
20
+ ```
21
+
22
+ Or use the lower-level API for more control:
23
+
24
+ ```ts
25
+ import { createRecommendViteConfig } from '@lark-apaas/coding-vite-preset';
26
+ import { mergeConfig } from 'vite';
27
+
28
+ const base = createRecommendViteConfig({
29
+ isDev: process.env.NODE_ENV !== 'production',
30
+ clientBasePath: '/app/myapp',
31
+ });
32
+
33
+ export default mergeConfig(base, {
34
+ // your overrides
35
+ });
36
+ ```
37
+
38
+ ## Environment Variables
39
+
40
+ | Variable | Default | Description |
41
+ |----------|---------|-------------|
42
+ | `NODE_ENV` | `development` | `production` enables minification, sourcemap hiding, polyfills |
43
+ | `CLIENT_BASE_PATH` | `/` | Client base path (e.g. `/app/app123`) |
44
+ | `ASSETS_CDN_PATH` | `/` | Production CDN path for static assets |
45
+ | `SERVER_PORT` | `3000` | Backend server port for API proxy |
46
+ | `CLIENT_DEV_PORT` | `8080` | Dev server port |
47
+ | `CLIENT_DEV_HOST` | `localhost` | Dev server host |
48
+ | `NEED_ROUTES` | `true` | Enable route parsing from app.tsx |
49
+ | `RELEASE_ID` | ISO timestamp | Release identifier injected into bundle |
50
+ | `DISABLE_INSPECTOR` | `false` | Set to `true` to disable dev inspector |
51
+
52
+ ## What's Included
53
+
54
+ - **React** via `@vitejs/plugin-react` v6 (Oxc-based)
55
+ - **TypeScript path aliases** via `vite-tsconfig-paths`
56
+ - **Polyfills** via `@vitejs/plugin-legacy` (modernPolyfills mode, no legacy chunks)
57
+ - **CSS compatibility** via `build.cssTarget` (iOS 12, Safari 12, Chrome 80)
58
+ - **HMR timing** tracking in dev mode
59
+ - **API proxy** to backend server
60
+ - **Static assets** plugin for `@shared/static/*` imports
61
+
62
+ ## Docs
63
+
64
+ - [Migration from fullstack-vite-preset](./docs/migration-from-fullstack.md)
65
+
66
+ ## License
67
+
68
+ MIT
package/lib/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { type UserConfig } from 'vite';
2
+ /**
3
+ * Define Fullstack Vite configuration
4
+ *
5
+ * Automatically reads configuration from environment variables, users only need to provide override configuration
6
+ *
7
+ * @param overrides - User-defined Vite configuration, will be deep merged with default configuration
8
+ * @returns Complete Vite configuration object
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * import { defineConfig } from '@lark-apaas/fullstack-vite-preset';
13
+ * import path from 'path';
14
+ *
15
+ * export default defineConfig({
16
+ * resolve: {
17
+ * alias: {
18
+ * '@': path.resolve(__dirname, 'client/src'),
19
+ * },
20
+ * },
21
+ * });
22
+ * ```
23
+ *
24
+ * Supported environment variables:
25
+ * - NODE_ENV: development | production (default: development)
26
+ * - NEED_ROUTES: true | false (default: true)
27
+ * - CLIENT_BASE_PATH: Client base path (default: /)
28
+ * - ASSETS_CDN_PATH: Production CDN path (default: /)
29
+ * - SERVER_PORT: Server port (default: 3000)
30
+ * - CLIENT_DEV_PORT: Client dev port (default: 8080)
31
+ * - CLIENT_DEV_HOST: Client dev host (default: localhost)
32
+ */
33
+ export declare function createFullstackViteConfig(overrides?: UserConfig): UserConfig;
34
+ export { createFullstackViteConfig as defineConfig };
35
+ export type { CreateRecommendViteConfigOptions } from './preset';
36
+ export { createRecommendViteConfig } from './preset';
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,GAAE,UAAe,GACzB,UAAU,CA+BZ;AAGD,OAAO,EAAE,yBAAyB,IAAI,YAAY,EAAE,CAAC;AAGrD,YAAY,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRecommendViteConfig = void 0;
4
+ exports.createFullstackViteConfig = createFullstackViteConfig;
5
+ exports.defineConfig = createFullstackViteConfig;
6
+ const vite_1 = require("vite");
7
+ const preset_1 = require("./preset");
8
+ const normalize_base_path_1 = require("./utils/normalize-base-path");
9
+ /**
10
+ * Define Fullstack Vite configuration
11
+ *
12
+ * Automatically reads configuration from environment variables, users only need to provide override configuration
13
+ *
14
+ * @param overrides - User-defined Vite configuration, will be deep merged with default configuration
15
+ * @returns Complete Vite configuration object
16
+ *
17
+ * @example
18
+ * ```javascript
19
+ * import { defineConfig } from '@lark-apaas/fullstack-vite-preset';
20
+ * import path from 'path';
21
+ *
22
+ * export default defineConfig({
23
+ * resolve: {
24
+ * alias: {
25
+ * '@': path.resolve(__dirname, 'client/src'),
26
+ * },
27
+ * },
28
+ * });
29
+ * ```
30
+ *
31
+ * Supported environment variables:
32
+ * - NODE_ENV: development | production (default: development)
33
+ * - NEED_ROUTES: true | false (default: true)
34
+ * - CLIENT_BASE_PATH: Client base path (default: /)
35
+ * - ASSETS_CDN_PATH: Production CDN path (default: /)
36
+ * - SERVER_PORT: Server port (default: 3000)
37
+ * - CLIENT_DEV_PORT: Client dev port (default: 8080)
38
+ * - CLIENT_DEV_HOST: Client dev host (default: localhost)
39
+ */
40
+ function createFullstackViteConfig(overrides = {}) {
41
+ // 1. Auto-load .env file (synchronous load to ensure env vars are immediately available)
42
+ try {
43
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
44
+ require('dotenv').config();
45
+ }
46
+ catch (e) {
47
+ // dotenv is an optional dependency, if not installed it won't affect usage
48
+ }
49
+ // 2. Read configuration from environment variables
50
+ const isDev = process.env.NODE_ENV !== 'production';
51
+ const needRoutes = process.env.NEED_ROUTES !== 'false'; // default true
52
+ // 3. Handle path configuration
53
+ const clientBasePath = (0, normalize_base_path_1.normalizeBasePath)(process.env.CLIENT_BASE_PATH || '/');
54
+ const publicPath = (0, normalize_base_path_1.normalizeBasePathWithoutTrailingSlash)(isDev
55
+ ? process.env.CLIENT_BASE_PATH || '/'
56
+ : process.env.ASSETS_CDN_PATH || '/');
57
+ // 4. Call preset function to generate base configuration
58
+ const baseConfig = (0, preset_1.createRecommendViteConfig)({
59
+ isDev,
60
+ needRoutes,
61
+ clientBasePath,
62
+ publicPath,
63
+ });
64
+ // 5. Deep merge user configuration
65
+ return (0, vite_1.mergeConfig)(baseConfig, overrides);
66
+ }
67
+ var preset_2 = require("./preset");
68
+ Object.defineProperty(exports, "createRecommendViteConfig", { enumerable: true, get: function () { return preset_2.createRecommendViteConfig; } });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAmCA,8DAiCC;AAGqC,iDAAY;AAvElD,+BAAoD;AACpD,qCAAqD;AACrD,qEAAuG;AAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,yBAAyB,CACvC,YAAwB,EAAE;IAE1B,yFAAyF;IACzF,IAAI,CAAC;QACH,8DAA8D;QAC9D,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,2EAA2E;IAC7E,CAAC;IAED,mDAAmD;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IACpD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,eAAe;IAEvE,+BAA+B;IAC/B,MAAM,cAAc,GAAG,IAAA,uCAAiB,EAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,IAAA,2DAAqC,EACtD,KAAK;QACH,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG;QACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CACvC,CAAC;IAEF,yDAAyD;IACzD,MAAM,UAAU,GAAG,IAAA,kCAAyB,EAAC;QAC3C,KAAK;QACL,UAAU;QACV,cAAc;QACd,UAAU;KACX,CAAC,CAAC;IAEH,mCAAmC;IACnC,OAAO,IAAA,kBAAW,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC;AAOD,mCAAqD;AAA5C,mHAAA,yBAAyB,OAAA"}
@@ -0,0 +1,4 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function clsx(...args: ClassValue[]): string;
3
+ export default clsx;
4
+ //# sourceMappingURL=clsx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clsx.d.ts","sourceRoot":"","sources":["../../src/module-alias/clsx.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAG5C,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,EAAE,UAEzC;AAED,eAAe,IAAI,CAAC"}
@@ -0,0 +1,13 @@
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.clsx = clsx;
7
+ const clsx_1 = __importDefault(require("clsx"));
8
+ const tailwind_merge_1 = require("tailwind-merge");
9
+ function clsx(...args) {
10
+ return (0, tailwind_merge_1.twMerge)((0, clsx_1.default)(...args));
11
+ }
12
+ exports.default = clsx;
13
+ //# sourceMappingURL=clsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clsx.js","sourceRoot":"","sources":["../../src/module-alias/clsx.ts"],"names":[],"mappings":";;;;;AAGA,oBAEC;AALD,gDAA4C;AAC5C,mDAAyC;AAEzC,SAAgB,IAAI,CAAC,GAAG,IAAkB;IACxC,OAAO,IAAA,wBAAO,EAAC,IAAA,cAAG,EAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import OriginalReactECharts from 'echarts-for-react';
3
+ import type { EChartsReactProps } from 'echarts-for-react';
4
+ /**
5
+ * EChartsReact wrapper component
6
+ * - Automatically converts HSL colors to hex in option
7
+ * - Removes label.color from funnel series
8
+ */
9
+ export declare class EChartsReact extends React.Component<EChartsReactProps> {
10
+ render(): React.CElement<EChartsReactProps, OriginalReactECharts>;
11
+ }
12
+ export * from 'echarts-for-react';
13
+ export default EChartsReact;
14
+ //# sourceMappingURL=echarts-for-react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echarts-for-react.d.ts","sourceRoot":"","sources":["../../src/module-alias/echarts-for-react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,oBAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA+G3D;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC;IAClE,MAAM;CAYP;AAED,cAAc,mBAAmB,CAAC;AAClC,eAAe,YAAY,CAAC"}
@@ -0,0 +1,142 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.EChartsReact = void 0;
21
+ const react_1 = __importDefault(require("react"));
22
+ const echarts_for_react_1 = __importDefault(require("echarts-for-react"));
23
+ const colorjs_io_1 = __importDefault(require("colorjs.io"));
24
+ /**
25
+ * Convert HSL/HSLA color to hex or rgba
26
+ */
27
+ function convertColorToHex(color) {
28
+ if (typeof color !== 'string')
29
+ return color;
30
+ const trimmed = color.trim();
31
+ if (!trimmed.startsWith('hsl')) {
32
+ return color;
33
+ }
34
+ try {
35
+ const colorObj = new colorjs_io_1.default(trimmed);
36
+ if (colorObj.alpha < 1) {
37
+ return colorObj.to('srgb').toString({ format: 'rgba' });
38
+ }
39
+ else {
40
+ return colorObj.to('srgb').toString({ format: 'hex' });
41
+ }
42
+ }
43
+ catch (error) {
44
+ console.warn(`Failed to convert color: ${color}`, error);
45
+ return color;
46
+ }
47
+ }
48
+ function convertColorValue(propValue, visited) {
49
+ if (typeof propValue === 'string') {
50
+ return convertColorToHex(propValue);
51
+ }
52
+ if (Array.isArray(propValue)) {
53
+ return propValue.map((item) => typeof item === 'string' ? convertColorToHex(item) : transformColors(item, visited));
54
+ }
55
+ return transformColors(propValue, visited);
56
+ }
57
+ /**
58
+ * Deep traverse object to transform all HSL colors in 'color' property
59
+ */
60
+ function transformColors(value, visited = new WeakSet()) {
61
+ if (value === null || value === undefined)
62
+ return value;
63
+ if (typeof value !== 'object')
64
+ return value;
65
+ if (visited.has(value))
66
+ return value;
67
+ if (value instanceof Date || value instanceof RegExp)
68
+ return value;
69
+ visited.add(value);
70
+ if (Array.isArray(value)) {
71
+ return value.map((item) => transformColors(item, visited));
72
+ }
73
+ const obj = value;
74
+ const result = {};
75
+ for (const key in obj) {
76
+ if (!Object.prototype.hasOwnProperty.call(obj, key))
77
+ continue;
78
+ const propValue = obj[key];
79
+ if (key === 'color') {
80
+ if (typeof propValue === 'function') {
81
+ result[key] = (...args) => convertColorValue(propValue(...args), visited);
82
+ }
83
+ else {
84
+ result[key] = convertColorValue(propValue, visited);
85
+ }
86
+ }
87
+ else {
88
+ result[key] = transformColors(propValue, visited);
89
+ }
90
+ }
91
+ return result;
92
+ }
93
+ /**
94
+ * Remove label.color and emphasis.label.color from funnel series
95
+ * to let ECharts use default contrast colors
96
+ */
97
+ function removeFunnelLabelColor(option) {
98
+ const opt = option;
99
+ if (!Array.isArray(opt.series))
100
+ return option;
101
+ const series = opt.series.map((item) => {
102
+ if (item?.type !== 'funnel')
103
+ return item;
104
+ let result = { ...item };
105
+ // remove label.color
106
+ if (result.label && typeof result.label === 'object') {
107
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
108
+ const { color: _, ...labelRest } = result.label;
109
+ result = { ...result, label: labelRest };
110
+ }
111
+ // remove emphasis.label.color
112
+ const emphasis = result.emphasis;
113
+ if (emphasis?.label && typeof emphasis.label === 'object') {
114
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
115
+ const { color: _, ...emphasisLabelRest } = emphasis.label;
116
+ result = { ...result, emphasis: { ...emphasis, label: emphasisLabelRest } };
117
+ }
118
+ return result;
119
+ });
120
+ return { ...opt, series };
121
+ }
122
+ /**
123
+ * EChartsReact wrapper component
124
+ * - Automatically converts HSL colors to hex in option
125
+ * - Removes label.color from funnel series
126
+ */
127
+ class EChartsReact extends react_1.default.Component {
128
+ render() {
129
+ const { option, ...rest } = this.props;
130
+ const transformedOption = option
131
+ ? removeFunnelLabelColor(transformColors(option))
132
+ : option;
133
+ return react_1.default.createElement(echarts_for_react_1.default, {
134
+ option: transformedOption,
135
+ ...rest,
136
+ });
137
+ }
138
+ }
139
+ exports.EChartsReact = EChartsReact;
140
+ __exportStar(require("echarts-for-react"), exports);
141
+ exports.default = EChartsReact;
142
+ //# sourceMappingURL=echarts-for-react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echarts-for-react.js","sourceRoot":"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AAC,EAAE,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,KAAgC,CAAC;YACrF,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC;QAC9E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,GAAG,EAAE,MAAM,EAAO,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAa,YAAa,SAAQ,eAAK,CAAC,SAA4B;IAClE,MAAM;QACJ,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEvC,MAAM,iBAAiB,GAAG,MAAM;YAC9B,CAAC,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC,CAAC,MAAM,CAAC;QAEX,OAAO,eAAK,CAAC,aAAa,CAAC,2BAAoB,EAAE;YAC/C,MAAM,EAAE,iBAAiB;YACzB,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAbD,oCAaC;AAED,oDAAkC;AAClC,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ import * as echartsNamespace from 'echarts';
2
+ export { echartsNamespace as echarts };
3
+ export * from 'echarts';
4
+ /**
5
+ * Mount echarts to window for debugging
6
+ */
7
+ export declare function registerEchartsToWindow(): void;
8
+ export declare function resgisterEchartsTheme(): void;
9
+ //# sourceMappingURL=echarts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echarts.d.ts","sourceRoot":"","sources":["../../src/module-alias/echarts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,gBAAgB,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,CAAC;AACvC,cAAc,SAAS,CAAC;AAOxB;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAM9C;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C"}
@@ -0,0 +1,84 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.echarts = void 0;
40
+ exports.registerEchartsToWindow = registerEchartsToWindow;
41
+ exports.resgisterEchartsTheme = resgisterEchartsTheme;
42
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
43
+ // @ts-nocheck - echarts types are complex, ignore for re-export
44
+ const echartsNamespace = __importStar(require("echarts"));
45
+ exports.echarts = echartsNamespace;
46
+ __exportStar(require("echarts"), exports);
47
+ const echarts_1 = require("echarts");
48
+ const registry_echarts_theme_1 = require("./registry_echarts_theme");
49
+ let isRegistered = false;
50
+ let isWindowMounted = false;
51
+ /**
52
+ * Mount echarts to window for debugging
53
+ */
54
+ function registerEchartsToWindow() {
55
+ if (isWindowMounted || typeof globalThis.window === 'undefined') {
56
+ return;
57
+ }
58
+ isWindowMounted = true;
59
+ globalThis.echarts = echartsNamespace;
60
+ }
61
+ function resgisterEchartsTheme() {
62
+ // Register ud theme, only register once globally
63
+ if (isRegistered) {
64
+ return;
65
+ }
66
+ isRegistered = true;
67
+ // After bundling main.js defer execution, css will be loaded
68
+ (0, echarts_1.registerTheme)('ud', (0, registry_echarts_theme_1.getShadcnEChartsTheme)());
69
+ if (process.env.NODE_ENV === 'development') {
70
+ // Listen for HMR update completion to re-register theme
71
+ // Vite uses import.meta.hot instead of webpack's module.hot
72
+ // @ts-expect-error - import.meta.hot is Vite-specific
73
+ if (import.meta.hot) {
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
+ // @ts-expect-error
76
+ import.meta.hot.on('vite:afterUpdate', () => {
77
+ (0, echarts_1.registerTheme)('ud', (0, registry_echarts_theme_1.getShadcnEChartsTheme)());
78
+ });
79
+ }
80
+ }
81
+ }
82
+ registerEchartsToWindow();
83
+ resgisterEchartsTheme();
84
+ //# sourceMappingURL=echarts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echarts.js","sourceRoot":"","sources":["../../src/module-alias/echarts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,0DAMC;AAED,sDAqBC;AA3CD,6DAA6D;AAC7D,gEAAgE;AAChE,0DAA4C;AACf,mCAAO;AACpC,0CAAwB;AACxB,qCAAwC;AACxC,qEAAiE;AAEjE,IAAI,YAAY,GAAG,KAAK,CAAC;AAC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