@aws-amplify/pubsub 6.0.1-unstable.cfbde4c.0 → 6.0.2-unstable.ff4e8d7.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 (101) hide show
  1. package/{lib → dist/cjs}/Providers/AWSIot.js +3 -1
  2. package/dist/cjs/Providers/AWSIot.js.map +1 -0
  3. package/{lib → dist/cjs}/Providers/MqttOverWS.js +4 -2
  4. package/dist/cjs/Providers/MqttOverWS.js.map +1 -0
  5. package/{lib → dist/cjs}/Providers/PubSub.js +3 -1
  6. package/dist/cjs/Providers/PubSub.js.map +1 -0
  7. package/{lib → dist/cjs}/Providers/constants.js +6 -7
  8. package/dist/cjs/Providers/constants.js.map +1 -0
  9. package/{lib → dist/cjs}/Providers/index.js +3 -1
  10. package/dist/cjs/Providers/index.js.map +1 -0
  11. package/{lib → dist/cjs}/clients/iot.js +3 -1
  12. package/dist/cjs/clients/iot.js.map +1 -0
  13. package/{lib → dist/cjs}/clients/mqtt.js +3 -1
  14. package/dist/cjs/clients/mqtt.js.map +1 -0
  15. package/{lib → dist/cjs}/index.js +3 -1
  16. package/dist/cjs/index.js.map +1 -0
  17. package/{lib → dist/cjs}/types/PubSub.js +5 -6
  18. package/dist/cjs/types/PubSub.js.map +1 -0
  19. package/{lib → dist/cjs}/types/index.js +3 -1
  20. package/dist/cjs/types/index.js.map +1 -0
  21. package/{lib → dist/cjs}/utils/ConnectionStateMonitor.js +3 -1
  22. package/dist/cjs/utils/ConnectionStateMonitor.js.map +1 -0
  23. package/{lib → dist/cjs}/utils/ReachabilityMonitor/index.js +3 -1
  24. package/dist/cjs/utils/ReachabilityMonitor/index.js.map +1 -0
  25. package/{lib → dist/cjs}/utils/ReachabilityMonitor/index.native.js +3 -1
  26. package/dist/cjs/utils/ReachabilityMonitor/index.native.js.map +1 -0
  27. package/{lib → dist/cjs}/utils/ReconnectionMonitor.js +3 -1
  28. package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -0
  29. package/{lib-esm/Providers/AWSIot.js → dist/esm/Providers/AWSIot.mjs} +8 -4
  30. package/dist/esm/Providers/AWSIot.mjs.map +1 -0
  31. package/{lib-esm/Providers/MqttOverWS.js → dist/esm/Providers/MqttOverWS.mjs} +16 -12
  32. package/dist/esm/Providers/MqttOverWS.mjs.map +1 -0
  33. package/{lib-esm/Providers/PubSub.js → dist/esm/Providers/PubSub.mjs} +7 -3
  34. package/dist/esm/Providers/PubSub.mjs.map +1 -0
  35. package/{lib-esm/Providers/constants.js → dist/esm/Providers/constants.mjs} +18 -14
  36. package/dist/esm/Providers/constants.mjs.map +1 -0
  37. package/dist/esm/Providers/index.mjs +4 -0
  38. package/dist/esm/Providers/index.mjs.map +1 -0
  39. package/dist/esm/clients/iot.mjs +4 -0
  40. package/dist/esm/clients/iot.mjs.map +1 -0
  41. package/dist/esm/clients/mqtt.mjs +5 -0
  42. package/dist/esm/clients/mqtt.mjs.map +1 -0
  43. package/dist/esm/index.mjs +6 -0
  44. package/dist/esm/index.mjs.map +1 -0
  45. package/{lib-esm/types/PubSub.js → dist/esm/types/PubSub.mjs} +5 -2
  46. package/dist/esm/types/PubSub.mjs.map +1 -0
  47. package/dist/esm/types/index.mjs +2 -0
  48. package/dist/esm/types/index.mjs.map +1 -0
  49. package/{lib-esm/utils/ConnectionStateMonitor.js → dist/esm/utils/ConnectionStateMonitor.mjs} +9 -5
  50. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -0
  51. package/dist/esm/utils/ReachabilityMonitor/index.d.ts +1 -0
  52. package/{lib-esm/utils/ReachabilityMonitor/index.js → dist/esm/utils/ReachabilityMonitor/index.mjs} +6 -2
  53. package/dist/esm/utils/ReachabilityMonitor/index.mjs.map +1 -0
  54. package/dist/esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  55. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs +9 -0
  56. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -0
  57. package/{lib-esm/utils/ReconnectionMonitor.js → dist/esm/utils/ReconnectionMonitor.mjs} +7 -3
  58. package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -0
  59. package/iot/packages.json +5 -4
  60. package/mqtt/packages.json +5 -4
  61. package/package.json +37 -36
  62. package/src/Providers/MqttOverWS.ts +3 -3
  63. package/src/Providers/PubSub.ts +2 -2
  64. package/lib/Providers/AWSIot.d.ts +0 -10
  65. package/lib/Providers/MqttOverWS.d.ts +0 -58
  66. package/lib/Providers/PubSub.d.ts +0 -11
  67. package/lib/Providers/constants.d.ts +0 -95
  68. package/lib/Providers/index.d.ts +0 -3
  69. package/lib/clients/iot.d.ts +0 -1
  70. package/lib/clients/mqtt.d.ts +0 -1
  71. package/lib/index.d.ts +0 -4
  72. package/lib/tsconfig.tsbuildinfo +0 -1
  73. package/lib/types/PubSub.d.ts +0 -45
  74. package/lib/types/index.d.ts +0 -1
  75. package/lib/utils/ConnectionStateMonitor.d.ts +0 -41
  76. package/lib/utils/ReachabilityMonitor/index.d.ts +0 -1
  77. package/lib/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  78. package/lib/utils/ReconnectionMonitor.d.ts +0 -29
  79. package/lib-esm/Providers/index.js +0 -5
  80. package/lib-esm/clients/iot.js +0 -3
  81. package/lib-esm/clients/mqtt.js +0 -3
  82. package/lib-esm/index.js +0 -6
  83. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  84. package/lib-esm/types/index.js +0 -3
  85. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +0 -1
  86. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  87. package/lib-esm/utils/ReachabilityMonitor/index.native.js +0 -5
  88. /package/{lib-esm → dist/cjs}/vendor/paho-mqtt.js +0 -0
  89. /package/{lib-esm → dist/esm}/Providers/AWSIot.d.ts +0 -0
  90. /package/{lib-esm → dist/esm}/Providers/MqttOverWS.d.ts +0 -0
  91. /package/{lib-esm → dist/esm}/Providers/PubSub.d.ts +0 -0
  92. /package/{lib-esm → dist/esm}/Providers/constants.d.ts +0 -0
  93. /package/{lib-esm → dist/esm}/Providers/index.d.ts +0 -0
  94. /package/{lib-esm → dist/esm}/clients/iot.d.ts +0 -0
  95. /package/{lib-esm → dist/esm}/clients/mqtt.d.ts +0 -0
  96. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  97. /package/{lib-esm → dist/esm}/types/PubSub.d.ts +0 -0
  98. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
  99. /package/{lib-esm → dist/esm}/utils/ConnectionStateMonitor.d.ts +0 -0
  100. /package/{lib-esm → dist/esm}/utils/ReconnectionMonitor.d.ts +0 -0
  101. /package/{lib → dist/esm}/vendor/paho-mqtt.js +0 -0
@@ -1,10 +1,11 @@
1
+ export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
- export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
4
- export const MAX_DELAY_MS = 5000;
5
- export const NON_RETRYABLE_CODES = [400, 401, 403];
6
- export const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
7
- export var MESSAGE_TYPES;
5
+ const MAX_DELAY_MS = 5000;
6
+ const NON_RETRYABLE_CODES = [400, 401, 403];
7
+ const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
8
+ var MESSAGE_TYPES;
8
9
  (function (MESSAGE_TYPES) {
9
10
  /**
10
11
  * Client -> Server message.
@@ -57,19 +58,19 @@ export var MESSAGE_TYPES;
57
58
  */
58
59
  MESSAGE_TYPES["GQL_ERROR"] = "error";
59
60
  })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
60
- export var SUBSCRIPTION_STATUS;
61
+ var SUBSCRIPTION_STATUS;
61
62
  (function (SUBSCRIPTION_STATUS) {
62
63
  SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
63
64
  SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
64
65
  SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
65
66
  })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
66
- export var SOCKET_STATUS;
67
+ var SOCKET_STATUS;
67
68
  (function (SOCKET_STATUS) {
68
69
  SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
69
70
  SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
70
71
  SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
71
72
  })(SOCKET_STATUS || (SOCKET_STATUS = {}));
72
- export const AWS_APPSYNC_REALTIME_HEADERS = {
73
+ const AWS_APPSYNC_REALTIME_HEADERS = {
73
74
  accept: 'application/json, text/javascript',
74
75
  'content-encoding': 'amz-1.0',
75
76
  'content-type': 'application/json; charset=UTF-8',
@@ -77,24 +78,27 @@ export const AWS_APPSYNC_REALTIME_HEADERS = {
77
78
  /**
78
79
  * Time in milleseconds to wait for GQL_CONNECTION_INIT message
79
80
  */
80
- export const CONNECTION_INIT_TIMEOUT = 15000;
81
+ const CONNECTION_INIT_TIMEOUT = 15000;
81
82
  /**
82
83
  * Time in milleseconds to wait for GQL_START_ACK message
83
84
  */
84
- export const START_ACK_TIMEOUT = 15000;
85
+ const START_ACK_TIMEOUT = 15000;
85
86
  /**
86
87
  * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
87
88
  */
88
- export const DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
89
+ const DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
89
90
  /**
90
91
  * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
91
92
  */
92
- export const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
93
+ const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
93
94
  /**
94
95
  * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
95
96
  */
96
- export const RECONNECT_DELAY = 5 * 1000;
97
+ const RECONNECT_DELAY = 5 * 1000;
97
98
  /**
98
99
  * Default interval time in milleseconds between when reconnect is re-attempted
99
100
  */
100
- export const RECONNECT_INTERVAL = 60 * 1000;
101
+ const RECONNECT_INTERVAL = 60 * 1000;
102
+
103
+ export { AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, CONNECTION_STATE_CHANGE, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, RECONNECT_DELAY, RECONNECT_INTERVAL, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS };
104
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../../../src/Providers/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';\nexport const MAX_DELAY_MS = 5000;\nexport const NON_RETRYABLE_CODES = [400, 401, 403];\nexport const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';\nexport var MESSAGE_TYPES;\n(function (MESSAGE_TYPES) {\n /**\n * Client -> Server message.\n * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication\n */\n MESSAGE_TYPES[\"GQL_CONNECTION_INIT\"] = \"connection_init\";\n /**\n * Server -> Client message\n * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection\n */\n MESSAGE_TYPES[\"GQL_CONNECTION_ERROR\"] = \"connection_error\";\n /**\n * Server -> Client message.\n * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message\n */\n MESSAGE_TYPES[\"GQL_CONNECTION_ACK\"] = \"connection_ack\";\n /**\n * Client -> Server message.\n * This message type is for register subscriptions with AWS AppSync RealTime\n */\n MESSAGE_TYPES[\"GQL_START\"] = \"start\";\n /**\n * Server -> Client message.\n * This message type is for the ack response from AWS AppSync RealTime for GQL_START message\n */\n MESSAGE_TYPES[\"GQL_START_ACK\"] = \"start_ack\";\n /**\n * Server -> Client message.\n * This message type is for subscription message from AWS AppSync RealTime\n */\n MESSAGE_TYPES[\"GQL_DATA\"] = \"data\";\n /**\n * Server -> Client message.\n * This message type helps the client to know is still receiving messages from AWS AppSync RealTime\n */\n MESSAGE_TYPES[\"GQL_CONNECTION_KEEP_ALIVE\"] = \"ka\";\n /**\n * Client -> Server message.\n * This message type is for unregister subscriptions with AWS AppSync RealTime\n */\n MESSAGE_TYPES[\"GQL_STOP\"] = \"stop\";\n /**\n * Server -> Client message.\n * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message\n */\n MESSAGE_TYPES[\"GQL_COMPLETE\"] = \"complete\";\n /**\n * Server -> Client message.\n * This message type is for sending error messages from AWS AppSync RealTime to the client\n */\n MESSAGE_TYPES[\"GQL_ERROR\"] = \"error\";\n})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));\nexport var SUBSCRIPTION_STATUS;\n(function (SUBSCRIPTION_STATUS) {\n SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS[\"PENDING\"] = 0] = \"PENDING\";\n SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS[\"CONNECTED\"] = 1] = \"CONNECTED\";\n SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS[\"FAILED\"] = 2] = \"FAILED\";\n})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));\nexport var SOCKET_STATUS;\n(function (SOCKET_STATUS) {\n SOCKET_STATUS[SOCKET_STATUS[\"CLOSED\"] = 0] = \"CLOSED\";\n SOCKET_STATUS[SOCKET_STATUS[\"READY\"] = 1] = \"READY\";\n SOCKET_STATUS[SOCKET_STATUS[\"CONNECTING\"] = 2] = \"CONNECTING\";\n})(SOCKET_STATUS || (SOCKET_STATUS = {}));\nexport const AWS_APPSYNC_REALTIME_HEADERS = {\n accept: 'application/json, text/javascript',\n 'content-encoding': 'amz-1.0',\n 'content-type': 'application/json; charset=UTF-8',\n};\n/**\n * Time in milleseconds to wait for GQL_CONNECTION_INIT message\n */\nexport const CONNECTION_INIT_TIMEOUT = 15000;\n/**\n * Time in milleseconds to wait for GQL_START_ACK message\n */\nexport const START_ACK_TIMEOUT = 15000;\n/**\n * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message\n */\nexport const DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;\n/**\n * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message\n */\nexport const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;\n/**\n * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted\n */\nexport const RECONNECT_DELAY = 5 * 1000;\n/**\n * Default interval time in milleseconds between when reconnect is re-attempted\n */\nexport const RECONNECT_INTERVAL = 60 * 1000;\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,YAAY,GAAG,KAAK;AACrB,MAAC,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;AACvC,MAAC,uBAAuB,GAAG,wBAAwB;AACrD,IAAC,cAAc;AACzB,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,qBAAqB,CAAC,GAAG,iBAAiB,CAAC;AAC7D;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,sBAAsB,CAAC,GAAG,kBAAkB,CAAC;AAC/D;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,oBAAoB,CAAC,GAAG,gBAAgB,CAAC;AAC3D;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;AACzC;AAC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K,aAAa,GAAG,EAAE,CAAC,CAAC,CAAC;AAC9B,MAAC,4BAA4B,GAAG;AAC5C,IAAI,MAAM,EAAE,mCAAmC;AAC/C,IAAI,kBAAkB,EAAE,SAAS;AACjC,IAAI,cAAc,EAAE,iCAAiC;AACrD,EAAE;AACF;AACA;AACA;AACY,MAAC,uBAAuB,GAAG,MAAM;AAC7C;AACA;AACA;AACY,MAAC,iBAAiB,GAAG,MAAM;AACvC;AACA;AACA;AACY,MAAC,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK;AACxD;AACA;AACA;AACY,MAAC,gCAAgC,GAAG,EAAE,GAAG,KAAK;AAC1D;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,GAAG,KAAK;AACxC;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,EAAE,GAAG;;;;"}
@@ -0,0 +1,4 @@
1
+ export { AbstractPubSub } from './PubSub.mjs';
2
+ export { AWSIoT } from './AWSIot.mjs';
3
+ export { MqttOverWS, mqttTopicMatch } from './MqttOverWS.mjs';
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,4 @@
1
+ import '../Providers/PubSub.mjs';
2
+ export { AWSIoT as PubSub } from '../Providers/AWSIot.mjs';
3
+ import '../Providers/MqttOverWS.mjs';
4
+ //# sourceMappingURL=iot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iot.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,5 @@
1
+ import '../Providers/PubSub.mjs';
2
+ export { MqttOverWS as PubSub } from '../Providers/MqttOverWS.mjs';
3
+ import '@aws-amplify/core/internals/utils';
4
+ import '@aws-amplify/core';
5
+ //# sourceMappingURL=mqtt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqtt.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,6 @@
1
+ export { CONNECTION_STATE_CHANGE } from './Providers/constants.mjs';
2
+ export { CONTROL_MSG, ConnectionState } from './types/PubSub.mjs';
3
+ import './Providers/PubSub.mjs';
4
+ export { AWSIoT as PubSub } from './Providers/AWSIot.mjs';
5
+ export { mqttTopicMatch } from './Providers/MqttOverWS.mjs';
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,4 +1,4 @@
1
- export var CONTROL_MSG;
1
+ var CONTROL_MSG;
2
2
  (function (CONTROL_MSG) {
3
3
  CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
4
4
  CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
@@ -7,7 +7,7 @@ export var CONTROL_MSG;
7
7
  CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
8
8
  })(CONTROL_MSG || (CONTROL_MSG = {}));
9
9
  /** @enum {string} */
10
- export var ConnectionState;
10
+ var ConnectionState;
11
11
  (function (ConnectionState) {
12
12
  /*
13
13
  * The connection is alive and healthy
@@ -42,3 +42,6 @@ export var ConnectionState;
42
42
  */
43
43
  ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
44
44
  })(ConnectionState || (ConnectionState = {}));
45
+
46
+ export { CONTROL_MSG, ConnectionState };
47
+ //# sourceMappingURL=PubSub.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PubSub.mjs","sources":["../../../src/types/PubSub.ts"],"sourcesContent":["export var CONTROL_MSG;\n(function (CONTROL_MSG) {\n CONTROL_MSG[\"CONNECTION_CLOSED\"] = \"Connection closed\";\n CONTROL_MSG[\"CONNECTION_FAILED\"] = \"Connection failed\";\n CONTROL_MSG[\"REALTIME_SUBSCRIPTION_INIT_ERROR\"] = \"AppSync Realtime subscription init error\";\n CONTROL_MSG[\"SUBSCRIPTION_ACK\"] = \"Subscription ack\";\n CONTROL_MSG[\"TIMEOUT_DISCONNECT\"] = \"Timeout disconnect\";\n})(CONTROL_MSG || (CONTROL_MSG = {}));\n/** @enum {string} */\nexport var ConnectionState;\n(function (ConnectionState) {\n /*\n * The connection is alive and healthy\n */\n ConnectionState[\"Connected\"] = \"Connected\";\n /*\n * The connection is alive, but the connection is offline\n */\n ConnectionState[\"ConnectedPendingNetwork\"] = \"ConnectedPendingNetwork\";\n /*\n * The connection has been disconnected while in use\n */\n ConnectionState[\"ConnectionDisrupted\"] = \"ConnectionDisrupted\";\n /*\n * The connection has been disconnected and the network is offline\n */\n ConnectionState[\"ConnectionDisruptedPendingNetwork\"] = \"ConnectionDisruptedPendingNetwork\";\n /*\n * The connection is in the process of connecting\n */\n ConnectionState[\"Connecting\"] = \"Connecting\";\n /*\n * The connection is not in use and is being disconnected\n */\n ConnectionState[\"ConnectedPendingDisconnect\"] = \"ConnectedPendingDisconnect\";\n /*\n * The connection is not in use and has been disconnected\n */\n ConnectionState[\"Disconnected\"] = \"Disconnected\";\n /*\n * The connection is alive, but a keep alive message has been missed\n */\n ConnectionState[\"ConnectedPendingKeepAlive\"] = \"ConnectedPendingKeepAlive\";\n})(ConnectionState || (ConnectionState = {}));\n"],"names":[],"mappings":"AAAU,IAAC,YAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,kCAAkC,CAAC,GAAG,0CAA0C,CAAC;AACjG,IAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACzD,IAAI,WAAW,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;AAC7D,CAAC,EAAE,WAAW,KAAK,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AACtC;AACU,IAAC,gBAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B;AACA;AACA;AACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC/C;AACA;AACA;AACA,IAAI,eAAe,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AAC3E;AACA;AACA;AACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AACnE;AACA;AACA;AACA,IAAI,eAAe,CAAC,mCAAmC,CAAC,GAAG,mCAAmC,CAAC;AAC/F;AACA;AACA;AACA,IAAI,eAAe,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACjD;AACA;AACA;AACA,IAAI,eAAe,CAAC,4BAA4B,CAAC,GAAG,4BAA4B,CAAC;AACjF;AACA;AACA;AACA,IAAI,eAAe,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACrD;AACA;AACA;AACA,IAAI,eAAe,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAAC;AAC/E,CAAC,EAAE,eAAe,KAAK,eAAe,GAAG,EAAE,CAAC,CAAC;;;;"}
@@ -0,0 +1,2 @@
1
+ export { CONTROL_MSG, ConnectionState } from './PubSub.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,9 +1,10 @@
1
+ import { Observable, map, filter } from 'rxjs';
2
+ import { ConnectionState } from '../types/PubSub.mjs';
3
+ import { ReachabilityMonitor } from './ReachabilityMonitor/index.mjs';
4
+
1
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
6
  // SPDX-License-Identifier: Apache-2.0
3
- import { Observable, map, filter } from 'rxjs';
4
- import { ConnectionState } from '../types/PubSub';
5
- import { ReachabilityMonitor } from './ReachabilityMonitor';
6
- export const CONNECTION_CHANGE = {
7
+ const CONNECTION_CHANGE = {
7
8
  KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
8
9
  KEEP_ALIVE: { keepAliveState: 'healthy' },
9
10
  CONNECTION_ESTABLISHED: { connectionState: 'connected' },
@@ -20,7 +21,7 @@ export const CONNECTION_CHANGE = {
20
21
  ONLINE: { networkState: 'connected' },
21
22
  OFFLINE: { networkState: 'disconnected' },
22
23
  };
23
- export class ConnectionStateMonitor {
24
+ class ConnectionStateMonitor {
24
25
  constructor() {
25
26
  this._networkMonitoringSubscription = undefined;
26
27
  this._linkedConnectionState = {
@@ -126,3 +127,6 @@ export class ConnectionStateMonitor {
126
127
  return ConnectionState.Connected;
127
128
  }
128
129
  }
130
+
131
+ export { CONNECTION_CHANGE, ConnectionStateMonitor };
132
+ //# sourceMappingURL=ConnectionStateMonitor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable, map, filter } from 'rxjs';\nimport { ConnectionState } from '../types/PubSub';\nimport { ReachabilityMonitor } from './ReachabilityMonitor';\nexport const CONNECTION_CHANGE = {\n KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },\n KEEP_ALIVE: { keepAliveState: 'healthy' },\n CONNECTION_ESTABLISHED: { connectionState: 'connected' },\n CONNECTION_FAILED: {\n intendedConnectionState: 'disconnected',\n connectionState: 'disconnected',\n },\n CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },\n OPENING_CONNECTION: {\n intendedConnectionState: 'connected',\n connectionState: 'connecting',\n },\n CLOSED: { connectionState: 'disconnected' },\n ONLINE: { networkState: 'connected' },\n OFFLINE: { networkState: 'disconnected' },\n};\nexport class ConnectionStateMonitor {\n constructor() {\n this._networkMonitoringSubscription = undefined;\n this._linkedConnectionState = {\n networkState: 'connected',\n connectionState: 'disconnected',\n intendedConnectionState: 'disconnected',\n keepAliveState: 'healthy',\n };\n // Attempt to update the state with the current actual network state\n this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new Observable(connectionStateObserver => {\n connectionStateObserver.next(this._linkedConnectionState);\n this._linkedConnectionStateObserver = connectionStateObserver;\n });\n }\n /**\n * Turn network state monitoring on if it isn't on already\n */\n enableNetworkMonitoring() {\n // If no initial network state was discovered, stop trying\n this._initialNetworkStateSubscription?.unsubscribe();\n // Maintain the network state based on the reachability monitor\n if (this._networkMonitoringSubscription === undefined) {\n this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n });\n }\n }\n /**\n * Turn network state monitoring off if it isn't off already\n */\n disableNetworkMonitoring() {\n this._networkMonitoringSubscription?.unsubscribe();\n this._networkMonitoringSubscription = undefined;\n }\n /**\n * Get the observable that allows us to monitor the connection state\n *\n * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates\n */\n get connectionStateObservable() {\n let previous;\n // The linked state aggregates state changes to any of the network, connection,\n // intendedConnection and keepAliveHealth. Some states will change these independent\n // states without changing the overall connection state.\n // After translating from linked states to ConnectionState, then remove any duplicates\n return this._linkedConnectionStateObservable\n .pipe(map(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe(filter(current => {\n const toInclude = current !== previous;\n previous = current;\n return toInclude;\n }));\n }\n /*\n * Updates local connection state and emits the full state to the observer.\n */\n record(statusUpdates) {\n // Maintain the network monitor\n if (statusUpdates.intendedConnectionState === 'connected') {\n this.enableNetworkMonitoring();\n }\n else if (statusUpdates.intendedConnectionState === 'disconnected') {\n this.disableNetworkMonitoring();\n }\n // Maintain the socket state\n const newSocketStatus = {\n ...this._linkedConnectionState,\n ...statusUpdates,\n };\n this._linkedConnectionState = { ...newSocketStatus };\n this._linkedConnectionStateObserver?.next(this._linkedConnectionState);\n }\n /*\n * Translate the ConnectionState structure into a specific ConnectionState string literal union\n */\n connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {\n if (connectionState === 'connected' && networkState === 'disconnected')\n return ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return ConnectionState.Disconnected;\n return ConnectionState.Connected;\n }\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iBAAiB,GAAG;AACjC,IAAI,iBAAiB,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;AACtD,IAAI,UAAU,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;AAC7C,IAAI,sBAAsB,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;AAC5D,IAAI,iBAAiB,EAAE;AACvB,QAAQ,uBAAuB,EAAE,cAAc;AAC/C,QAAQ,eAAe,EAAE,cAAc;AACvC,KAAK;AACL,IAAI,kBAAkB,EAAE,EAAE,uBAAuB,EAAE,cAAc,EAAE;AACnE,IAAI,kBAAkB,EAAE;AACxB,QAAQ,uBAAuB,EAAE,WAAW;AAC5C,QAAQ,eAAe,EAAE,YAAY;AACrC,KAAK;AACL,IAAI,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE;AAC/C,IAAI,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE;AACzC,IAAI,OAAO,EAAE,EAAE,YAAY,E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AAI,CAAC,sBAAsB,CAAC,CAAC;AAC/E,KAAK;AACL;AACA;AACA;AACA,IAAI,0BAA0B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,uBAAuB,EAAE,cAAc,GAAG,EAAE;AAC5G,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,YAAY,KAAK,cAAc;AAC9E,YAAY,OAAO,eAAe,CAAC,uBAAuB,CAAC;AAC3D,QAAQ,IAAI,eAAe,KAAK,WAAW;AAC3C,YAAY,uBAAuB,KAAK,cAAc;AACtD,YAAY,OAAO,eAAe,CAAC,0BAA0B,CAAC;AAC9D,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,YAAY,KAAK,cAAc;AAC3C,YAAY,OAAO,eAAe,CAAC,iCAAiC,CAAC;AACrE,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,OAAO,eAAe,CAAC,mBAAmB,CAAC;AACvD,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;AAC7E,YAAY,OAAO,eAAe,CAAC,yBAAyB,CAAC;AAC7D;AACA,QAAQ,IAAI,eAAe,KAAK,YAAY;AAC5C,YAAY,OAAO,eAAe,CAAC,UAAU,CAAC;AAC9C,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,OAAO,eAAe,CAAC,YAAY,CAAC;AAChD,QAAQ,OAAO,eAAe,CAAC,SAAS,CAAC;AACzC,KAAK;AACL;;;;"}
@@ -0,0 +1 @@
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/dist/esm/Reachability/types").NetworkStatus>;
@@ -1,4 +1,8 @@
1
+ import { Reachability } from '@aws-amplify/core/internals/utils';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
- import { Reachability } from '@aws-amplify/core/internals/utils';
4
- export const ReachabilityMonitor = () => new Reachability().networkMonitor();
5
+ const ReachabilityMonitor = () => new Reachability().networkMonitor();
6
+
7
+ export { ReachabilityMonitor };
8
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor();\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc;;;;"}
@@ -0,0 +1 @@
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/dist/esm/Reachability/types").NetworkStatus>;
@@ -0,0 +1,9 @@
1
+ import { Reachability } from '@aws-amplify/core/internals/utils';
2
+ import NetInfo from '@react-native-community/netinfo';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);
7
+
8
+ export { ReachabilityMonitor };
9
+ //# sourceMappingURL=index.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport { default as NetInfo } from '@react-native-community/netinfo';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc,CAAC,OAAO;;;;"}
@@ -1,5 +1,6 @@
1
- import { RECONNECT_DELAY, RECONNECT_INTERVAL } from '../Providers/constants';
2
- export var ReconnectEvent;
1
+ import { RECONNECT_INTERVAL, RECONNECT_DELAY } from '../Providers/constants.mjs';
2
+
3
+ var ReconnectEvent;
3
4
  (function (ReconnectEvent) {
4
5
  ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
5
6
  ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
@@ -10,7 +11,7 @@ export var ReconnectEvent;
10
11
  * Attempting to reconnect only once creates unrecoverable states when the network state isn't
11
12
  * supported by the browser, so this keeps retrying every minute until halted.
12
13
  */
13
- export class ReconnectionMonitor {
14
+ class ReconnectionMonitor {
14
15
  constructor() {
15
16
  this.reconnectObservers = [];
16
17
  }
@@ -63,3 +64,6 @@ export class ReconnectionMonitor {
63
64
  });
64
65
  }
65
66
  }
67
+
68
+ export { ReconnectEvent, ReconnectionMonitor };
69
+ //# sourceMappingURL=ReconnectionMonitor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReconnectionMonitor.mjs","sources":["../../../src/utils/ReconnectionMonitor.ts"],"sourcesContent":["import { RECONNECT_DELAY, RECONNECT_INTERVAL } from '../Providers/constants';\nexport var ReconnectEvent;\n(function (ReconnectEvent) {\n ReconnectEvent[\"START_RECONNECT\"] = \"START_RECONNECT\";\n ReconnectEvent[\"HALT_RECONNECT\"] = \"HALT_RECONNECT\";\n})(ReconnectEvent || (ReconnectEvent = {}));\n/**\n * Captures the reconnect event logic used to determine when to reconnect to PubSub providers.\n * Reconnnect attempts are delayed by 5 seconds to let the interface settle.\n * Attempting to reconnect only once creates unrecoverable states when the network state isn't\n * supported by the browser, so this keeps retrying every minute until halted.\n */\nexport class ReconnectionMonitor {\n constructor() {\n this.reconnectObservers = [];\n }\n /**\n * Add reconnect observer to the list of observers to alert on reconnect\n */\n addObserver(reconnectObserver) {\n this.reconnectObservers.push(reconnectObserver);\n }\n /**\n * Given a reconnect event, start the appropriate behavior\n */\n record(event) {\n if (event === ReconnectEvent.START_RECONNECT) {\n // If the reconnection hasn't been started\n if (this.reconnectSetTimeoutId === undefined &&\n this.reconnectIntervalId === undefined) {\n this.reconnectSetTimeoutId = setTimeout(() => {\n // Reconnect now\n this._triggerReconnect();\n // Retry reconnect every periodically until it works\n this.reconnectIntervalId = setInterval(() => {\n this._triggerReconnect();\n }, RECONNECT_INTERVAL);\n }, RECONNECT_DELAY);\n }\n }\n if (event === ReconnectEvent.HALT_RECONNECT) {\n if (this.reconnectIntervalId) {\n clearInterval(this.reconnectIntervalId);\n this.reconnectIntervalId = undefined;\n }\n if (this.reconnectSetTimeoutId) {\n clearTimeout(this.reconnectSetTimeoutId);\n this.reconnectSetTimeoutId = undefined;\n }\n }\n }\n /**\n * Complete all reconnect observers\n */\n close() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.complete?.();\n });\n }\n _triggerReconnect() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.next?.();\n });\n }\n}\n"],"names":[],"mappings":";;AACU,IAAC,eAAe;AAC1B,CAAC,UAAU,cAAc,EAAE;AAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC1D,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AACxD,CAAC,EAAE,cAAc,KAAK,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mBAAmB,CAAC;AACjC,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA,IAAI,WAAW,CAAC,iBAAiB,EAAE;AACnC,QAAQ,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACxD,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,CAAC,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,KAAK,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AACL;;;;"}
package/iot/packages.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@aws-amplify/pubsub/iot",
3
- "main": "../lib/clients/iot.js",
4
- "browser": "../lib-esm/clients/iot.js",
5
- "module": "../lib-esm/clients/iot.js",
6
- "typings": "../lib-esm/clients/iot.d.ts"
3
+ "main": "../dist/cjs/clients/iot.js",
4
+ "browser": "../dist/esm/clients/iot.mjs",
5
+ "module": "../dist/esm/clients/iot.mjs",
6
+ "typings": "../dist/esm/clients/iot.d.ts",
7
+ "react-native": "../src/clients/iot.ts"
7
8
  }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@aws-amplify/pubsub/mqtt",
3
- "main": "../lib/clients/mqtt.js",
4
- "browser": "../lib-esm/clients/mqtt.js",
5
- "module": "../lib-esm/clients/mqtt.js",
6
- "typings": "../lib-esm/clients/mqtt.d.ts"
3
+ "main": "../dist/cjs/clients/mqtt.js",
4
+ "browser": "../dist/esm/clients/mqtt.mjs",
5
+ "module": "../dist/esm/clients/mqtt.mjs",
6
+ "typings": "../dist/esm/clients/mqtt.d.ts",
7
+ "react-native": "../src/clients/mqtt.ts"
7
8
  }
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@aws-amplify/pubsub",
3
- "version": "6.0.1-unstable.cfbde4c.0+cfbde4c",
3
+ "version": "6.0.2-unstable.ff4e8d7.0+ff4e8d7",
4
4
  "description": "Pubsub category of aws-amplify",
5
- "main": "./lib/index.js",
6
- "module": "./lib-esm/index.js",
7
- "typings": "./lib-esm/index.d.ts",
8
- "react-native": {
9
- "./lib/index": "./lib-esm/index.js"
10
- },
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "typings": "./dist/esm/index.d.ts",
8
+ "react-native": "./src/index.ts",
11
9
  "sideEffects": false,
12
10
  "publishConfig": {
13
11
  "access": "public"
@@ -15,13 +13,13 @@
15
13
  "scripts": {
16
14
  "test": "npm run lint && jest -w 1 --coverage",
17
15
  "test:size": "size-limit",
18
- "build-with-test": "npm run clean && npm test && tsc && webpack",
19
- "build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && cp -R src/vendor lib/vendor && webpack && webpack --config ./webpack.config.dev.js",
20
- "build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm && cp -R src/vendor lib-esm/vendor",
21
- "build:cjs:watch": "rimraf lib && tsc -m commonjs --outDir lib --watch",
22
- "build:esm:watch": "rimraf lib-esm && tsc -m esnext --outDir lib-esm --watch",
23
- "build": "npm run clean && npm run build:esm && npm run build:cjs",
24
- "clean": "npm run clean:size && rimraf lib-esm lib dist",
16
+ "build-with-test": "npm run clean && npm run build",
17
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
+ "build:esm-cjs": "rollup -c rollup.config.mjs && cp -R src/vendor dist/cjs/vendor && cp -R src/vendor dist/esm/vendor",
19
+ "build:cjs:watch": "rimraf dist/cjs && tsc -m commonjs --outDir dist/cjs --watch",
20
+ "build:esm:watch": "rimraf dist/esm && tsc -m esnext --outDir dist/esm --watch",
21
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
22
+ "clean": "npm run clean:size && rimraf dist lib lib-esm",
25
23
  "clean:size": "rimraf dual-publish-tmp tmp*",
26
24
  "format": "echo \"Not implemented\"",
27
25
  "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
@@ -30,28 +28,31 @@
30
28
  "typesVersions": {
31
29
  ">=4.2": {
32
30
  "iot": [
33
- "./lib-esm/clients/iot.d.ts"
31
+ "./dist/esm/clients/iot.d.ts"
34
32
  ],
35
33
  "mqtt": [
36
- "./lib-esm/clients/mqtt.d.ts"
34
+ "./dist/esm/clients/mqtt.d.ts"
37
35
  ]
38
36
  }
39
37
  },
40
38
  "exports": {
41
39
  ".": {
42
- "types": "./lib-esm/index.d.ts",
43
- "import": "./lib-esm/index.js",
44
- "require": "./lib/index.js"
40
+ "types": "./dist/esm/index.d.ts",
41
+ "import": "./dist/esm/index.mjs",
42
+ "require": "./dist/cjs/index.js",
43
+ "react-native": "./src/index.ts"
45
44
  },
46
45
  "./iot": {
47
- "types": "./lib-esm/clients/iot.d.ts",
48
- "import": "./lib-esm/clients/iot.js",
49
- "require": "./lib/clients/iot.js"
46
+ "types": "./dist/esm/clients/iot.d.ts",
47
+ "import": "./dist/esm/clients/iot.mjs",
48
+ "require": "./dist/cjs/clients/iot.js",
49
+ "react-native": "./src/clients/iot.ts"
50
50
  },
51
51
  "./mqtt": {
52
- "types": "./lib-esm/clients/mqtt.d.ts",
53
- "import": "./lib-esm/clients/mqtt.js",
54
- "require": "./lib/clients/mqtt.js"
52
+ "types": "./dist/esm/clients/mqtt.d.ts",
53
+ "import": "./dist/esm/clients/mqtt.mjs",
54
+ "require": "./dist/cjs/clients/mqtt.js",
55
+ "react-native": "./src/clients/mqtt.ts"
55
56
  }
56
57
  },
57
58
  "repository": {
@@ -65,14 +66,14 @@
65
66
  },
66
67
  "homepage": "https://aws-amplify.github.io/",
67
68
  "files": [
68
- "lib",
69
- "lib-esm",
69
+ "dist/cjs",
70
+ "dist/esm",
70
71
  "src",
71
72
  "iot",
72
73
  "mqtt"
73
74
  ],
74
75
  "dependencies": {
75
- "@aws-amplify/auth": "6.0.1-unstable.cfbde4c.0+cfbde4c",
76
+ "@aws-amplify/auth": "6.0.2-unstable.ff4e8d7.0+ff4e8d7",
76
77
  "buffer": "4.9.2",
77
78
  "graphql": "15.8.0",
78
79
  "rxjs": "^7.8.1",
@@ -80,22 +81,24 @@
80
81
  "url": "0.11.0"
81
82
  },
82
83
  "peerDependencies": {
83
- "@aws-amplify/core": "6.0.1-unstable.cfbde4c.0+cfbde4c"
84
+ "@aws-amplify/core": "6.0.2-unstable.ff4e8d7.0+ff4e8d7"
84
85
  },
85
86
  "devDependencies": {
86
- "@aws-amplify/core": "6.0.1-unstable.cfbde4c.0+cfbde4c",
87
+ "@aws-amplify/core": "6.0.2-unstable.ff4e8d7.0+ff4e8d7",
88
+ "@rollup/plugin-typescript": "11.1.5",
89
+ "rollup": "3.29.4",
87
90
  "typescript": "5.0.2"
88
91
  },
89
92
  "size-limit": [
90
93
  {
91
94
  "name": "PubSub (IoT provider)",
92
- "path": "./lib-esm/index.js",
95
+ "path": "./dist/esm/index.mjs",
93
96
  "import": "{ generateClient }",
94
97
  "limit": "1.2 kB"
95
98
  },
96
99
  {
97
100
  "name": "PubSub (Mqtt provider)",
98
- "path": "./lib-esm/clients/mqtt.js",
101
+ "path": "./dist/esm/clients/mqtt.mjs",
99
102
  "import": "{ generateClient }",
100
103
  "limit": "1.07 kB"
101
104
  }
@@ -139,10 +142,8 @@
139
142
  },
140
143
  "coveragePathIgnorePatterns": [
141
144
  "node_modules",
142
- "dist",
143
- "lib",
144
- "lib-esm"
145
+ "dist"
145
146
  ]
146
147
  },
147
- "gitHead": "cfbde4c7962de77bd43ba20811b84c4d7d333b42"
148
+ "gitHead": "ff4e8d7a5d4e343b5ef6c8cbb86e621ac108da9c"
148
149
  }
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  // @ts-ignore
5
- import * as Paho from '../vendor/paho-mqtt';
5
+ import * as Paho from '../vendor/paho-mqtt.js';
6
6
  import { Observable, SubscriptionLike as Subscription, Observer } from 'rxjs';
7
7
 
8
8
  import { AbstractPubSub } from './PubSub';
@@ -14,7 +14,7 @@ import {
14
14
  PublishInput,
15
15
  SubscribeInput,
16
16
  } from '../types/PubSub';
17
- import { Hub, HubPayload, ConsoleLogger as Logger } from '@aws-amplify/core';
17
+ import { Hub, HubPayload, ConsoleLogger } from '@aws-amplify/core';
18
18
  import { amplifyUuid } from '@aws-amplify/core/internals/utils';
19
19
  import {
20
20
  ConnectionStateMonitor,
@@ -26,7 +26,7 @@ import {
26
26
  } from '../utils/ReconnectionMonitor';
27
27
  import { AMPLIFY_SYMBOL, CONNECTION_STATE_CHANGE } from './constants';
28
28
 
29
- const logger = new Logger('MqttOverWS');
29
+ const logger = new ConsoleLogger('MqttOverWS');
30
30
 
31
31
  export function mqttTopicMatch(filter: string, topic: string) {
32
32
  const filterArray = filter.split('/');
@@ -8,8 +8,8 @@ import {
8
8
  PublishInput,
9
9
  SubscribeInput,
10
10
  } from '../types/PubSub';
11
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
12
- const logger = new Logger('AbstractPubSubProvider');
11
+ import { ConsoleLogger } from '@aws-amplify/core';
12
+ const logger = new ConsoleLogger('AbstractPubSubProvider');
13
13
 
14
14
  export abstract class AbstractPubSub<T extends PubSubOptions>
15
15
  implements PubSubBase
@@ -1,10 +0,0 @@
1
- import { MqttOverWS, MqttOptions } from './MqttOverWS';
2
- export interface AWSIoTOptions extends MqttOptions {
3
- region?: string;
4
- endpoint?: string;
5
- }
6
- export declare class AWSIoT extends MqttOverWS {
7
- constructor(options?: AWSIoTOptions);
8
- protected get region(): string | undefined;
9
- protected get endpoint(): Promise<string>;
10
- }
@@ -1,58 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { AbstractPubSub } from './PubSub';
3
- import { PubSubContentObserver, PubSubContent, PubSubOptions, PublishInput, SubscribeInput } from '../types/PubSub';
4
- export declare function mqttTopicMatch(filter: string, topic: string): boolean;
5
- export interface MqttOptions extends PubSubOptions {
6
- clientId?: string;
7
- url?: string;
8
- endpoint?: string;
9
- }
10
- interface PahoClient {
11
- onMessageArrived: (params: {
12
- destinationName: string;
13
- payloadString: string;
14
- }) => void;
15
- onConnectionLost: (params: {
16
- errorCode: number;
17
- }) => void;
18
- connect: (params: {
19
- [k: string]: string | number | boolean | (() => void);
20
- }) => void;
21
- disconnect: () => void;
22
- isConnected: () => boolean;
23
- subscribe: (topic: string) => void;
24
- unsubscribe: (topic: string) => void;
25
- send(topic: string, message: string): void;
26
- }
27
- declare class ClientsQueue {
28
- private promises;
29
- get(clientId: string, clientFactory?: (input: string) => Promise<PahoClient | undefined>): Promise<PahoClient | undefined>;
30
- get allClients(): string[];
31
- remove(clientId: string): void;
32
- }
33
- export declare class MqttOverWS extends AbstractPubSub<MqttOptions> {
34
- private _clientsQueue;
35
- private connectionState?;
36
- private readonly connectionStateMonitor;
37
- private readonly reconnectionMonitor;
38
- constructor(options?: MqttOptions);
39
- protected get clientId(): string;
40
- protected get endpoint(): Promise<string | undefined>;
41
- protected get clientsQueue(): ClientsQueue;
42
- protected get isSSLEnabled(): boolean;
43
- onDisconnect({ clientId, errorCode, ...args }: {
44
- clientId?: string;
45
- errorCode?: number;
46
- }): void;
47
- newClient({ url, clientId }: MqttOptions): Promise<PahoClient>;
48
- protected connect(clientId: string, options?: MqttOptions): Promise<PahoClient | undefined>;
49
- protected disconnect(clientId: string): Promise<void>;
50
- publish({ topics, message }: PublishInput): Promise<void>;
51
- protected _topicObservers: Map<string, Set<PubSubContentObserver>>;
52
- protected _clientIdObservers: Map<string, Set<PubSubContentObserver>>;
53
- private _onMessage;
54
- subscribe({ topics, options, }: SubscribeInput & {
55
- options?: MqttOptions;
56
- }): Observable<PubSubContent>;
57
- }
58
- export {};
@@ -1,11 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { PubSubBase, PubSubOptions, PubSubContent, PublishInput, SubscribeInput } from '../types/PubSub';
3
- export declare abstract class AbstractPubSub<T extends PubSubOptions> implements PubSubBase {
4
- private _config;
5
- constructor(options: T);
6
- configure(config: T): T;
7
- protected get options(): T;
8
- abstract newClient(clientOptions: T): Promise<any>;
9
- abstract publish(input: PublishInput): void;
10
- abstract subscribe(input: SubscribeInput): Observable<PubSubContent>;
11
- }