@graphprotocol/client-polling-live 2.0.0-alpha-20230529114058-fd0e72a → 2.0.0-rc-20230529114534-751ce44

Sign up to get free protection for your applications and to get access to all the features.
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
- var _a;
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 = (_a = liveDirectiveNode.arguments) === null || _a === void 0 ? void 0 : _a.find((argNode) => argNode.name.value === 'interval');
47
+ const intervalArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'interval');
50
48
  let pauseOnBackground = defaultPauseOnBackground;
51
- const pauseOnBackgroundArgNode = (_b = liveDirectiveNode.arguments) === null || _b === void 0 ? void 0 : _b.find((argNode) => argNode.name.value === 'pauseOnBackground');
52
- if (((_c = pauseOnBackgroundArgNode === null || pauseOnBackgroundArgNode === void 0 ? void 0 : pauseOnBackgroundArgNode.value) === null || _c === void 0 ? void 0 : _c.kind) === graphql_1.Kind.BOOLEAN) {
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 (((_d = intervalArgNode === null || intervalArgNode === void 0 ? void 0 : intervalArgNode.value) === null || _d === void 0 ? void 0 : _d.kind) === graphql_1.Kind.INT) {
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 (_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.hidden) !== null && _b !== void 0 ? _b : false;
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
- var _a;
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 = (_a = liveDirectiveNode.arguments) === null || _a === void 0 ? void 0 : _a.find((argNode) => argNode.name.value === 'interval');
45
+ const intervalArgNode = liveDirectiveNode.arguments?.find((argNode) => argNode.name.value === 'interval');
48
46
  let pauseOnBackground = defaultPauseOnBackground;
49
- const pauseOnBackgroundArgNode = (_b = liveDirectiveNode.arguments) === null || _b === void 0 ? void 0 : _b.find((argNode) => argNode.name.value === 'pauseOnBackground');
50
- if (((_c = pauseOnBackgroundArgNode === null || pauseOnBackgroundArgNode === void 0 ? void 0 : pauseOnBackgroundArgNode.value) === null || _c === void 0 ? void 0 : _c.kind) === Kind.BOOLEAN) {
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 (((_d = intervalArgNode === null || intervalArgNode === void 0 ? void 0 : intervalArgNode.value) === null || _d === void 0 ? void 0 : _d.kind) === Kind.INT) {
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 (_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.hidden) !== null && _b !== void 0 ? _b : false;
59
+ return globalThis.document?.hidden ?? false;
63
60
  }
64
61
  setExecuteFn((args) => new Repeater((push, stop) => {
65
62
  let finished = false;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphprotocol/client-polling-live",
3
- "version": "2.0.0-alpha-20230529114058-fd0e72a",
3
+ "version": "2.0.0-rc-20230529114534-751ce44",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^15.2.0 || ^16.0.0",
8
- "@graphql-tools/merge": "^8.3.14",
9
- "@envelop/core": "^2.4.2 || ^3.0.0"
8
+ "@graphql-tools/merge": "^8.3.14 || ^9.0.0",
9
+ "@envelop/core": "^2.4.2 || ^3.0.0 || ^4.0.0"
10
10
  },
11
11
  "dependencies": {
12
12
  "@repeaterjs/repeater": "^3.0.4",