@trycourier/react-hooks 5.1.3-internal.e22afd0.0 → 6.0.1-internal.00141d1.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.
- package/dist/inbox/index.js +0 -8
- package/dist/index.js +13 -2
- package/dist/use-transport.js +82 -0
- package/package.json +14 -4
- package/typings/inbox/actions/new-message.d.ts +1 -1
- package/typings/inbox/actions/new-message.d.ts.map +1 -1
- package/typings/inbox/index.d.ts +1 -2
- package/typings/inbox/index.d.ts.map +1 -1
- package/typings/inbox/types.d.ts +2 -1
- package/typings/inbox/types.d.ts.map +1 -1
- package/typings/inbox/use-inbox-actions.d.ts +1 -1
- package/typings/inbox/use-inbox-actions.d.ts.map +1 -1
- package/typings/inbox/use-inbox.d.ts +1 -1
- package/typings/inbox/use-inbox.d.ts.map +1 -1
- package/typings/index.d.ts +1 -0
- package/typings/index.d.ts.map +1 -1
- package/typings/use-transport.d.ts +12 -0
- package/typings/use-transport.d.ts.map +1 -0
package/dist/inbox/index.js
CHANGED
|
@@ -5,12 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "IInboxMessagePreview", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _reactProvider.IInboxMessagePreview;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
8
|
Object.defineProperty(exports, "IInbox", {
|
|
15
9
|
enumerable: true,
|
|
16
10
|
get: function get() {
|
|
@@ -24,8 +18,6 @@ Object.defineProperty(exports, "useInbox", {
|
|
|
24
18
|
}
|
|
25
19
|
});
|
|
26
20
|
|
|
27
|
-
var _reactProvider = require("@trycourier/react-provider");
|
|
28
|
-
|
|
29
21
|
var _types = require("./types");
|
|
30
22
|
|
|
31
23
|
var _useInbox = _interopRequireDefault(require("./use-inbox"));
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -8,7 +10,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
10
|
var _exportNames = {
|
|
9
11
|
usePreferences: true,
|
|
10
12
|
UsePreferences: true,
|
|
11
|
-
PreferenceSection: true
|
|
13
|
+
PreferenceSection: true,
|
|
14
|
+
useTransport: true
|
|
12
15
|
};
|
|
13
16
|
Object.defineProperty(exports, "usePreferences", {
|
|
14
17
|
enumerable: true,
|
|
@@ -28,6 +31,12 @@ Object.defineProperty(exports, "PreferenceSection", {
|
|
|
28
31
|
return _types.PreferenceSection;
|
|
29
32
|
}
|
|
30
33
|
});
|
|
34
|
+
Object.defineProperty(exports, "useTransport", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function get() {
|
|
37
|
+
return _useTransport["default"];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
31
40
|
|
|
32
41
|
var _inbox = require("./inbox");
|
|
33
42
|
|
|
@@ -45,4 +54,6 @@ Object.keys(_inbox).forEach(function (key) {
|
|
|
45
54
|
|
|
46
55
|
var _usePreferences = _interopRequireWildcard(require("./preferences/use-preferences"));
|
|
47
56
|
|
|
48
|
-
var _types = require("./preferences/types");
|
|
57
|
+
var _types = require("./preferences/types");
|
|
58
|
+
|
|
59
|
+
var _useTransport = _interopRequireDefault(require("./use-transport"));
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _transport = require("@trycourier/transport");
|
|
13
|
+
|
|
14
|
+
var _jwtDecode = _interopRequireDefault(require("jwt-decode"));
|
|
15
|
+
|
|
16
|
+
var useTransport = function useTransport(_ref) {
|
|
17
|
+
var tenantId = _ref.tenantId,
|
|
18
|
+
authorization = _ref.authorization,
|
|
19
|
+
clientSourceId = _ref.clientSourceId,
|
|
20
|
+
clientKey = _ref.clientKey,
|
|
21
|
+
transport = _ref.transport,
|
|
22
|
+
userSignature = _ref.userSignature,
|
|
23
|
+
wsOptions = _ref.wsOptions;
|
|
24
|
+
var transportRef = (0, _react.useRef)();
|
|
25
|
+
var newTransport = (0, _react.useMemo)(function () {
|
|
26
|
+
var _transportRef$current;
|
|
27
|
+
|
|
28
|
+
if (transport) {
|
|
29
|
+
return transport;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (authorization && transportRef !== null && transportRef !== void 0 && (_transportRef$current = transportRef.current) !== null && _transportRef$current !== void 0 && _transportRef$current.authorization && transportRef !== null && transportRef !== void 0 && transportRef.current.transport) {
|
|
33
|
+
var _transportRef$current2;
|
|
34
|
+
|
|
35
|
+
var oldDecodedAuth = (0, _jwtDecode["default"])(transportRef === null || transportRef === void 0 ? void 0 : (_transportRef$current2 = transportRef.current) === null || _transportRef$current2 === void 0 ? void 0 : _transportRef$current2.authorization);
|
|
36
|
+
var newDecodedAuth = (0, _jwtDecode["default"])(authorization);
|
|
37
|
+
|
|
38
|
+
if (oldDecodedAuth.scope === newDecodedAuth.scope && oldDecodedAuth.tenantId === newDecodedAuth.tenantId) {
|
|
39
|
+
transportRef.current.transport.renewSession(authorization);
|
|
40
|
+
return transportRef.current.transport;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!clientKey && !authorization) {
|
|
45
|
+
if (undefined !== "production") {
|
|
46
|
+
console.warn("Courier: Missing ClientKey or Authorization");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!clientSourceId) {
|
|
53
|
+
if (undefined !== "production") {
|
|
54
|
+
console.warn("Courier: Missing ClientSourceId");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var newTransport = new _transport.CourierTransport({
|
|
61
|
+
tenantId: tenantId,
|
|
62
|
+
authorization: authorization,
|
|
63
|
+
clientSourceId: clientSourceId,
|
|
64
|
+
clientKey: clientKey,
|
|
65
|
+
userSignature: userSignature,
|
|
66
|
+
wsOptions: wsOptions
|
|
67
|
+
}); // keep track of the transport so we don't reconnect when we don't have to
|
|
68
|
+
|
|
69
|
+
if (authorization) {
|
|
70
|
+
transportRef.current = {
|
|
71
|
+
authorization: authorization,
|
|
72
|
+
transport: newTransport
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return newTransport;
|
|
77
|
+
}, [tenantId, authorization, clientKey, transport, userSignature, wsOptions]);
|
|
78
|
+
return newTransport;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var _default = useTransport;
|
|
82
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/react-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1-internal.00141d1.0+00141d1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "typings/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"concat-md": "^0.3.5"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@trycourier/client-graphql": "^
|
|
23
|
+
"@trycourier/client-graphql": "^6.0.1-internal.00141d1.0+00141d1",
|
|
24
|
+
"@trycourier/core": "^6.0.1-internal.00141d1.0+00141d1",
|
|
24
25
|
"deep-extend": "^0.6.0",
|
|
25
26
|
"rimraf": "^3.0.2"
|
|
26
27
|
},
|
|
@@ -33,8 +34,17 @@
|
|
|
33
34
|
"typings/"
|
|
34
35
|
],
|
|
35
36
|
"exports": {
|
|
36
|
-
".":
|
|
37
|
+
".": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./typings/index.d.ts",
|
|
40
|
+
"default": "./dist/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./typings/index.d.ts",
|
|
44
|
+
"default": "./dist/index.js"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
37
47
|
"./use-inbox": "./dist/inbox/use-inbox.js"
|
|
38
48
|
},
|
|
39
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "00141d141f9340b87df46100da169d0c17a79b34"
|
|
40
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-message.d.ts","sourceRoot":"","sources":["../../../src/inbox/actions/new-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"new-message.d.ts","sourceRoot":"","sources":["../../../src/inbox/actions/new-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,oBAAoB,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,eAAO,MAAM,UAAU,YAAa,oBAAoB,KAAG,UAGzD,CAAC"}
|
package/typings/inbox/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/typings/inbox/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Brand, IInboxMessagePreview
|
|
1
|
+
import { Brand, IInboxMessagePreview } from "@trycourier/core";
|
|
2
|
+
import { OnEvent } from "@trycourier/react-provider";
|
|
2
3
|
export interface IInbox<T = IInboxMessagePreview> {
|
|
3
4
|
tenantId?: string;
|
|
4
5
|
brand?: Brand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,oBAAoB;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IInboxMessagePreview } from "@trycourier/react-provider";
|
|
2
1
|
import { IInbox } from "./types";
|
|
3
2
|
import { IGetInboxMessagesParams } from "@trycourier/client-graphql";
|
|
3
|
+
import { IInboxMessagePreview } from "@trycourier/core";
|
|
4
4
|
export interface IFetchMessagesParams {
|
|
5
5
|
params?: IGetInboxMessagesParams;
|
|
6
6
|
after?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-inbox-actions.d.ts","sourceRoot":"","sources":["../../src/inbox/use-inbox-actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-inbox-actions.d.ts","sourceRoot":"","sources":["../../src/inbox/use-inbox-actions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAS,MAAM,4BAA4B,CAAC;AAmB5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,qBAAqB,EAAE,CAAC,MAAM,CAAC,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAClE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,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
|
|
2
1
|
import { IInboxActions } from "./use-inbox-actions";
|
|
3
2
|
import { IInbox } from "./types";
|
|
3
|
+
import { IInboxMessagePreview } from "@trycourier/core";
|
|
4
4
|
declare const useInbox: () => IInbox<IInboxMessagePreview> & IInboxActions;
|
|
5
5
|
export default useInbox;
|
|
6
6
|
//# sourceMappingURL=use-inbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-inbox.d.ts","sourceRoot":"","sources":["../../src/inbox/use-inbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-inbox.d.ts","sourceRoot":"","sources":["../../src/inbox/use-inbox.ts"],"names":[],"mappings":"AAKA,OAAwB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAwB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,QAAA,MAAM,QAAQ,QAAO,OAAO,oBAAoB,CAAC,GAAG,aAkFnD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./inbox";
|
|
2
2
|
export { default as usePreferences, UsePreferences, } from "./preferences/use-preferences";
|
|
3
3
|
export { PreferenceSection } from "./preferences/types";
|
|
4
|
+
export { default as useTransport } from "./use-transport";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CourierTransport, Transport, ITransportOptions } from "@trycourier/transport";
|
|
2
|
+
declare const useTransport: ({ tenantId, authorization, clientSourceId, clientKey, transport, userSignature, wsOptions, }: {
|
|
3
|
+
tenantId?: string | undefined;
|
|
4
|
+
authorization?: string | undefined;
|
|
5
|
+
clientSourceId?: string | undefined;
|
|
6
|
+
clientKey?: string | undefined;
|
|
7
|
+
transport?: CourierTransport | Transport | undefined;
|
|
8
|
+
userSignature?: string | undefined;
|
|
9
|
+
wsOptions?: ITransportOptions["wsOptions"];
|
|
10
|
+
}) => CourierTransport | Transport | undefined;
|
|
11
|
+
export default useTransport;
|
|
12
|
+
//# sourceMappingURL=use-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-transport.d.ts","sourceRoot":"","sources":["../src/use-transport.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAO/B,QAAA,MAAM,YAAY;;;;;;;gBAeJ,iBAAiB,CAAC,WAAW,CAAC;MACxC,gBAAgB,GAAG,SAAS,GAAG,SAiElC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|