node-miio 0.4.0 → 0.6.0

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 (150) hide show
  1. package/.claude/skills/release/SKILL.md +11 -0
  2. package/AGENTS.md +17 -2
  3. package/CONTRIBUTING.md +41 -87
  4. package/README.md +43 -7
  5. package/dist/cli/commands/cloud/devices.d.ts +10 -0
  6. package/dist/cli/commands/cloud/login.d.ts +8 -0
  7. package/dist/cli/commands/cloud/logout.d.ts +4 -0
  8. package/dist/cli/commands/cloud/map.d.ts +10 -0
  9. package/dist/cli/commands/cloud/map.js +131 -0
  10. package/dist/cli/commands/cloud/map.js.map +1 -0
  11. package/dist/cli/commands/cloud.d.ts +5 -0
  12. package/dist/cli/commands/cloud.js +3 -1
  13. package/dist/cli/commands/cloud.js.map +1 -1
  14. package/dist/cli/commands/configure.d.ts +18 -0
  15. package/dist/cli/commands/control.d.ts +4 -0
  16. package/dist/cli/commands/discover.d.ts +9 -0
  17. package/dist/cli/commands/inspect.d.ts +4 -0
  18. package/dist/cli/commands/miot-spec.d.ts +10 -0
  19. package/dist/cli/commands/protocol/call.d.ts +9 -0
  20. package/dist/cli/commands/protocol/json-dump.d.ts +8 -0
  21. package/dist/cli/commands/protocol/packet.d.ts +8 -0
  22. package/dist/cli/commands/protocol.d.ts +5 -0
  23. package/dist/cli/commands/tokens/update.d.ts +9 -0
  24. package/dist/cli/commands/tokens.d.ts +5 -0
  25. package/dist/cli/device-finder.d.ts +3 -0
  26. package/dist/cli/index.d.ts +2 -0
  27. package/dist/cli/log.d.ts +9 -0
  28. package/dist/cli/prompt.d.ts +11 -0
  29. package/dist/cli/terminal_qr.d.ts +7 -0
  30. package/dist/lib/check_result.d.ts +6 -0
  31. package/dist/lib/cloud/client.d.ts +142 -0
  32. package/dist/lib/cloud/client.js +2 -5
  33. package/dist/lib/cloud/client.js.map +1 -1
  34. package/dist/lib/cloud/crypto.d.ts +56 -0
  35. package/dist/lib/cloud/errors.d.ts +26 -0
  36. package/dist/lib/cloud/http.d.ts +55 -0
  37. package/dist/lib/cloud/index.d.ts +5 -0
  38. package/dist/lib/cloud/login.d.ts +57 -0
  39. package/dist/lib/cloud/login.js +2 -2
  40. package/dist/lib/cloud/login.js.map +1 -1
  41. package/dist/lib/cloud/session_store.d.ts +27 -0
  42. package/dist/lib/connect_to_device.d.ts +10 -0
  43. package/dist/lib/device.d.ts +151 -0
  44. package/dist/lib/device.js +53 -19
  45. package/dist/lib/device.js.map +1 -1
  46. package/dist/lib/device_info.d.ts +66 -0
  47. package/dist/lib/device_info.js +23 -10
  48. package/dist/lib/device_info.js.map +1 -1
  49. package/dist/lib/devices/air-monitor.d.ts +8 -0
  50. package/dist/lib/devices/air-purifier.d.ts +40 -0
  51. package/dist/lib/devices/capabilities/battery-level.d.ts +22 -0
  52. package/dist/lib/devices/capabilities/buzzer.d.ts +33 -0
  53. package/dist/lib/devices/capabilities/changeable-led-brightness.d.ts +35 -0
  54. package/dist/lib/devices/capabilities/colorable.d.ts +21 -0
  55. package/dist/lib/devices/capabilities/dimmable.d.ts +21 -0
  56. package/dist/lib/devices/capabilities/mode.d.ts +21 -0
  57. package/dist/lib/devices/capabilities/power.d.ts +21 -0
  58. package/dist/lib/devices/capabilities/sensor.d.ts +15 -0
  59. package/dist/lib/devices/capabilities/switchable-led.d.ts +35 -0
  60. package/dist/lib/devices/chuangmi.plug.v1.d.ts +31 -0
  61. package/dist/lib/devices/eyecare-lamp2.d.ts +91 -0
  62. package/dist/lib/devices/gateway/86sw1.d.ts +7 -0
  63. package/dist/lib/devices/gateway/86sw2.d.ts +7 -0
  64. package/dist/lib/devices/gateway/ctrl_ln1.d.ts +8 -0
  65. package/dist/lib/devices/gateway/ctrl_ln2.d.ts +8 -0
  66. package/dist/lib/devices/gateway/ctrl_neutral1.d.ts +8 -0
  67. package/dist/lib/devices/gateway/ctrl_neutral2.d.ts +8 -0
  68. package/dist/lib/devices/gateway/cube.d.ts +6 -0
  69. package/dist/lib/devices/gateway/developer-api.d.ts +15 -0
  70. package/dist/lib/devices/gateway/light-channel.d.ts +10 -0
  71. package/dist/lib/devices/gateway/light-mixin.d.ts +2 -0
  72. package/dist/lib/devices/gateway/magnet.d.ts +6 -0
  73. package/dist/lib/devices/gateway/magnet2.d.ts +5 -0
  74. package/dist/lib/devices/gateway/motion.d.ts +6 -0
  75. package/dist/lib/devices/gateway/motion2.d.ts +6 -0
  76. package/dist/lib/devices/gateway/plug.d.ts +6 -0
  77. package/dist/lib/devices/gateway/sensor_ht.d.ts +5 -0
  78. package/dist/lib/devices/gateway/subdevice.d.ts +70 -0
  79. package/dist/lib/devices/gateway/subdevices.d.ts +49 -0
  80. package/dist/lib/devices/gateway/switch.d.ts +6 -0
  81. package/dist/lib/devices/gateway/switch2.d.ts +6 -0
  82. package/dist/lib/devices/gateway/voltage.d.ts +23 -0
  83. package/dist/lib/devices/gateway/weather.d.ts +5 -0
  84. package/dist/lib/devices/gateway.d.ts +98 -0
  85. package/dist/lib/devices/humidifier.d.ts +20 -0
  86. package/dist/lib/devices/philips-light-bulb.d.ts +8 -0
  87. package/dist/lib/devices/power-plug.d.ts +30 -0
  88. package/dist/lib/devices/power-strip.d.ts +7 -0
  89. package/dist/lib/devices/vacuums/dreamevacuum.d.ts +81 -0
  90. package/dist/lib/devices/vacuums/dreamevacuum.js +10 -2
  91. package/dist/lib/devices/vacuums/dreamevacuum.js.map +1 -1
  92. package/dist/lib/devices/vacuums/mijiavacuum.d.ts +4 -0
  93. package/dist/lib/devices/vacuums/miot-vacuum.d.ts +130 -0
  94. package/dist/lib/devices/vacuums/miot-vacuum.js +2 -0
  95. package/dist/lib/devices/vacuums/miot-vacuum.js.map +1 -1
  96. package/dist/lib/devices/vacuums/vacuum.d.ts +276 -0
  97. package/dist/lib/devices/vacuums/vacuum.js +2 -0
  98. package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
  99. package/dist/lib/devices/vacuums/vacuum_device.d.ts +17 -0
  100. package/dist/lib/devices/vacuums/vacuum_device.js +14 -0
  101. package/dist/lib/devices/vacuums/vacuum_device.js.map +1 -0
  102. package/dist/lib/devices/vacuums/vacuum_errors.d.ts +10 -0
  103. package/dist/lib/devices/vacuums/vacuum_errors.js +25 -0
  104. package/dist/lib/devices/vacuums/vacuum_errors.js.map +1 -0
  105. package/dist/lib/devices/vacuums/vacuum_modes.d.ts +51 -0
  106. package/dist/lib/devices/vacuums/viomivacuum.d.ts +76 -0
  107. package/dist/lib/devices/vacuums/viomivacuum.js +2 -0
  108. package/dist/lib/devices/vacuums/viomivacuum.js.map +1 -1
  109. package/dist/lib/devices/yeelight.color.d.ts +3 -0
  110. package/dist/lib/devices/yeelight.d.ts +159 -0
  111. package/dist/lib/devices/yeelight.mono.d.ts +3 -0
  112. package/dist/lib/discovery.d.ts +53 -0
  113. package/dist/lib/events.d.ts +18 -0
  114. package/dist/lib/events.js +3 -0
  115. package/dist/lib/events.js.map +1 -0
  116. package/dist/lib/index.d.ts +60 -0
  117. package/dist/lib/index.js +5 -1
  118. package/dist/lib/index.js.map +1 -1
  119. package/dist/lib/info_from_hostname.d.ts +13 -0
  120. package/dist/lib/logger.d.ts +43 -0
  121. package/dist/lib/logger.js +62 -0
  122. package/dist/lib/logger.js.map +1 -0
  123. package/dist/lib/management.d.ts +53 -0
  124. package/dist/lib/maps/map_watcher.d.ts +71 -0
  125. package/dist/lib/maps/map_watcher.js +2 -5
  126. package/dist/lib/maps/map_watcher.js.map +1 -1
  127. package/dist/lib/maps/roborock_map.d.ts +83 -0
  128. package/dist/lib/miio_error.d.ts +12 -0
  129. package/dist/lib/miot/miot_api.d.ts +54 -0
  130. package/dist/lib/miot/miot_spec.d.ts +114 -0
  131. package/dist/lib/miot/spec_client.d.ts +125 -0
  132. package/dist/lib/miot/spec_client.js +2 -2
  133. package/dist/lib/miot/spec_client.js.map +1 -1
  134. package/dist/lib/models.d.ts +271 -0
  135. package/dist/lib/network.d.ts +58 -0
  136. package/dist/lib/network.js +5 -2
  137. package/dist/lib/network.js.map +1 -1
  138. package/dist/lib/packet.d.ts +21 -0
  139. package/dist/lib/placeholder.d.ts +7 -0
  140. package/dist/lib/protocol.d.ts +299 -0
  141. package/dist/lib/safeish_json.d.ts +7 -0
  142. package/dist/lib/tokens.d.ts +12 -0
  143. package/dist/types/abstract-things/climate/index.d.ts +431 -0
  144. package/dist/types/abstract-things/electricals/index.d.ts +5 -0
  145. package/dist/types/abstract-things/index.d.ts +206 -0
  146. package/dist/types/abstract-things/lights/index.d.ts +14 -0
  147. package/dist/types/abstract-things/values/index.d.ts +12 -0
  148. package/docs/cloud.md +5 -1
  149. package/package.json +6 -3
  150. package/snapshots/vacuum-specs.json.gz +0 -0
@@ -0,0 +1,159 @@
1
+ export const ColorTemperature: new (...args: any[]) => {
2
+ propertyUpdated(key: any, value: any): void;
3
+ changeColor(color: any, options: any): Promise<null>;
4
+ id: string | null;
5
+ metadata: Record<string, unknown> & {
6
+ types: string[];
7
+ capabilities: string[];
8
+ addCapabilities(...capabilities: string[]): void;
9
+ };
10
+ init(): Promise</*elided*/ any | undefined>;
11
+ initCallback(): Promise<void>;
12
+ destroy(): Promise<void>;
13
+ destroyCallback: (() => Promise<void>) & (() => Promise<void>);
14
+ debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
15
+ matches(...tags: string[]): boolean;
16
+ emitEvent(event: string, data?: unknown, options?: unknown): void;
17
+ on(event: string, listener: (...args: never[]) => void): unknown;
18
+ off(event: string, listener: (...args: never[]) => void): unknown;
19
+ extendWith<T>(...mixins: T[]): T & Thing;
20
+ readonly miioModel?: string;
21
+ readonly _properties: Record<string, unknown>;
22
+ readonly _propertiesToMonitor: string[];
23
+ readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
24
+ readonly _reversePropertyDefinitions: Record<string, string>;
25
+ readonly management: import("../management").DeviceManagement;
26
+ debugFn?: import("../logger").DebugFn;
27
+ readonly handle: import("../management").DeviceHandle;
28
+ miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
29
+ call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
30
+ refresh?: string[];
31
+ refreshDelay?: number;
32
+ sid?: number;
33
+ retries?: number;
34
+ }): Promise<Response>;
35
+ defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
36
+ _pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
37
+ poll(_isInitial?: boolean): Promise<void>;
38
+ _loadProperties(properties?: string[]): Promise<void>;
39
+ setProperty(key: string, value: unknown): void;
40
+ setRawProperty(name: string, value: unknown): void;
41
+ property<T>(key: string): T;
42
+ get connected(): boolean;
43
+ get properties(): Record<string, unknown>;
44
+ miioProperties(): Record<string, unknown>;
45
+ getProperties(props: string[]): {};
46
+ loadProperties(props: string[]): Promise<{}>;
47
+ updatePollDuration(duration: number): void;
48
+ updateMaxPollFailures(failures: number): void;
49
+ updateColor(value: import("abstract-things/values").Color): void;
50
+ } & Thing;
51
+ export const ColorFull: new (...args: any[]) => {
52
+ propertyUpdated(key: any, value: any): void;
53
+ changeColor(color: any, options: any): Promise<null>;
54
+ id: string | null;
55
+ metadata: Record<string, unknown> & {
56
+ types: string[];
57
+ capabilities: string[];
58
+ addCapabilities(...capabilities: string[]): void;
59
+ };
60
+ init(): Promise</*elided*/ any | undefined>;
61
+ initCallback(): Promise<void>;
62
+ destroy(): Promise<void>;
63
+ destroyCallback: (() => Promise<void>) & (() => Promise<void>);
64
+ debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
65
+ matches(...tags: string[]): boolean;
66
+ emitEvent(event: string, data?: unknown, options?: unknown): void;
67
+ on(event: string, listener: (...args: never[]) => void): unknown;
68
+ off(event: string, listener: (...args: never[]) => void): unknown;
69
+ extendWith<T>(...mixins: T[]): T & Thing;
70
+ readonly miioModel?: string;
71
+ readonly _properties: Record<string, unknown>;
72
+ readonly _propertiesToMonitor: string[];
73
+ readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
74
+ readonly _reversePropertyDefinitions: Record<string, string>;
75
+ readonly management: import("../management").DeviceManagement;
76
+ debugFn?: import("../logger").DebugFn;
77
+ readonly handle: import("../management").DeviceHandle;
78
+ miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
79
+ call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
80
+ refresh?: string[];
81
+ refreshDelay?: number;
82
+ sid?: number;
83
+ retries?: number;
84
+ }): Promise<Response>;
85
+ defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
86
+ _pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
87
+ poll(_isInitial?: boolean): Promise<void>;
88
+ _loadProperties(properties?: string[]): Promise<void>;
89
+ setProperty(key: string, value: unknown): void;
90
+ setRawProperty(name: string, value: unknown): void;
91
+ property<T>(key: string): T;
92
+ get connected(): boolean;
93
+ get properties(): Record<string, unknown>;
94
+ miioProperties(): Record<string, unknown>;
95
+ getProperties(props: string[]): {};
96
+ loadProperties(props: string[]): Promise<{}>;
97
+ updatePollDuration(duration: number): void;
98
+ updateMaxPollFailures(failures: number): void;
99
+ updateColor(value: import("abstract-things/values").Color): void;
100
+ } & Thing;
101
+ export const Yeelight: new (options?: any) => {
102
+ propertyUpdated(key: any, value: any): void;
103
+ changePower(power: any): Promise<null>;
104
+ /**
105
+ * Make the current state the default state, meaning the light will restore
106
+ * to this state after power has been cut.
107
+ */
108
+ setDefault(): Promise<null>;
109
+ changeBrightness(brightness: any, options: any): Promise<null>;
110
+ changeName(name: any): Promise<any>;
111
+ id: string | null;
112
+ metadata: Record<string, unknown> & {
113
+ types: string[];
114
+ capabilities: string[];
115
+ addCapabilities(...capabilities: string[]): void;
116
+ };
117
+ init(): Promise</*elided*/ any | undefined>;
118
+ initCallback(): Promise<void>;
119
+ destroy(): Promise<void>;
120
+ destroyCallback: (() => Promise<void>) & (() => Promise<void>);
121
+ debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
122
+ matches(...tags: string[]): boolean;
123
+ emitEvent(event: string, data?: unknown, options?: unknown): void;
124
+ on(event: string, listener: (...args: never[]) => void): unknown;
125
+ off(event: string, listener: (...args: never[]) => void): unknown;
126
+ extendWith<T>(...mixins: T[]): T & Thing;
127
+ readonly miioModel?: string;
128
+ readonly _properties: Record<string, unknown>;
129
+ readonly _propertiesToMonitor: string[];
130
+ readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
131
+ readonly _reversePropertyDefinitions: Record<string, string>;
132
+ readonly management: import("../management").DeviceManagement;
133
+ debugFn?: import("../logger").DebugFn;
134
+ readonly handle: import("../management").DeviceHandle;
135
+ miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
136
+ call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
137
+ refresh?: string[];
138
+ refreshDelay?: number;
139
+ sid?: number;
140
+ retries?: number;
141
+ }): Promise<Response>;
142
+ defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
143
+ _pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
144
+ poll(_isInitial?: boolean): Promise<void>;
145
+ _loadProperties(properties?: string[]): Promise<void>;
146
+ setProperty(key: string, value: unknown): void;
147
+ setRawProperty(name: string, value: unknown): void;
148
+ property<T>(key: string): T;
149
+ get connected(): boolean;
150
+ get properties(): Record<string, unknown>;
151
+ miioProperties(): Record<string, unknown>;
152
+ getProperties(props: string[]): {};
153
+ loadProperties(props: string[]): Promise<{}>;
154
+ updatePollDuration(duration: number): void;
155
+ updateMaxPollFailures(failures: number): void;
156
+ updatePower<T>(value: T): void;
157
+ updateBrightness(value: number): void;
158
+ } & Thing;
159
+ import { Thing } from "abstract-things";
@@ -0,0 +1,3 @@
1
+ export = YeelightMono;
2
+ declare class YeelightMono {
3
+ }
@@ -0,0 +1,53 @@
1
+ import util from "node:util";
2
+ import { TimedServiceDiscovery, BasicServiceDiscovery, type Service } from "tinkerhub-discovery";
3
+ import { type ConnectToDeviceOptions } from "./connect_to_device";
4
+ import type { DeviceInfo } from "./device_info";
5
+ import type { IDevice } from "./device";
6
+ declare const tryAdd: unique symbol;
7
+ export interface BrowserOptions {
8
+ cacheTime?: number;
9
+ tokens?: Record<string, string>;
10
+ }
11
+ interface BrowserService extends Service {
12
+ address: string;
13
+ port: number;
14
+ token: string | Buffer | null;
15
+ autoToken?: boolean;
16
+ model?: string;
17
+ hostname?: string;
18
+ connect: (options?: Partial<ConnectToDeviceOptions>) => Promise<IDevice | undefined>;
19
+ }
20
+ export declare class Browser extends TimedServiceDiscovery<BrowserService> {
21
+ static get type(): string;
22
+ private handle?;
23
+ private readonly manualTokens;
24
+ constructor(options: BrowserOptions);
25
+ _manualToken(id: any): string | null;
26
+ start(): void;
27
+ destroy(): Promise<void>;
28
+ search(): void;
29
+ [tryAdd](device: DeviceInfo): void;
30
+ [util.inspect.custom](): string;
31
+ }
32
+ export interface DevicesOptions extends BrowserOptions {
33
+ token?: string | Buffer;
34
+ filter?: (reg: {
35
+ id: string;
36
+ model: string;
37
+ type: string;
38
+ }) => boolean;
39
+ skipSubDevices?: boolean;
40
+ }
41
+ export declare class Devices extends BasicServiceDiscovery<IDevice & {
42
+ id: string;
43
+ }> {
44
+ static get type(): string;
45
+ private readonly _filter?;
46
+ private readonly _skipSubDevices?;
47
+ private readonly _browser;
48
+ constructor(options: DevicesOptions);
49
+ destroy(): Promise<void>;
50
+ [util.inspect.custom](): string;
51
+ _bindSubDevices(device: any): void;
52
+ }
53
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Payload of the `stateChanged` event (`device.on("stateChanged", ...)`), emitted for every change of `state()`.
3
+ */
4
+ export interface StateChangedEvent {
5
+ key: string;
6
+ value: unknown;
7
+ }
8
+ /**
9
+ * Payload of the `errorChanged` event (`device.on("errorChanged", ...)`): the error, or `null` when it's cleared.
10
+ *
11
+ * abstract-things converts the errors set by the devices (`{ code, message }`) into this shape.
12
+ */
13
+ export type ErrorChangedEvent = {
14
+ /** The error code, e.g. `10` (Roborock) or `"charging-error"` */
15
+ id: number | string;
16
+ /** A human-readable description, if known */
17
+ description?: string;
18
+ } | null;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/lib/events.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ /// <reference path="../types/abstract-things/climate/index.d.ts" />
2
+ /// <reference path="../types/abstract-things/electricals/index.d.ts" />
3
+ /// <reference path="../types/abstract-things/index.d.ts" />
4
+ /// <reference path="../types/abstract-things/lights/index.d.ts" />
5
+ /// <reference path="../types/abstract-things/values/index.d.ts" />
6
+ import * as discovery from "./discovery";
7
+ import { models } from "./models";
8
+ import { connectToDevice } from "./connect_to_device";
9
+ import { infoFromHostname } from "./info_from_hostname";
10
+ import type { BrowserOptions, DevicesOptions } from "./discovery";
11
+ export { Device as MiioDevice } from "./device";
12
+ export { MiioError } from "./miio_error";
13
+ export { configureLogging, type MiioLogger } from "./logger";
14
+ export type { StateChangedEvent, ErrorChangedEvent } from "./events";
15
+ export { Vacuum, MOP_ROUTES, type RoborockConsumable, } from "./devices/vacuums/vacuum";
16
+ export { resolveVacuumModes, type VacuumMode, type VacuumModes, } from "./devices/vacuums/vacuum_modes";
17
+ export { MijiaVacuum } from "./devices/vacuums/mijiavacuum";
18
+ export { isVacuum, type VacuumDevice } from "./devices/vacuums/vacuum_device";
19
+ export { ViomiVacuum } from "./devices/vacuums/viomivacuum";
20
+ export { DreameVacuum } from "./devices/vacuums/dreamevacuum";
21
+ export { MiotVacuum, type MiotMode } from "./devices/vacuums/miot-vacuum";
22
+ export { MiotSpecClient, configureMiotSpecs, type MiotSpecOptions, type ResolvedMiotSpec, } from "./miot/spec_client";
23
+ export { MiotSpecIndex, parseUrn, type MiotSpec } from "./miot/miot_spec";
24
+ export { MiotError } from "./miot/miot_api";
25
+ export * from "./cloud/index";
26
+ export { parseRoborockMap, roomAt, roomOfPixel, MapParseError, MM_PER_PIXEL, PIXEL, type RoborockMap, type MapRoom, type MapPoint, type MapRectangle, type MapArea, type MapImage, } from "./maps/roborock_map";
27
+ export { MapWatcher, type MapWatcherDevice, type MapWatcherOptions, type MapWatcherEvents, } from "./maps/map_watcher";
28
+ export {
29
+ /**
30
+ * Get information about the models supported. Can be used to extend the models
31
+ * supported.
32
+ */
33
+ models,
34
+ /**
35
+ * Resolve a device from the given options.
36
+ *
37
+ * Options:
38
+ * `address`, **required** the address to the device as an IP or hostname
39
+ * `port`, optional port number, if not specified the default 54321 will be used
40
+ * `token`, optional token of the device
41
+ */
42
+ connectToDevice as device,
43
+ /**
44
+ * Extract information about a device from its hostname on the local network.
45
+ */
46
+ infoFromHostname, };
47
+ /**
48
+ * Browse for devices available on the network. Will not automatically
49
+ * connect to them.
50
+ *
51
+ * @param options
52
+ */
53
+ export declare function browse(options?: BrowserOptions): discovery.Browser;
54
+ /**
55
+ * Get access to all devices on the current network. Will find and connect to
56
+ * devices automatically.
57
+ *
58
+ * @param options
59
+ */
60
+ export declare function devices(options?: DevicesOptions): discovery.Devices;
package/dist/lib/index.js CHANGED
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.infoFromHostname = exports.device = exports.models = exports.MapWatcher = exports.PIXEL = exports.MM_PER_PIXEL = exports.MapParseError = exports.roomOfPixel = exports.roomAt = exports.parseRoborockMap = exports.MiotError = exports.parseUrn = exports.MiotSpecIndex = exports.configureMiotSpecs = exports.MiotSpecClient = exports.MiotVacuum = exports.DreameVacuum = exports.ViomiVacuum = exports.MijiaVacuum = exports.resolveVacuumModes = exports.MOP_ROUTES = exports.Vacuum = exports.MiioError = exports.MiioDevice = void 0;
39
+ exports.infoFromHostname = exports.device = exports.models = exports.MapWatcher = exports.PIXEL = exports.MM_PER_PIXEL = exports.MapParseError = exports.roomOfPixel = exports.roomAt = exports.parseRoborockMap = exports.MiotError = exports.parseUrn = exports.MiotSpecIndex = exports.configureMiotSpecs = exports.MiotSpecClient = exports.MiotVacuum = exports.DreameVacuum = exports.ViomiVacuum = exports.isVacuum = exports.MijiaVacuum = exports.resolveVacuumModes = exports.MOP_ROUTES = exports.Vacuum = exports.configureLogging = exports.MiioError = exports.MiioDevice = void 0;
40
40
  exports.browse = browse;
41
41
  exports.devices = devices;
42
42
  const discovery = __importStar(require("./discovery"));
@@ -50,6 +50,8 @@ var device_1 = require("./device");
50
50
  Object.defineProperty(exports, "MiioDevice", { enumerable: true, get: function () { return device_1.Device; } });
51
51
  var miio_error_1 = require("./miio_error");
52
52
  Object.defineProperty(exports, "MiioError", { enumerable: true, get: function () { return miio_error_1.MiioError; } });
53
+ var logger_1 = require("./logger");
54
+ Object.defineProperty(exports, "configureLogging", { enumerable: true, get: function () { return logger_1.configureLogging; } });
53
55
  var vacuum_1 = require("./devices/vacuums/vacuum");
54
56
  Object.defineProperty(exports, "Vacuum", { enumerable: true, get: function () { return vacuum_1.Vacuum; } });
55
57
  Object.defineProperty(exports, "MOP_ROUTES", { enumerable: true, get: function () { return vacuum_1.MOP_ROUTES; } });
@@ -57,6 +59,8 @@ var vacuum_modes_1 = require("./devices/vacuums/vacuum_modes");
57
59
  Object.defineProperty(exports, "resolveVacuumModes", { enumerable: true, get: function () { return vacuum_modes_1.resolveVacuumModes; } });
58
60
  var mijiavacuum_1 = require("./devices/vacuums/mijiavacuum");
59
61
  Object.defineProperty(exports, "MijiaVacuum", { enumerable: true, get: function () { return mijiavacuum_1.MijiaVacuum; } });
62
+ var vacuum_device_1 = require("./devices/vacuums/vacuum_device");
63
+ Object.defineProperty(exports, "isVacuum", { enumerable: true, get: function () { return vacuum_device_1.isVacuum; } });
60
64
  var viomivacuum_1 = require("./devices/vacuums/viomivacuum");
61
65
  Object.defineProperty(exports, "ViomiVacuum", { enumerable: true, get: function () { return viomivacuum_1.ViomiVacuum; } });
62
66
  var dreamevacuum_1 = require("./devices/vacuums/dreamevacuum");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,wBAEC;AAQD,0BAEC;AA3FD,uDAAyC;AACzC,qCAAkC;AAwDhC,uFAxDO,eAAM,OAwDP;AAvDR,2DAAsD;AAgEjC,uFAhEZ,mCAAe,OAgEG;AA/D3B,6DAAwD;AAmEtD,iGAnEO,qCAAgB,OAmEP;AAhElB,mCAAgD;AAAvC,oGAAA,MAAM,OAAc;AAC7B,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,mDAIkC;AAHhC,gGAAA,MAAM,OAAA;AACN,oGAAA,UAAU,OAAA;AAGZ,+DAIwC;AAHtC,kHAAA,kBAAkB,OAAA;AAIpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,4GAAA,YAAY,OAAA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HAAA,kBAAkB,OAAA;AAIpB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,iEAA8E;AAArE,yGAAA,QAAQ,OAAA;AACjB,6DAA4D;AAAnD,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,4GAAA,YAAY,OAAA;AACrB,6DAA0E;AAAjE,yGAAA,UAAU,OAAA;AACnB,kDAK4B;AAJ1B,6GAAA,cAAc,OAAA;AACd,iHAAA,kBAAkB,OAAA;AAIpB,8CAA0E;AAAjE,0GAAA,aAAa,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAChC,4CAA4C;AAAnC,qGAAA,SAAS,OAAA;AAClB,gDAA8B;AAC9B,oDAa6B;AAZ3B,gHAAA,gBAAgB,OAAA;AAChB,sGAAA,MAAM,OAAA;AACN,2GAAA,WAAW,OAAA;AACX,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA;AACZ,qGAAA,KAAK,OAAA;AAQP,kDAK4B;AAJ1B,yGAAA,UAAU,OAAA;AA2BZ;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,OAAwB;IAC7C,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,OAAwB;IAC9C,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ *
3
+ * @param hostname
4
+ */
5
+ export declare function infoFromHostname(hostname: string): {
6
+ model: string;
7
+ type: string;
8
+ id?: undefined;
9
+ } | {
10
+ model: string;
11
+ id: string;
12
+ type?: undefined;
13
+ } | null;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A logger that node-miio can send its debug messages to, e.g. the one provided by Homebridge or Matterbridge.
3
+ * Only `debug` is used: node-miio doesn't log anything above that level.
4
+ */
5
+ export interface MiioLogger {
6
+ debug(message: string, ...args: unknown[]): void;
7
+ }
8
+ export type DebugFn = (...msgs: unknown[]) => void;
9
+ /**
10
+ * Sends node-miio's debug messages to a logger, in addition to the `debug` package (`DEBUG=miio*`, used by the CLI).
11
+ *
12
+ * This is the global logger, used for messages that aren't about a specific device (network, MIoT specs, cloud…).
13
+ * Use the `logger` option of `device()` for the messages of a specific device.
14
+ *
15
+ * @param options The options
16
+ * @param options.logger The logger, or `undefined` to stop sending messages to it
17
+ */
18
+ export declare function configureLogging(options: {
19
+ logger?: MiioLogger;
20
+ }): void;
21
+ /**
22
+ * Removes secrets (tokens, passwords) from a log message, so users can share their logs safely.
23
+ *
24
+ * @param message The message
25
+ * @returns The message, with the secrets replaced by `***`
26
+ */
27
+ export declare function redact(message: string): string;
28
+ /**
29
+ * Masks a token: only its first 4 characters are kept, enough to tell tokens apart.
30
+ *
31
+ * @param token The token as hex
32
+ * @returns The masked token
33
+ */
34
+ export declare function maskToken(token?: string): string;
35
+ /**
36
+ * Creates a debug function that logs to the `debug` package under `namespace`, and to a {@link MiioLogger}:
37
+ * the one returned by `getLogger` (e.g. the device's), or the global one (see {@link configureLogging}).
38
+ *
39
+ * @param namespace The `debug` namespace (e.g. `miio:network`)
40
+ * @param getLogger Returns the logger to use instead of the global one, if any
41
+ * @returns The debug function
42
+ */
43
+ export declare function createDebug(namespace: string, getLogger?: () => MiioLogger | undefined): DebugFn;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.configureLogging = configureLogging;
7
+ exports.redact = redact;
8
+ exports.maskToken = maskToken;
9
+ exports.createDebug = createDebug;
10
+ const node_util_1 = __importDefault(require("node:util"));
11
+ const debug_1 = __importDefault(require("debug"));
12
+ let globalLogger;
13
+ /**
14
+ * Sends node-miio's debug messages to a logger, in addition to the `debug` package (`DEBUG=miio*`, used by the CLI).
15
+ *
16
+ * This is the global logger, used for messages that aren't about a specific device (network, MIoT specs, cloud…).
17
+ * Use the `logger` option of `device()` for the messages of a specific device.
18
+ *
19
+ * @param options The options
20
+ * @param options.logger The logger, or `undefined` to stop sending messages to it
21
+ */
22
+ function configureLogging(options) {
23
+ globalLogger = options.logger;
24
+ }
25
+ /** Keys whose values are never logged */
26
+ const SECRET_KEYS = /"(token|passwd|password|ssecurity|serviceToken)"\s*:\s*"[^"]*"/g;
27
+ /**
28
+ * Removes secrets (tokens, passwords) from a log message, so users can share their logs safely.
29
+ *
30
+ * @param message The message
31
+ * @returns The message, with the secrets replaced by `***`
32
+ */
33
+ function redact(message) {
34
+ return message.replace(SECRET_KEYS, '"$1":"***"');
35
+ }
36
+ /**
37
+ * Masks a token: only its first 4 characters are kept, enough to tell tokens apart.
38
+ *
39
+ * @param token The token as hex
40
+ * @returns The masked token
41
+ */
42
+ function maskToken(token) {
43
+ return token ? `${token.slice(0, 4)}***` : String(token);
44
+ }
45
+ /**
46
+ * Creates a debug function that logs to the `debug` package under `namespace`, and to a {@link MiioLogger}:
47
+ * the one returned by `getLogger` (e.g. the device's), or the global one (see {@link configureLogging}).
48
+ *
49
+ * @param namespace The `debug` namespace (e.g. `miio:network`)
50
+ * @param getLogger Returns the logger to use instead of the global one, if any
51
+ * @returns The debug function
52
+ */
53
+ function createDebug(namespace, getLogger) {
54
+ const debug = (0, debug_1.default)(namespace);
55
+ return (...msgs) => {
56
+ const message = redact(node_util_1.default.format(...msgs));
57
+ debug("%s", message);
58
+ const logger = getLogger?.() ?? globalLogger;
59
+ logger?.debug(`[${namespace}] ${message}`);
60
+ };
61
+ }
62
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":";;;;;AAyBA,4CAEC;AAYD,wBAEC;AAQD,8BAEC;AAUD,kCAWC;AAxED,0DAA6B;AAE7B,kDAAiC;AAYjC,IAAI,YAAoC,CAAC;AAEzC;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC/D,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;AAChC,CAAC;AAED,yCAAyC;AACzC,MAAM,WAAW,GACf,iEAAiE,CAAC;AAEpE;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,OAAe;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CACzB,SAAiB,EACjB,SAAwC;IAExC,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,SAAS,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,MAAM,MAAM,GAAG,SAAS,EAAE,EAAE,IAAI,YAAY,CAAC;QAC7C,MAAM,EAAE,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { DeviceInfo } from "./device_info";
2
+ export interface DeviceHandle {
3
+ ref: {
4
+ release: () => void;
5
+ };
6
+ api: DeviceInfo;
7
+ }
8
+ /**
9
+ * Management of a device. Supports querying it for information and changing
10
+ * the Wi-Fi settings.
11
+ */
12
+ export declare class DeviceManagement {
13
+ private readonly api;
14
+ constructor(device: {
15
+ handle: DeviceHandle;
16
+ });
17
+ get model(): string | undefined;
18
+ get token(): string | null;
19
+ get autoToken(): boolean | undefined;
20
+ get address(): string;
21
+ get port(): number | undefined;
22
+ /**
23
+ * Get information about this device. Includes model info, token and
24
+ * connection information.
25
+ */
26
+ info(): Promise<import("./protocol").MiioDeviceInfo>;
27
+ /**
28
+ * Update the wireless settings of this device. Needs `ssid` and `passwd`
29
+ * to be set in the options object.
30
+ *
31
+ * `uid` can be set to associate the device with a Mi Home user id.
32
+ *
33
+ * @param options
34
+ * @param options.ssid
35
+ * @param options.passwd
36
+ */
37
+ updateWireless(options: {
38
+ ssid?: string;
39
+ passwd?: string;
40
+ }): Promise<boolean>;
41
+ /**
42
+ * Get the wireless state of this device. Includes if the device is
43
+ * online and counters for things such as authentication failures and
44
+ * connection success and failures.
45
+ */
46
+ wirelessState(): Promise<unknown>;
47
+ /**
48
+ * Update the token used to connect to this device.
49
+ *
50
+ * @param token
51
+ */
52
+ updateToken(token: string | Buffer): Promise<boolean>;
53
+ }
@@ -0,0 +1,71 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { CloudServer, XiaomiCloud } from "../cloud/client";
3
+ import type { MapPoint, RoborockMap } from "./roborock_map";
4
+ /** What the watcher needs from the vacuum (e.g. a Roborock {@link Vacuum}) */
5
+ export interface MapWatcherDevice {
6
+ getCloudMap(cloud: Pick<XiaomiCloud, "getMapFileUrl" | "download">, server: CloudServer | string): Promise<RoborockMap>;
7
+ cleaning(): Promise<boolean>;
8
+ on(event: "cleaningChanged", listener: (cleaning: boolean) => void): unknown;
9
+ off(event: "cleaningChanged", listener: (cleaning: boolean) => void): unknown;
10
+ }
11
+ export interface MapWatcherOptions {
12
+ /** The server the device is registered in (see {@link XiaomiCloud.findDevice}) */
13
+ server: CloudServer | string;
14
+ /** How often to download the map while cleaning (default 10s, minimum 5s) */
15
+ intervalMs?: number;
16
+ /** The longest wait after consecutive errors (default 5 minutes) */
17
+ maxBackoffMs?: number;
18
+ }
19
+ export interface MapWatcherEvents {
20
+ /** A new map was downloaded */
21
+ map: [RoborockMap];
22
+ /** The robot moved to another room, or left the rooms (`undefined`), e.g. when it stops cleaning */
23
+ currentRoom: [number | undefined];
24
+ /** The robot moved */
25
+ position: [MapPoint | undefined];
26
+ /** The map couldn't be downloaded. With {@link CloudSessionExpiredError}, the watcher stops polling */
27
+ failed: [Error];
28
+ }
29
+ /**
30
+ * Downloads the vacuum's map from the Xiaomi Cloud while it's cleaning, to report the room it's in.
31
+ *
32
+ * ```ts
33
+ * const watcher = new MapWatcher(vacuum, cloud, { server: "de" });
34
+ * watcher.on("currentRoom", (room) => console.log("Now in room", room));
35
+ * await watcher.start();
36
+ * ```
37
+ */
38
+ export declare class MapWatcher extends EventEmitter<MapWatcherEvents> {
39
+ private readonly device;
40
+ private readonly cloud;
41
+ private readonly options;
42
+ private readonly intervalMs;
43
+ private readonly maxBackoffMs;
44
+ private timer?;
45
+ private polling;
46
+ private started;
47
+ private failures;
48
+ private lastRoom?;
49
+ private lastPosition?;
50
+ constructor(device: MapWatcherDevice, cloud: Pick<XiaomiCloud, "getMapFileUrl" | "download">, options: MapWatcherOptions);
51
+ private readonly onCleaningChanged;
52
+ /**
53
+ * Starts following the vacuum: the map is downloaded while it's cleaning.
54
+ */
55
+ start(): Promise<void>;
56
+ /**
57
+ * Stops following the vacuum.
58
+ */
59
+ stop(): void;
60
+ /**
61
+ * Downloads the map once.
62
+ *
63
+ * @returns The map, or `undefined` if it failed (see the `failed` event)
64
+ */
65
+ refresh(): Promise<RoborockMap | undefined>;
66
+ private startPolling;
67
+ private stopPolling;
68
+ private poll;
69
+ private updateRoom;
70
+ private updatePosition;
71
+ }
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MapWatcher = void 0;
7
4
  const node_events_1 = require("node:events");
8
- const debug_1 = __importDefault(require("debug"));
5
+ const logger_1 = require("../logger");
9
6
  const errors_1 = require("../cloud/errors");
10
- const debug = (0, debug_1.default)("miio:map-watcher");
7
+ const debug = (0, logger_1.createDebug)("miio:map-watcher");
11
8
  const MIN_INTERVAL_MS = 5_000;
12
9
  /**
13
10
  * Downloads the vacuum's map from the Xiaomi Cloud while it's cleaning, to report the room it's in.
@@ -1 +1 @@
1
- {"version":3,"file":"map_watcher.js","sourceRoot":"","sources":["../../../src/lib/maps/map_watcher.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA2C;AAE3C,kDAAiC;AAGjC,4CAA2D;AAI3D,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,kBAAkB,CAAC,CAAC;AAiC/C,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAa,UAAW,SAAQ,0BAA8B;IAWzC;IACA;IACA;IAZF,UAAU,CAAS;IACnB,YAAY,CAAS;IAC9B,KAAK,CAAkB;IACvB,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,CAAU;IAClB,YAAY,CAAY;IAEhC,YACmB,MAAwB,EACxB,KAAsD,EACtD,OAA0B;QAE3C,KAAK,EAAE,CAAC;QAJS,WAAM,GAAN,MAAM,CAAkB;QACxB,UAAK,GAAL,KAAK,CAAiD;QACtD,YAAO,GAAP,OAAO,CAAmB;QAG3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,MAAM,EAAE,eAAe,CAAC,CAAC;QAC1E,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,GAAG,MAAM,CAAC;IACzD,CAAC;IAEgB,iBAAiB,GAAG,CAAC,QAAiB,EAAE,EAAE;QACzD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;aAAM,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