@rfkit/charts 1.4.0 → 1.4.2

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 (175) hide show
  1. package/README.md +156 -273
  2. package/components/AxisY/heatmap/index.d.ts +1 -1
  3. package/components/AxisY/heatmap/variants/standard/index.d.ts +6 -0
  4. package/components/Container/runtime.d.ts +10 -0
  5. package/components/Cursor/popover-support.d.ts +8 -0
  6. package/components/Toolbar/registry.d.ts +12 -0
  7. package/components/Toolbar/toggles/index.d.ts +10 -0
  8. package/components/Zoom/ZoomViewportLayer.d.ts +7 -0
  9. package/components/ui/button.d.ts +2 -2
  10. package/config/constants.d.ts +2 -2
  11. package/hooks/index.d.ts +1 -2
  12. package/hooks/module-subscription-core.d.ts +23 -0
  13. package/hooks/publish/enhancedPublish.d.ts +1 -1
  14. package/hooks/publish/index.d.ts +0 -1
  15. package/hooks/publish/publish-event.d.ts +9 -0
  16. package/hooks/useLevelStreamAnalyzer.d.ts +1 -1
  17. package/hooks/useModuleSubscription.d.ts +21 -23
  18. package/index.d.ts +5 -5
  19. package/index.js +7378 -6950
  20. package/modules/Gauge/render.d.ts +0 -2
  21. package/{components/HeatmapCapture → modules/Heatmap/Capture}/tools.d.ts +1 -1
  22. package/modules/Heatmap/CursorPopover.d.ts +6 -0
  23. package/modules/Heatmap/render.d.ts +2 -0
  24. package/modules/Level/CursorPopover.d.ts +6 -0
  25. package/modules/Occupancy/CursorPopover.d.ts +3 -0
  26. package/modules/Occupancy/TotalLine/index.d.ts +1 -1
  27. package/modules/Occupancy/total-line-runtime.d.ts +4 -0
  28. package/modules/Spectrum/AxisYCanvas/index.d.ts +6 -0
  29. package/{components/AxisYByCanvas → modules/Spectrum/AxisYCanvas}/useCanvasAxisY.d.ts +1 -1
  30. package/modules/Spectrum/BandLayer/index.d.ts +5 -0
  31. package/modules/Spectrum/BandLayer/useBandLayerController.d.ts +2 -0
  32. package/{components → modules/Spectrum}/Blaze/tools.d.ts +1 -1
  33. package/modules/Spectrum/CursorPopover.d.ts +6 -0
  34. package/{components → modules/Spectrum}/FrequencyAllocation/color.d.ts +1 -1
  35. package/{components → modules/Spectrum}/FrequencyAllocation/model/resolveFrequencyAllocationData.d.ts +1 -1
  36. package/{components → modules/Spectrum}/FrequencyAllocation/model/resolver.d.ts +1 -1
  37. package/{components → modules/Spectrum}/FrequencyAllocation/model/useAllocationAtCursor.d.ts +1 -1
  38. package/{components → modules/Spectrum}/FrequencyAllocation/model/useFrequencyAllocationData.d.ts +1 -1
  39. package/{components → modules/Spectrum}/FrequencyAllocation/presenters/AllocationInfo/index.d.ts +1 -1
  40. package/{components → modules/Spectrum}/FrequencyAllocation/presenters/AllocationSegments/index.d.ts +1 -1
  41. package/{components → modules/Spectrum}/FrequencyAllocation/tools.d.ts +1 -1
  42. package/{components → modules/Spectrum}/FrequencyAllocation/types.d.ts +1 -1
  43. package/{components → modules/Spectrum}/FrequencyDataBoard/panels/StationInfoPanel/index.d.ts +1 -1
  44. package/{components → modules/Spectrum}/FrequencyTagLine/index.d.ts +1 -1
  45. package/{components → modules/Spectrum}/Markers/MarkerItem/index.d.ts +1 -1
  46. package/{components → modules/Spectrum}/Markers/hooks/useMarkerEvents.d.ts +1 -1
  47. package/{components → modules/Spectrum}/Markers/hooks/useMarkers.d.ts +2 -2
  48. package/{components → modules/Spectrum}/Markers/tools.d.ts +1 -1
  49. package/{components → modules/Spectrum}/Scope/useScope.d.ts +1 -1
  50. package/{components → modules/Spectrum}/Signal/model/resolver.d.ts +1 -1
  51. package/{components → modules/Spectrum}/Signal/model/useStationInfoAtCursor.d.ts +1 -1
  52. package/{components → modules/Spectrum}/Signal/tools.d.ts +1 -1
  53. package/{components → modules/Spectrum}/Signal/useSignalDataManager.d.ts +1 -1
  54. package/{components → modules/Spectrum}/Signal/utils.d.ts +3 -3
  55. package/modules/Spectrum/render.d.ts +31 -52
  56. package/{hooks → modules/Spectrum}/useSpectrumAnalyzer/index.d.ts +1 -1
  57. package/modules/base/BaseRenderer.d.ts +63 -0
  58. package/modules/base/CircularRenderer.d.ts +4 -5
  59. package/package.json +21 -4
  60. package/{modules/tools.d.ts → runtime/passThrough.d.ts} +1 -1
  61. package/store/chart-store.d.ts +11 -0
  62. package/store/context.d.ts +5 -2
  63. package/store/hooks/index.d.ts +1 -1
  64. package/store/hooks/useStore.d.ts +11 -1
  65. package/store/index.d.ts +1 -1
  66. package/store/reducer.d.ts +1 -33
  67. package/store/runtime.d.ts +16 -0
  68. package/tailwind-bridge.css +28 -101
  69. package/theme/init-charts-theme.d.ts +7 -11
  70. package/theme/style-scope.d.ts +0 -1
  71. package/{utils/theme.d.ts → theme/theme-color.d.ts} +0 -11
  72. package/theme/theme-contract.d.ts +28 -0
  73. package/theme/theme-runtime.d.ts +14 -0
  74. package/theme/theme-styles.d.ts +10 -0
  75. package/theme/theme-tokens.d.ts +85 -0
  76. package/types/common.d.ts +1 -1
  77. package/types/store/index.d.ts +6 -4
  78. package/types/store/ui.d.ts +4 -4
  79. package/utils/index.d.ts +0 -1
  80. package/utils/subscription.d.ts +18 -3
  81. package/components/AxisY/heatmap/type/Default/index.d.ts +0 -6
  82. package/components/AxisYByCanvas/index.d.ts +0 -6
  83. package/components/Band/index.d.ts +0 -5
  84. package/components/Band/useBand.d.ts +0 -2
  85. package/components/Cursor/popovers/index.d.ts +0 -10
  86. package/components/SignalAnalysis/Switch/index.d.ts +0 -3
  87. package/components/ToolsBar/registry.d.ts +0 -12
  88. package/components/ToolsBar/toggles/index.d.ts +0 -10
  89. package/components/Zoom/ZoomOffsetContainer/index.d.ts +0 -7
  90. package/lib/LevelStream/useAxisY.d.ts +0 -1
  91. package/theme/charts-theme-controller.d.ts +0 -27
  92. package/theme/charts-theme-environment.d.ts +0 -7
  93. package/theme/shadcn-theme-config.d.ts +0 -221
  94. /package/{lib → charts}/Dial/Chart.d.ts +0 -0
  95. /package/{lib → charts}/Dial/index.d.ts +0 -0
  96. /package/{lib → charts}/Gauge/Chart.d.ts +0 -0
  97. /package/{lib → charts}/Gauge/index.d.ts +0 -0
  98. /package/{lib → charts}/Heatmap/Chart.d.ts +0 -0
  99. /package/{lib → charts}/Heatmap/index.d.ts +0 -0
  100. /package/{lib → charts}/IQ/Chart.d.ts +0 -0
  101. /package/{lib → charts}/IQ/index.d.ts +0 -0
  102. /package/{lib → charts}/LevelStream/Chart.d.ts +0 -0
  103. /package/{lib → charts}/LevelStream/index.d.ts +0 -0
  104. /package/{lib → charts}/Occupancy/Chart.d.ts +0 -0
  105. /package/{lib → charts}/Occupancy/index.d.ts +0 -0
  106. /package/{lib → charts}/SpatialSpectrum/Chart.d.ts +0 -0
  107. /package/{lib → charts}/SpatialSpectrum/index.d.ts +0 -0
  108. /package/{lib → charts}/Spectrum/Chart.d.ts +0 -0
  109. /package/{lib → charts}/Spectrum/index.d.ts +0 -0
  110. /package/{lib → charts}/index.d.ts +0 -0
  111. /package/components/AxisY/heatmap/{type/Default → variants/standard}/GradientRibbon/index.d.ts +0 -0
  112. /package/components/AxisY/occupancy/{type/Default → variants/standard}/index.d.ts +0 -0
  113. /package/components/{ToolsBar → Toolbar}/controls/Reset.d.ts +0 -0
  114. /package/components/{ToolsBar → Toolbar}/controls/SegmentsDisplayControl/index.d.ts +0 -0
  115. /package/components/{ToolsBar → Toolbar}/controls/SeriesControl/index.d.ts +0 -0
  116. /package/components/{ToolsBar → Toolbar}/controls/SeriesDisplayControl/index.d.ts +0 -0
  117. /package/components/{ToolsBar → Toolbar}/controls/index.d.ts +0 -0
  118. /package/components/{ToolsBar → Toolbar}/decorations/GradientRibbon/index.d.ts +0 -0
  119. /package/components/{ToolsBar → Toolbar}/decorations/SpacerLine.d.ts +0 -0
  120. /package/components/{ToolsBar → Toolbar}/decorations/index.d.ts +0 -0
  121. /package/components/{ToolsBar → Toolbar}/index.d.ts +0 -0
  122. /package/components/{ToolsBar → Toolbar}/primitives/IconBox.d.ts +0 -0
  123. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarContentBox.d.ts +0 -0
  124. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarDropdown.d.ts +0 -0
  125. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarGlyph.d.ts +0 -0
  126. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarGroup.d.ts +0 -0
  127. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarGroupIconBox.d.ts +0 -0
  128. /package/components/{ToolsBar → Toolbar}/primitives/ToolbarSurface.d.ts +0 -0
  129. /package/components/{ToolsBar → Toolbar}/primitives/index.d.ts +0 -0
  130. /package/components/{ToolsBar → Toolbar}/primitives/styles.d.ts +0 -0
  131. /package/{components/GaugeBox/index.d.ts → modules/Gauge/InteractionSurface.d.ts} +0 -0
  132. /package/{components/HeatmapCapture → modules/Heatmap/Capture}/Area/index.d.ts +0 -0
  133. /package/{components/HeatmapCapture → modules/Heatmap/Capture}/RowIndex/index.d.ts +0 -0
  134. /package/{components/HeatmapCapture → modules/Heatmap/Capture}/Slider/index.d.ts +0 -0
  135. /package/{components/FrequencyTagLine → modules/Heatmap/Capture}/Switch/index.d.ts +0 -0
  136. /package/{components/HeatmapCapture → modules/Heatmap/Capture}/index.d.ts +0 -0
  137. /package/{components/HeatmapCapture → modules/Heatmap/TimeRange}/Switch/index.d.ts +0 -0
  138. /package/{components → modules/Heatmap}/TimeRange/useTimeRange.d.ts +0 -0
  139. /package/{components → modules/Spectrum}/Blaze/index.d.ts +0 -0
  140. /package/{components → modules/Spectrum}/DeltaMeasurement/Switch.d.ts +0 -0
  141. /package/{components → modules/Spectrum}/DeltaMeasurement/index.d.ts +0 -0
  142. /package/{components → modules/Spectrum}/DragFrame/index.d.ts +0 -0
  143. /package/{components → modules/Spectrum}/FrequencyAllocation/Switch/index.d.ts +0 -0
  144. /package/{components → modules/Spectrum}/FrequencyAllocation/data.d.ts +0 -0
  145. /package/{components → modules/Spectrum}/FrequencyAllocation/index.d.ts +0 -0
  146. /package/{components → modules/Spectrum}/FrequencyAllocation/model/index.d.ts +0 -0
  147. /package/{components → modules/Spectrum}/FrequencyAllocation/overlays/Tooltip/index.d.ts +0 -0
  148. /package/{components → modules/Spectrum}/FrequencyAllocation/overlays/index.d.ts +0 -0
  149. /package/{components → modules/Spectrum}/FrequencyAllocation/presenters/index.d.ts +0 -0
  150. /package/{components → modules/Spectrum}/FrequencyDataBoard/hooks/index.d.ts +0 -0
  151. /package/{components → modules/Spectrum}/FrequencyDataBoard/hooks/useStationInfoAtCursor.d.ts +0 -0
  152. /package/{components → modules/Spectrum}/FrequencyDataBoard/index.d.ts +0 -0
  153. /package/{components → modules/Spectrum}/FrequencyDataBoard/panels/index.d.ts +0 -0
  154. /package/{components → modules/Spectrum}/FrequencyTagLine/Board/index.d.ts +0 -0
  155. /package/{components/Limit → modules/Spectrum/FrequencyTagLine}/Switch/index.d.ts +0 -0
  156. /package/{components → modules/Spectrum}/Legend/index.d.ts +0 -0
  157. /package/{components → modules/Spectrum}/Limit/Item.d.ts +0 -0
  158. /package/{components/TimeRange → modules/Spectrum/Limit}/Switch/index.d.ts +0 -0
  159. /package/{components → modules/Spectrum}/Limit/index.d.ts +0 -0
  160. /package/{components → modules/Spectrum}/Markers/Switch/index.d.ts +0 -0
  161. /package/{components → modules/Spectrum}/Markers/index.d.ts +0 -0
  162. /package/{components → modules/Spectrum}/Scope/index.d.ts +0 -0
  163. /package/{components → modules/Spectrum}/SegmentsZebra/index.d.ts +0 -0
  164. /package/{components → modules/Spectrum}/Signal/Switch/index.d.ts +0 -0
  165. /package/{components → modules/Spectrum}/Signal/index.d.ts +0 -0
  166. /package/{components → modules/Spectrum}/Signal/metadata/index.d.ts +0 -0
  167. /package/{components → modules/Spectrum}/Signal/metadata/signalType.d.ts +0 -0
  168. /package/{components → modules/Spectrum}/Signal/model/index.d.ts +0 -0
  169. /package/{components → modules/Spectrum}/Signal/model/useUnifiedSignals.d.ts +0 -0
  170. /package/{components → modules/Spectrum}/Signal/presenters/SignalSegments/index.d.ts +0 -0
  171. /package/{components → modules/Spectrum}/Signal/presenters/index.d.ts +0 -0
  172. /package/{components → modules/Spectrum}/Stripe/Switch/index.d.ts +0 -0
  173. /package/{components → modules/Spectrum}/Stripe/index.d.ts +0 -0
  174. /package/{hooks/publish → modules/Spectrum}/useMarkerPublish.d.ts +0 -0
  175. /package/{hooks → modules/Spectrum}/useSpectrumAnalyzer/useTemplateComparison.d.ts +0 -0
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # rfkit-charts
2
2
 
3
- 服务于无线电监测产品的 web 图表组件库
3
+ 服务于无线电监测产品的 Web 图表组件库。
4
+
5
+ - 仓库名:`rfkit-charts`
6
+ - npm 发布名:`@rfkit/charts`
4
7
 
5
8
  ## 安装
6
9
 
@@ -8,319 +11,199 @@
8
11
  pnpm add @rfkit/charts
9
12
  ```
10
13
 
11
- ## 主题与 Tailwind 集成
12
-
13
- 默认情况下,消费方只需要安装并直接使用组件:
14
-
15
- ```ts
16
- import { Spectrum } from '@rfkit/charts';
17
- ```
14
+ 正式版本由源码仓库内的 Release PR 自动发布到 npm;仓库里的本地 `publish:*` 脚本只作为维护调试或应急入口,不属于常规发布流程。
18
15
 
19
- 本库发布产物已经默认携带新 UI 所需的样式,并会自动注入 charts 侧需要的主题 / 尺寸变量定义。外部项目不需要再额外引入 `tailwind-bridge.css` 才能让组件正常显示。
16
+ ## 发布入口
20
17
 
21
- 也就是说,默认推荐接法仍然是:
18
+ 当前对外正式入口只有两个:
22
19
 
23
- ```ts
24
- import { Spectrum } from '@rfkit/charts';
25
- ```
20
+ - JS / TS:`@rfkit/charts`
21
+ - CSS bridge:`@rfkit/charts/tailwind-bridge.css`
26
22
 
27
- 如果你的应用已经在使用 `@rfkit/theme`,接法也不需要改。charts 会只读根节点上的这两个契约标识:
23
+ 默认直接从包根导入组件即可。组件运行所需样式会随包根入口自动加载,普通消费方不需要额外引 CSS。
28
24
 
29
- - `theme`
30
- - `theme-follow-OS`
25
+ ## 快速开始
31
26
 
32
- 也就是说,外部继续这样初始化即可:
27
+ 公开组件默认通过 `ref` 暴露 `Publish` 能力,不走 `publish` prop。
33
28
 
34
- ```ts
29
+ ```tsx
30
+ import { useEffect, useRef } from 'react';
35
31
  import {
36
- initTheme,
37
- toggleTheme,
38
- toggleThemeMode
39
- } from '@rfkit/theme';
40
-
41
- initTheme();
42
- toggleTheme();
43
- toggleThemeMode();
44
- ```
45
-
46
- `initChartsTheme()` 现在主要用于两个场景:
32
+ ChartType,
33
+ PSType,
34
+ Spectrum,
35
+ type Publish
36
+ } from '@rfkit/charts';
47
37
 
48
- - 你想覆盖 charts 默认的 `themeConfigs` / `sizeConfigs`
49
- - 你想通过 `subscribeThemeChange` 订阅 charts 解析后的主题状态
38
+ export function Demo() {
39
+ const chartRef = useRef<Publish>(null);
50
40
 
51
- 只有在外部项目自己也使用 `Tailwind CSS v4 + shadcn/ui`,并且希望复用本库这套语义 token 时,才需要额外引入 bridge:
41
+ useEffect(() => {
42
+ chartRef.current?.({
43
+ pstype: PSType.Spectrum,
44
+ data: new Float32Array([12, 28, 19, 35, 17])
45
+ });
46
+ }, []);
52
47
 
53
- ```css
54
- @import "tailwindcss";
55
- @import "@rfkit/charts/tailwind-bridge.css";
48
+ return <Spectrum ref={chartRef} type={ChartType.SingleFrequency} />;
49
+ }
56
50
  ```
57
51
 
58
- 说明:
52
+ ## Publish 使用方式
59
53
 
60
- - 默认包入口已经自动携带组件运行所需样式,并自动注入 charts 侧默认主题 / 尺寸变量
61
- - charts 默认只读取 `theme` / `theme-follow-OS`,不再把自己当主题真源
62
- - `@rfkit/charts/tailwind-bridge.css` 只提供 Tailwind/shadcn 语义 token 复用能力,不包含全局 reset
63
- - 如果外部项目继续使用 `@rfkit/theme` 的 `initTheme()` / `toggleTheme()` / `toggleThemeMode()`,charts 会自动跟随刷新
64
- - 更完整的主题桥接说明见 [docs/theme-migration.md](/Users/hugh/workspace/github/rfkit-charts/docs/theme-migration.md)
54
+ 大多数图表的数据输入都通过组件 `ref` 返回的 `Publish` 函数完成。
65
55
 
66
- 更多项目说明见:[docs/README.md](/Users/hugh/workspace/github/rfkit-charts/docs/README.md)
67
-
68
- ## 基本使用
69
-
70
- ```jsx
56
+ ```tsx
57
+ import { useEffect, useRef } from 'react';
71
58
  import {
72
- // 频谱图
73
- Spectrum,
74
- LevelStream,
75
- // IQ图
76
- IQ,
77
- // 仪表图
78
59
  Gauge,
79
- Dial,
80
- // 辅助图形
81
- Heatmap,
82
- Occupancy,
60
+ PSType,
61
+ type Publish
83
62
  } from '@rfkit/charts';
84
63
 
85
- // 行为推送
86
- const publishRef = useRef(null);
87
- const handlePublishChange = (publish) => {
88
- publishRef.current? = publish;
89
- };
90
-
91
- // 图表类型
92
- export enum ChartType {
93
- // 频谱图
94
- SingleFrequency = 'singleFrequency',
95
- Scan = 'scan',
96
- MScan = 'mscan',
97
- ScanDF360 = 'ScanDF360',
98
- DDC = 'ddc',
99
- Lite = 'lite',
100
- LiteNormalized = 'liteNormalized',
101
- LevelStream = 'levelStream',
102
- // IQ图
103
- IQEye = 'iqEye',
104
- IQLine = 'iqLine',
105
- IQPlanisphere = 'iqPlanisphere',
106
- IQStream = 'iqStream',
107
- // 辅助图形
108
- Heatmap = 'heatmap',
109
- Occupancy = 'occupancy',
110
- }
64
+ export function GaugeDemo() {
65
+ const gaugeRef = useRef<Publish>(null);
111
66
 
112
- // 频谱图
113
- <Spectrum type="singleFrequency" publish={handlePublishChange} /> // 单频频谱
114
- <Spectrum type="scan" publish={handlePublishChange} /> // 扫描频谱
115
- <Spectrum type="scanDF360" publish={handlePublishChange} /> // 扫描测向概率统计
116
- <Spectrum type="ddc" publish={handlePublishChange} channel onChannelChange /> // DCC
117
- <Spectrum type="lite" publish={handlePublishChange} /> // 精简模式
118
- <Spectrum type="liteNormalized" publish={handlePublishChange} /> // 精简模式(Y轴范围0-1)
119
-
120
- // DDC特殊参数
121
- export interface Props {
122
- channel?: number; // 默认32
123
- onChannelChange?: (c: {
124
- frequency: number;
125
- type: MarkerEventType;
126
- list: number[];
127
- }) => void;
67
+ useEffect(() => {
68
+ gaugeRef.current?.({
69
+ pstype: PSType.Gauge,
70
+ value: 42,
71
+ limit: 60
72
+ });
73
+
74
+ gaugeRef.current?.({
75
+ pstype: PSType.Reset
76
+ });
77
+ }, []);
78
+
79
+ return <Gauge ref={gaugeRef} />;
128
80
  }
81
+ ```
129
82
 
130
- // 电平瀑布图
131
- <LevelStream />
83
+ 常用公开类型:
132
84
 
133
- // IQ类型
134
- <IQ type={ChartType} publish={handlePublishChange} />
85
+ - `Publish`
86
+ - `PublishData`
87
+ - `PublishSpectrum`
88
+ - `PublishHeatmap`
89
+ - `PublishIQ`
90
+ - `PublishLevelStream`
91
+ - `PublishDial`
92
+ - `PublishGauge`
93
+ - `SetSeries`
94
+ - `SetSegments`
95
+ - `SetMarker`
135
96
 
136
- // 仪表盘
137
- <Gauge publish={handlePublishChange} />
138
- <Dial axisY={{range}} onChange={onChange} publish={handlePublishChange} />
139
- ```
97
+ 工具栏相关命名统一使用:
140
98
 
141
- **publish(行为推送工具)**
142
-
143
- ```typescript
144
- export enum PSType {
145
- // 频谱数据
146
- SPECTRUM = 'spectrum',
147
- // 天线因子数据
148
- ANTENNA_FACTOR = 'antennaFactor',
149
- // 占用度数据
150
- OCCUPANCY = 'occupancy',
151
- // 电平流数据
152
- LEVEL_STREAM = 'levelStream',
153
- // 瀑布图数据
154
- HEATMAP = 'heatmap',
155
- // IQ数据
156
- IQ = 'IQ',
157
- // 示向度盘
158
- DIAL = 'dial',
159
- // 刻度尺
160
- GAUGE = 'gauge',
161
-
162
- // 频谱线属性
163
- SERIES = 'series',
164
- // 频谱带宽规则:一般用于单频频谱
165
- SPECTRUM_BANDWIDTH = 'spectrumBandwidth',
166
- // 多段扫描规则:一般用于扫描数据的多段组合
167
- SEGMENTS = 'segments',
168
- // 多路DCC
169
- CHANNELS = 'channels',
170
- // Marker
171
- MARKER = 'marker',
172
-
173
- // 图形操作
174
- RESET = 'reset',
175
- }
99
+ - 工具栏枚举使用 `ToolbarItemType`
100
+ - 组件参数使用 `toolbar`
176
101
 
177
- // 系列配置
178
- interface SeriesConfig {
179
- readonly name: string;
180
- // 内外可设置属性
181
- label?: string;
182
- color?: string;
183
- }
102
+ ## 主题接入
184
103
 
185
- // 推送频谱线属性
186
- export interface SetSeries extends SeriesConfig {
187
- pstype: PSType.Series;
188
- }
104
+ charts 只读取根节点上的两个契约:
189
105
 
190
- // 设置频谱带宽规则
191
- export interface SetSpectrumBandwidth extends SpectrumBandwidth {
192
- pstype: PSType.SpectrumBandwidth;
193
- }
106
+ - `theme="light" | "dark"`
107
+ - `theme-follow-OS="true" | "false"`
194
108
 
195
- // 设置多段扫描规则
196
- export interface SetSegments {
197
- pstype: PSType.Segments;
198
- event?: SegmentsEvent; // 事件类型:默认覆盖数据
199
- data?: SegmentsOriginal[]; // 多段扫描规则:设置数据才使用
200
- index?: number; // 段索引:需要外部聚焦某段才使用
201
- }
109
+ 应用层直接写这两个属性即可:
202
110
 
203
- // 设置天线因子
204
- export interface SetAntennaFactor {
205
- pstype: PSType.AntennaFactor;
206
- data: Float32Array;
207
- }
111
+ ```ts
112
+ document.documentElement.setAttribute('theme', 'dark');
113
+ document.documentElement.setAttribute('theme-follow-OS', 'false');
114
+ ```
208
115
 
209
- // 设置台站库信息
210
- export interface SetStationInfo {
211
- pstype: PSType.StationInfo;
212
- data: StationInfoType[];
213
- }
116
+ 如果宿主已经在用 `@rfkit/theme`,通常不需要额外迁移,因为它写的也是同一套根契约。
214
117
 
215
- // 设置多路DCC信道
216
- export interface SetChannels {
217
- pstype: PSType.Channels;
218
- event: MarkerEventType;
219
- frequency?: number;
220
- }
118
+ ### `initChartsTheme()`
221
119
 
222
- // 设置Marker
223
- export interface SetMarker {
224
- pstype: PSType.Marker;
225
- event: MarkerEventType;
226
- marker?: Partial<MarkerType>;
227
- frequencies?: number[]; // 设计规定:frequencies必须是频率数据
228
- silent?: boolean; // 是否通知外部onChange回调
229
- }
120
+ `initChartsTheme()` 现在只承担三件事:
230
121
 
231
- // 额外的频谱数据
232
- export interface SpectrumExtraData {
233
- [key: string]: Float32Array;
234
- }
235
- // 推送频谱数据
236
- export interface PublishSpectrum {
237
- pstype: PSType.Spectrum;
238
- data?: Float32Array;
239
- // 一般仅在静态绘制
240
- maxData?: Float32Array;
241
- minData?: Float32Array;
242
- avgData?: Float32Array;
243
- backgroundNoiseData?: Float32Array;
244
- templateData?: Float32Array;
245
- extraData?: SpectrumExtraData;
246
- // 瀑布图可选参数
247
- timestamp?: string;
248
- // 扫描可选参数
249
- offset?: number; // 当前段的点偏移量
250
- segmentOffset?: number; // 当前段的索引
251
- }
122
+ - 覆盖 charts 默认 `tokens`
123
+ - 覆盖默认 `sizes`
124
+ - 通过 `onChange` 订阅解析后的主题状态
252
125
 
253
- // 推送瀑布图数据
254
- export interface PublishHeatmap {
255
- pstype: PSType.Heatmap;
256
- data: TimestampedFloat32Array[];
257
- timestamps: number[];
258
- }
126
+ ```ts
127
+ import { initChartsTheme } from '@rfkit/charts';
128
+
129
+ initChartsTheme({
130
+ onChange: ({ followOS, theme, contractTheme }) => {
131
+ console.log(followOS, theme, contractTheme);
132
+ },
133
+ tokens: {
134
+ semantic: {
135
+ primary: {
136
+ light: '#2A51F7',
137
+ dark: '#4371F8'
138
+ }
139
+ }
140
+ },
141
+ sizes: {
142
+ spacing: {
143
+ base: {
144
+ middle: '8px',
145
+ small: '4px'
146
+ }
147
+ }
148
+ }
149
+ });
150
+ ```
259
151
 
260
- // 推送占用度数据
261
- export interface PublishOccupancy {
262
- pstype: PSType.Occupancy;
263
- data: Float32Array;
264
- totalOccupancy: number;
265
- }
152
+ ### 读取和订阅主题状态
266
153
 
267
- // 推送电平流数据
268
- export interface PublishLevelStream {
269
- pstype: PSType.LevelStream;
270
- data: number;
271
- }
154
+ ```ts
155
+ import {
156
+ getChartsThemeState,
157
+ subscribeChartsThemeChange
158
+ } from '@rfkit/charts';
272
159
 
273
- // 推送IQ数据
274
- export interface PublishIQ {
275
- pstype: PSType.IQ;
276
- IData: number[];
277
- Qdata: number[];
278
- }
160
+ const state = getChartsThemeState();
161
+ console.log(state.theme, state.preference);
279
162
 
280
- // 推送Dial数据
281
- export interface PublishDial {
282
- pstype?: PSType.Dial;
283
- series: Array<{
284
- value: number;
285
- color: string;
286
- }>;
287
- range?: number[]; // 概率范围 0-360
288
- yawAngle?: number; // 偏航角 0-360
289
- isNorthFacing?: boolean; // 是否朝北
290
- }
163
+ const cleanup = subscribeChartsThemeChange((nextState) => {
164
+ console.log(nextState.followOS, nextState.contractTheme);
165
+ });
291
166
 
292
- // 推送Gauge数据
293
- export interface PublishGauge {
294
- pstype?: PSType.Gauge;
295
- value: number; // 值
296
- limit: number; // 门限值
297
- }
167
+ cleanup();
168
+ ```
298
169
 
299
- // 推送图形操作
300
- export interface Reset {
301
- pstype: PSType.Reset;
302
- }
170
+ ### `tailwind-bridge.css`
303
171
 
304
- // 推送渲染数据(内部)
305
- export interface Render {
306
- pstype: PSType.Render;
307
- [key: string]: unknown;
308
- }
172
+ 只有当宿主自己也在用 `Tailwind CSS v4 + shadcn/ui`,并且想复用 charts 的 canonical token 时,才需要额外引入:
309
173
 
310
- export type PublishData =
311
- | SetSeries
312
- | SetSpectrumBandwidth
313
- | SetSegments
314
- | SetChannels
315
- | SetMarker
316
- | SetAntennaFactor
317
- | PublishSpectrum
318
- | PublishHeatmap
319
- | PublishOccupancy
320
- | PublishLevelStream
321
- | PublishIQ
322
- | PublishDial
323
- | PublishGauge
324
- | Reset
325
- | Render;
174
+ ```css
175
+ @import "tailwindcss";
176
+ @import "@rfkit/charts/tailwind-bridge.css";
326
177
  ```
178
+
179
+ 这份 bridge 的边界是:
180
+
181
+ - 只做 canonical charts token 到 Tailwind / shadcn 语义色板的映射
182
+ - 不包含全局 reset
183
+ - 不再兜底旧 `--theme-*` 变量
184
+ - 不负责替宿主生成 `:root` 上的 canonical token
185
+
186
+ ## 非公开边界
187
+
188
+ 以下内容不属于对外源码 API:
189
+
190
+ - 任意 `src/**` 源码路径
191
+ - `test/**` preview / example 宿主
192
+ - 仓库内部工程文档
193
+
194
+ ## 主题变更摘要
195
+
196
+ 当前主题系统已经完成二阶段收口,外部需要注意的 breaking change 主要有:
197
+
198
+ - `initChartsTheme()` 不再接受 `themeConfigs` / `sizeConfigs` / `subscribeThemeChange`
199
+ - 新配置入口改为 `tokens` / `sizes` / `onChange`
200
+ - `applyChartsTheme()` 与 `applyChartsThemePreference()` 已移除
201
+ - 默认运行时不再输出旧 `--theme-*` alias
202
+ - `@rfkit/charts/tailwind-bridge.css` 不再暴露 deprecated bridge token
203
+
204
+ ## 文档边界
205
+
206
+ - 对外安装、接入方式、主题契约和常用用法以本文为准。
207
+ - 精确公开 API 以 `@rfkit/charts` 包根导出的类型声明和编辑器智能提示为准。
208
+ - npm 打包产物只同步根 `README.md`,不会把仓库内的 `docs/*` 一并作为公开文档入口发布。
209
+ - 仓库内部专题文档只在源码仓库内维护,不属于发布包对外文档入口。
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { RenderChartType } from '../../../types';
3
- import GradientRibbon from './type/Default/GradientRibbon';
3
+ import GradientRibbon from './variants/standard/GradientRibbon';
4
4
  export { GradientRibbon };
5
5
  interface Props {
6
6
  id: string;
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ interface Props {
3
+ id: string;
4
+ }
5
+ declare const StandardHeatmapAxisYVariant: React.FC<Props>;
6
+ export default StandardHeatmapAxisYVariant;
@@ -0,0 +1,10 @@
1
+ import type { SystemConfig } from '../../types/store';
2
+ export interface ContainerSizeSnapshot {
3
+ height: number;
4
+ width: number;
5
+ }
6
+ type ContainerElementLike = Pick<HTMLElement, 'offsetHeight' | 'offsetWidth'>;
7
+ export declare const readContainerSize: (element: ContainerElementLike | null | undefined) => ContainerSizeSnapshot | null;
8
+ export declare const hasContainerSizeChanged: (previousSize: ContainerSizeSnapshot | null, nextSize: ContainerSizeSnapshot | null) => boolean;
9
+ export declare const createNextSystemConfig: (system: SystemConfig, size: ContainerSizeSnapshot) => SystemConfig;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import type React from 'react';
2
+ export declare const POPOVER_ROW_CLASS = "mt-1 flex items-center justify-between gap-1 text-xs text-popover-foreground";
3
+ export declare const POPOVER_VALUE_CLASS = "inline-flex min-w-9 justify-end";
4
+ export declare const useCursorPopoverUpdateKey: (key: string, id: string) => number;
5
+ export declare const FrequencyDisplay: React.FC<{
6
+ frequency: string;
7
+ unit: string;
8
+ }>;
@@ -0,0 +1,12 @@
1
+ import type React from 'react';
2
+ import { ChartType, ToolbarItemType } from '../../config';
3
+ export interface ToolbarItemConfig {
4
+ component: React.ComponentType<Record<string, unknown>>;
5
+ toolType: ToolbarItemType;
6
+ supportedCharts: ChartType[];
7
+ excludedCharts?: ChartType[];
8
+ props?: Record<string, unknown>;
9
+ }
10
+ export declare const TOOLBAR_ITEM_CONFIGS: ToolbarItemConfig[];
11
+ export declare const isToolbarItemVisible: (config: ToolbarItemConfig, chartType: ChartType | undefined, hiddenTools?: string[]) => boolean;
12
+ export declare const resolveToolbarItemProps: (config: ToolbarItemConfig, chartType: ChartType | undefined) => Record<string, unknown>;
@@ -0,0 +1,10 @@
1
+ export { AutorangingControl as AutorangingSwitch, UnitControl as UnitSwitch } from '../../AxisY/spectrum/controls';
2
+ export { default as ZoomSwitch } from '../../Zoom/Switch';
3
+ export { default as FluorescenceSwitch } from '../../../modules/Fluorescence/Switch';
4
+ export { default as HeatmapCaptureSwitch } from '../../../modules/Heatmap/Capture/Switch';
5
+ export { default as TimeRangeSwitch } from '../../../modules/Heatmap/TimeRange/Switch';
6
+ export { default as DeltaMeasurementSwitch } from '../../../modules/Spectrum/DeltaMeasurement/Switch';
7
+ export { default as FrequencyAllocationSwitch } from '../../../modules/Spectrum/FrequencyAllocation/Switch';
8
+ export { default as LimitSwitch } from '../../../modules/Spectrum/Limit/Switch';
9
+ export { default as MarkersSwitch } from '../../../modules/Spectrum/Markers/Switch';
10
+ export { default as SignalSwitch } from '../../../modules/Spectrum/Signal/Switch';
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ children: React.ReactNode;
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ }
6
+ declare const ZoomViewportLayer: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
7
+ export default ZoomViewportLayer;
@@ -1,14 +1,14 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  import type { ButtonHTMLAttributes } from 'react';
3
3
  declare const buttonVariants: (props?: {
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost";
4
+ variant?: "link" | "destructive" | "secondary" | "default" | "outline" | "ghost";
5
5
  size?: "default" | "icon" | "sm" | "lg";
6
6
  } & import("class-variance-authority/types").ClassProp) => string;
7
7
  export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {
8
8
  asChild?: boolean;
9
9
  };
10
10
  export declare const Button: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<(props?: {
11
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost";
11
+ variant?: "link" | "destructive" | "secondary" | "default" | "outline" | "ghost";
12
12
  size?: "default" | "icon" | "sm" | "lg";
13
13
  } & import("class-variance-authority/types").ClassProp) => string> & {
14
14
  asChild?: boolean;
@@ -97,7 +97,7 @@ export declare enum ToolType {
97
97
  FrequencyDataBoard = "frequencyDataBoard",
98
98
  FrequencyTagLine = "frequencyTagLine",
99
99
  GridLines = "gridLines",
100
- GuageBox = "guageBox",
100
+ GaugeBox = "gaugeBox",
101
101
  HeatmapCapture = "heatmapCapture",
102
102
  Legend = "legend",
103
103
  Limit = "limit",
@@ -112,7 +112,7 @@ export declare enum ToolType {
112
112
  Frame = "frame",
113
113
  Area = "area"
114
114
  }
115
- export declare enum ToolsBarItemType {
115
+ export declare enum ToolbarItemType {
116
116
  AutorangingSwitch = "AutorangingSwitch",
117
117
  UnitSwitch = "UnitSwitch",
118
118
  StepSwitch = "StepSwitch",
package/hooks/index.d.ts CHANGED
@@ -2,11 +2,10 @@
2
2
  * Hooks 统一导出
3
3
  */
4
4
  export { useChannel, usePoints, useSegments } from './data';
5
- export { type EnhancedPublish, PUB_SUB, useMarkerPublish, usePublish, useSafePublish } from './publish';
5
+ export { type EnhancedPublish, PUB_SUB, usePublish, useSafePublish } from './publish';
6
6
  export { SET_SEGMENTS_DISPLAY, type UseSpectrumChartTypeProps, useSpectrumChartType, useSpectrumRule } from './spectrum';
7
7
  export { default as useChart } from './useChart';
8
8
  export { withChartPublisher } from './useChartComponent';
9
9
  export { default as useLevelStreamAnalyzer } from './useLevelStreamAnalyzer';
10
10
  export { useModuleSubscription } from './useModuleSubscription';
11
11
  export { useFilteredSeries, useSeriesForComponent, useSeriesManager } from './useSeriesManager';
12
- export { default as useSpectrumAnalyzer } from './useSpectrumAnalyzer';
@@ -0,0 +1,23 @@
1
+ export type ModulePublishType = 'antennaFactor' | 'autoranging' | 'band' | 'channels' | 'clear' | 'dial' | 'fluorescence' | 'gauge' | 'heatmap' | 'iq' | 'levelStream' | 'marker' | 'occupancy' | 'option' | 'points' | 'render' | 'reset' | 'resize' | 'segments' | 'series' | 'signal' | 'spectrum' | 'spectrumBandwidth' | 'scope';
2
+ export interface ModulePublishEventBase {
3
+ pstype?: ModulePublishType;
4
+ }
5
+ export interface ChartSubscriptionInterface<TData = unknown> {
6
+ updateSeries?(data: TData, ...args: unknown[]): void;
7
+ reset(): void;
8
+ resize(): void;
9
+ setRange?(range: unknown): void;
10
+ setSeries?(config: unknown): void;
11
+ useRangeAutoFocus?(): void;
12
+ }
13
+ export type DataExtractor<TData, TEvent extends ModulePublishEventBase = ModulePublishEventBase> = (event: TEvent) => TData;
14
+ export type ModuleEventHandler<TData = unknown, TEvent extends ModulePublishEventBase = ModulePublishEventBase> = (event: TEvent, chart: ChartSubscriptionInterface<TData>) => void;
15
+ export interface ModuleSubscriptionHandlerOptions<TData = unknown, TEvent extends ModulePublishEventBase = ModulePublishEventBase> {
16
+ chart: ChartSubscriptionInterface<TData>;
17
+ eventHandlers?: Partial<Record<ModulePublishType, ModuleEventHandler<TData, TEvent>>>;
18
+ extractData?: DataExtractor<TData, TEvent>;
19
+ handleRender?: ModuleEventHandler<TData, TEvent>;
20
+ renderPSTypes?: ModulePublishType[];
21
+ treatMissingPSTypeAsRender?: boolean;
22
+ }
23
+ export declare const handleModuleSubscriptionEvent: <TData = unknown, TEvent extends ModulePublishEventBase = ModulePublishEventBase>(event: TEvent, { chart, eventHandlers, extractData, handleRender, renderPSTypes, treatMissingPSTypeAsRender }: ModuleSubscriptionHandlerOptions<TData, TEvent>) => void;
@@ -1,5 +1,5 @@
1
1
  import type { Publish, PublishData } from '../../types';
2
- import type { rawData } from '../../utils/subscription';
2
+ import { type rawData } from '../../utils/subscription.ts';
3
3
  type ReadyCleanup = () => void;
4
4
  type ReadyCallback = () => ReadyCleanup | undefined;
5
5
  export interface EnhancedPublish extends Publish {
@@ -2,6 +2,5 @@
2
2
  * 发布相关 hooks
3
3
  */
4
4
  export type { EnhancedPublish } from './enhancedPublish';
5
- export { default as useMarkerPublish } from './useMarkerPublish';
6
5
  export { default as usePublish, PUB_SUB } from './usePublish';
7
6
  export { default as useSafePublish } from './useSafePublish';
@@ -0,0 +1,9 @@
1
+ export interface PublishEventLike {
2
+ pstype?: string;
3
+ }
4
+ interface NormalizeRenderPublishEventOptions {
5
+ allowImplicitRender?: boolean;
6
+ renderPSTypes?: string[];
7
+ }
8
+ export declare const normalizeRenderPublishEvent: <T extends PublishEventLike>(event: T, options?: NormalizeRenderPublishEventOptions) => T;
9
+ export {};
@@ -3,7 +3,7 @@ interface levelStreamRenderData {
3
3
  probabilityRangeData: Float32Array;
4
4
  spectrumData: Float32Array;
5
5
  }
6
- export default function uselevelStreamAnalyzer(): {
6
+ export default function useLevelStreamAnalyzer(): {
7
7
  analyzer: LevelStreamAnalyzer;
8
8
  updateLevelStreamData: (renderData: levelStreamRenderData) => void;
9
9
  };