@graphprotocol/client-polling-live 1.0.2-alpha-20221208174851-df44cb6 → 1.1.0-alpha-20230110145237-1560b86
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 +20 -14
 - package/esm/index.js +20 -14
 - package/package.json +1 -1
 
    
        package/cjs/index.js
    CHANGED
    
    | 
         @@ -49,27 +49,33 @@ function usePollingLive({ config: { defaultInterval = 1000 } = {} } = {}) { 
     | 
|
| 
       49 
49 
     | 
    
         
             
                            if (((_b = intervalArgNode === null || intervalArgNode === void 0 ? void 0 : intervalArgNode.value) === null || _b === void 0 ? void 0 : _b.kind) === graphql_1.Kind.INT) {
         
     | 
| 
       50 
50 
     | 
    
         
             
                                intervalMs = parseInt(intervalArgNode.value.value);
         
     | 
| 
       51 
51 
     | 
    
         
             
                            }
         
     | 
| 
      
 52 
     | 
    
         
            +
                            function checkHidden() {
         
     | 
| 
      
 53 
     | 
    
         
            +
                                var _a, _b;
         
     | 
| 
      
 54 
     | 
    
         
            +
                                return (_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.hidden) !== null && _b !== void 0 ? _b : false;
         
     | 
| 
      
 55 
     | 
    
         
            +
                            }
         
     | 
| 
       52 
56 
     | 
    
         
             
                            setExecuteFn((args) => new repeater_1.Repeater((push, stop) => {
         
     | 
| 
       53 
57 
     | 
    
         
             
                                let finished = false;
         
     | 
| 
       54 
58 
     | 
    
         
             
                                async function pump() {
         
     | 
| 
       55 
59 
     | 
    
         
             
                                    if (finished) {
         
     | 
| 
       56 
60 
     | 
    
         
             
                                        return;
         
     | 
| 
       57 
61 
     | 
    
         
             
                                    }
         
     | 
| 
       58 
     | 
    
         
            -
                                     
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                                         
     | 
| 
       61 
     | 
    
         
            -
                                             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                                         
     | 
| 
      
 62 
     | 
    
         
            +
                                    if (!checkHidden()) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                                        const result = await executeFn(args);
         
     | 
| 
      
 64 
     | 
    
         
            +
                                        if ((0, core_1.isAsyncIterable)(result)) {
         
     | 
| 
      
 65 
     | 
    
         
            +
                                            push({
         
     | 
| 
      
 66 
     | 
    
         
            +
                                                data: null,
         
     | 
| 
      
 67 
     | 
    
         
            +
                                                errors: [new graphql_1.GraphQLError('Execution returned AsyncIterable which is not supported!')],
         
     | 
| 
      
 68 
     | 
    
         
            +
                                                isLive: true,
         
     | 
| 
      
 69 
     | 
    
         
            +
                                            });
         
     | 
| 
      
 70 
     | 
    
         
            +
                                            stop();
         
     | 
| 
      
 71 
     | 
    
         
            +
                                            return;
         
     | 
| 
      
 72 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 73 
     | 
    
         
            +
                                        result.isLive = true;
         
     | 
| 
      
 74 
     | 
    
         
            +
                                        if (finished) {
         
     | 
| 
      
 75 
     | 
    
         
            +
                                            return;
         
     | 
| 
      
 76 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 77 
     | 
    
         
            +
                                        push(result);
         
     | 
| 
       71 
78 
     | 
    
         
             
                                    }
         
     | 
| 
       72 
     | 
    
         
            -
                                    push(result);
         
     | 
| 
       73 
79 
     | 
    
         
             
                                    setTimeout(pump, intervalMs);
         
     | 
| 
       74 
80 
     | 
    
         
             
                                }
         
     | 
| 
       75 
81 
     | 
    
         
             
                                pump();
         
     | 
    
        package/esm/index.js
    CHANGED
    
    | 
         @@ -47,27 +47,33 @@ export default function usePollingLive({ config: { defaultInterval = 1000 } = {} 
     | 
|
| 
       47 
47 
     | 
    
         
             
                            if (((_b = intervalArgNode === null || intervalArgNode === void 0 ? void 0 : intervalArgNode.value) === null || _b === void 0 ? void 0 : _b.kind) === Kind.INT) {
         
     | 
| 
       48 
48 
     | 
    
         
             
                                intervalMs = parseInt(intervalArgNode.value.value);
         
     | 
| 
       49 
49 
     | 
    
         
             
                            }
         
     | 
| 
      
 50 
     | 
    
         
            +
                            function checkHidden() {
         
     | 
| 
      
 51 
     | 
    
         
            +
                                var _a, _b;
         
     | 
| 
      
 52 
     | 
    
         
            +
                                return (_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.hidden) !== null && _b !== void 0 ? _b : false;
         
     | 
| 
      
 53 
     | 
    
         
            +
                            }
         
     | 
| 
       50 
54 
     | 
    
         
             
                            setExecuteFn((args) => new Repeater((push, stop) => {
         
     | 
| 
       51 
55 
     | 
    
         
             
                                let finished = false;
         
     | 
| 
       52 
56 
     | 
    
         
             
                                async function pump() {
         
     | 
| 
       53 
57 
     | 
    
         
             
                                    if (finished) {
         
     | 
| 
       54 
58 
     | 
    
         
             
                                        return;
         
     | 
| 
       55 
59 
     | 
    
         
             
                                    }
         
     | 
| 
       56 
     | 
    
         
            -
                                     
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                                         
     | 
| 
       59 
     | 
    
         
            -
                                             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                                         
     | 
| 
      
 60 
     | 
    
         
            +
                                    if (!checkHidden()) {
         
     | 
| 
      
 61 
     | 
    
         
            +
                                        const result = await executeFn(args);
         
     | 
| 
      
 62 
     | 
    
         
            +
                                        if (isAsyncIterable(result)) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                                            push({
         
     | 
| 
      
 64 
     | 
    
         
            +
                                                data: null,
         
     | 
| 
      
 65 
     | 
    
         
            +
                                                errors: [new GraphQLError('Execution returned AsyncIterable which is not supported!')],
         
     | 
| 
      
 66 
     | 
    
         
            +
                                                isLive: true,
         
     | 
| 
      
 67 
     | 
    
         
            +
                                            });
         
     | 
| 
      
 68 
     | 
    
         
            +
                                            stop();
         
     | 
| 
      
 69 
     | 
    
         
            +
                                            return;
         
     | 
| 
      
 70 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 71 
     | 
    
         
            +
                                        result.isLive = true;
         
     | 
| 
      
 72 
     | 
    
         
            +
                                        if (finished) {
         
     | 
| 
      
 73 
     | 
    
         
            +
                                            return;
         
     | 
| 
      
 74 
     | 
    
         
            +
                                        }
         
     | 
| 
      
 75 
     | 
    
         
            +
                                        push(result);
         
     | 
| 
       69 
76 
     | 
    
         
             
                                    }
         
     | 
| 
       70 
     | 
    
         
            -
                                    push(result);
         
     | 
| 
       71 
77 
     | 
    
         
             
                                    setTimeout(pump, intervalMs);
         
     | 
| 
       72 
78 
     | 
    
         
             
                                }
         
     | 
| 
       73 
79 
     | 
    
         
             
                                pump();
         
     |