@lark-apaas/miaoda-presets 0.1.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
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
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8
+ IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
9
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
10
+ EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
11
+ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
12
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
13
+ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Presets
@@ -0,0 +1,49 @@
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.createEslintConfig = createEslintConfig;
7
+ const js_1 = __importDefault(require("@eslint/js"));
8
+ const globals_1 = __importDefault(require("globals"));
9
+ const eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
10
+ const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
11
+ const eslint_1 = __importDefault(require("./recommend/eslint"));
12
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
13
+ const importPlugin = require('eslint-plugin-import');
14
+ function createEslintConfig() {
15
+ return typescript_eslint_1.default.config({ ignores: ['dist', 'node_modules', 'build'] }, {
16
+ extends: [js_1.default.configs.recommended, eslint_1.default, ...typescript_eslint_1.default.configs.recommended],
17
+ files: ['src/**/*.{ts,tsx}'],
18
+ languageOptions: {
19
+ ecmaVersion: 2020,
20
+ globals: {
21
+ ...globals_1.default.browser,
22
+ ...globals_1.default.node,
23
+ // for NodeJS globals typescript
24
+ NodeJS: true,
25
+ },
26
+ },
27
+ plugins: {
28
+ 'react-hooks': eslint_plugin_react_hooks_1.default,
29
+ import: importPlugin,
30
+ },
31
+ settings: {
32
+ 'import/resolver': {
33
+ node: {
34
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
35
+ },
36
+ alias: {
37
+ map: [['@', './src']],
38
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
39
+ },
40
+ },
41
+ 'import/parsers': {
42
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
43
+ },
44
+ },
45
+ rules: {
46
+ ...eslint_plugin_react_hooks_1.default.configs.recommended.rules,
47
+ },
48
+ });
49
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * play-render 使用的 umd-loader
4
+ */
5
+ // Define scripts with their dependencies
6
+ const scripts = {
7
+ react: {
8
+ src: 'https://unpkg.byted-static.com/react/18.2.0/umd/react.development.js',
9
+ deps: [],
10
+ },
11
+ 'react-dom': {
12
+ src: 'https://unpkg.byted-static.com/react-dom/18.2.0/umd/react-dom.development.js',
13
+ deps: ['react'],
14
+ },
15
+ dayjs: {
16
+ src: 'https://unpkg.byted-static.com/dayjs/1.11.13/dayjs.min.js',
17
+ deps: [],
18
+ },
19
+ echarts: {
20
+ src: 'https://unpkg.byted-static.com/echarts/5.4.3/dist/echarts.min.js',
21
+ deps: [],
22
+ },
23
+ antdIcons: {
24
+ src: 'https://unpkg.byted-static.com/ant-design/icons/5.6.1/dist/index.umd.min.js',
25
+ deps: ['react'],
26
+ },
27
+ antd: {
28
+ src: 'https://unpkg.byted-static.com/byted/spark-ui/5.26.6-patch.7/dist/antd-with-locales.js',
29
+ // src: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/antd/5.26.6-patch.6/antd-with-locales.js',
30
+ // src: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/antd/5.26.6-patch.5/antd.js',
31
+ deps: ['react', 'react-dom', 'dayjs'],
32
+ },
33
+ };
34
+ // Function to load script
35
+ function loadScript(src) {
36
+ return new Promise((resolve, reject) => {
37
+ const script = document.createElement('script');
38
+ script.src = src;
39
+ script.onload = resolve;
40
+ script.onerror = reject;
41
+ document.head.appendChild(script);
42
+ });
43
+ }
44
+ // Function to load scripts based on dependencies
45
+ function loadScriptsWithDeps() {
46
+ const loaded = new Set();
47
+ const loading = new Map();
48
+ function loadWithDeps(name) {
49
+ // If already loaded, return resolved promise
50
+ if (loaded.has(name)) {
51
+ return Promise.resolve();
52
+ }
53
+ // If currently loading, return the existing promise
54
+ if (loading.has(name)) {
55
+ return loading.get(name);
56
+ }
57
+ const script = scripts[name];
58
+ // Create loading promise for this script
59
+ const loadingPromise = Promise.all(
60
+ // Map dependencies to promises
61
+ script.deps.map((dep) => loadWithDeps(dep)))
62
+ .then(() => {
63
+ // After all dependencies are loaded, load this script
64
+ return loadScript(script.src);
65
+ })
66
+ .then(() => {
67
+ // Mark as loaded after successful load
68
+ loaded.add(name);
69
+ console.log('loaded', name);
70
+ });
71
+ // Store the loading promise
72
+ loading.set(name, loadingPromise);
73
+ return loadingPromise;
74
+ }
75
+ // Load all scripts
76
+ return Promise.all(Object.keys(scripts).map((name) => loadWithDeps(name)));
77
+ }
78
+ // Start loading all scripts
79
+ window.__FEISUDA_SCRIPTS_LOADED__ = loadScriptsWithDeps();
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,93 @@
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.registerDayjsPlugins = registerDayjsPlugins;
21
+ __exportStar(require("dayjs"), exports);
22
+ // side-effects
23
+ const dayjs_1 = __importDefault(require("dayjs"));
24
+ const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
25
+ const arraySupport_1 = __importDefault(require("dayjs/plugin/arraySupport"));
26
+ const calendar_1 = __importDefault(require("dayjs/plugin/calendar"));
27
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
28
+ const dayOfYear_1 = __importDefault(require("dayjs/plugin/dayOfYear"));
29
+ const duration_1 = __importDefault(require("dayjs/plugin/duration"));
30
+ const isBetween_1 = __importDefault(require("dayjs/plugin/isBetween"));
31
+ const isLeapYear_1 = __importDefault(require("dayjs/plugin/isLeapYear"));
32
+ const isMoment_1 = __importDefault(require("dayjs/plugin/isMoment"));
33
+ const isSameOrAfter_1 = __importDefault(require("dayjs/plugin/isSameOrAfter"));
34
+ const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
35
+ const isToday_1 = __importDefault(require("dayjs/plugin/isToday"));
36
+ const isTomorrow_1 = __importDefault(require("dayjs/plugin/isTomorrow"));
37
+ const isYesterday_1 = __importDefault(require("dayjs/plugin/isYesterday"));
38
+ const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
39
+ const isoWeeksInYear_1 = __importDefault(require("dayjs/plugin/isoWeeksInYear"));
40
+ const localeData_1 = __importDefault(require("dayjs/plugin/localeData"));
41
+ const localizedFormat_1 = __importDefault(require("dayjs/plugin/localizedFormat"));
42
+ const minMax_1 = __importDefault(require("dayjs/plugin/minMax"));
43
+ const negativeYear_1 = __importDefault(require("dayjs/plugin/negativeYear"));
44
+ const objectSupport_1 = __importDefault(require("dayjs/plugin/objectSupport"));
45
+ const pluralGetSet_1 = __importDefault(require("dayjs/plugin/pluralGetSet"));
46
+ const preParsePostFormat_1 = __importDefault(require("dayjs/plugin/preParsePostFormat"));
47
+ const quarterOfYear_1 = __importDefault(require("dayjs/plugin/quarterOfYear"));
48
+ const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
49
+ const toArray_1 = __importDefault(require("dayjs/plugin/toArray"));
50
+ const toObject_1 = __importDefault(require("dayjs/plugin/toObject"));
51
+ const updateLocale_1 = __importDefault(require("dayjs/plugin/updateLocale"));
52
+ const weekOfYear_1 = __importDefault(require("dayjs/plugin/weekOfYear"));
53
+ const weekYear_1 = __importDefault(require("dayjs/plugin/weekYear"));
54
+ const weekday_1 = __importDefault(require("dayjs/plugin/weekday"));
55
+ let isRegistered = false;
56
+ function registerDayjsPlugins() {
57
+ if (isRegistered) {
58
+ return;
59
+ }
60
+ isRegistered = true;
61
+ // 默认导入所有插件
62
+ dayjs_1.default.extend(advancedFormat_1.default);
63
+ dayjs_1.default.extend(arraySupport_1.default);
64
+ dayjs_1.default.extend(calendar_1.default);
65
+ dayjs_1.default.extend(customParseFormat_1.default);
66
+ dayjs_1.default.extend(dayOfYear_1.default);
67
+ dayjs_1.default.extend(duration_1.default);
68
+ dayjs_1.default.extend(isBetween_1.default);
69
+ dayjs_1.default.extend(isLeapYear_1.default);
70
+ dayjs_1.default.extend(isMoment_1.default);
71
+ dayjs_1.default.extend(isSameOrAfter_1.default);
72
+ dayjs_1.default.extend(isSameOrBefore_1.default);
73
+ dayjs_1.default.extend(isToday_1.default);
74
+ dayjs_1.default.extend(isTomorrow_1.default);
75
+ dayjs_1.default.extend(isYesterday_1.default);
76
+ dayjs_1.default.extend(isoWeek_1.default);
77
+ dayjs_1.default.extend(isoWeeksInYear_1.default);
78
+ dayjs_1.default.extend(localeData_1.default);
79
+ dayjs_1.default.extend(localizedFormat_1.default);
80
+ dayjs_1.default.extend(minMax_1.default);
81
+ dayjs_1.default.extend(negativeYear_1.default);
82
+ dayjs_1.default.extend(objectSupport_1.default);
83
+ dayjs_1.default.extend(pluralGetSet_1.default);
84
+ dayjs_1.default.extend(preParsePostFormat_1.default);
85
+ dayjs_1.default.extend(quarterOfYear_1.default);
86
+ dayjs_1.default.extend(relativeTime_1.default);
87
+ dayjs_1.default.extend(toArray_1.default);
88
+ dayjs_1.default.extend(toObject_1.default);
89
+ dayjs_1.default.extend(updateLocale_1.default);
90
+ dayjs_1.default.extend(weekOfYear_1.default);
91
+ dayjs_1.default.extend(weekYear_1.default);
92
+ dayjs_1.default.extend(weekday_1.default);
93
+ }
@@ -0,0 +1,148 @@
1
+ {
2
+ "version": 1,
3
+ "themeName": "UD Theme Style",
4
+ "theme": {
5
+ "seriesCnt": "6",
6
+ "backgroundColor": "rgba(0,0,0,0)",
7
+ "titleColor": "#1f2329",
8
+ "subtitleColor": "#8f959e",
9
+ "textColorShow": false,
10
+ "textColor": "#333",
11
+ "markTextColor": "#ffffff",
12
+ "color": [
13
+ "#3370eb",
14
+ "#1bcebf",
15
+ "#ffc60a",
16
+ "#ed6d0c",
17
+ "#dca1e4",
18
+ "#25b2e5",
19
+ "#6dcdeb",
20
+ "#288fcb",
21
+ "#94b5f5",
22
+ "#8f61d1",
23
+ "#8f61d1",
24
+ "#bf78e9",
25
+ "#008280",
26
+ "#27ad8e",
27
+ "#7bc335"
28
+ ],
29
+ "borderColor": "#dee0e3",
30
+ "borderWidth": 0,
31
+ "visualMapColor": ["#25b2e5", "#6dcdeb", "#288fcb"],
32
+ "legendTextColor": "#8f959e",
33
+ "kColor": "#fdc6c4",
34
+ "kColor0": "transparent",
35
+ "kBorderColor": "#f54a45",
36
+ "kBorderColor0": "#32a645",
37
+ "kBorderWidth": "2",
38
+ "lineWidth": "1",
39
+ "symbolSize": "6",
40
+ "symbol": "emptyCircle",
41
+ "symbolBorderWidth": "1",
42
+ "lineSmooth": true,
43
+ "graphLineWidth": 1,
44
+ "graphLineColor": "#dee0e3",
45
+ "mapLabelColor": "#000",
46
+ "mapLabelColorE": "#516b91",
47
+ "mapBorderColor": "#516b91",
48
+ "mapBorderColorE": "#516b91",
49
+ "mapBorderWidth": 0.5,
50
+ "mapBorderWidthE": 1,
51
+ "mapAreaColor": "#f3f3f3",
52
+ "mapAreaColorE": "#a5e7f0",
53
+ "axes": [
54
+ {
55
+ "type": "all",
56
+ "name": "通用坐标轴",
57
+ "axisLineShow": true,
58
+ "axisLineColor": "#dee0e3",
59
+ "axisTickShow": false,
60
+ "axisTickColor": "#333",
61
+ "axisLabelShow": true,
62
+ "axisLabelColor": "#8f959e",
63
+ "splitLineShow": true,
64
+ "splitLineColor": ["#dee0e3"],
65
+ "splitAreaShow": false,
66
+ "splitAreaColor": ["rgba(250,250,250,0.05)", "rgba(200,200,200,0.02)"]
67
+ },
68
+ {
69
+ "type": "category",
70
+ "name": "类目坐标轴",
71
+ "axisLineShow": true,
72
+ "axisLineColor": "#333",
73
+ "axisTickShow": true,
74
+ "axisTickColor": "#333",
75
+ "axisLabelShow": true,
76
+ "axisLabelColor": "#333",
77
+ "splitLineShow": false,
78
+ "splitLineColor": ["#ccc"],
79
+ "splitAreaShow": false,
80
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
81
+ },
82
+ {
83
+ "type": "value",
84
+ "name": "数值坐标轴",
85
+ "axisLineShow": true,
86
+ "axisLineColor": "#333",
87
+ "axisTickShow": true,
88
+ "axisTickColor": "#333",
89
+ "axisLabelShow": true,
90
+ "axisLabelColor": "#333",
91
+ "splitLineShow": true,
92
+ "splitLineColor": ["#ccc"],
93
+ "splitAreaShow": false,
94
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
95
+ },
96
+ {
97
+ "type": "log",
98
+ "name": "对数坐标轴",
99
+ "axisLineShow": true,
100
+ "axisLineColor": "#333",
101
+ "axisTickShow": true,
102
+ "axisTickColor": "#333",
103
+ "axisLabelShow": true,
104
+ "axisLabelColor": "#333",
105
+ "splitLineShow": true,
106
+ "splitLineColor": ["#ccc"],
107
+ "splitAreaShow": false,
108
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
109
+ },
110
+ {
111
+ "type": "time",
112
+ "name": "时间坐标轴",
113
+ "axisLineShow": true,
114
+ "axisLineColor": "#333",
115
+ "axisTickShow": true,
116
+ "axisTickColor": "#333",
117
+ "axisLabelShow": true,
118
+ "axisLabelColor": "#333",
119
+ "splitLineShow": true,
120
+ "splitLineColor": ["#ccc"],
121
+ "splitAreaShow": false,
122
+ "splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
123
+ }
124
+ ],
125
+ "axisSeperateSetting": false,
126
+ "toolboxColor": "#8f959e",
127
+ "toolboxEmphasisColor": "#1f2329",
128
+ "tooltipAxisColor": "#dee0e3",
129
+ "tooltipAxisWidth": 1,
130
+ "timelineLineColor": "#336df4",
131
+ "timelineLineWidth": "-1",
132
+ "timelineItemColor": "#336df4",
133
+ "timelineItemColorE": "#1456f0",
134
+ "timelineCheckColor": "#1456f0",
135
+ "timelineCheckBorderColor": "#94b4ff",
136
+ "timelineItemBorderWidth": "0.5",
137
+ "timelineControlColor": "#336df4",
138
+ "timelineControlBorderColor": "#336df4",
139
+ "timelineControlBorderWidth": 0.5,
140
+ "timelineLabelColor": "#8f959e",
141
+ "datazoomBackgroundColor": "rgba(0,0,0,0)",
142
+ "datazoomDataColor": "rgba(255,255,255,0.3)",
143
+ "datazoomFillColor": "rgba(167,183,204,0.4)",
144
+ "datazoomHandleColor": "#a7b7cc",
145
+ "datazoomHandleWidth": "100",
146
+ "datazoomLabelColor": "#333"
147
+ }
148
+ }
@@ -0,0 +1,37 @@
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.echarts = void 0;
21
+ exports.resgisterEchartsTheme = resgisterEchartsTheme;
22
+ var echarts_1 = require("echarts");
23
+ Object.defineProperty(exports, "echarts", { enumerable: true, get: function () { return __importDefault(echarts_1).default; } });
24
+ __exportStar(require("echarts"), exports);
25
+ const echarts_2 = require("echarts");
26
+ const echartThemeUD_json_1 = __importDefault(require("./echartThemeUD.json"));
27
+ let isRegistered = false;
28
+ function resgisterEchartsTheme() {
29
+ // 注册 ud 主题,全局仅注册一次
30
+ if (isRegistered) {
31
+ return;
32
+ }
33
+ isRegistered = true;
34
+ (0, echarts_2.registerTheme)('ud', echartThemeUD_json_1.default.theme);
35
+ }
36
+ resgisterEchartsTheme();
37
+ // registerChinaMap();
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // index.js - ESLint 推荐配置
4
+ exports.default = {
5
+ name: 'preset-recommend-eslint',
6
+ rules: {
7
+ // React Refresh 相关 - 开发时不影响渲染的检测
8
+ 'react-refresh/only-export-components': 'off',
9
+ // 不会影响渲染的检测先关掉
10
+ // TypeScript 变量和类型检查
11
+ '@typescript-eslint/no-unused-vars': 'off', // 未使用变量检查关闭
12
+ '@typescript-eslint/no-explicit-any': 'off', // 允许使用 any 类型
13
+ '@typescript-eslint/no-empty-interface': 'off', // 允许空接口
14
+ '@typescript-eslint/no-empty-object-type': 'off', // 允许空对象类型
15
+ '@typescript-eslint/no-redeclare': 'error', // 禁止重复声明
16
+ // React 相关检查
17
+ 'react/jsx-no-undef-props': 'off', // 不检查未定义的 props
18
+ 'react/no-unknown-property': 'off', // 允许未知属性
19
+ 'react-hooks/exhaustive-deps': 'off', // 不强制检查依赖数组
20
+ // JavaScript 基础规则
21
+ 'no-undef': 'error', // 禁止使用未声明的变量
22
+ 'no-console': 'off', // 允许使用 console
23
+ 'prefer-const': 'off', // 不强制使用 const
24
+ // Import 相关检查
25
+ 'import/no-unresolved': 'error', // 检查导入路径是否存在
26
+ 'import/named': 'error', // 检查命名导入是否存在
27
+ },
28
+ };
@@ -0,0 +1,140 @@
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.createRecommendRspackConfig = createRecommendRspackConfig;
7
+ const path_1 = __importDefault(require("path"));
8
+ const core_1 = __importDefault(require("@rspack/core"));
9
+ // eslint-disable-next-line max-lines-per-function
10
+ function createRecommendRspackConfig(options) {
11
+ const { enableReactRrefresh = false, isDev = true } = options;
12
+ console.log('isDev:', isDev);
13
+ console.log('enableReactRrefresh:', enableReactRrefresh);
14
+ return {
15
+ experiments: {
16
+ css: true,
17
+ },
18
+ module: {
19
+ rules: [
20
+ {
21
+ test: /\.svg$/,
22
+ type: 'asset',
23
+ parser: {
24
+ dataUrlCondition: {
25
+ maxSize: 10 * 1024, // 对应vite的assetsInlineLimit
26
+ },
27
+ },
28
+ },
29
+ {
30
+ test: /\.(png|jpe?g|gif|webp|ico)$/,
31
+ type: 'asset',
32
+ parser: {
33
+ dataUrlCondition: {
34
+ maxSize: 10 * 1024, // 对应vite的assetsInlineLimit
35
+ },
36
+ },
37
+ },
38
+ {
39
+ test: /\.css$/,
40
+ use: ['postcss-loader'],
41
+ type: 'css',
42
+ },
43
+ {
44
+ test: /\.tsx?$/,
45
+ use: [
46
+ {
47
+ loader: 'builtin:swc-loader',
48
+ options: {
49
+ /**
50
+ * @type {import('@swc/core').JscConfig}
51
+ */
52
+ jsc: {
53
+ parser: {
54
+ syntax: 'typescript',
55
+ jsx: true,
56
+ },
57
+ transform: {
58
+ react: {
59
+ runtime: 'automatic',
60
+ ...(isDev
61
+ ? {
62
+ importSource: path_1.default.dirname(require.resolve('@apaas-ai/miaoda-inspector-jsx-runtime')),
63
+ }
64
+ : {}),
65
+ development: isDev,
66
+ refresh: enableReactRrefresh,
67
+ },
68
+ },
69
+ },
70
+ },
71
+ },
72
+ ...(isDev ? [require.resolve('@apaas-ai/miaoda-inspector-babel-plugin')] : []),
73
+ ],
74
+ },
75
+ ],
76
+ },
77
+ plugins: [
78
+ // 针对 clsx/echarts 等包,让其默认好用
79
+ new core_1.default.NormalModuleReplacementPlugin(/^(clsx|echarts)$/, function (resource) {
80
+ if (!resource.context.endsWith('module-alias')) {
81
+ if (resource.request.endsWith('echarts')) {
82
+ resource.request = require.resolve('../module-alias/echarts.js');
83
+ }
84
+ else {
85
+ resource.request = require.resolve('../module-alias/clsx.js');
86
+ }
87
+ }
88
+ }),
89
+ new core_1.default.DefinePlugin({
90
+ 'process.env.NODE_ENV': JSON.stringify(isDev ? 'development' : 'production'),
91
+ 'process.env.CWD': JSON.stringify(process.cwd()),
92
+ }),
93
+ new core_1.default.optimize.LimitChunkCountPlugin({
94
+ maxChunks: 1,
95
+ }),
96
+ ],
97
+ optimization: {
98
+ moduleIds: 'deterministic',
99
+ concatenateModules: true,
100
+ minimize: true, // 对应vite的minify配置
101
+ minimizer: [
102
+ new core_1.default.SwcJsMinimizerRspackPlugin({
103
+ minimizerOptions: {
104
+ // 保持不压缩
105
+ minify: !isDev,
106
+ mangle: !isDev,
107
+ format: {
108
+ beautify: isDev,
109
+ comments: false,
110
+ },
111
+ compress: {
112
+ keep_classnames: true,
113
+ keep_fnames: true,
114
+ keep_fargs: !isDev,
115
+ unused: true,
116
+ dead_code: true,
117
+ drop_debugger: true,
118
+ // FIXME: 先临时开始 console.log
119
+ // drop_console: !isDev,
120
+ const_to_let: !isDev,
121
+ booleans_as_integers: !isDev,
122
+ booleans: !isDev,
123
+ // maybe unsafe
124
+ reduce_funcs: !isDev,
125
+ reduce_vars: !isDev,
126
+ },
127
+ },
128
+ }),
129
+ new core_1.default.LightningCssMinimizerRspackPlugin(),
130
+ ],
131
+ sideEffects: true,
132
+ usedExports: true,
133
+ innerGraph: true,
134
+ providedExports: true,
135
+ mergeDuplicateChunks: true,
136
+ splitChunks: false, // 禁用代码分割,保持单文件输出
137
+ },
138
+ devtool: isDev ? 'source-map' : false, // 对应vite的sourcemap配置
139
+ };
140
+ }
@@ -0,0 +1,49 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createRecommendTailwindConfig = createRecommendTailwindConfig;
37
+ const path = __importStar(require("path"));
38
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
+ function createRecommendTailwindConfig(options) {
40
+ return {
41
+ darkMode: 'class',
42
+ content: [
43
+ // 让 framework 里的 tailwind 生效
44
+ path.join(path.dirname(require.resolve('@lark-apaas/client-core')), '/**/*.js'),
45
+ ],
46
+ prefix: '',
47
+ plugins: [],
48
+ };
49
+ }
@@ -0,0 +1,89 @@
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.createRspackConfig = createRspackConfig;
7
+ const path_1 = __importDefault(require("path"));
8
+ const core_1 = __importDefault(require("@rspack/core"));
9
+ const rspack_1 = require("./recommend/rspack");
10
+ const webpack_merge_1 = __importDefault(require("webpack-merge"));
11
+ // eslint-disable-next-line max-lines-per-function
12
+ function createRspackConfig(options) {
13
+ const { enableReactRrefresh = false, isDev = true } = options;
14
+ console.log('isDev:', isDev);
15
+ console.log('enableReactRrefresh:', enableReactRrefresh);
16
+ // 构建外部依赖配置,对应vite的rollupOptions.external和globals
17
+ const externals = isDev
18
+ ? {
19
+ antd: 'antd',
20
+ '@ant-design/icons': 'icons',
21
+ dayjs: 'dayjs',
22
+ react: 'React',
23
+ 'react-dom': 'ReactDOM',
24
+ echarts: 'echarts',
25
+ }
26
+ : {};
27
+ const recommendConfig = (0, rspack_1.createRecommendRspackConfig)({ enableReactRrefresh, isDev });
28
+ return (0, webpack_merge_1.default)(recommendConfig, {
29
+ mode: isDev ? 'development' : 'production',
30
+ entry: './src/index.tsx',
31
+ output: {
32
+ publicPath: '/',
33
+ // path: path.resolve(__dirname, 'dist'),
34
+ filename: 'assets/index.js',
35
+ cssFilename: 'assets/index.css',
36
+ assetModuleFilename: (pathData) => {
37
+ // 对应vite的assetFileNames逻辑
38
+ const ext = path_1.default.extname(pathData.filename || '');
39
+ if (ext === '.css') {
40
+ return 'assets/index.css';
41
+ }
42
+ return pathData.filename ? `assets/${pathData.filename}` : 'assets/asset-[hash][ext]';
43
+ },
44
+ library: {
45
+ type: 'self', // 对应vite的iife格式
46
+ },
47
+ globalObject: 'this',
48
+ },
49
+ resolve: {
50
+ mainFields: ['module', 'browser', 'main'],
51
+ alias: {},
52
+ tsConfig: {
53
+ // 默认读取命令执行的顶层目录的 resolve 规则
54
+ configFile: path_1.default.resolve(process.cwd(), './tsconfig.json'),
55
+ },
56
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
57
+ },
58
+ devServer: isDev
59
+ ? undefined
60
+ : {
61
+ host: '::',
62
+ port: 8080,
63
+ hot: true,
64
+ liveReload: false,
65
+ historyApiFallback: true,
66
+ watchFiles: {
67
+ options: {
68
+ usePolling: false, // 对应vite的watch.usePolling
69
+ },
70
+ },
71
+ },
72
+ experiments: {
73
+ css: true,
74
+ },
75
+ externals,
76
+ plugins: [
77
+ new core_1.default.HtmlRspackPlugin({
78
+ template: 'index.html',
79
+ inject: 'body',
80
+ defer: false,
81
+ minify: false,
82
+ templateParameters: {
83
+ title: 'local-mock-data',
84
+ injectScript: '',
85
+ },
86
+ }),
87
+ ],
88
+ });
89
+ }
@@ -0,0 +1,15 @@
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.createTailwindConfig = createTailwindConfig;
7
+ const webpack_merge_1 = __importDefault(require("webpack-merge"));
8
+ const tailwind_1 = require("./recommend/tailwind");
9
+ function createTailwindConfig(options) {
10
+ const { isDevBuildMode = true } = options;
11
+ const recommendConfig = (0, tailwind_1.createRecommendTailwindConfig)({ isDev: isDevBuildMode });
12
+ return (0, webpack_merge_1.default)(recommendConfig, {
13
+ content: ['./src/**/*.{ts,tsx}'],
14
+ });
15
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": false,
19
+ "noUnusedLocals": false,
20
+ "noUnusedParameters": false,
21
+ "noImplicitAny": false,
22
+ "noFallthroughCasesInSwitch": false,
23
+
24
+ "sourceMap": true,
25
+ "allowJs": true,
26
+ "strictNullChecks": false
27
+ }
28
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@lark-apaas/miaoda-presets",
3
+ "version": "0.1.0-alpha.1",
4
+ "files": [
5
+ "lib"
6
+ ],
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc && npm run copy:json",
12
+ "copy:json": "cp -r src/*.json lib",
13
+ "watch": "tsc --watch",
14
+ "bump": "changeset version",
15
+ "change": "changeset",
16
+ "check": "biome check --write",
17
+ "dev": "rslib build --watch",
18
+ "format": "biome format --write",
19
+ "storybook": "storybook dev",
20
+ "test": "echo 0",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "dependencies": {
24
+ "@lark-apaas/miaoda-inspector-babel-plugin": "workspace:*",
25
+ "@lark-apaas/miaoda-inspector-jsx-runtime": "workspace:*",
26
+ "@babel/core": "^7.28.0",
27
+ "@babel/parser": "^7.28.0",
28
+ "@babel/traverse": "^7.28.0",
29
+ "@babel/types": "^7.28.2",
30
+ "@eslint/js": "^9.34.0",
31
+ "@react-dev-inspector/middleware": "^2.0.1",
32
+ "@rsdoctor/rspack-plugin": "^1.1.8",
33
+ "@rspack/dev-server": "^1.1.3",
34
+ "@rspack/plugin-react-refresh": "^1.4.3",
35
+ "dayjs": "^1.11.14",
36
+ "echarts": "^6.0.0",
37
+ "eslint-import-resolver-alias": "^1.1.2",
38
+ "eslint-plugin-import": "^2.32.0",
39
+ "eslint-plugin-react-hooks": "^5.2.0",
40
+ "eslint-plugin-react-refresh": "^0.4.20",
41
+ "globals": "^15.15.0",
42
+ "magic-string": "^0.30.18",
43
+ "tsconfig-paths-webpack-plugin": "^4.2.0",
44
+ "typescript-eslint": "^8.41.0",
45
+ "webpack-merge": "^6.0.1",
46
+ "tailwindcss": "^4.1.13"
47
+ },
48
+ "devDependencies": {
49
+ "@biomejs/biome": "2.0.6",
50
+ "@changesets/cli": "^2.29.5",
51
+ "@rspack/core": "^1.4.4",
52
+ "@types/node": "^22.15.30",
53
+ "@types/react": "^18.3.23",
54
+ "@types/react-dom": "^18.3.7",
55
+ "typescript": "^5.9.2"
56
+ },
57
+ "peerDependencies": {
58
+ "react": ">=16.14.0",
59
+ "react-dom": ">=16.14.0"
60
+ }
61
+ }