/** * 内部工具:非数组则返回空数组,供 matter-kit 内部 reduce 等逻辑使用(未在 minituya matter-kit 文档单独列出)。 * @param array - 任意值,期望为数组 * @returns {T[]} 原数组或空数组 */ export declare const getArray: (array: T[]) => T[]; /** * 内部工具:将对象数组按指定键建立映射表(未在 minituya matter-kit 文档单独列出)。 * @param arr - 对象数组 * @param key - 作为索引的字段名(如 `'code'`) * @returns {Record} 键到元素的映射 */ export declare const buildMap: (arr: T[], key: keyof T) => Record; /** * 读取 schema 中 `color_temp_control` 的 min/max,并推导色温换算用的卡尔文上下界(供 `temp2Number` / `number2Temp` 使用)。 * @internal matter-kit 内部使用,未在文档站单独暴露 * @since 1.15.0 * @param schemaObj - dpSchema 对象 * @example * ```ts * import { createMatterKit } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const range = matterKit.utils.getTempRange({ * color_temp_control: { property: { min: 153, max: 500 } }, * } as any); * ``` * @returns {{ MAX_TEMP: number; MIN_TEMP: number; MAX_KELVIN: number; MIN_KELVIN: number }} schema 色温与推导的卡尔文边界 */ export declare const getTempRange: (schemaObj: any) => { MAX_TEMP: any; MIN_TEMP: any; MAX_KELVIN: number; MIN_KELVIN: number; }; /** * 将色温卡尔文值转换为标准 temp 数值(0~1000),用于滑动条等非线性展示。 * @public * @since 1.15.0 * @param temperature - 色温卡尔文值(如 color_temp_control 上报) * @param schemaObj - dpSchema 对象 * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const tempValue = matterKit.utils.temp2Number(370, dpSchema); * ``` * @returns {number} 0~1000 的标准色温数值 */ export declare const temp2Number: (temperature: number, schemaObj: any) => number; /** * 将标准 temp 数值(0~1000)转换为色温卡尔文值,用于下发到 Matter color_temp_control。 * @public * @since 1.15.0 * @param temperature - 标准色温数值(0~1000) * @param schemaObj - dpSchema 对象 * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const kelvin = matterKit.utils.number2Temp(600, dpSchema); * ``` * @returns {number} 色温卡尔文值 */ export declare const number2Temp: (temperature: number, schemaObj: any) => number; /** * 将 Matter `brightness_control` 范围(1~254)映射为标准 `bright_value`(10~1000)。 * @public * @since 1.15.0 * @param bright - Matter 亮度值(brightness_control) * @param schemaObj - dpSchema 对象 * @example * ```ts * import { matterKit, useDpSchema } from '@ray-js/panel-sdk'; * const dpSchema = useDpSchema() * const brightValue = matterKit.utils.bright2Number(190, dpSchema); * ``` * @returns {number} 标准侧 `bright_value`(10~1000) */ export declare const bright2Number: (bright: number, schemaObj: any) => number; /** * 将标准 bright_value(10~1000)映射为 Matter brightness_control(1~254),用于下发。 * @public * @since 1.15.0 * @param bright - 标准亮度值(10~1000) * @param schemaObj - dpSchema 对象 * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const matterBright = matterKit.utils.number2Bright(750, dpSchema); * ``` * @returns {number} Matter brightness_control 数值 */ export declare const number2Bright: (bright: number, schemaObj: any) => number; /** * 根据色温(卡尔文)计算用于 UI 的 RGB 十六进制颜色字符串,常用于色温滑动条色条。 * @public * @since 1.15.0 * @param kelvin - 色温卡尔文值(非 0~1000 的 temp_value) * @example * ```ts * import { createMatterKit } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const hex = matterKit.utils.getTempRgb(370); * ``` * @returns {string} 十六进制颜色,如 `#ffa500` */ export declare const getTempRgb: (kelvin: number) => string; /** * 在索引与色温值的映射表中查找接近 6500K 的索引,供色温条等 UI 逻辑使用。 * @internal 经 `matterKit.utils` 透出但文档站无独立页面,不作为对外稳定 API * @since 1.15.0 * @param obj - 索引(字符串键)到色温数值的映射对象 * @example * ```ts * import { createMatterKit } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const index = matterKit.utils.get6500K({ '1': 3000, '2': 6500, '3': 8000 }); * ``` * @returns {number} 匹配的索引;找不到时为 `-1` */ export declare const get6500K: (obj: any) => number; /** * 根据 schema 判断当前设备是否为 Matter 照明面板。 * @public * @since 1.15.0 * @param schema - Matter 面板的 schema(数组或 code 为键的对象) * @param force - 为 `true` 时忽略缓存,重新计算 * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const isMatter = matterKit.utils.checkIsMatterDevice(dpSchema); * ``` * @returns {boolean} 是否为 Matter 面板 */ export declare const checkIsMatterDevice: (schema: any, force?: boolean) => boolean; /** * 判断 Matter 设备是否具备白光能力(与路数相关:1、2、4、5 路为 true,3 路为 false)。 * @public * @since 1.15.0 * @param dpSchema - dpSchema 对象 * @param force - 未接入 matter-kit 推断路数时需传入 `true` * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const hasWhite = matterKit.utils.checkIsMatterHasWhite(dpSchema); * ``` * @returns {boolean} 是否具备白光 */ export declare const checkIsMatterHasWhite: (dpSchema: any, force?: boolean) => boolean; /** * 根据 DP schema 推断 Matter 照明设备路数。 * @public * @since 1.15.0 * @param schemaObj - dpSchema 对象 * @param force - 未接入 matter-kit 时判断 4 路需传入 `true`,以读取 brightness_control 上的 hasBrightValueCode * @example * ```ts * import { createMatterKit, useDpSchema } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const dpSchema = useDpSchema(); * const road = matterKit.utils.getMatterRoad(dpSchema); * ``` * @returns {number} 路数:`1` 仅亮度;`2` 亮度+色温;`3` 色相饱和度+亮度;`4` 色相饱和度+亮度+亮度值;`5` 色相饱和度+亮度+色温;`0` 无法识别;异常时可能回退为 `5` * * @remarks * - **1 路**:`brightness_control` * - **2 路**:`brightness_control` + `color_temp_control` * - **3 路**:`hs_color_set` + `brightness_control` * - **4 路**:`hs_color_set` + `brightness_control` + `bright_value`(依赖 schema 标记) * - **5 路**:`hs_color_set` + `brightness_control` + `color_temp_control` */ export declare const getMatterRoad: (schemaObj: any, force?: boolean) => number; /** * matter-kit 工具对象类型,用于 `createMatterKit` 返回值的 `utils` 字段。 * @public * @since 1.15.0 * @example * ```ts * import { createMatterKit } from '@ray-js/panel-sdk'; * * const matterKit = createMatterKit(); * const utils = matterKit.utils; * ``` */ export interface MatterUtils { /** * 读取 schema 中 color_temp_control 的 min/max,并推导色温换算用的卡尔文上下界(供 temp2Number / number2Temp 使用)。 */ getTempRange: typeof getTempRange; /** * 将色温卡尔文值转换为标准 temp 数值(0~1000),用于滑动条等非线性展示。 */ temp2Number: typeof temp2Number; /** * 将标准 temp 数值(0~1000)转换为色温卡尔文值,用于下发到 Matter color_temp_control。 */ number2Temp: typeof number2Temp; /** * 将 Matter `brightness_control` 范围(1~254)映射为标准 `bright_value`(10~1000)。 */ bright2Number: typeof bright2Number; /** * 将标准 bright_value(10~1000)映射为 Matter brightness_control(1~254),用于下发。 */ number2Bright: typeof number2Bright; /** * 根据色温(卡尔文)计算用于 UI 的 RGB 十六进制颜色字符串,常用于色温滑动条色条。 */ getTempRgb: typeof getTempRgb; /** * 在索引与色温值的映射表中查找接近 6500K 的索引,供色温条等 UI 逻辑使用。 */ get6500K: typeof get6500K; /** * 根据 schema 判断当前设备是否为 Matter 照明面板。 */ checkIsMatterDevice: typeof checkIsMatterDevice; /** * 判断 Matter 设备是否具备白光能力(与路数相关:1、2、4、5 路为 true,3 路为 false)。 */ checkIsMatterHasWhite: typeof checkIsMatterHasWhite; /** * 根据 DP schema 推断 Matter 照明设备路数。 */ getMatterRoad: typeof getMatterRoad; } export declare const matterUtils: MatterUtils;