@vita-mojo/mqtt 1.0.7 → 1.0.8

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.
package/client.cjs.js CHANGED
@@ -10,14 +10,15 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var mqtt__default = /*#__PURE__*/_interopDefaultLegacy(mqtt);
12
12
 
13
+ const defaultLogger = {
14
+ log: (...args) => console.log('[MQTT]', ...args),
15
+ error: (...args) => console.error('[MQTT]', ...args),
16
+ warn: (...args) => console.warn('[MQTT]', ...args)
17
+ };
13
18
  const mqttContext = react.createContext({
14
19
  mqttClient: null,
15
20
  connected: false,
16
- logger: {
17
- log: (...args) => console.log('[MQTT]', ...args),
18
- error: (...args) => console.error('[MQTT]', ...args),
19
- warn: (...args) => console.warn('[MQTT]', ...args)
20
- }
21
+ logger: defaultLogger
21
22
  });
22
23
  function MqttProvider({
23
24
  children,
@@ -29,11 +30,7 @@ function MqttProvider({
29
30
  sessionDuration,
30
31
  clientId,
31
32
  extraOpts,
32
- logger = {
33
- log: (...args) => console.log('[MQTT]', ...args),
34
- error: (...args) => console.error('[MQTT]', ...args),
35
- warn: (...args) => console.warn('[MQTT]', ...args)
36
- }
33
+ logger = defaultLogger
37
34
  }) {
38
35
  const [client, setClient] = react.useState(null);
39
36
  const [connected, setConnected] = react.useState(false);
@@ -103,7 +100,7 @@ function MqttProvider({
103
100
  logger.log('MQTT client disconnected');
104
101
  });
105
102
  };
106
- }, [password, storeUUID, tenantUUID, url, username, extraOpts, sessionDuration, clientId, logger]);
103
+ }, [password, storeUUID, tenantUUID, url, username, extraOpts, sessionDuration, clientId]);
107
104
  const value = react.useMemo(() => {
108
105
  return {
109
106
  mqttClient: client,
package/client.esm.js CHANGED
@@ -2,14 +2,15 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import mqtt from 'mqtt';
3
3
  import { createContext, useState, useEffect, useMemo, useContext, useRef } from 'react';
4
4
 
5
+ const defaultLogger = {
6
+ log: (...args) => console.log('[MQTT]', ...args),
7
+ error: (...args) => console.error('[MQTT]', ...args),
8
+ warn: (...args) => console.warn('[MQTT]', ...args)
9
+ };
5
10
  const mqttContext = createContext({
6
11
  mqttClient: null,
7
12
  connected: false,
8
- logger: {
9
- log: (...args) => console.log('[MQTT]', ...args),
10
- error: (...args) => console.error('[MQTT]', ...args),
11
- warn: (...args) => console.warn('[MQTT]', ...args)
12
- }
13
+ logger: defaultLogger
13
14
  });
14
15
  function MqttProvider({
15
16
  children,
@@ -21,11 +22,7 @@ function MqttProvider({
21
22
  sessionDuration,
22
23
  clientId,
23
24
  extraOpts,
24
- logger = {
25
- log: (...args) => console.log('[MQTT]', ...args),
26
- error: (...args) => console.error('[MQTT]', ...args),
27
- warn: (...args) => console.warn('[MQTT]', ...args)
28
- }
25
+ logger = defaultLogger
29
26
  }) {
30
27
  const [client, setClient] = useState(null);
31
28
  const [connected, setConnected] = useState(false);
@@ -95,7 +92,7 @@ function MqttProvider({
95
92
  logger.log('MQTT client disconnected');
96
93
  });
97
94
  };
98
- }, [password, storeUUID, tenantUUID, url, username, extraOpts, sessionDuration, clientId, logger]);
95
+ }, [password, storeUUID, tenantUUID, url, username, extraOpts, sessionDuration, clientId]);
99
96
  const value = useMemo(() => {
100
97
  return {
101
98
  mqttClient: client,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vita-mojo/mqtt",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "peerDependencies": {
5
5
  "axios": "*",
6
6
  "react": "*"
@@ -13,9 +13,9 @@ export interface MqttProps {
13
13
  clientId?: string | (() => string);
14
14
  extraOpts?: mqtt.IClientOptions;
15
15
  logger?: {
16
- log: (...args: any[]) => void;
17
- error: (...args: any[]) => void;
18
- warn: (...args: any[]) => void;
16
+ log: (...args: unknown[]) => void;
17
+ error: (...args: unknown[]) => void;
18
+ warn: (...args: unknown[]) => void;
19
19
  };
20
20
  }
21
21
  export declare function MqttProvider({ children, url, username, password, storeUUID, tenantUUID, sessionDuration, clientId, extraOpts, logger, }: MqttProps): import("react/jsx-runtime").JSX.Element;
@@ -24,8 +24,8 @@ export declare function useMqtt(): {
24
24
  mqttClient: mqtt.MqttClient | null;
25
25
  connected: boolean;
26
26
  logger: {
27
- log: (...args: any[]) => void;
28
- error: (...args: any[]) => void;
29
- warn: (...args: any[]) => void;
27
+ log: (...args: unknown[]) => void;
28
+ error: (...args: unknown[]) => void;
29
+ warn: (...args: unknown[]) => void;
30
30
  } | undefined;
31
31
  };
@@ -5,7 +5,7 @@ export declare class MqttPublisher {
5
5
  mqttUsername: string;
6
6
  mqttPassword: string;
7
7
  });
8
- trigger(topic: string, data: any, params?: Pick<MqttPublishParams, 'qos' | 'retain'>, errorCb?: (error: any) => void): Promise<void>;
8
+ trigger(topic: string, data: unknown, params?: Pick<MqttPublishParams, 'qos' | 'retain'>, errorCb?: (error: unknown) => void): Promise<void>;
9
9
  }
10
10
  interface MqttPublishParams {
11
11
  /**
@@ -7,6 +7,6 @@ export declare class MqttService {
7
7
  mqttUsername: string;
8
8
  mqttPassword: string;
9
9
  }, extraMQTTOptions?: MQTTOptions);
10
- trigger(topic: string, data: any, options?: mqtt.IClientPublishOptions, cb?: mqtt.PacketCallback): void;
10
+ trigger(topic: string, data: unknown, options?: mqtt.IClientPublishOptions, cb?: mqtt.PacketCallback): void;
11
11
  }
12
12
  export {};