[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/js/dist/ -> api-fetch.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["apiFetch"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = "./node_modules/@wordpress/api-fetch/build-module/index.js");
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js":
  91  /*!*********************************************************************!*\
  92    !*** ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js ***!
  93    \*********************************************************************/
  94  /*! exports provided: default */
  95  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96  
  97  "use strict";
  98  __webpack_require__.r(__webpack_exports__);
  99  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _asyncToGenerator; });
 100  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
 101    try {
 102      var info = gen[key](arg);
 103      var value = info.value;
 104    } catch (error) {
 105      reject(error);
 106      return;
 107    }
 108  
 109    if (info.done) {
 110      resolve(value);
 111    } else {
 112      Promise.resolve(value).then(_next, _throw);
 113    }
 114  }
 115  
 116  function _asyncToGenerator(fn) {
 117    return function () {
 118      var self = this,
 119          args = arguments;
 120      return new Promise(function (resolve, reject) {
 121        var gen = fn.apply(self, args);
 122  
 123        function _next(value) {
 124          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
 125        }
 126  
 127        function _throw(err) {
 128          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
 129        }
 130  
 131        _next(undefined);
 132      });
 133    };
 134  }
 135  
 136  /***/ }),
 137  
 138  /***/ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js":
 139  /*!*******************************************************************!*\
 140    !*** ./node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
 141    \*******************************************************************/
 142  /*! exports provided: default */
 143  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 144  
 145  "use strict";
 146  __webpack_require__.r(__webpack_exports__);
 147  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _defineProperty; });
 148  function _defineProperty(obj, key, value) {
 149    if (key in obj) {
 150      Object.defineProperty(obj, key, {
 151        value: value,
 152        enumerable: true,
 153        configurable: true,
 154        writable: true
 155      });
 156    } else {
 157      obj[key] = value;
 158    }
 159  
 160    return obj;
 161  }
 162  
 163  /***/ }),
 164  
 165  /***/ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js":
 166  /*!*****************************************************************!*\
 167    !*** ./node_modules/@babel/runtime/helpers/esm/objectSpread.js ***!
 168    \*****************************************************************/
 169  /*! exports provided: default */
 170  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 171  
 172  "use strict";
 173  __webpack_require__.r(__webpack_exports__);
 174  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _objectSpread; });
 175  /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js");
 176  
 177  function _objectSpread(target) {
 178    for (var i = 1; i < arguments.length; i++) {
 179      var source = arguments[i] != null ? arguments[i] : {};
 180      var ownKeys = Object.keys(source);
 181  
 182      if (typeof Object.getOwnPropertySymbols === 'function') {
 183        ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
 184          return Object.getOwnPropertyDescriptor(source, sym).enumerable;
 185        }));
 186      }
 187  
 188      ownKeys.forEach(function (key) {
 189        Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(target, key, source[key]);
 190      });
 191    }
 192  
 193    return target;
 194  }
 195  
 196  /***/ }),
 197  
 198  /***/ "./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js":
 199  /*!****************************************************************************!*\
 200    !*** ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js ***!
 201    \****************************************************************************/
 202  /*! exports provided: default */
 203  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 204  
 205  "use strict";
 206  __webpack_require__.r(__webpack_exports__);
 207  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _objectWithoutProperties; });
 208  /* harmony import */ var _objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./objectWithoutPropertiesLoose */ "./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js");
 209  
 210  function _objectWithoutProperties(source, excluded) {
 211    if (source == null) return {};
 212    var target = Object(_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(source, excluded);
 213    var key, i;
 214  
 215    if (Object.getOwnPropertySymbols) {
 216      var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
 217  
 218      for (i = 0; i < sourceSymbolKeys.length; i++) {
 219        key = sourceSymbolKeys[i];
 220        if (excluded.indexOf(key) >= 0) continue;
 221        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
 222        target[key] = source[key];
 223      }
 224    }
 225  
 226    return target;
 227  }
 228  
 229  /***/ }),
 230  
 231  /***/ "./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js":
 232  /*!*********************************************************************************!*\
 233    !*** ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js ***!
 234    \*********************************************************************************/
 235  /*! exports provided: default */
 236  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 237  
 238  "use strict";
 239  __webpack_require__.r(__webpack_exports__);
 240  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _objectWithoutPropertiesLoose; });
 241  function _objectWithoutPropertiesLoose(source, excluded) {
 242    if (source == null) return {};
 243    var target = {};
 244    var sourceKeys = Object.keys(source);
 245    var key, i;
 246  
 247    for (i = 0; i < sourceKeys.length; i++) {
 248      key = sourceKeys[i];
 249      if (excluded.indexOf(key) >= 0) continue;
 250      target[key] = source[key];
 251    }
 252  
 253    return target;
 254  }
 255  
 256  /***/ }),
 257  
 258  /***/ "./node_modules/@wordpress/api-fetch/build-module/index.js":
 259  /*!*****************************************************************!*\
 260    !*** ./node_modules/@wordpress/api-fetch/build-module/index.js ***!
 261    \*****************************************************************/
 262  /*! exports provided: default */
 263  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 264  
 265  "use strict";
 266  __webpack_require__.r(__webpack_exports__);
 267  /* harmony import */ var _babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
 268  /* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread */ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js");
 269  /* harmony import */ var _babel_runtime_helpers_esm_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectWithoutProperties */ "./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js");
 270  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
 271  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__);
 272  /* harmony import */ var _middlewares_nonce__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./middlewares/nonce */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js");
 273  /* harmony import */ var _middlewares_root_url__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./middlewares/root-url */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js");
 274  /* harmony import */ var _middlewares_preloading__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./middlewares/preloading */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js");
 275  /* harmony import */ var _middlewares_namespace_endpoint__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./middlewares/namespace-endpoint */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js");
 276  /* harmony import */ var _middlewares_http_v1__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./middlewares/http-v1 */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js");
 277  
 278  
 279  
 280  
 281  /**
 282   * WordPress dependencies
 283   */
 284  
 285  /**
 286   * Internal dependencies
 287   */
 288  
 289  
 290  
 291  
 292  
 293  
 294  var middlewares = [];
 295  
 296  function registerMiddleware(middleware) {
 297    middlewares.push(middleware);
 298  }
 299  
 300  function checkCloudflareError(error) {
 301    if (typeof error === 'string' && error.indexOf('Cloudflare Ray ID') >= 0) {
 302      throw {
 303        code: 'cloudflare_error'
 304      };
 305    }
 306  }
 307  
 308  function apiFetch(options) {
 309    var raw = function raw(nextOptions) {
 310      var url = nextOptions.url,
 311          path = nextOptions.path,
 312          body = nextOptions.body,
 313          data = nextOptions.data,
 314          _nextOptions$parse = nextOptions.parse,
 315          parse = _nextOptions$parse === void 0 ? true : _nextOptions$parse,
 316          remainingOptions = Object(_babel_runtime_helpers_esm_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_2__["default"])(nextOptions, ["url", "path", "body", "data", "parse"]);
 317  
 318      var headers = remainingOptions.headers || {};
 319  
 320      if (!headers['Content-Type'] && data) {
 321        headers['Content-Type'] = 'application/json';
 322      }
 323  
 324      var responsePromise = window.fetch(url || path, Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_1__["default"])({}, remainingOptions, {
 325        credentials: 'include',
 326        body: body || JSON.stringify(data),
 327        headers: headers
 328      }));
 329  
 330      var checkStatus = function checkStatus(response) {
 331        if (response.status >= 200 && response.status < 300) {
 332          return response;
 333        }
 334  
 335        throw response;
 336      };
 337  
 338      var parseResponse = function parseResponse(response) {
 339        if (parse) {
 340          return response.json ? response.json() : Promise.reject(response);
 341        }
 342  
 343        return response;
 344      };
 345  
 346      return responsePromise.then(checkStatus).then(parseResponse).catch(function (response) {
 347        if (!parse) {
 348          throw response;
 349        }
 350  
 351        var invalidJsonError = {
 352          code: 'invalid_json',
 353          message: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('The response is not a valid JSON response.')
 354        };
 355  
 356        if (!response || !response.json) {
 357          throw invalidJsonError;
 358        }
 359        /*
 360         * Response data is a stream, which will be consumed by the .json() call.
 361         * If we need to re-use this data to send to the Cloudflare error handler,
 362         * we need a clone of the original response, so the stream can be consumed
 363         * in the .text() call, instead.
 364         */
 365  
 366  
 367        var responseClone = response.clone();
 368        return response.json().catch(
 369        /*#__PURE__*/
 370        Object(_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__["default"])(
 371        /*#__PURE__*/
 372        regeneratorRuntime.mark(function _callee() {
 373          var text;
 374          return regeneratorRuntime.wrap(function _callee$(_context) {
 375            while (1) {
 376              switch (_context.prev = _context.next) {
 377                case 0:
 378                  _context.next = 2;
 379                  return responseClone.text();
 380  
 381                case 2:
 382                  text = _context.sent;
 383                  checkCloudflareError(text);
 384                  throw invalidJsonError;
 385  
 386                case 5:
 387                case "end":
 388                  return _context.stop();
 389              }
 390            }
 391          }, _callee, this);
 392        }))).then(function (error) {
 393          var unknownError = {
 394            code: 'unknown_error',
 395            message: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('An unknown error occurred.')
 396          };
 397          checkCloudflareError(error);
 398          throw error || unknownError;
 399        });
 400      });
 401    };
 402  
 403    var steps = [raw, _middlewares_http_v1__WEBPACK_IMPORTED_MODULE_8__["default"], _middlewares_namespace_endpoint__WEBPACK_IMPORTED_MODULE_7__["default"]].concat(middlewares);
 404  
 405    var next = function next(nextOptions) {
 406      var nextMiddleware = steps.pop();
 407      return nextMiddleware(nextOptions, next);
 408    };
 409  
 410    return next(options);
 411  }
 412  
 413  apiFetch.use = registerMiddleware;
 414  apiFetch.createNonceMiddleware = _middlewares_nonce__WEBPACK_IMPORTED_MODULE_4__["default"];
 415  apiFetch.createPreloadingMiddleware = _middlewares_preloading__WEBPACK_IMPORTED_MODULE_6__["default"];
 416  apiFetch.createRootURLMiddleware = _middlewares_root_url__WEBPACK_IMPORTED_MODULE_5__["default"];
 417  /* harmony default export */ __webpack_exports__["default"] = (apiFetch);
 418  
 419  
 420  /***/ }),
 421  
 422  /***/ "./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js":
 423  /*!*******************************************************************************!*\
 424    !*** ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js ***!
 425    \*******************************************************************************/
 426  /*! exports provided: default */
 427  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 428  
 429  "use strict";
 430  __webpack_require__.r(__webpack_exports__);
 431  /* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread */ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js");
 432  
 433  
 434  function httpV1Middleware(options, next) {
 435    var newOptions = Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__["default"])({}, options);
 436  
 437    if (newOptions.method) {
 438      if (['PATCH', 'PUT', 'DELETE'].indexOf(newOptions.method.toUpperCase()) >= 0) {
 439        if (!newOptions.headers) {
 440          newOptions.headers = {};
 441        }
 442  
 443        newOptions.headers['X-HTTP-Method-Override'] = newOptions.method;
 444        newOptions.headers['Content-Type'] = 'application/json';
 445        newOptions.method = 'POST';
 446      }
 447    }
 448  
 449    return next(newOptions, next);
 450  }
 451  
 452  /* harmony default export */ __webpack_exports__["default"] = (httpV1Middleware);
 453  
 454  
 455  /***/ }),
 456  
 457  /***/ "./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js":
 458  /*!******************************************************************************************!*\
 459    !*** ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js ***!
 460    \******************************************************************************************/
 461  /*! exports provided: default */
 462  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 463  
 464  "use strict";
 465  __webpack_require__.r(__webpack_exports__);
 466  /* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread */ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js");
 467  
 468  
 469  var namespaceAndEndpointMiddleware = function namespaceAndEndpointMiddleware(options, next) {
 470    var path = options.path;
 471    var namespaceTrimmed, endpointTrimmed;
 472  
 473    if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') {
 474      namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, '');
 475      endpointTrimmed = options.endpoint.replace(/^\//, '');
 476  
 477      if (endpointTrimmed) {
 478        path = namespaceTrimmed + '/' + endpointTrimmed;
 479      } else {
 480        path = namespaceTrimmed;
 481      }
 482    }
 483  
 484    delete options.namespace;
 485    delete options.endpoint;
 486    return next(Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__["default"])({}, options, {
 487      path: path
 488    }));
 489  };
 490  
 491  /* harmony default export */ __webpack_exports__["default"] = (namespaceAndEndpointMiddleware);
 492  
 493  
 494  /***/ }),
 495  
 496  /***/ "./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js":
 497  /*!*****************************************************************************!*\
 498    !*** ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js ***!
 499    \*****************************************************************************/
 500  /*! exports provided: default */
 501  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 502  
 503  "use strict";
 504  __webpack_require__.r(__webpack_exports__);
 505  /* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread */ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js");
 506  /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
 507  /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_1__);
 508  
 509  
 510  /**
 511   * External dependencies
 512   */
 513  
 514  
 515  var createNonceMiddleware = function createNonceMiddleware(nonce) {
 516    return function (options, next) {
 517      var usedNonce = nonce;
 518      /**
 519       * This is not ideal but it's fine for now.
 520       *
 521       * Configure heartbeat to refresh the wp-api nonce, keeping the editor
 522       * authorization intact.
 523       */
 524  
 525      Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_1__["addAction"])('heartbeat.tick', 'core/api-fetch/create-nonce-middleware', function (response) {
 526        if (response['rest-nonce']) {
 527          usedNonce = response['rest-nonce'];
 528        }
 529      });
 530      var headers = options.headers || {}; // If an 'X-WP-Nonce' header (or any case-insensitive variation
 531      // thereof) was specified, no need to add a nonce header.
 532  
 533      var addNonceHeader = true;
 534  
 535      for (var headerName in headers) {
 536        if (headers.hasOwnProperty(headerName)) {
 537          if (headerName.toLowerCase() === 'x-wp-nonce') {
 538            addNonceHeader = false;
 539            break;
 540          }
 541        }
 542      }
 543  
 544      if (addNonceHeader) {
 545        // Do not mutate the original headers object, if any.
 546        headers = Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__["default"])({}, headers, {
 547          'X-WP-Nonce': usedNonce
 548        });
 549      }
 550  
 551      return next(Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__["default"])({}, options, {
 552        headers: headers
 553      }));
 554    };
 555  };
 556  
 557  /* harmony default export */ __webpack_exports__["default"] = (createNonceMiddleware);
 558  
 559  
 560  /***/ }),
 561  
 562  /***/ "./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js":
 563  /*!**********************************************************************************!*\
 564    !*** ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js ***!
 565    \**********************************************************************************/
 566  /*! exports provided: default */
 567  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 568  
 569  "use strict";
 570  __webpack_require__.r(__webpack_exports__);
 571  var createPreloadingMiddleware = function createPreloadingMiddleware(preloadedData) {
 572    return function (options, next) {
 573      function getStablePath(path) {
 574        var splitted = path.split('?');
 575        var query = splitted[1];
 576        var base = splitted[0];
 577  
 578        if (!query) {
 579          return base;
 580        } // 'b=1&c=2&a=5'
 581  
 582  
 583        return base + '?' + query // [ 'b=1', 'c=2', 'a=5' ]
 584        .split('&') // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ]
 585        .map(function (entry) {
 586          return entry.split('=');
 587        }) // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ]
 588        .sort(function (a, b) {
 589          return a[0].localeCompare(b[0]);
 590        }) // [ 'a=5', 'b=1', 'c=2' ]
 591        .map(function (pair) {
 592          return pair.join('=');
 593        }) // 'a=5&b=1&c=2'
 594        .join('&');
 595      }
 596  
 597      var _options$parse = options.parse,
 598          parse = _options$parse === void 0 ? true : _options$parse;
 599  
 600      if (typeof options.path === 'string' && parse) {
 601        var method = options.method || 'GET';
 602        var path = getStablePath(options.path);
 603  
 604        if ('GET' === method && preloadedData[path]) {
 605          return Promise.resolve(preloadedData[path].body);
 606        }
 607      }
 608  
 609      return next(options);
 610    };
 611  };
 612  
 613  /* harmony default export */ __webpack_exports__["default"] = (createPreloadingMiddleware);
 614  
 615  
 616  /***/ }),
 617  
 618  /***/ "./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js":
 619  /*!********************************************************************************!*\
 620    !*** ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js ***!
 621    \********************************************************************************/
 622  /*! exports provided: default */
 623  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 624  
 625  "use strict";
 626  __webpack_require__.r(__webpack_exports__);
 627  /* harmony import */ var _babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectSpread */ "./node_modules/@babel/runtime/helpers/esm/objectSpread.js");
 628  /* harmony import */ var _namespace_endpoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./namespace-endpoint */ "./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js");
 629  
 630  
 631  /**
 632   * Internal dependencies
 633   */
 634  
 635  
 636  var createRootURLMiddleware = function createRootURLMiddleware(rootURL) {
 637    return function (options, next) {
 638      return Object(_namespace_endpoint__WEBPACK_IMPORTED_MODULE_1__["default"])(options, function (optionsWithPath) {
 639        var url = optionsWithPath.url;
 640        var path = optionsWithPath.path;
 641        var apiRoot;
 642  
 643        if (typeof path === 'string') {
 644          apiRoot = rootURL;
 645  
 646          if (-1 !== rootURL.indexOf('?')) {
 647            path = path.replace('?', '&');
 648          }
 649  
 650          path = path.replace(/^\//, ''); // API root may already include query parameter prefix if site is
 651          // configured to use plain permalinks.
 652  
 653          if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) {
 654            path = path.replace('?', '&');
 655          }
 656  
 657          url = apiRoot + path;
 658        }
 659  
 660        return next(Object(_babel_runtime_helpers_esm_objectSpread__WEBPACK_IMPORTED_MODULE_0__["default"])({}, optionsWithPath, {
 661          url: url
 662        }));
 663      });
 664    };
 665  };
 666  
 667  /* harmony default export */ __webpack_exports__["default"] = (createRootURLMiddleware);
 668  
 669  
 670  /***/ }),
 671  
 672  /***/ "@wordpress/hooks":
 673  /*!****************************************!*\
 674    !*** external {"this":["wp","hooks"]} ***!
 675    \****************************************/
 676  /*! no static exports found */
 677  /***/ (function(module, exports) {
 678  
 679  (function() { module.exports = this["wp"]["hooks"]; }());
 680  
 681  /***/ }),
 682  
 683  /***/ "@wordpress/i18n":
 684  /*!***************************************!*\
 685    !*** external {"this":["wp","i18n"]} ***!
 686    \***************************************/
 687  /*! no static exports found */
 688  /***/ (function(module, exports) {
 689  
 690  (function() { module.exports = this["wp"]["i18n"]; }());
 691  
 692  /***/ })
 693  
 694  /******/ })["default"];
 695  //# sourceMappingURL=api-fetch.js.map


Generated: Mon Jan 7 01:00:05 2019 Cross-referenced by PHPXref 0.7.1