@rfkit/charts 1.10.0 → 1.10.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.
@@ -1 +1 @@
1
- export { useStationFinder, useStationInfoAtCursor } from './useStationInfoAtCursor';
1
+ export { useSignalFinder, useSignalInfoAtCursor, useStationFinder, useStationInfoAtCursor } from './useStationInfoAtCursor';
@@ -1 +1 @@
1
- export { useStationFinder, useStationInfoAtCursor } from '../../Signal/model';
1
+ export { useSignalFinder, useSignalInfoAtCursor, useStationFinder, useStationInfoAtCursor } from '../../Signal/model';
@@ -7,7 +7,7 @@ interface Props {
7
7
  frequency: string;
8
8
  }) => void;
9
9
  updateKey?: number;
10
- showStationInfo?: boolean;
10
+ showSignalInfo?: boolean;
11
11
  cursorSample?: CursorSampleSnapshot | null;
12
12
  }
13
13
  declare const _default: React.NamedExoticComponent<Props>;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import type { StationInfoType } from '../../../../../types';
2
+ import { type UnifiedSignalItem } from '../../../Signal/model';
3
3
  interface Props {
4
- stationInfo?: StationInfoType;
4
+ signalInfo?: UnifiedSignalItem;
5
5
  }
6
6
  declare const _default: React.NamedExoticComponent<Props>;
7
7
  export default _default;
@@ -1 +1 @@
1
- export { default as StationInfoPanel } from './StationInfoPanel';
1
+ export { default as SignalInfoPanel } from './StationInfoPanel';
@@ -1,7 +1,8 @@
1
1
  import type React from 'react';
2
2
  /**
3
3
  * Signal 开关组件
4
- * 控制 signal 的显示状态
4
+ * 控制 signal 的显示状态,并组合为“总开关 + 树形筛选”:
5
+ * 台站库/信号库 → 信号类型 → 信号等级。
5
6
  */
6
7
  declare const Switch: React.FC;
7
8
  export default Switch;
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import SignalSwitch from './Switch';
3
- export { useStationFinder } from './model';
3
+ export { useSignalFinder, useStationFinder } from './model';
4
4
  export { useSignalDataManager } from './useSignalDataManager';
5
5
  export { SignalSwitch };
6
6
  interface Props {
@@ -1 +1,2 @@
1
- export { SIGNAL_TYPE_MAP, SignalType, signalTypeMap } from './signalType';
1
+ export { normalizeSignalLevel, resolveSignalColor, SIGNAL_LEVEL_FIRST, SIGNAL_LEVEL_MAP, SIGNAL_LEVEL_ORDER, SIGNAL_LEVEL_SECOND, SIGNAL_LEVEL_THIRD, SIGNAL_LEVEL_UNASSIGNED, type SignalLevelMeta } from './level.ts';
2
+ export { normalizeSignalType, SIGNAL_TYPE_MAP, SIGNAL_TYPE_ORDER, SignalType, type SignalTypeKey, type SignalTypeMeta, signalTypeMap } from './signalType.ts';
@@ -0,0 +1,25 @@
1
+ export declare const SIGNAL_LEVEL_UNASSIGNED = -1;
2
+ export declare const SIGNAL_LEVEL_FIRST = 0;
3
+ export declare const SIGNAL_LEVEL_SECOND = 1;
4
+ export declare const SIGNAL_LEVEL_THIRD = 2;
5
+ export interface SignalLevelMeta {
6
+ name: string;
7
+ color: string;
8
+ }
9
+ export declare const SIGNAL_LEVEL_ORDER: readonly [-1, 0, 1, 2];
10
+ export declare const SIGNAL_LEVEL_MAP: Record<number, SignalLevelMeta>;
11
+ /**
12
+ * 等级规范化:-1/0/1/2 分别对应未分配/一级/二级/三级;
13
+ * 缺失、非整数或不在集合内的值统一归为 -1(未分配)
14
+ */
15
+ export declare const normalizeSignalLevel: (value: unknown) => number;
16
+ /**
17
+ * 颜色解析:外部显式 color 优先;信号库合法类型使用等级色,
18
+ * 台站库与信号库其他类型均使用类型色。
19
+ */
20
+ export declare const resolveSignalColor: (item: {
21
+ source: "station" | "simple";
22
+ color?: string;
23
+ level?: number;
24
+ signalType?: string;
25
+ }) => string;
@@ -1,16 +1,21 @@
1
- export declare enum SignalType {
2
- LEGITIMATE = "Legitimate",
3
- KNOWN = "Know",
4
- UNKNOWN = "UnKnown",
5
- ILLEGAL = "Illegal"
6
- }
7
- export declare const SIGNAL_TYPE_MAP: Record<string, {
1
+ export declare const SignalType: {
2
+ readonly LEGITIMATE: "Legitimate";
3
+ readonly UNKNOWN: "UnKnown";
4
+ readonly KNOWN: "Know";
5
+ readonly VIOLATION: "Violation";
6
+ readonly ILLEGAL: "Illegal";
7
+ };
8
+ export type SignalType = (typeof SignalType)[keyof typeof SignalType];
9
+ export interface SignalTypeMeta {
8
10
  name: string;
9
11
  color: string;
10
12
  isLegitimate: boolean;
11
- }>;
12
- export declare const signalTypeMap: Record<string, {
13
- name: string;
14
- color: string;
15
- isLegitimate: boolean;
16
- }>;
13
+ }
14
+ export declare const SIGNAL_TYPE_MAP: Record<string, SignalTypeMeta>;
15
+ export type SignalTypeKey = keyof typeof SIGNAL_TYPE_MAP;
16
+ export declare const SIGNAL_TYPE_ORDER: SignalTypeKey[];
17
+ /**
18
+ * 类型规范化:缺失或无法识别的类型统一归入 UnKnown
19
+ */
20
+ export declare const normalizeSignalType: (value: unknown) => SignalTypeKey;
21
+ export declare const signalTypeMap: Record<string, SignalTypeMeta>;
@@ -1,3 +1,4 @@
1
- export { createStationRangeIndex, findStationAtCursor, findStationInRangeIndex, resolveActiveSignalKey, resolveSignalMatchCandidates, resolveSignalPositions, resolveSignalSegments, resolveStaticSignalSegments, type SignalPosition, type SignalSegmentData } from './resolver';
2
- export { useStationFinder, useStationInfoAtCursor } from './useStationInfoAtCursor';
1
+ export { createSignalRangeIndex, createStationRangeIndex, findSignalAtCursor, findSignalInRangeIndex, findStationAtCursor, findStationInRangeIndex, resolveActiveSignalKey, resolveSignalMatchCandidates, resolveSignalPositions, resolveSignalPresentation, resolveSignalSegments, resolveStaticSignalSegments, type SignalPosition, type SignalSegmentData } from './resolver';
2
+ export { buildSignalTree, filterSignalItemsByHiddenKeys, getSignalLeafKey, getUnifiedSignalKey, isStationInfo, resolveNodeCheckState, resolveSignalSource, SIGNAL_SOURCE_LABEL, SIGNAL_SOURCE_ORDER, type SignalNodeCheckState, type SignalSource, type SignalTree, type SignalTreeLevelNode, type SignalTreeSourceNode, type SignalTreeTypeNode, toggleNodeHiddenKeys, type UnifiedSignalItem } from './tree';
3
+ export { useSignalFinder, useSignalInfoAtCursor, useStationFinder, useStationInfoAtCursor } from './useStationInfoAtCursor';
3
4
  export { useUnifiedSignals } from './useUnifiedSignals';
@@ -0,0 +1,15 @@
1
+ import { type FrequencyRange, type FrequencyRangeInput } from '../../../../utils/frequencyCalculation.ts';
2
+ import { type UnifiedSignalItem } from './tree.ts';
3
+ export interface SignalMatchCandidate {
4
+ item: UnifiedSignalItem;
5
+ range: FrequencyRange;
6
+ startIndex: number;
7
+ stopIndex: number;
8
+ }
9
+ /** 将统一信号转换为频率范围输入(兼容 string | number)。 */
10
+ export declare function toFrequencyRangeInput(item: UnifiedSignalItem): FrequencyRangeInput;
11
+ export declare function resolveBestSignalMatch<T extends SignalMatchCandidate>(candidates: T[], options: {
12
+ currentFrequency: number;
13
+ currentPointIndex: number;
14
+ indexTolerance?: number;
15
+ }): T | undefined;
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import type { SegmentType, StationInfoType } from '../../../../types';
3
- import { type SignalMatchCandidate, type UnifiedSignalItem } from '../utils';
3
+ import { type SignalMatchCandidate } from './match.ts';
4
+ import { type UnifiedSignalItem } from './tree.ts';
4
5
  export interface SignalPosition extends SignalMatchCandidate {
5
6
  key: string;
6
7
  position: {
@@ -17,6 +18,7 @@ export interface SignalSegmentData {
17
18
  activeSignalKey?: string;
18
19
  style: CSSProperties;
19
20
  }
21
+ export declare const resolveSignalPresentation: (item: UnifiedSignalItem) => Pick<SignalPosition, "color" | "tooltip">;
20
22
  export declare const resolveSignalMatchCandidates: (signalItems: UnifiedSignalItem[], segment: SegmentType) => SignalMatchCandidate[];
21
23
  export declare const resolveSignalPositions: (signalItems: UnifiedSignalItem[], segment: SegmentType) => SignalPosition[];
22
24
  export declare const resolveSignalSegments: ({ segments, signalItems, isCursorActive, currentFrequency, currentPosition }: {
@@ -51,6 +53,19 @@ export declare const findStationAtCursor: ({ frequency, signalItems, segments, c
51
53
  pointIndex: number;
52
54
  };
53
55
  }) => StationInfoType | undefined;
56
+ export declare const findSignalAtCursor: ({ frequency, signalItems, segments, currentPosition }: {
57
+ frequency: number;
58
+ signalItems: UnifiedSignalItem[];
59
+ segments: SegmentType[];
60
+ currentPosition: {
61
+ segmentIndex: number;
62
+ pointIndex: number;
63
+ };
64
+ }) => UnifiedSignalItem | undefined;
65
+ export declare const createSignalRangeIndex: ({ signalItems, segments }: {
66
+ signalItems: UnifiedSignalItem[];
67
+ segments: SegmentType[];
68
+ }) => SignalMatchCandidate[][];
54
69
  export declare const createStationRangeIndex: ({ signalItems, segments }: {
55
70
  signalItems: UnifiedSignalItem[];
56
71
  segments: SegmentType[];
@@ -63,3 +78,11 @@ export declare const findStationInRangeIndex: ({ frequency, stationRangeIndex, c
63
78
  pointIndex: number;
64
79
  };
65
80
  }) => StationInfoType | undefined;
81
+ export declare const findSignalInRangeIndex: ({ frequency, signalRangeIndex, currentPosition }: {
82
+ frequency: number;
83
+ signalRangeIndex: SignalMatchCandidate[][];
84
+ currentPosition: {
85
+ segmentIndex: number;
86
+ pointIndex: number;
87
+ };
88
+ }) => UnifiedSignalItem | undefined;
@@ -0,0 +1,70 @@
1
+ import type { StationInfoType } from '../../../../types';
2
+ import type { SignalData } from '../../../../types/store';
3
+ /**
4
+ * 统一的信号数据类型(兼容 StationInfo 和 SignalData)
5
+ * 与 utils.ts 保持同一类型,此处作为树形筛选的独立纯函数模块载体
6
+ */
7
+ export type UnifiedSignalItem = StationInfoType | SignalData;
8
+ export type SignalSource = 'station' | 'simple';
9
+ export declare const SIGNAL_SOURCE_ORDER: SignalSource[];
10
+ export declare const SIGNAL_SOURCE_LABEL: Record<SignalSource, string>;
11
+ /**
12
+ * 判断是否为完整的台站信息
13
+ */
14
+ export declare function isStationInfo(item: UnifiedSignalItem): item is StationInfoType;
15
+ export declare const resolveSignalSource: (item: UnifiedSignalItem) => SignalSource;
16
+ /**
17
+ * 叶子键:source:signalType:level(类型与等级均为规范化后的值)
18
+ */
19
+ export declare const getSignalLeafKey: (item: UnifiedSignalItem) => string;
20
+ /**
21
+ * 统一渲染键始终带来源前缀:优先使用业务 id;无 id 时回退名称/频率范围,
22
+ * 避免缺省数据在台站库和信号库之间产生 React 重复键。
23
+ */
24
+ export declare function getUnifiedSignalKey(item: UnifiedSignalItem): string;
25
+ export interface SignalTreeLevelNode {
26
+ level: number;
27
+ label: string;
28
+ leafKey: string;
29
+ hasData: boolean;
30
+ }
31
+ export interface SignalTreeTypeNode {
32
+ signalType: string;
33
+ label: string;
34
+ leafKeys: string[];
35
+ dataLeafKeys: string[];
36
+ hasData: boolean;
37
+ levels: SignalTreeLevelNode[];
38
+ }
39
+ export interface SignalTreeSourceNode {
40
+ source: SignalSource;
41
+ label: string;
42
+ leafKeys: string[];
43
+ dataLeafKeys: string[];
44
+ hasData: boolean;
45
+ types: SignalTreeTypeNode[];
46
+ }
47
+ export interface SignalTree {
48
+ sources: SignalTreeSourceNode[];
49
+ }
50
+ /**
51
+ * 从未过滤的统一信号数据构建数据驱动的树目录。
52
+ * 来源与类型按固定顺序排列,但没有实际数据的节点不进入目录;
53
+ * 台站库是独立来源,不继续展开类型和等级。
54
+ */
55
+ export declare const buildSignalTree: (signalItems: UnifiedSignalItem[]) => SignalTree;
56
+ export type SignalNodeCheckState = 'checked' | 'indeterminate' | 'unchecked' | 'disabled';
57
+ /**
58
+ * 父节点依据当前有数据的后代计算:
59
+ * 全部可见 checked、部分可见 indeterminate、全部隐藏 unchecked、没有可用后代 disabled。
60
+ */
61
+ export declare const resolveNodeCheckState: (leafKeysWithData: ReadonlySet<string>, hiddenCategoryKeys: ReadonlySet<string>, fixedLeafKeys: string[]) => SignalNodeCheckState;
62
+ /**
63
+ * 级联选择:取消父节点时记录其完整固定后代,使后续出现的数据仍遵循用户选择。
64
+ * 全部数据后代可见时取消父节点(隐藏完整固定后代);否则恢复全部固定后代可见。
65
+ */
66
+ export declare const toggleNodeHiddenKeys: (hiddenCategoryKeys: string[], fixedLeafKeys: string[], leafKeysWithData: ReadonlySet<string>) => string[];
67
+ /**
68
+ * 隐藏集合过滤:默认全部显示,命中隐藏叶子键的条目被剔除。
69
+ */
70
+ export declare const filterSignalItemsByHiddenKeys: (signalItems: UnifiedSignalItem[], hiddenCategoryKeys: string[]) => UnifiedSignalItem[];
@@ -1,9 +1,12 @@
1
1
  import type { CursorSampleSnapshot } from '../../../../runtime/interaction';
2
- interface UseStationFinderProps {
2
+ import { type UnifiedSignalItem } from './tree';
3
+ interface UseSignalFinderProps {
3
4
  frequency: string;
4
5
  enabled?: boolean;
5
6
  cursorSample?: CursorSampleSnapshot | null;
6
7
  }
7
- export declare function useStationInfoAtCursor({ frequency, enabled, cursorSample }: UseStationFinderProps): import("../../../..").StationInfoType | undefined;
8
+ export declare function useSignalInfoAtCursor(props: UseSignalFinderProps): UnifiedSignalItem | undefined;
9
+ export declare function useStationInfoAtCursor(props: UseSignalFinderProps): import("../../../..").StationInfoType | undefined;
10
+ export declare const useSignalFinder: typeof useSignalInfoAtCursor;
8
11
  export declare const useStationFinder: typeof useStationInfoAtCursor;
9
12
  export {};
@@ -1,6 +1,7 @@
1
- import type { UnifiedSignalItem } from '../utils';
1
+ import type { UnifiedSignalItem } from './tree';
2
2
  interface UseUnifiedSignalsOptions {
3
3
  respectVisibility?: boolean;
4
+ filterHidden?: boolean;
4
5
  }
5
- export declare function useUnifiedSignals({ respectVisibility }?: UseUnifiedSignalsOptions): UnifiedSignalItem[];
6
+ export declare function useUnifiedSignals({ respectVisibility, filterHidden }?: UseUnifiedSignalsOptions): UnifiedSignalItem[];
6
7
  export {};
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- import type { SignalPosition } from '../../model';
2
+ import { type SignalPosition } from '../../model';
3
3
  interface SignalSegmentsProps {
4
4
  style: React.CSSProperties;
5
5
  signalPositions: SignalPosition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfkit/charts",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "type": "module",
5
5
  "description": "Chart components for wireless monitoring web applications",
6
6
  "exports": {
@@ -0,0 +1 @@
1
+ export declare const scheduleRuntimeCleanup: (cleanup: () => void) => (() => void);
package/types/common.d.ts CHANGED
@@ -67,6 +67,7 @@ export type SegmentsType = SegmentType[] & {
67
67
  totalPoints?: number;
68
68
  };
69
69
  export interface StationInfoType {
70
+ id?: string;
70
71
  signalName: string;
71
72
  orgName: string;
72
73
  frequency: number;
@@ -74,6 +75,8 @@ export interface StationInfoType {
74
75
  modulation: string;
75
76
  signalType: string;
76
77
  remark: string;
78
+ level?: number;
79
+ color?: string;
77
80
  startFrequency: number;
78
81
  stopFrequency: number;
79
82
  }
@@ -3,12 +3,14 @@ export declare enum SignalDataType {
3
3
  Simple = "simple"
4
4
  }
5
5
  export interface SignalData {
6
+ id?: string;
6
7
  startFrequency?: number | string;
7
8
  stopFrequency?: number | string;
8
9
  frequency?: number | string;
9
10
  bandwidth?: number | string;
10
11
  color?: string;
11
12
  signalType?: string;
13
+ level?: number;
12
14
  }
13
15
  export type SelectedSignal = {
14
16
  segIndex: number;
@@ -18,6 +20,7 @@ export interface SignalProps {
18
20
  show: boolean;
19
21
  display: boolean;
20
22
  data: SignalData[];
23
+ hiddenCategoryKeys: string[];
21
24
  onChange: (e: SelectedSignal) => void;
22
25
  }
23
26
  export interface SignalAnalysisProps {
@@ -1,27 +0,0 @@
1
- import type { StationInfoType } from '../../../types';
2
- import type { SignalData } from '../../../types/store';
3
- import type { FrequencyRange, FrequencyRangeInput } from '../../../utils';
4
- /**
5
- * 统一的信号数据类型(兼容 StationInfo 和 SignalData)
6
- */
7
- export type UnifiedSignalItem = StationInfoType | SignalData;
8
- export interface SignalMatchCandidate {
9
- item: UnifiedSignalItem;
10
- range: FrequencyRange;
11
- startIndex: number;
12
- stopIndex: number;
13
- }
14
- /**
15
- * 判断是否为完整的台站信息
16
- */
17
- export declare function isStationInfo(item: UnifiedSignalItem): item is StationInfoType;
18
- export declare function getUnifiedSignalKey(item: UnifiedSignalItem): string;
19
- /**
20
- * 将统一的信号数据转换为频率范围输入(处理 string | number 类型)
21
- */
22
- export declare function toFrequencyRangeInput(item: UnifiedSignalItem): FrequencyRangeInput;
23
- export declare function resolveBestSignalMatch<T extends SignalMatchCandidate>(candidates: T[], options: {
24
- currentFrequency: number;
25
- currentPointIndex: number;
26
- indexTolerance?: number;
27
- }): T | undefined;