Bläddra i källkod

📦 build(mini-charts): 重构包结构和清理测试文件

- 在 package.json 中新增 `./components` 子路径导出,支持按需导入组件
- 添加 `@tarojs/plugin-platform-weapp` 依赖以支持微信小程序平台
- 注释掉 src/index.ts 中所有旧的 u-charts 核心库导出,为后续重构做准备
- 删除过时的 u-charts.test.ts 测试文件,该文件已不适用于新的组件化架构

🔧 chore(mini-shared-ui-components): 调整 TypeScript 配置

- 移除 `allowImportingTsExtensions` 选项以符合标准 TypeScript 导入规范
- 调整 `include` 路径,移除 `testing` 目录,仅保留 `src` 和 `tests` 目录
yourname 3 veckor sedan
förälder
incheckning
98d9b61b54

+ 6 - 0
mini-ui-packages/mini-charts/package.json

@@ -15,6 +15,11 @@
       "types": "./dist/src/lib/index.d.ts",
       "import": "./dist/src/lib/index.js",
       "require": "./dist/src/lib/index.js"
+    },
+    "./components": {
+      "types": "./dist/src/components/index.d.ts",
+      "import": "./dist/src/components/index.js",
+      "require": "./dist/src/components/index.js"
     }
   },
   "scripts": {
@@ -27,6 +32,7 @@
   },
   "dependencies": {
     "@tarojs/components": "4.1.4",
+    "@tarojs/plugin-platform-weapp": "4.1.4",
     "@tarojs/react": "4.1.4",
     "@tarojs/taro": "4.1.4",
     "react": "^18.0.0",

+ 202 - 202
mini-ui-packages/mini-charts/src/index.ts

@@ -1,225 +1,225 @@
-// Export modularized config and utility functions with type definitions
-export {
-  config,
-  assign,
-  util
-} from './lib/config';
+// // Export modularized config and utility functions with type definitions
+// export {
+//   config,
+//   assign,
+//   util
+// } from './lib/config';
 
-export {
-  hexToRgb
-} from './lib/utils/color';
+// export {
+//   hexToRgb
+// } from './lib/utils/color';
 
-export {
-  findRange,
-  calCandleMA
-} from './lib/utils/math';
+// export {
+//   findRange,
+//   calCandleMA
+// } from './lib/utils/math';
 
-export {
-  convertCoordinateOrigin,
-  isInAngleRange,
-  calValidDistance
-} from './lib/utils/coordinate';
+// export {
+//   convertCoordinateOrigin,
+//   isInAngleRange,
+//   calValidDistance
+// } from './lib/utils/coordinate';
 
-export {
-  measureText
-} from './lib/utils/text';
+// export {
+//   measureText
+// } from './lib/utils/text';
 
-export {
-  avoidCollision,
-  isCollision
-} from './lib/utils/collision';
+// export {
+//   avoidCollision,
+//   isCollision
+// } from './lib/utils/collision';
 
-export {
-  getH5Offset,
-  createCurveControlPoints,
-  getTouches
-} from './lib/utils/misc';
+// export {
+//   getH5Offset,
+//   createCurveControlPoints,
+//   getTouches
+// } from './lib/utils/misc';
 
-// Export core chart classes
-export {
-  uCharts,
-  uChartsEvent
-} from './lib/charts/index';
+// // Export core chart classes
+// export {
+//   uCharts,
+//   uChartsEvent
+// } from './lib/charts/index';
 
-// Default export for backward compatibility
-export { default } from './lib/charts/index';
+// // Default export for backward compatibility
+// export { default } from './lib/charts/index';
 
-// Re-export config and util from u-charts for backward compatibility
-export { config as uChartsConfig, util as uChartsUtil } from './lib/config';
+// // Re-export config and util from u-charts for backward compatibility
+// export { config as uChartsConfig, util as uChartsUtil } from './lib/config';
 
-// Export chart types
-export type {
-  CanvasContext,
-  ChartsTitle,
-  ChartsConfig,
-  YAxisConfig,
-  XAxisConfig,
-  LegendConfig,
-  ExtraConfig,
-  ScrollOption,
-  TouchEvent,
-  TouchPoint,
-  ToolTipOption as ChartsToolTipOption,
-  EventListener,
-  EventMap
-} from './lib/charts/index';
+// // Export chart types
+// export type {
+//   CanvasContext,
+//   ChartsTitle,
+//   ChartsConfig,
+//   YAxisConfig,
+//   XAxisConfig,
+//   LegendConfig,
+//   ExtraConfig,
+//   ScrollOption,
+//   TouchEvent,
+//   TouchPoint,
+//   ToolTipOption as ChartsToolTipOption,
+//   EventListener,
+//   EventMap
+// } from './lib/charts/index';
 
-// Export data processing functions
-export {
-  fixPieSeries,
-  fillSeries,
-  fillCustomColor,
-  getDataRange,
-  dataCombine,
-  dataCombineStack,
-  calXAxisData,
-  getXAxisPoints,
-  calYAxisData,
-  calCategoriesData,
-  getToolTipData,
-  getMixToolTipData
-} from './lib/data-processing/index';
+// // Export data processing functions
+// export {
+//   fixPieSeries,
+//   fillSeries,
+//   fillCustomColor,
+//   getDataRange,
+//   dataCombine,
+//   dataCombineStack,
+//   calXAxisData,
+//   getXAxisPoints,
+//   calYAxisData,
+//   calCategoriesData,
+//   getToolTipData,
+//   getMixToolTipData
+// } from './lib/data-processing/index';
 
-export type {
-  SeriesItem,
-  ChartOptions,
-  ChartExtraOptions,
-  BarOptions,
-  ColumnOptions,
-  TooltipOptions,
-  MountOptions,
-  XAxisOptions,
-  YAxisOptions,
-  YAxisDataItem,
-  ChartData,
-  UChartsConfig,
-  DataRange,
-  XAxisDataResult,
-  YAxisDataResult,
-  AxisPointsResult,
-  CategoriesDataResult,
-  ToolTipOption,
-  ToolTipDataResult
-} from './lib/data-processing/index';
+// export type {
+//   SeriesItem,
+//   ChartOptions,
+//   ChartExtraOptions,
+//   BarOptions,
+//   ColumnOptions,
+//   TooltipOptions,
+//   MountOptions,
+//   XAxisOptions,
+//   YAxisOptions,
+//   YAxisDataItem,
+//   ChartData,
+//   UChartsConfig,
+//   DataRange,
+//   XAxisDataResult,
+//   YAxisDataResult,
+//   AxisPointsResult,
+//   CategoriesDataResult,
+//   ToolTipOption,
+//   ToolTipDataResult
+// } from './lib/data-processing/index';
 
-// Export charts data points calculation functions
-export {
-  getDataPoints,
-  getLineDataPoints,
-  getColumnDataPoints,
-  getCandleDataPoints,
-  getMountDataPoints,
-  getBarDataPoints,
-  getStackDataPoints,
-  getBarStackDataPoints,
-  getPieDataPoints,
-  getRoseDataPoints,
-  getRadarDataPoints,
-  getGaugeDataPoints,
-  getGaugeArcbarDataPoints,
-  getArcbarDataPoints,
-  getGaugeAxisPoints,
-  getFunnelDataPoints
-} from './lib/charts-data/index';
+// // Export charts data points calculation functions
+// export {
+//   getDataPoints,
+//   getLineDataPoints,
+//   getColumnDataPoints,
+//   getCandleDataPoints,
+//   getMountDataPoints,
+//   getBarDataPoints,
+//   getStackDataPoints,
+//   getBarStackDataPoints,
+//   getPieDataPoints,
+//   getRoseDataPoints,
+//   getRadarDataPoints,
+//   getGaugeDataPoints,
+//   getGaugeArcbarDataPoints,
+//   getArcbarDataPoints,
+//   getGaugeAxisPoints,
+//   getFunnelDataPoints
+// } from './lib/charts-data/index';
 
-// Export renderer functions
-export {
-  drawPointShape,
-  drawActivePoint,
-  drawRingTitle,
-  drawPointText,
-  drawToolTipSplitLine,
-  drawMarkLine,
-  drawToolTipHorizentalLine,
-  drawToolTipSplitArea,
-  drawBarToolTipSplitArea,
-  drawToolTip,
-  drawToolTipBridge,
-  drawCanvas
-} from './lib/renderers/index';
+// // Export renderer functions
+// export {
+//   drawPointShape,
+//   drawActivePoint,
+//   drawRingTitle,
+//   drawPointText,
+//   drawToolTipSplitLine,
+//   drawMarkLine,
+//   drawToolTipHorizentalLine,
+//   drawToolTipSplitArea,
+//   drawBarToolTipSplitArea,
+//   drawToolTip,
+//   drawToolTipBridge,
+//   drawCanvas
+// } from './lib/renderers/index';
 
-export type {
-  Point as RendererPoint,
-  ToolTipTextItem,
-  ToolTipOption as RendererToolTipOption,
-  MarkLineDataItem,
-  ActivePointOption,
-  TitleOption
-} from './lib/renderers/index';
+// export type {
+//   Point as RendererPoint,
+//   ToolTipTextItem,
+//   ToolTipOption as RendererToolTipOption,
+//   MarkLineDataItem,
+//   ActivePointOption,
+//   TitleOption
+// } from './lib/renderers/index';
 
-// Export helper functions
-export {
-  // Index finders
-  findCurrentIndex,
-  findBarChartCurrentIndex,
-  findLegendIndex,
-  findRadarChartCurrentIndex,
-  findFunnelChartCurrentIndex,
-  findWordChartCurrentIndex,
-  findMapChartCurrentIndex,
-  findRoseChartCurrentIndex,
-  findPieChartCurrentIndex,
-  // Area checkers
-  isInExactLegendArea,
-  isInExactChartArea,
-  isInExactPieChartArea,
-  // Data helpers
-  getSeriesDataItem,
-  filterSeries,
-  splitPoints,
-  getMaxTextListLength,
-  getRadarCoordinateSeries,
-  // Legend helpers
-  calLegendData,
-  getPieTextMaxLength,
-  // Coordinate helpers
-  lonlat2mercator,
-  mercator2lonlat,
-  getBoundingBox,
-  coordinateToPoint,
-  pointToCoordinate,
-  isRayIntersectsSegment,
-  isPoiWithinPoly,
-  // Data fixers
-  fixColumeData,
-  fixBarData,
-  fixColumeMeterData,
-  fixColumeStackData,
-  fixBarStackData,
-  // Misc helpers
-  getXAxisTextList,
-  getYAxisTextList,
-  calTooltipYAxisData,
-  calMarkLineData,
-  contextRotate,
-  normalInt,
-  collisionNew,
-  getWordCloudPoint
-} from './lib/helper-functions/index';
+// // Export helper functions
+// export {
+//   // Index finders
+//   findCurrentIndex,
+//   findBarChartCurrentIndex,
+//   findLegendIndex,
+//   findRadarChartCurrentIndex,
+//   findFunnelChartCurrentIndex,
+//   findWordChartCurrentIndex,
+//   findMapChartCurrentIndex,
+//   findRoseChartCurrentIndex,
+//   findPieChartCurrentIndex,
+//   // Area checkers
+//   isInExactLegendArea,
+//   isInExactChartArea,
+//   isInExactPieChartArea,
+//   // Data helpers
+//   getSeriesDataItem,
+//   filterSeries,
+//   splitPoints,
+//   getMaxTextListLength,
+//   getRadarCoordinateSeries,
+//   // Legend helpers
+//   calLegendData,
+//   getPieTextMaxLength,
+//   // Coordinate helpers
+//   lonlat2mercator,
+//   mercator2lonlat,
+//   getBoundingBox,
+//   coordinateToPoint,
+//   pointToCoordinate,
+//   isRayIntersectsSegment,
+//   isPoiWithinPoly,
+//   // Data fixers
+//   fixColumeData,
+//   fixBarData,
+//   fixColumeMeterData,
+//   fixColumeStackData,
+//   fixBarStackData,
+//   // Misc helpers
+//   getXAxisTextList,
+//   getYAxisTextList,
+//   calTooltipYAxisData,
+//   calMarkLineData,
+//   contextRotate,
+//   normalInt,
+//   collisionNew,
+//   getWordCloudPoint
+// } from './lib/helper-functions/index';
 
-export type {
-  LegendData,
-  PieData,
-  RadarData
-} from './lib/helper-functions/index';
+// export type {
+//   LegendData,
+//   PieData,
+//   RadarData
+// } from './lib/helper-functions/index';
 
-// Export draw controllers (core drawing control functions)
-export {
-  drawCharts
-} from './lib/draw-controllers/index';
+// // Export draw controllers (core drawing control functions)
+// export {
+//   drawCharts
+// } from './lib/draw-controllers/index';
 
-export {
-  Animation,
-  AnimationFunction
-} from './lib/draw-controllers/index';
+// export {
+//   Animation,
+//   AnimationFunction
+// } from './lib/draw-controllers/index';
 
-export type {
-  DrawChartsContext,
-  DrawChartsFunction,
-  AnimationOptions,
-  TimingFunction,
-  TimingFunctions
-} from './lib/draw-controllers/index';
+// export type {
+//   DrawChartsContext,
+//   DrawChartsFunction,
+//   AnimationOptions,
+//   TimingFunction,
+//   TimingFunctions
+// } from './lib/draw-controllers/index';
 
 // ============================================================================
 // React Chart Components (Story 016.009)

+ 0 - 129
mini-ui-packages/mini-charts/tests/u-charts.test.ts

@@ -1,129 +0,0 @@
-/**
- * u-charts 库基础测试
- * Story 016.001 - 验证 u-charts 库可以正确导入
- *
- * 注意:由于原始 u-charts 库中存在一些变量重复声明的问题(非严格模式),
- * 在 Jest 严格环境下会报错。本测试仅验证基础导出功能。
- */
-
-// 简化测试 - 只验证配置导出
-describe('u-charts 库基础测试', () => {
-  describe('配置导出验证', () => {
-    it('应该正确导出配置对象', () => {
-      const { config } = require('../src/lib/u-charts');
-      expect(config).toBeDefined();
-      expect(config.version).toBe('v2.5.0-20230101');
-      expect(config.color).toBeDefined();
-      expect(Array.isArray(config.color)).toBe(true);
-    });
-
-    it('配置应该包含必要的默认值', () => {
-      const { config } = require('../src/lib/u-charts');
-      expect(config.yAxisWidth).toBe(15);
-      expect(config.xAxisHeight).toBe(22);
-      expect(config.fontSize).toBe(13);
-      expect(config.fontColor).toBe('#666666');
-    });
-  });
-
-  describe('工具函数导出验证', () => {
-    it('应该正确导出 util 工具对象', () => {
-      const { util } = require('../src/lib/u-charts');
-      expect(util).toBeDefined();
-      expect(typeof util.toFixed).toBe('function');
-      expect(typeof util.isFloat).toBe('function');
-    });
-
-    it('应该正确导出 assign 函数', () => {
-      const { assign } = require('../src/lib/u-charts');
-      expect(assign).toBeDefined();
-      expect(typeof assign).toBe('function');
-    });
-
-    it('util.toFixed 应该正确格式化数字', () => {
-      const { util } = require('../src/lib/u-charts');
-      expect(util.toFixed(3.14159, 2)).toBe('3.14');
-      expect(util.toFixed(10, 2)).toBe(10);
-    });
-
-    it('util.isFloat 应该正确判断浮点数', () => {
-      const { util } = require('../src/lib/u-charts');
-      expect(util.isFloat(3.14)).toBe(true);
-      expect(util.isFloat(10)).toBe(false);
-    });
-  });
-
-  describe('辅助函数导出验证', () => {
-    it('应该正确导出辅助函数', () => {
-      const uChartsModule = require('../src/lib/u-charts');
-      expect(uChartsModule.hexToRgb).toBeDefined();
-      expect(uChartsModule.findRange).toBeDefined();
-      expect(uChartsModule.measureText).toBeDefined();
-      expect(uChartsModule.dataCombine).toBeDefined();
-    });
-
-    it('hexToRgb 应该正确转换颜色', () => {
-      const { hexToRgb } = require('../src/lib/u-charts');
-      expect(hexToRgb('#FF0000', 1)).toBe('rgba(255,0,0,1)');
-      expect(hexToRgb('#00FF00', 0.5)).toBe('rgba(0,255,0,0.5)');
-    });
-
-    it('findRange 应该正确查找范围', () => {
-      const { findRange } = require('../src/lib/u-charts');
-      expect(findRange(123, 'upper', 10)).toBe(130);
-      expect(findRange(98, 'lower', 10)).toBe(90);
-    });
-
-    it('assign 应该正确合并对象', () => {
-      const { assign } = require('../src/lib/u-charts');
-      const target = { a: 1 };
-      const source = { b: 2 };
-      const result = assign(target, source);
-      expect(result).toEqual({ a: 1, b: 2 });
-    });
-  });
-
-  describe('类导出验证', () => {
-    it('应该正确导出 uChartsEvent 类', () => {
-      const { uChartsEvent } = require('../src/lib/u-charts');
-      expect(uChartsEvent).toBeDefined();
-      expect(typeof uChartsEvent).toBe('function');
-    });
-
-    it('应该能够实例化 uChartsEvent', () => {
-      const { uChartsEvent } = require('../src/lib/u-charts');
-      const event = new uChartsEvent();
-      expect(event).toBeDefined();
-      expect(event.events).toBeDefined();
-      expect(event.events).toEqual({});
-    });
-
-    it('uChartsEvent 应该支持添加和触发事件监听器', () => {
-      const { uChartsEvent } = require('../src/lib/u-charts');
-      const event = new uChartsEvent();
-      const mockListener = jest.fn();
-
-      event.addEventListener('test', mockListener);
-      expect(event.events.test).toHaveLength(1);
-
-      event.trigger('test', 'arg1', 'arg2');
-      expect(mockListener).toHaveBeenCalledWith('arg1', 'arg2');
-    });
-
-    it('应该正确导出 uCharts 类', () => {
-      const { uCharts } = require('../src/lib/u-charts');
-      expect(uCharts).toBeDefined();
-      expect(typeof uCharts).toBe('function');
-    });
-  });
-
-  describe('主入口导出测试', () => {
-    it('应该从主入口正确导出所有内容', () => {
-      const index = require('../src/index');
-      expect(index.uCharts).toBeDefined();
-      expect(index.uChartsEvent).toBeDefined();
-      expect(index.config).toBeDefined();
-      expect(index.util).toBeDefined();
-    });
-  });
-});

+ 1 - 2
mini-ui-packages/mini-shared-ui-components/tsconfig.json

@@ -18,8 +18,7 @@
     "experimentalDecorators": true,
     "emitDecoratorMetadata": true,
     "types": ["react", "node"],
-    "allowImportingTsExtensions": true
   },
-  "include": ["src/**/*", "tests", "testing"],
+  "include": ["src/**/*", "tests"],
   "exclude": ["node_modules", "dist"]
 }