@jobber/hooks 2.0.0 → 2.0.2-pre.14
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/index.js +24 -13
- package/dist/useAssert/index.js +2 -1
- package/dist/useAssert/useAssert.js +2 -1
- package/dist/useCollectionQuery/index.js +2 -1
- package/dist/useCollectionQuery/mdxUtils.js +19 -7
- package/dist/useCollectionQuery/test-utilities/index.js +17 -6
- package/dist/useCollectionQuery/test-utilities/mocks.d.ts +3 -3
- package/dist/useCollectionQuery/test-utilities/mocks.js +17 -17
- package/dist/useCollectionQuery/test-utilities/queries.js +57 -9
- package/dist/useCollectionQuery/test-utilities/utils.js +4 -38
- package/dist/useCollectionQuery/uniqueEdges.js +5 -4
- package/dist/useCollectionQuery/uniqueNodes.js +4 -3
- package/dist/useCollectionQuery/useCollectionQuery.d.ts +2 -2
- package/dist/useCollectionQuery/useCollectionQuery.js +60 -101
- package/dist/useCollectionQuery/useCollectionQuery.test.js +240 -438
- package/dist/useFocusTrap/index.js +2 -1
- package/dist/useFocusTrap/useFocusTrap.d.ts +1 -0
- package/dist/useFocusTrap/useFocusTrap.js +11 -10
- package/dist/useFocusTrap/useFocusTrap.test.js +19 -20
- package/dist/useFormState/index.js +2 -1
- package/dist/useFormState/useFormState.d.ts +1 -0
- package/dist/useFormState/useFormState.js +5 -20
- package/dist/useIsMounted/index.js +2 -1
- package/dist/useIsMounted/useIsMounted.js +5 -4
- package/dist/useIsMounted/useIsMounted.test.js +8 -8
- package/dist/useLiveAnnounce/index.js +2 -1
- package/dist/useLiveAnnounce/useLiveAnnounce.js +9 -24
- package/dist/useLiveAnnounce/useLiveAnnounce.test.js +36 -97
- package/dist/useOnKeyDown/index.js +2 -1
- package/dist/useOnKeyDown/useOnKeyDown.d.ts +2 -2
- package/dist/useOnKeyDown/useOnKeyDown.js +7 -6
- package/dist/useOnKeyDown/useOnKeyDown.test.js +9 -10
- package/dist/usePasswordStrength/index.js +2 -1
- package/dist/usePasswordStrength/usePasswordStrength.js +9 -8
- package/dist/useRefocusOnActivator/index.js +2 -1
- package/dist/useRefocusOnActivator/useRefocusOnActivator.js +5 -4
- package/dist/useResizeObserver/index.js +15 -4
- package/dist/useResizeObserver/useResizeObserver.d.ts +1 -0
- package/dist/useResizeObserver/useResizeObserver.js +20 -36
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
__exportStar(require("./useAssert"), exports);
|
|
18
|
+
__exportStar(require("./useCollectionQuery"), exports);
|
|
19
|
+
__exportStar(require("./useFocusTrap"), exports);
|
|
20
|
+
__exportStar(require("./useFormState"), exports);
|
|
21
|
+
__exportStar(require("./useIsMounted"), exports);
|
|
22
|
+
__exportStar(require("./useLiveAnnounce"), exports);
|
|
23
|
+
__exportStar(require("./useOnKeyDown"), exports);
|
|
24
|
+
__exportStar(require("./usePasswordStrength"), exports);
|
|
25
|
+
__exportStar(require("./useRefocusOnActivator"), exports);
|
|
26
|
+
__exportStar(require("./useResizeObserver"), exports);
|
package/dist/useAssert/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAssert = void 0;
|
|
3
4
|
var useAssert_1 = require("./useAssert");
|
|
4
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return useAssert_1.useAssert; } });
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
exports.useAssert = void 0;
|
|
7
|
+
const process_1 = __importDefault(require("process"));
|
|
7
8
|
function useAssert(shouldShow, message, options) {
|
|
8
9
|
if (process_1.default.env.NODE_ENV !== "production" && shouldShow) {
|
|
9
10
|
if (options === null || options === void 0 ? void 0 : options.warn) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCollectionQuery = void 0;
|
|
3
4
|
var useCollectionQuery_1 = require("./useCollectionQuery");
|
|
4
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "useCollectionQuery", { enumerable: true, get: function () { return useCollectionQuery_1.useCollectionQuery; } });
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
exports.returnValues = exports.subscriptionPropsList = exports.propsList = exports.getLoadingState = exports.apolloClient = exports.LIST_QUERY = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
5
|
+
exports.LIST_QUERY = (0, client_1.gql) `
|
|
6
|
+
query ListQuery($cursor: String) {
|
|
7
|
+
allPlanets(first: 4, after: $cursor) {
|
|
8
|
+
pageInfo {
|
|
9
|
+
hasNextPage
|
|
10
|
+
endCursor
|
|
11
|
+
}
|
|
12
|
+
edges {
|
|
13
|
+
node {
|
|
14
|
+
name
|
|
15
|
+
id
|
|
16
|
+
}
|
|
17
|
+
cursor
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
9
22
|
exports.apolloClient = new client_1.ApolloClient({
|
|
10
23
|
uri: "https://swapi-graphql.netlify.app/.netlify/functions/index",
|
|
11
24
|
cache: new client_1.InMemoryCache(),
|
|
@@ -137,4 +150,3 @@ exports.returnValues = [
|
|
|
137
150
|
value: "boolean",
|
|
138
151
|
},
|
|
139
152
|
];
|
|
140
|
-
var templateObject_1;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
__exportStar(require("./queries"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./mocks"), exports);
|
|
@@ -28,7 +28,7 @@ export declare const listQueryResponseMock: jest.Mock<{
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
}, [any]>;
|
|
31
|
+
}, [id: any]>;
|
|
32
32
|
export declare const listQueryWithTotalCountResponseMock: jest.Mock<{
|
|
33
33
|
data: {
|
|
34
34
|
conversation: {
|
|
@@ -55,7 +55,7 @@ export declare const listQueryWithTotalCountResponseMock: jest.Mock<{
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
}, [any]>;
|
|
58
|
+
}, [id: any]>;
|
|
59
59
|
export declare const subscriptionQueryMock: jest.Mock<{
|
|
60
60
|
data: {
|
|
61
61
|
conversationMessage: {
|
|
@@ -67,7 +67,7 @@ export declare const subscriptionQueryMock: jest.Mock<{
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
}, [any]>;
|
|
70
|
+
}, [id: any]>;
|
|
71
71
|
export declare function buildListRequestMock(query: DocumentNode, responseMock: jest.Mock, id?: string | undefined, searchTerm?: string | undefined): {
|
|
72
72
|
request: {
|
|
73
73
|
query: DocumentNode;
|
|
@@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
exports.setListQueryMockHasNextPage = exports.buildListRequestMockForNextPage = exports.buildSubscriptionRequestMock = exports.buildListRequestMock = exports.subscriptionQueryMock = exports.listQueryWithTotalCountResponseMock = exports.listQueryResponseMock = exports.wrapper = void 0;
|
|
7
|
+
const react_testing_1 = require("@apollo/react-testing");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const queries_1 = require("./queries");
|
|
10
11
|
function wrapper(mocks) {
|
|
11
|
-
function ApolloMockedProvider(
|
|
12
|
-
var children = _a.children;
|
|
12
|
+
function ApolloMockedProvider({ children, }) {
|
|
13
13
|
return (react_1.default.createElement(react_testing_1.MockedProvider, { addTypename: true, mocks: mocks }, children));
|
|
14
14
|
}
|
|
15
15
|
return ApolloMockedProvider;
|
|
16
16
|
}
|
|
17
17
|
exports.wrapper = wrapper;
|
|
18
|
-
|
|
19
|
-
exports.listQueryResponseMock = jest.fn(
|
|
18
|
+
let listQueryHasNextPage = true;
|
|
19
|
+
exports.listQueryResponseMock = jest.fn(id => {
|
|
20
20
|
return {
|
|
21
21
|
data: {
|
|
22
22
|
conversation: {
|
|
@@ -28,14 +28,14 @@ exports.listQueryResponseMock = jest.fn(function (id) {
|
|
|
28
28
|
__typename: "SMSMessageEdge",
|
|
29
29
|
node: {
|
|
30
30
|
__typename: "SMSMessage",
|
|
31
|
-
id: id || uuid_1.v1(),
|
|
31
|
+
id: id || (0, uuid_1.v1)(),
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
35
|
nodes: [
|
|
36
36
|
{
|
|
37
37
|
__typename: "SMSMessage",
|
|
38
|
-
id: id || uuid_1.v1(),
|
|
38
|
+
id: id || (0, uuid_1.v1)(),
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
pageInfo: {
|
|
@@ -48,7 +48,7 @@ exports.listQueryResponseMock = jest.fn(function (id) {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
|
-
exports.listQueryWithTotalCountResponseMock = jest.fn(
|
|
51
|
+
exports.listQueryWithTotalCountResponseMock = jest.fn(id => {
|
|
52
52
|
return {
|
|
53
53
|
data: {
|
|
54
54
|
conversation: {
|
|
@@ -60,14 +60,14 @@ exports.listQueryWithTotalCountResponseMock = jest.fn(function (id) {
|
|
|
60
60
|
__typename: "SMSMessageEdge",
|
|
61
61
|
node: {
|
|
62
62
|
__typename: "SMSMessage",
|
|
63
|
-
id: id || uuid_1.v1(),
|
|
63
|
+
id: id || (0, uuid_1.v1)(),
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
67
|
nodes: [
|
|
68
68
|
{
|
|
69
69
|
__typename: "SMSMessage",
|
|
70
|
-
id: id || uuid_1.v1(),
|
|
70
|
+
id: id || (0, uuid_1.v1)(),
|
|
71
71
|
},
|
|
72
72
|
],
|
|
73
73
|
pageInfo: {
|
|
@@ -81,7 +81,7 @@ exports.listQueryWithTotalCountResponseMock = jest.fn(function (id) {
|
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
83
|
});
|
|
84
|
-
exports.subscriptionQueryMock = jest.fn(
|
|
84
|
+
exports.subscriptionQueryMock = jest.fn(id => {
|
|
85
85
|
return {
|
|
86
86
|
data: {
|
|
87
87
|
conversationMessage: {
|
|
@@ -101,7 +101,7 @@ function buildListRequestMock(query, responseMock, id, searchTerm) {
|
|
|
101
101
|
query: query,
|
|
102
102
|
variables: { searchTerm: searchTerm },
|
|
103
103
|
},
|
|
104
|
-
result:
|
|
104
|
+
result: () => responseMock(id),
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
exports.buildListRequestMock = buildListRequestMock;
|
|
@@ -110,7 +110,7 @@ function buildSubscriptionRequestMock(id) {
|
|
|
110
110
|
request: {
|
|
111
111
|
query: queries_1.SUBSCRIPTION_QUERY,
|
|
112
112
|
},
|
|
113
|
-
result:
|
|
113
|
+
result: () => (0, exports.subscriptionQueryMock)(id),
|
|
114
114
|
delay: 100,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
@@ -121,7 +121,7 @@ function buildListRequestMockForNextPage(query, responseMock, id) {
|
|
|
121
121
|
query: query,
|
|
122
122
|
variables: { cursor: "MZ" },
|
|
123
123
|
},
|
|
124
|
-
result:
|
|
124
|
+
result: () => responseMock(id),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
exports.buildListRequestMockForNextPage = buildListRequestMockForNextPage;
|
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
exports.SUBSCRIPTION_QUERY = exports.LIST_QUERY_WITH_TOTAL_COUNT = exports.LIST_QUERY = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
5
|
+
exports.LIST_QUERY = (0, client_1.gql) `
|
|
6
|
+
query ConversationMessages($cursor: string, $searchTerm: string) {
|
|
7
|
+
conversation(id: "MQ==") {
|
|
8
|
+
smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {
|
|
9
|
+
edges {
|
|
10
|
+
node {
|
|
11
|
+
__typename
|
|
12
|
+
id
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
nodes {
|
|
16
|
+
__typename
|
|
17
|
+
id
|
|
18
|
+
}
|
|
19
|
+
pageInfo {
|
|
20
|
+
endCursor
|
|
21
|
+
hasNextPage
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
exports.LIST_QUERY_WITH_TOTAL_COUNT = (0, client_1.gql) `
|
|
28
|
+
query ConversationMessages($cursor: string, $searchTerm: string) {
|
|
29
|
+
conversation(id: "MQ==") {
|
|
30
|
+
smsMessages(first: 1, after: $cursor, searchTerm: $searchTerm) {
|
|
31
|
+
edges {
|
|
32
|
+
node {
|
|
33
|
+
__typename
|
|
34
|
+
id
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
nodes {
|
|
38
|
+
__typename
|
|
39
|
+
id
|
|
40
|
+
}
|
|
41
|
+
pageInfo {
|
|
42
|
+
endCursor
|
|
43
|
+
hasNextPage
|
|
44
|
+
}
|
|
45
|
+
totalCount
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
exports.SUBSCRIPTION_QUERY = (0, client_1.gql) `
|
|
51
|
+
subscription ConversationMessage($conversationId: EncodedId!) {
|
|
52
|
+
conversationMessage(conversationId: $conversationId) {
|
|
53
|
+
smsMessage {
|
|
54
|
+
__typename
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
@@ -8,45 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
|
|
43
|
-
switch (_a.label) {
|
|
44
|
-
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, milliseconds); })];
|
|
45
|
-
case 1:
|
|
46
|
-
_a.sent();
|
|
47
|
-
return [2 /*return*/];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
12
|
+
exports.wait = void 0;
|
|
13
|
+
function wait(milliseconds = 0) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
yield new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
50
16
|
});
|
|
51
17
|
}
|
|
52
18
|
exports.wait = wait;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueEdges = exports.createEdge = void 0;
|
|
3
4
|
function createEdge(node) {
|
|
4
5
|
return {
|
|
5
6
|
node: node,
|
|
6
7
|
cursor: "",
|
|
7
|
-
__typename: node.__typename
|
|
8
|
+
__typename: `${node.__typename}Edge`,
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
11
|
exports.createEdge = createEdge;
|
|
11
12
|
function uniqueEdges(edges) {
|
|
12
|
-
|
|
13
|
-
edges.forEach(
|
|
14
|
-
result.set(edge.__typename
|
|
13
|
+
const result = new Map();
|
|
14
|
+
edges.forEach(edge => {
|
|
15
|
+
result.set(`${edge.__typename}-${edge.node.__typename}-${edge.node.id}`, edge);
|
|
15
16
|
});
|
|
16
17
|
return Array.from(result.values());
|
|
17
18
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueNodes = void 0;
|
|
3
4
|
function uniqueNodes(nodes) {
|
|
4
|
-
|
|
5
|
-
nodes.forEach(
|
|
6
|
-
result.set(node.__typename
|
|
5
|
+
const result = new Map();
|
|
6
|
+
nodes.forEach(node => {
|
|
7
|
+
result.set(`${node.__typename}-${node.id}`, node);
|
|
7
8
|
});
|
|
8
9
|
return Array.from(result.values());
|
|
9
10
|
}
|
|
@@ -64,8 +64,8 @@ interface CollectionQueryResult<TQuery> {
|
|
|
64
64
|
refresh(): void;
|
|
65
65
|
nextPage(): void;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
type GetCollectionByPathFunction<TQuery> = (data: TQuery | undefined) => Collection | undefined;
|
|
68
|
+
type GetNodeByPath<TSubscription> = (data: TSubscription | undefined) => Node | undefined;
|
|
69
69
|
export declare function useCollectionQuery<TQuery, TSubscription = undefined>({ query, queryOptions, getCollectionByPath, subscription, }: UseCollectionQueryArguments<TQuery, TSubscription>): CollectionQueryResult<TQuery>;
|
|
70
70
|
export declare function isAlreadyUpdated(outputCollection: Collection, newNode: Node): boolean;
|
|
71
71
|
export {};
|