@miot-rn/car-component 1.0.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.
Files changed (242) hide show
  1. package/README.md +325 -0
  2. package/dist/assets/i18n/ar.d.ts +55 -0
  3. package/dist/assets/i18n/ar.js +55 -0
  4. package/dist/assets/i18n/bo.d.ts +55 -0
  5. package/dist/assets/i18n/bo.js +55 -0
  6. package/dist/assets/i18n/cs.d.ts +55 -0
  7. package/dist/assets/i18n/cs.js +55 -0
  8. package/dist/assets/i18n/de.d.ts +55 -0
  9. package/dist/assets/i18n/de.js +55 -0
  10. package/dist/assets/i18n/el.d.ts +55 -0
  11. package/dist/assets/i18n/el.js +55 -0
  12. package/dist/assets/i18n/en.d.ts +55 -0
  13. package/dist/assets/i18n/en.js +55 -0
  14. package/dist/assets/i18n/es.d.ts +55 -0
  15. package/dist/assets/i18n/es.js +55 -0
  16. package/dist/assets/i18n/es_us.d.ts +55 -0
  17. package/dist/assets/i18n/es_us.js +55 -0
  18. package/dist/assets/i18n/fi.d.ts +55 -0
  19. package/dist/assets/i18n/fi.js +55 -0
  20. package/dist/assets/i18n/fr.d.ts +55 -0
  21. package/dist/assets/i18n/fr.js +55 -0
  22. package/dist/assets/i18n/he.d.ts +55 -0
  23. package/dist/assets/i18n/he.js +55 -0
  24. package/dist/assets/i18n/hu.d.ts +55 -0
  25. package/dist/assets/i18n/hu.js +55 -0
  26. package/dist/assets/i18n/id.d.ts +55 -0
  27. package/dist/assets/i18n/id.js +55 -0
  28. package/dist/assets/i18n/it.d.ts +55 -0
  29. package/dist/assets/i18n/it.js +55 -0
  30. package/dist/assets/i18n/ja.d.ts +55 -0
  31. package/dist/assets/i18n/ja.js +55 -0
  32. package/dist/assets/i18n/ko.d.ts +55 -0
  33. package/dist/assets/i18n/ko.js +55 -0
  34. package/dist/assets/i18n/nb.d.ts +55 -0
  35. package/dist/assets/i18n/nb.js +55 -0
  36. package/dist/assets/i18n/nl.d.ts +55 -0
  37. package/dist/assets/i18n/nl.js +55 -0
  38. package/dist/assets/i18n/pl.d.ts +55 -0
  39. package/dist/assets/i18n/pl.js +55 -0
  40. package/dist/assets/i18n/pt.d.ts +55 -0
  41. package/dist/assets/i18n/pt.js +55 -0
  42. package/dist/assets/i18n/pt_pt.d.ts +55 -0
  43. package/dist/assets/i18n/pt_pt.js +55 -0
  44. package/dist/assets/i18n/ro.d.ts +55 -0
  45. package/dist/assets/i18n/ro.js +55 -0
  46. package/dist/assets/i18n/ru.d.ts +55 -0
  47. package/dist/assets/i18n/ru.js +55 -0
  48. package/dist/assets/i18n/sk.d.ts +55 -0
  49. package/dist/assets/i18n/sk.js +55 -0
  50. package/dist/assets/i18n/sv.d.ts +55 -0
  51. package/dist/assets/i18n/sv.js +55 -0
  52. package/dist/assets/i18n/th.d.ts +55 -0
  53. package/dist/assets/i18n/th.js +55 -0
  54. package/dist/assets/i18n/tr.d.ts +55 -0
  55. package/dist/assets/i18n/tr.js +55 -0
  56. package/dist/assets/i18n/uk.d.ts +55 -0
  57. package/dist/assets/i18n/uk.js +55 -0
  58. package/dist/assets/i18n/vi.d.ts +55 -0
  59. package/dist/assets/i18n/vi.js +55 -0
  60. package/dist/assets/i18n/zh.d.ts +55 -0
  61. package/dist/assets/i18n/zh.js +55 -0
  62. package/dist/assets/i18n/zh_hk.d.ts +55 -0
  63. package/dist/assets/i18n/zh_hk.js +55 -0
  64. package/dist/assets/i18n/zh_tw.d.ts +55 -0
  65. package/dist/assets/i18n/zh_tw.js +55 -0
  66. package/dist/assets/image/dark/car_background_dark.png +0 -0
  67. package/dist/assets/image/default/car_background.png +0 -0
  68. package/dist/components/airConditioningCard/index.d.ts +24 -0
  69. package/dist/components/airConditioningCard/index.js +103 -0
  70. package/dist/components/carInfoHeader/carImage.d.ts +8 -0
  71. package/dist/components/carInfoHeader/carImage.js +42 -0
  72. package/dist/components/carInfoHeader/dualRangeIndicator.d.ts +15 -0
  73. package/dist/components/carInfoHeader/dualRangeIndicator.js +124 -0
  74. package/dist/components/carInfoHeader/index.d.ts +37 -0
  75. package/dist/components/carInfoHeader/index.js +118 -0
  76. package/dist/components/carInfoHeader/parkingStatus.d.ts +12 -0
  77. package/dist/components/carInfoHeader/parkingStatus.js +100 -0
  78. package/dist/components/carInfoHeader/rangeProgressBar.d.ts +14 -0
  79. package/dist/components/carInfoHeader/rangeProgressBar.js +77 -0
  80. package/dist/components/carInfoHeader/singleRangeIndicator.d.ts +11 -0
  81. package/dist/components/carInfoHeader/singleRangeIndicator.js +58 -0
  82. package/dist/components/cardContainer/index.d.ts +8 -0
  83. package/dist/components/cardContainer/index.js +22 -0
  84. package/dist/components/containerWithGap/gapWrap.d.ts +8 -0
  85. package/dist/components/containerWithGap/gapWrap.js +31 -0
  86. package/dist/components/containerWithGap/index.d.ts +12 -0
  87. package/dist/components/containerWithGap/index.js +43 -0
  88. package/dist/components/flatSelect/FlatOption.d.ts +18 -0
  89. package/dist/components/flatSelect/FlatOption.js +117 -0
  90. package/dist/components/flatSelect/FlatSelect.d.ts +14 -0
  91. package/dist/components/flatSelect/FlatSelect.js +112 -0
  92. package/dist/components/flatSelect/index.d.ts +2 -0
  93. package/dist/components/flatSelect/index.js +2 -0
  94. package/dist/components/flatSelect/index.zh-CN.md +89 -0
  95. package/dist/components/groupContainer/index.d.ts +9 -0
  96. package/dist/components/groupContainer/index.js +48 -0
  97. package/dist/components/otherSettingCard/index.d.ts +8 -0
  98. package/dist/components/otherSettingCard/index.js +40 -0
  99. package/dist/components/pageBackground/index.d.ts +7 -0
  100. package/dist/components/pageBackground/index.js +22 -0
  101. package/dist/components/seatControl/index.d.ts +34 -0
  102. package/dist/components/seatControl/index.js +98 -0
  103. package/dist/components/seatControl/seatCard.d.ts +11 -0
  104. package/dist/components/seatControl/seatCard.js +24 -0
  105. package/dist/components/seatControl/seatCardRow.d.ts +29 -0
  106. package/dist/components/seatControl/seatCardRow.js +48 -0
  107. package/dist/components/seatControlGroup/index.d.ts +40 -0
  108. package/dist/components/seatControlGroup/index.js +51 -0
  109. package/dist/components/steeringWheelHotCard/index.d.ts +17 -0
  110. package/dist/components/steeringWheelHotCard/index.js +66 -0
  111. package/dist/components/titleContainer/TitleContainer.d.ts +4 -0
  112. package/dist/components/titleContainer/TitleContainer.js +148 -0
  113. package/dist/components/titleContainer/TitleContainer.zh-CN.md +62 -0
  114. package/dist/components/titleContainer/index.d.ts +1 -0
  115. package/dist/components/titleContainer/index.js +1 -0
  116. package/dist/components/titleContainer/interface.d.ts +48 -0
  117. package/dist/components/titleContainer/interface.js +21 -0
  118. package/dist/components/warningForRunningCard/index.d.ts +6 -0
  119. package/dist/components/warningForRunningCard/index.js +20 -0
  120. package/dist/config/ConnectStatus.d.ts +7 -0
  121. package/dist/config/ConnectStatus.js +8 -0
  122. package/dist/config/index.d.ts +16 -0
  123. package/dist/config/index.js +16 -0
  124. package/dist/config/seatFunctionType.d.ts +7 -0
  125. package/dist/config/seatFunctionType.js +24 -0
  126. package/dist/config/seatGearLevel.d.ts +21 -0
  127. package/dist/config/seatGearLevel.js +19 -0
  128. package/dist/config/seatI18nKeys.d.ts +9 -0
  129. package/dist/config/seatI18nKeys.js +9 -0
  130. package/dist/config/seatPosition.d.ts +8 -0
  131. package/dist/config/seatPosition.js +8 -0
  132. package/dist/config/seatRowConfig.d.ts +6 -0
  133. package/dist/config/seatRowConfig.js +6 -0
  134. package/dist/global.d.js +0 -0
  135. package/dist/hooks/CONNECT_STATUS.d.ts +6 -0
  136. package/dist/hooks/CONNECT_STATUS.js +5 -0
  137. package/dist/hooks/index.d.ts +6 -0
  138. package/dist/hooks/index.js +7 -0
  139. package/dist/hooks/useAirConditionData.d.ts +29 -0
  140. package/dist/hooks/useAirConditionData.js +89 -0
  141. package/dist/hooks/useDualRangeData.d.ts +18 -0
  142. package/dist/hooks/useDualRangeData.js +82 -0
  143. package/dist/hooks/useParkingStatusData.d.ts +19 -0
  144. package/dist/hooks/useParkingStatusData.js +100 -0
  145. package/dist/hooks/useSeatControlData.d.ts +94 -0
  146. package/dist/hooks/useSeatControlData.js +251 -0
  147. package/dist/hooks/useSingleRangeData.d.ts +15 -0
  148. package/dist/hooks/useSingleRangeData.js +97 -0
  149. package/dist/hooks/useSteeringWheelData.d.ts +11 -0
  150. package/dist/hooks/useSteeringWheelData.js +56 -0
  151. package/dist/icons/CarInUsed.d.ts +4 -0
  152. package/dist/icons/CarInUsed.js +13 -0
  153. package/dist/icons/DeviceManage.d.ts +4 -0
  154. package/dist/icons/DeviceManage.js +13 -0
  155. package/dist/icons/ElectricPower.d.ts +4 -0
  156. package/dist/icons/ElectricPower.js +13 -0
  157. package/dist/icons/ErrorStatus.d.ts +4 -0
  158. package/dist/icons/ErrorStatus.js +13 -0
  159. package/dist/icons/FuelPower.d.ts +4 -0
  160. package/dist/icons/FuelPower.js +18 -0
  161. package/dist/icons/Loading.d.ts +4 -0
  162. package/dist/icons/Loading.js +16 -0
  163. package/dist/icons/MijiaLogo.d.ts +4 -0
  164. package/dist/icons/MijiaLogo.js +16 -0
  165. package/dist/icons/Minus.d.ts +4 -0
  166. package/dist/icons/Minus.js +15 -0
  167. package/dist/icons/ParkingStatus.d.ts +4 -0
  168. package/dist/icons/ParkingStatus.js +15 -0
  169. package/dist/icons/SeatGearHeatingLevelOne.d.ts +4 -0
  170. package/dist/icons/SeatGearHeatingLevelOne.js +22 -0
  171. package/dist/icons/SeatGearHeatingLevelThree.d.ts +4 -0
  172. package/dist/icons/SeatGearHeatingLevelThree.js +18 -0
  173. package/dist/icons/SeatGearHeatingLevelTwo.d.ts +4 -0
  174. package/dist/icons/SeatGearHeatingLevelTwo.js +22 -0
  175. package/dist/icons/SeatGearHeatingOff.d.ts +4 -0
  176. package/dist/icons/SeatGearHeatingOff.js +18 -0
  177. package/dist/icons/SeatGearVentilationLevelOne.d.ts +4 -0
  178. package/dist/icons/SeatGearVentilationLevelOne.js +17 -0
  179. package/dist/icons/SeatGearVentilationLevelThree.d.ts +4 -0
  180. package/dist/icons/SeatGearVentilationLevelThree.js +13 -0
  181. package/dist/icons/SeatGearVentilationLevelTwo.d.ts +4 -0
  182. package/dist/icons/SeatGearVentilationLevelTwo.js +17 -0
  183. package/dist/icons/SeatGearVentilationOff.d.ts +4 -0
  184. package/dist/icons/SeatGearVentilationOff.js +16 -0
  185. package/dist/icons/SentryMode.d.ts +4 -0
  186. package/dist/icons/SentryMode.js +13 -0
  187. package/dist/icons/SmartScene.d.ts +4 -0
  188. package/dist/icons/SmartScene.js +13 -0
  189. package/dist/icons/SteeringWheelFirstGear.d.ts +4 -0
  190. package/dist/icons/SteeringWheelFirstGear.js +13 -0
  191. package/dist/icons/SteeringWheelHot.d.ts +4 -0
  192. package/dist/icons/SteeringWheelHot.js +13 -0
  193. package/dist/icons/SteeringWheelSecondGear.d.ts +4 -0
  194. package/dist/icons/SteeringWheelSecondGear.js +13 -0
  195. package/dist/icons/SteeringWheelThirdGear.d.ts +4 -0
  196. package/dist/icons/SteeringWheelThirdGear.js +13 -0
  197. package/dist/icons/Warning.d.ts +4 -0
  198. package/dist/icons/Warning.js +13 -0
  199. package/dist/icons/index.d.ts +24 -0
  200. package/dist/icons/index.js +27 -0
  201. package/dist/index.d.ts +21 -0
  202. package/dist/index.js +20 -0
  203. package/dist/modules/MODULES.md +245 -0
  204. package/dist/modules/airconditionModule/README.md +262 -0
  205. package/dist/modules/airconditionModule/index.d.ts +17 -0
  206. package/dist/modules/airconditionModule/index.js +63 -0
  207. package/dist/modules/carInfoModule/README.md +418 -0
  208. package/dist/modules/carInfoModule/index.d.ts +26 -0
  209. package/dist/modules/carInfoModule/index.js +67 -0
  210. package/dist/modules/index.d.ts +2 -0
  211. package/dist/modules/index.js +2 -0
  212. package/dist/modules/seatModule/README.md +345 -0
  213. package/dist/modules/seatModule/index.d.ts +15 -0
  214. package/dist/modules/seatModule/index.js +40 -0
  215. package/dist/modules/steeringWheelModule/README.md +216 -0
  216. package/dist/modules/steeringWheelModule/index.d.ts +13 -0
  217. package/dist/modules/steeringWheelModule/index.js +31 -0
  218. package/dist/resources/i18n.d.ts +1730 -0
  219. package/dist/resources/i18n.js +84 -0
  220. package/dist/resources/images.d.ts +1 -0
  221. package/dist/resources/images.js +45 -0
  222. package/dist/spec/index.d.ts +494 -0
  223. package/dist/spec/index.js +911 -0
  224. package/dist/types.d.ts +63 -0
  225. package/dist/types.js +1 -0
  226. package/dist/utils/checkSameValue.d.ts +1 -0
  227. package/dist/utils/checkSameValue.js +11 -0
  228. package/dist/utils/fns.d.ts +5 -0
  229. package/dist/utils/fns.js +167 -0
  230. package/dist/utils/get-value-or-default.d.ts +1 -0
  231. package/dist/utils/get-value-or-default.js +4 -0
  232. package/dist/utils/getLocalI18n.d.ts +1 -0
  233. package/dist/utils/getLocalI18n.js +9 -0
  234. package/dist/utils/i18n.d.ts +1 -0
  235. package/dist/utils/i18n.js +141 -0
  236. package/dist/utils/objects.d.ts +2 -0
  237. package/dist/utils/objects.js +222 -0
  238. package/dist/utils/spec.d.ts +8 -0
  239. package/dist/utils/spec.js +171 -0
  240. package/dist/utils/types.d.ts +3 -0
  241. package/dist/utils/types.js +25 -0
  242. package/package.json +27 -0
@@ -0,0 +1,63 @@
1
+ export interface SpecRawItem {
2
+ iid: number;
3
+ type: string;
4
+ description: string;
5
+ [key: string]: unknown;
6
+ }
7
+ export interface SpecPropertyRaw extends SpecRawItem {
8
+ format: string;
9
+ access: string[];
10
+ unit?: string;
11
+ valueList?: {
12
+ value: number;
13
+ description: string;
14
+ }[];
15
+ valueRange?: number[];
16
+ }
17
+ export interface SpecActionRaw extends SpecRawItem {
18
+ in: unknown[];
19
+ out: unknown[];
20
+ }
21
+ export interface SpecEventRaw extends SpecRawItem {
22
+ arguments: number[];
23
+ }
24
+ export interface Spec {
25
+ siid: number;
26
+ piid?: number;
27
+ eiid?: number;
28
+ aiid?: number;
29
+ miid?: number;
30
+ did?: string;
31
+ value?: unknown;
32
+ in?: unknown[];
33
+ out?: unknown[];
34
+ description?: string;
35
+ dataSource?: number;
36
+ viid?: number;
37
+ skey?: string;
38
+ pkey?: string;
39
+ akey?: string;
40
+ ekey?: string;
41
+ service?: unknown;
42
+ prop?: SpecPropertyRaw;
43
+ action?: SpecActionRaw;
44
+ event?: SpecEventRaw;
45
+ source?: unknown;
46
+ sDescription?: string;
47
+ mkey?: string;
48
+ mDescription?: string;
49
+ reiids?: number[];
50
+ reIndexs?: number[];
51
+ [key: string]: unknown;
52
+ }
53
+ export interface QuerySpecParams {
54
+ mkey?: string;
55
+ mDescription?: string;
56
+ skey?: string;
57
+ sDescription?: string;
58
+ pkey?: string;
59
+ akey?: string;
60
+ ekey?: string;
61
+ description?: string;
62
+ dataSource?: unknown;
63
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function checkSameValue(a: any, b: any, isEqual?: boolean): boolean;
@@ -0,0 +1,11 @@
1
+ // 仅一侧值为字符串和数值时做隐式转换
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ export function checkSameValue(a, b, isEqual = true) {
4
+ const typeofA = typeof a;
5
+ const typeofB = typeof b;
6
+ if (typeofA === 'number' && typeofB === 'string' || typeofB === 'number' && typeofA === 'string') {
7
+ // eslint-disable-next-line eqeqeq
8
+ return isEqual ? a == b : a != b;
9
+ }
10
+ return isEqual ? a === b : a !== b;
11
+ }
@@ -0,0 +1,5 @@
1
+ export declare function NOOP(): void;
2
+ export declare function safeTrim(value: any): any;
3
+ export declare function isSameArrayElements(a: any[], b: any[]): boolean;
4
+ export declare function getType(o: any): string;
5
+ export declare function getStringGenerator(template: any, witch?: number): any;
@@ -0,0 +1,167 @@
1
+ // @native begin
2
+ /* eslint-disable func-names */
3
+
4
+ // import Resources, { Language } from '../resources';
5
+ // const LANGUAGE = Resources.getLanguage();
6
+
7
+ // 空函数
8
+ export function NOOP() {}
9
+
10
+ // 安全去除字符串首尾空格
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ export function safeTrim(value) {
13
+ return typeof value === 'string' ? value.trim() : value;
14
+ }
15
+
16
+ // 判断两个数组的元素相同
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ export function isSameArrayElements(a, b) {
19
+ if (a === b) {
20
+ return true;
21
+ }
22
+ if (!a && b || a && !b) {
23
+ return false;
24
+ }
25
+ if (a && b && a.length !== b.length) {
26
+ return false;
27
+ }
28
+ for (let i = 0, l = a.length; i < l; i++) {
29
+ const item = a[i];
30
+ if (b.find(n => {
31
+ return n === item;
32
+ }) === undefined) {
33
+ return false;
34
+ }
35
+ }
36
+ return true;
37
+ }
38
+
39
+ // 获取数据类型
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ export function getType(o) {
42
+ return Object.prototype.toString.call(o).slice(8, -1);
43
+ }
44
+
45
+ // 利用多语言模版进行字符串求值
46
+ // 不分语种
47
+ // export function getStringGenerator(template) {
48
+ // let i18n = (Resources.createI18n({
49
+ // [LANGUAGE]: {
50
+ // text: template
51
+ // }
52
+ // }, LANGUAGE) || {}).strings;
53
+ // return i18n.text;
54
+ // }
55
+ const StringGeneratorTypes = {
56
+ normal: 'StringGeneratorTypes:normal',
57
+ oneByOne: 'StringGeneratorTypes:oneByOne',
58
+ // 比较两个属性值
59
+ compare: 'StringGeneratorTypes:compare',
60
+ // 比较单个属性值与预设值
61
+ compareEach: 'StringGeneratorTypes:compareEach'
62
+ };
63
+ function formatStringRet(template) {
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ return function (...args) {
66
+ let ret = template;
67
+ args.forEach((a, index) => {
68
+ ret = ret.replace(new RegExp(`\\{${index + 1}\\}`, 'g'), a);
69
+ });
70
+ return ret;
71
+ };
72
+ }
73
+
74
+ /* eslint-disable no-use-before-define, @typescript-eslint/no-use-before-define */
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ function formatArrayRet(template, witch = 0) {
77
+ const [first, ...rest] = template;
78
+ if (witch) {
79
+ return formatArrayNormal(template, witch);
80
+ }
81
+ switch (first) {
82
+ case StringGeneratorTypes.oneByOne:
83
+ return formatArrayOnebyOne(rest);
84
+ case StringGeneratorTypes.compare:
85
+ return formatArrayCompare(rest);
86
+ case StringGeneratorTypes.compareEach:
87
+ return formatArrayCompareEach(rest);
88
+ case StringGeneratorTypes.normal:
89
+ default:
90
+ return formatArrayNormal(template, witch);
91
+ }
92
+ }
93
+
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ function formatArrayNormal(template, witch = 0) {
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, func-names
97
+ return function (...args) {
98
+ const target = args[witch];
99
+ for (let i = 1, l = template.length; i < l; i++) {
100
+ const t = template[i];
101
+ const type = getType(t);
102
+ if (type !== 'Array') {
103
+ return getStringGenerator([template[0], [target, t]], witch + 1)(...args);
104
+ }
105
+ if (type === 'Array' && target === t[0]) {
106
+ const ttype = getType(t[1]);
107
+ return getStringGenerator(ttype === 'Array' ? [template[0], ...t.slice(1)] : t[1], witch + 1)(...args);
108
+ }
109
+ }
110
+ return getStringGenerator(template[0])(...args);
111
+ };
112
+ }
113
+
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ function formatArrayOnebyOne(template) {
116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, func-names
117
+ return function (...values) {
118
+ // @ts-ignore
119
+ // eslint-disable-next-line no-undef
120
+ return getTemplateValueOneByOne(values, template);
121
+ };
122
+ }
123
+
124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
+ function formatArrayCompare(template) {
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, func-names
127
+ return function (...values) {
128
+ // @ts-ignore
129
+ // eslint-disable-next-line no-undef
130
+ return getTemplateValueCompare(values, template);
131
+ };
132
+ }
133
+
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
+ function formatArrayCompareEach(template) {
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, func-names
137
+ return function (...values) {
138
+ // @ts-ignore
139
+ // eslint-disable-next-line no-undef
140
+ return getTemplateValueCompareEach(values, template);
141
+ };
142
+ }
143
+
144
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
+ export function getStringGenerator(template, witch = 0) {
146
+ if (!template) {
147
+ // eslint-disable-next-line func-names
148
+ return function () {
149
+ return '';
150
+ };
151
+ }
152
+ const type = getType(template);
153
+ switch (type) {
154
+ case 'String':
155
+ return formatStringRet(template);
156
+ case 'Array':
157
+ return formatArrayRet(template, witch);
158
+ case 'Function':
159
+ return template;
160
+ default:
161
+ // eslint-disable-next-line func-names
162
+ return function () {
163
+ return template;
164
+ };
165
+ }
166
+ }
167
+ /* eslint-enable no-use-before-define, @typescript-eslint/no-use-before-define */
@@ -0,0 +1 @@
1
+ export default function getValueOrDefault(host: any, p: string, d: any): any;
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export default function getValueOrDefault(host, p, d) {
3
+ return host && p in host ? host[p] : d;
4
+ }
@@ -0,0 +1 @@
1
+ export declare const getLocalI18n: (key: string) => string | Record<string, string>;
@@ -0,0 +1,9 @@
1
+ import { getLocalI18n as getI18n } from '@miot-rn/common-component/dist/specs/i18n-parser';
2
+ import { initI18nConfig, hasInitI18nConfig } from '@miot-rn/common-component/dist/resources/i18n';
3
+ import { i18ns } from "../resources/i18n";
4
+ export const getLocalI18n = key => {
5
+ if (!hasInitI18nConfig) {
6
+ initI18nConfig(i18ns);
7
+ }
8
+ return getI18n(key);
9
+ };
@@ -0,0 +1 @@
1
+ export declare function getPluralRules(locale: string, n: number, ord?: boolean): string;
@@ -0,0 +1,141 @@
1
+ // 标准 https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html
2
+
3
+ // @ts-ignore
4
+ // import { Host } from 'miot';
5
+
6
+ /*
7
+ const Quantity = {
8
+ zero: 'zero', // 语言需要对数字0进行特殊处理。(比如阿拉伯语)
9
+ one: 'one', // 语言需要对类似1的数字进行特殊处理。(比如英语和其它大多数语言里的1;在俄语里,任何以1结尾但不以11结尾的数也属于此类型。)
10
+ two: 'two', // 语言需要对类似2的数字进行特殊处理。(比如威尔士语)
11
+ few: 'few', // 语言需要对较小数字进行特殊处理(比如捷克语里的2、3、4;或者波兰语里以2、3、4结尾但不是12、13、14的数。)
12
+ many: 'many', // 语言需要对较大数字进行特殊处理(比如马耳他语里以11-99结尾的数)
13
+ other: 'other', // 语言不需要对数字进行特殊处理。
14
+ };
15
+ */
16
+
17
+ /**
18
+ * 获取复数规则,实现参考 https://formatjs.io/docs/polyfills/intl-pluralrules/
19
+ * @param {string} locale
20
+ * @param {number} number
21
+ * @param {string} type cardinal / ordinal
22
+ * @returns {string} Quantity
23
+ */
24
+ /* eslint-disable eqeqeq */
25
+ export function getPluralRules(locale, n, ord = false) {
26
+ if (locale === 'zh' || locale === 'zh_tw' || locale === 'zh_hk') {
27
+ return 'other';
28
+ }
29
+ if (locale === 'de') {
30
+ const s = String(n).split('.');
31
+ const v0 = !s[1];
32
+ if (ord) return 'other';
33
+ return n == 1 && v0 ? 'one' : 'other';
34
+ }
35
+ if (locale === 'en') {
36
+ const s = String(n).split('.');
37
+ const v0 = !s[1];
38
+ const t0 = Number(s[0]) == n;
39
+ const n10 = t0 && s[0].slice(-1);
40
+ const n100 = t0 && s[0].slice(-2);
41
+ if (ord)
42
+ // @ts-ignore
43
+ return n10 == 1 && n100 != 11 ? 'one' : n10 == 2 && n100 != 12 ? 'two' : n10 == 3 && n100 != 13 ? 'few' : 'other';
44
+ return n == 1 && v0 ? 'one' : 'other';
45
+ }
46
+ if (locale === 'es') {
47
+ const _n = String(n);
48
+ const se = _n.split(/[ce]/);
49
+ const e = Number(se[1]) || 0;
50
+ // const c = e;
51
+ const s = String(e ? Number(se[0]) * 10 ** e : _n).split('.');
52
+ const i = s[0];
53
+ const v0 = !s[1];
54
+ const i1000000 = i.slice(-6);
55
+ if (ord) return 'other';
56
+ // @ts-ignore
57
+ return n == 1 ? 'one' : e == 0 && i != 0 && i1000000 == 0 && v0 || e < 0 || e > 5 ? 'many' : 'other';
58
+ }
59
+ if (locale === 'fr') {
60
+ const _n = String(n);
61
+ const se = _n.split(/[ce]/);
62
+ const e = Number(se[1]) || 0;
63
+ // const c = e;
64
+ const s = String(e ? Number(se[0]) * 10 ** e : _n).split('.');
65
+ const i = s[0];
66
+ const v0 = !s[1];
67
+ const i1000000 = i.slice(-6);
68
+ if (ord) return n == 1 ? 'one' : 'other';
69
+ // @ts-ignore
70
+ return n >= 0 && n < 2 ? 'one' : e == 0 && i != 0 && i1000000 == 0 && v0 || e < 0 || e > 5 ? 'many' : 'other';
71
+ }
72
+ if (locale === 'id') {
73
+ return 'other';
74
+ }
75
+ if (locale === 'it') {
76
+ const _n = String(n);
77
+ const se = _n.split(/[ce]/);
78
+ const e = Number(se[1]) || 0;
79
+ // const c = e;
80
+ const s = String(e ? Number(se[0]) * 10 ** e : _n).split('.');
81
+ const i = s[0];
82
+ const v0 = !s[1];
83
+ const i1000000 = i.slice(-6);
84
+ if (ord) return n == 11 || n == 8 || n == 80 || n == 800 ? 'many' : 'other';
85
+ // @ts-ignore
86
+ return n == 1 && v0 ? 'one' : e == 0 && i != 0 && i1000000 == 0 && v0 || e < 0 || e > 5 ? 'many' : 'other';
87
+ }
88
+ if (locale === 'ja') {
89
+ return 'other';
90
+ }
91
+ if (locale === 'ko') {
92
+ return 'other';
93
+ }
94
+ if (locale === 'nl') {
95
+ const s = String(n).split('.');
96
+ const v0 = !s[1];
97
+ if (ord) return 'other';
98
+ return n == 1 && v0 ? 'one' : 'other';
99
+ }
100
+ if (locale === 'pl') {
101
+ const s = String(n).split('.');
102
+ const i = s[0];
103
+ const v0 = !s[1];
104
+ const i10 = Number(i.slice(-1));
105
+ const i100 = Number(i.slice(-2));
106
+ if (ord) return 'other';
107
+ return n == 1 && v0 ? 'one' : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) ? 'few' : v0 && i != '1' && (i10 == 0 || i10 == 1) || v0 && i10 >= 5 && i10 <= 9 || v0 && i100 >= 12 && i100 <= 14 ? 'many' : 'other';
108
+ }
109
+ if (locale === 'pt') {
110
+ const _n = String(n);
111
+ const se = _n.split(/[ce]/);
112
+ const e = Number(se[1]) || 0;
113
+ // const c = e;
114
+ const s = String(e ? Number(se[0]) * 10 ** e : _n).split('.');
115
+ const i = s[0];
116
+ const v0 = !s[1];
117
+ const i1000000 = i.slice(-6);
118
+ if (ord) return 'other';
119
+ // @ts-ignore
120
+ return i == '0' || i == '1' ? 'one' : e == 0 && i != '0' && i1000000 == '0' && v0 || e < 0 || e > 5 ? 'many' : 'other';
121
+ }
122
+ if (locale === 'ru') {
123
+ const s = String(n).split('.');
124
+ const i = s[0];
125
+ const v0 = !s[1];
126
+ const i10 = Number(i.slice(-1));
127
+ const i100 = Number(i.slice(-2));
128
+ if (ord) return 'other';
129
+ return v0 && i10 == 1 && i100 != 11 ? 'one' : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) ? 'few' : v0 && i10 == 0 || v0 && i10 >= 5 && i10 <= 9 || v0 && i100 >= 11 && i100 <= 14 ? 'many' : 'other';
130
+ }
131
+ if (locale === 'th') {
132
+ if (ord) return 'other';
133
+ return n == 1 ? 'one' : 'other';
134
+ }
135
+ if (locale === 'tr') {
136
+ if (ord) return 'other';
137
+ return n == 1 ? 'one' : 'other';
138
+ }
139
+ return 'other';
140
+ }
141
+ /* eslint-enable eqeqeq */
@@ -0,0 +1,2 @@
1
+ export declare function copy(value: any): any;
2
+ export declare function deepEqual(a: any, b: any): boolean;
@@ -0,0 +1,222 @@
1
+ import { getType } from "./types";
2
+ const ReactSpecialKeys = new Set(['_owner', '__v', '__o']); // 预定义需跳过的特殊属性
3
+
4
+ /**
5
+ * 判断基础类型
6
+ * @param v
7
+ * @returns {boolean}
8
+ */
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ function isPrimary(v) {
11
+ if (v === null || v === undefined) {
12
+ return true;
13
+ }
14
+ return ['number', 'string', 'boolean', 'symbol'].includes(typeof v);
15
+ }
16
+
17
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
18
+ const TypeHandlers = {
19
+ '[object Array]': {
20
+ related: false,
21
+ create: () => {
22
+ return [];
23
+ },
24
+ forEach: (src, fn) => {
25
+ src.forEach((v, i) => fn(v, i));
26
+ },
27
+ map: (src, fn) => {
28
+ return src.map((v, i) => fn(v, i));
29
+ },
30
+ set: (src, key, value) => {
31
+ src[key] = value;
32
+ }
33
+ },
34
+ '[object Object]': {
35
+ related: true,
36
+ create: () => {
37
+ return {};
38
+ },
39
+ forEach: (src, fn) => {
40
+ Object.entries(src).forEach(([k, v]) => fn(v, k));
41
+ },
42
+ map: (src, fn) => {
43
+ return Object.entries(src).map(([k, v]) => fn(v, k));
44
+ },
45
+ set: (src, key, value) => {
46
+ src[key] = value;
47
+ }
48
+ },
49
+ '[object Set]': {
50
+ related: false,
51
+ create: () => {
52
+ return new Set();
53
+ },
54
+ forEach: (src, fn) => {
55
+ src.forEach(v => fn(v));
56
+ },
57
+ map: (src, fn) => {
58
+ return Array.from(src.entries()).map(vs => fn(vs[0]));
59
+ },
60
+ set: (src, key, value) => {
61
+ src.add(value);
62
+ }
63
+ },
64
+ '[object Map]': {
65
+ related: true,
66
+ create: () => {
67
+ return new Map();
68
+ },
69
+ forEach: (src, fn) => {
70
+ src.forEach((v, k) => fn(v, k));
71
+ },
72
+ map: (src, fn) => {
73
+ return Array.from(src.entries()).map(([k, v]) => fn(v, k));
74
+ },
75
+ set: (src, key, value) => {
76
+ src.set(key, value);
77
+ }
78
+ }
79
+ };
80
+ /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
81
+
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ function _copy(value, memo) {
84
+ if (isPrimary(value) || value instanceof Function) {
85
+ return value;
86
+ }
87
+ let newValue = memo.get(value);
88
+ if (newValue) {
89
+ return newValue;
90
+ }
91
+ const type = TypeHandlers[Object.prototype.toString.call(value)];
92
+ if (type !== undefined) {
93
+ newValue = type.create();
94
+ memo.set(value, newValue);
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
+ type.forEach(value, (v, k) => {
97
+ type.set(newValue, k, _copy(v, memo));
98
+ });
99
+ } else {
100
+ // 不认识的类型默认处理
101
+ newValue = JSON.parse(JSON.stringify(value));
102
+ }
103
+ return newValue;
104
+ }
105
+
106
+ /**
107
+ * 深度拷贝函数
108
+ * 1 基础类型:直接返回原值
109
+ * 2 数组 or 对象:深copy,支持 Object, Array, Map, Set, Function
110
+ * @returns {*}
111
+ * @param value
112
+ */
113
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
+ export function copy(value) {
115
+ return _copy(value, new Map());
116
+ }
117
+
118
+ /**
119
+ * @description 深度比较两个对象是否相等(优化版)基础版本来源:https://github.com/FormidableLabs/react-fast-compare
120
+ * @author guhao
121
+ * @param {any} a
122
+ * @param {any} b
123
+ * @returns {boolean}
124
+ */
125
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
126
+ export function deepEqual(a, b) {
127
+ // 快速相等(包括 +0/-0 和 NaN 处理)
128
+ if (Object.is(a, b)) return true;
129
+
130
+ // 类型检查
131
+ const typeA = getType(a);
132
+ const typeB = getType(b);
133
+ if (typeA !== typeB) return false;
134
+
135
+ // 处理非对象类型
136
+ if (!a || !b || typeof a !== 'object') {
137
+ return typeA === 'Date' ? a.getTime() === b.getTime() : false;
138
+ }
139
+
140
+ // 构造函数一致性检查
141
+ if (a.constructor !== b.constructor) return false;
142
+
143
+ // 分类型处理
144
+ switch (typeA) {
145
+ // 数组处理(反向遍历优化)
146
+ case 'Array':
147
+ {
148
+ if (a.length !== b.length) return false;
149
+ for (let i = a.length - 1; i >= 0; i--) {
150
+ if (!deepEqual(a[i], b[i])) return false;
151
+ }
152
+ return true;
153
+ }
154
+
155
+ // Date 处理(时间戳比对)
156
+ case 'Date':
157
+ return a.getTime() === b.getTime();
158
+
159
+ // RegExp 处理(源和标志比对)
160
+ case 'RegExp':
161
+ return a.source === b.source && a.flags === b.flags;
162
+
163
+ // Map 处理(合并两次遍历为一次)
164
+ case 'Map':
165
+ {
166
+ if (a.size !== b.size) return false;
167
+ for (const [key, val] of a) {
168
+ if (!b.has(key) || !deepEqual(val, b.get(key))) return false;
169
+ }
170
+ return true;
171
+ }
172
+
173
+ // Set 处理(值存在性检查)
174
+ case 'Set':
175
+ {
176
+ if (a.size !== b.size) return false;
177
+ for (const val of a) {
178
+ if (!b.has(val)) return false;
179
+ }
180
+ return true;
181
+ }
182
+
183
+ // ArrayBuffer 视图处理(直接内存比对)
184
+ case 'ArrayBufferView':
185
+ {
186
+ const viewA = new DataView(a.buffer, a.byteOffset, a.byteLength);
187
+ const viewB = new DataView(b.buffer, b.byteOffset, b.byteLength);
188
+ if (viewA.byteLength !== viewB.byteLength) return false;
189
+ for (let i = 0; i < viewA.byteLength; i++) {
190
+ if (viewA.getUint8(i) !== viewB.getUint8(i)) return false;
191
+ }
192
+ return true;
193
+ }
194
+
195
+ // 通用对象处理
196
+ case 'Object':
197
+ {
198
+ const keysA = Object.keys(a);
199
+ const keysB = Object.keys(b);
200
+ if (keysA.length !== keysB.length) return false;
201
+
202
+ // 使用 Set 优化属性存在性检查
203
+ const keysBSet = new Set(keysB);
204
+ for (const key of keysA) {
205
+ if (!keysBSet.has(key)) return false;
206
+ }
207
+
208
+ // 深度比较属性值(跳过 React 特殊属性)
209
+ for (const key of keysA) {
210
+ // @ts-ignore
211
+ // eslint-disable-next-line no-continue
212
+ if (ReactSpecialKeys.has(key) && a.$$typeof) continue;
213
+ if (!deepEqual(a[key], b[key])) return false;
214
+ }
215
+ return true;
216
+ }
217
+
218
+ // 其他未处理类型默认返回 false
219
+ default:
220
+ return false;
221
+ }
222
+ }
@@ -0,0 +1,8 @@
1
+ import { Spec } from '../types';
2
+ export declare function isSpecProp(prop: any): boolean;
3
+ export declare function encodeProp(prop: Spec): string;
4
+ export declare function decodeProp(key: string): any;
5
+ export declare function encodeSceneKey(o: Spec): string;
6
+ export declare function encodeIidsKey(o: Spec): string;
7
+ export declare function specAccess(prop: Spec, type: string): boolean;
8
+ export declare function specsToSubscribeKeys(specs?: Spec[]): string[];