@graphprotocol/client-polling-live 2.0.0-alpha-20230529114058-fd0e72a → 2.0.0-alpha-20230529114412-f3e9433
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/cjs/index.js +6 -9
- package/esm/index.js +6 -9
- package/package.json +1 -1
package/cjs/index.js
CHANGED
@@ -19,12 +19,10 @@ function usePollingLive({ config: { defaultInterval = 1000, defaultPauseOnBackgr
|
|
19
19
|
}
|
20
20
|
},
|
21
21
|
onExecute({ args, executeFn, setExecuteFn }) {
|
22
|
-
var _a, _b, _c, _d;
|
23
22
|
let liveDirectiveNode;
|
24
23
|
args.document = (0, graphql_1.visit)(args.document, {
|
25
24
|
OperationDefinition(node) {
|
26
|
-
|
27
|
-
if (args.operationName != null && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) !== args.operationName) {
|
25
|
+
if (args.operationName != null && node.name?.value !== args.operationName) {
|
28
26
|
return;
|
29
27
|
}
|
30
28
|
const directives = [];
|
@@ -46,22 +44,21 @@ function usePollingLive({ config: { defaultInterval = 1000, defaultPauseOnBackgr
|
|
46
44
|
},
|
47
45
|
});
|
48
46
|
if (liveDirectiveNode) {
|
49
|
-
const intervalArgNode =
|
47
|
+
const intervalArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'interval');
|
50
48
|
let pauseOnBackground = defaultPauseOnBackground;
|
51
|
-
const pauseOnBackgroundArgNode =
|
52
|
-
if (
|
49
|
+
const pauseOnBackgroundArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'pauseOnBackground');
|
50
|
+
if (pauseOnBackgroundArgNode?.value?.kind === graphql_1.Kind.BOOLEAN) {
|
53
51
|
pauseOnBackground = pauseOnBackgroundArgNode.value.value;
|
54
52
|
}
|
55
53
|
let intervalMs = defaultInterval;
|
56
|
-
if (
|
54
|
+
if (intervalArgNode?.value?.kind === graphql_1.Kind.INT) {
|
57
55
|
intervalMs = parseInt(intervalArgNode.value.value);
|
58
56
|
}
|
59
57
|
function checkHidden() {
|
60
|
-
var _a, _b;
|
61
58
|
if (!pauseOnBackground) {
|
62
59
|
return false;
|
63
60
|
}
|
64
|
-
return
|
61
|
+
return globalThis.document?.hidden ?? false;
|
65
62
|
}
|
66
63
|
setExecuteFn((args) => new repeater_1.Repeater((push, stop) => {
|
67
64
|
let finished = false;
|
package/esm/index.js
CHANGED
@@ -17,12 +17,10 @@ export default function usePollingLive({ config: { defaultInterval = 1000, defau
|
|
17
17
|
}
|
18
18
|
},
|
19
19
|
onExecute({ args, executeFn, setExecuteFn }) {
|
20
|
-
var _a, _b, _c, _d;
|
21
20
|
let liveDirectiveNode;
|
22
21
|
args.document = visit(args.document, {
|
23
22
|
OperationDefinition(node) {
|
24
|
-
|
25
|
-
if (args.operationName != null && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.value) !== args.operationName) {
|
23
|
+
if (args.operationName != null && node.name?.value !== args.operationName) {
|
26
24
|
return;
|
27
25
|
}
|
28
26
|
const directives = [];
|
@@ -44,22 +42,21 @@ export default function usePollingLive({ config: { defaultInterval = 1000, defau
|
|
44
42
|
},
|
45
43
|
});
|
46
44
|
if (liveDirectiveNode) {
|
47
|
-
const intervalArgNode =
|
45
|
+
const intervalArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'interval');
|
48
46
|
let pauseOnBackground = defaultPauseOnBackground;
|
49
|
-
const pauseOnBackgroundArgNode =
|
50
|
-
if (
|
47
|
+
const pauseOnBackgroundArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'pauseOnBackground');
|
48
|
+
if (pauseOnBackgroundArgNode?.value?.kind === Kind.BOOLEAN) {
|
51
49
|
pauseOnBackground = pauseOnBackgroundArgNode.value.value;
|
52
50
|
}
|
53
51
|
let intervalMs = defaultInterval;
|
54
|
-
if (
|
52
|
+
if (intervalArgNode?.value?.kind === Kind.INT) {
|
55
53
|
intervalMs = parseInt(intervalArgNode.value.value);
|
56
54
|
}
|
57
55
|
function checkHidden() {
|
58
|
-
var _a, _b;
|
59
56
|
if (!pauseOnBackground) {
|
60
57
|
return false;
|
61
58
|
}
|
62
|
-
return
|
59
|
+
return globalThis.document?.hidden ?? false;
|
63
60
|
}
|
64
61
|
setExecuteFn((args) => new Repeater((push, stop) => {
|
65
62
|
let finished = false;
|