[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> keyboard-shortcuts.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["keyboardShortcuts"] =
   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 = 471);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 11:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["compose"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 12:
  98  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99  
 100  "use strict";
 101  
 102  // EXPORTS
 103  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
 104  
 105  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
 106  var arrayWithHoles = __webpack_require__(38);
 107  
 108  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
 109  function _iterableToArrayLimit(arr, i) {
 110    var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
 111  
 112    if (_i == null) return;
 113    var _arr = [];
 114    var _n = true;
 115    var _d = false;
 116  
 117    var _s, _e;
 118  
 119    try {
 120      for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
 121        _arr.push(_s.value);
 122  
 123        if (i && _arr.length === i) break;
 124      }
 125    } catch (err) {
 126      _d = true;
 127      _e = err;
 128    } finally {
 129      try {
 130        if (!_n && _i["return"] != null) _i["return"]();
 131      } finally {
 132        if (_d) throw _e;
 133      }
 134    }
 135  
 136    return _arr;
 137  }
 138  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 139  var unsupportedIterableToArray = __webpack_require__(28);
 140  
 141  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
 142  var nonIterableRest = __webpack_require__(39);
 143  
 144  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
 145  
 146  
 147  
 148  
 149  function _slicedToArray(arr, i) {
 150    return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
 151  }
 152  
 153  /***/ }),
 154  
 155  /***/ 15:
 156  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 157  
 158  "use strict";
 159  
 160  // EXPORTS
 161  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
 162  
 163  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
 164  var arrayLikeToArray = __webpack_require__(24);
 165  
 166  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
 167  
 168  function _arrayWithoutHoles(arr) {
 169    if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
 170  }
 171  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 172  var iterableToArray = __webpack_require__(42);
 173  
 174  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 175  var unsupportedIterableToArray = __webpack_require__(28);
 176  
 177  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 178  function _nonIterableSpread() {
 179    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 180  }
 181  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 182  
 183  
 184  
 185  
 186  function _toConsumableArray(arr) {
 187    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 188  }
 189  
 190  /***/ }),
 191  
 192  /***/ 17:
 193  /***/ (function(module, exports) {
 194  
 195  (function() { module.exports = window["wp"]["keycodes"]; }());
 196  
 197  /***/ }),
 198  
 199  /***/ 2:
 200  /***/ (function(module, exports) {
 201  
 202  (function() { module.exports = window["lodash"]; }());
 203  
 204  /***/ }),
 205  
 206  /***/ 24:
 207  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 208  
 209  "use strict";
 210  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 211  function _arrayLikeToArray(arr, len) {
 212    if (len == null || len > arr.length) len = arr.length;
 213  
 214    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 215      arr2[i] = arr[i];
 216    }
 217  
 218    return arr2;
 219  }
 220  
 221  /***/ }),
 222  
 223  /***/ 28:
 224  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 225  
 226  "use strict";
 227  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 228  /* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 229  
 230  function _unsupportedIterableToArray(o, minLen) {
 231    if (!o) return;
 232    if (typeof o === "string") return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 233    var n = Object.prototype.toString.call(o).slice(8, -1);
 234    if (n === "Object" && o.constructor) n = o.constructor.name;
 235    if (n === "Map" || n === "Set") return Array.from(o);
 236    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 237  }
 238  
 239  /***/ }),
 240  
 241  /***/ 38:
 242  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 243  
 244  "use strict";
 245  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
 246  function _arrayWithHoles(arr) {
 247    if (Array.isArray(arr)) return arr;
 248  }
 249  
 250  /***/ }),
 251  
 252  /***/ 39:
 253  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 254  
 255  "use strict";
 256  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
 257  function _nonIterableRest() {
 258    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 259  }
 260  
 261  /***/ }),
 262  
 263  /***/ 4:
 264  /***/ (function(module, exports) {
 265  
 266  (function() { module.exports = window["wp"]["data"]; }());
 267  
 268  /***/ }),
 269  
 270  /***/ 40:
 271  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 272  
 273  "use strict";
 274  
 275  
 276  var LEAF_KEY, hasWeakMap;
 277  
 278  /**
 279   * Arbitrary value used as key for referencing cache object in WeakMap tree.
 280   *
 281   * @type {Object}
 282   */
 283  LEAF_KEY = {};
 284  
 285  /**
 286   * Whether environment supports WeakMap.
 287   *
 288   * @type {boolean}
 289   */
 290  hasWeakMap = typeof WeakMap !== 'undefined';
 291  
 292  /**
 293   * Returns the first argument as the sole entry in an array.
 294   *
 295   * @param {*} value Value to return.
 296   *
 297   * @return {Array} Value returned as entry in array.
 298   */
 299  function arrayOf( value ) {
 300      return [ value ];
 301  }
 302  
 303  /**
 304   * Returns true if the value passed is object-like, or false otherwise. A value
 305   * is object-like if it can support property assignment, e.g. object or array.
 306   *
 307   * @param {*} value Value to test.
 308   *
 309   * @return {boolean} Whether value is object-like.
 310   */
 311  function isObjectLike( value ) {
 312      return !! value && 'object' === typeof value;
 313  }
 314  
 315  /**
 316   * Creates and returns a new cache object.
 317   *
 318   * @return {Object} Cache object.
 319   */
 320  function createCache() {
 321      var cache = {
 322          clear: function() {
 323              cache.head = null;
 324          },
 325      };
 326  
 327      return cache;
 328  }
 329  
 330  /**
 331   * Returns true if entries within the two arrays are strictly equal by
 332   * reference from a starting index.
 333   *
 334   * @param {Array}  a         First array.
 335   * @param {Array}  b         Second array.
 336   * @param {number} fromIndex Index from which to start comparison.
 337   *
 338   * @return {boolean} Whether arrays are shallowly equal.
 339   */
 340  function isShallowEqual( a, b, fromIndex ) {
 341      var i;
 342  
 343      if ( a.length !== b.length ) {
 344          return false;
 345      }
 346  
 347      for ( i = fromIndex; i < a.length; i++ ) {
 348          if ( a[ i ] !== b[ i ] ) {
 349              return false;
 350          }
 351      }
 352  
 353      return true;
 354  }
 355  
 356  /**
 357   * Returns a memoized selector function. The getDependants function argument is
 358   * called before the memoized selector and is expected to return an immutable
 359   * reference or array of references on which the selector depends for computing
 360   * its own return value. The memoize cache is preserved only as long as those
 361   * dependant references remain the same. If getDependants returns a different
 362   * reference(s), the cache is cleared and the selector value regenerated.
 363   *
 364   * @param {Function} selector      Selector function.
 365   * @param {Function} getDependants Dependant getter returning an immutable
 366   *                                 reference or array of reference used in
 367   *                                 cache bust consideration.
 368   *
 369   * @return {Function} Memoized selector.
 370   */
 371  /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
 372      var rootCache, getCache;
 373  
 374      // Use object source as dependant if getter not provided
 375      if ( ! getDependants ) {
 376          getDependants = arrayOf;
 377      }
 378  
 379      /**
 380       * Returns the root cache. If WeakMap is supported, this is assigned to the
 381       * root WeakMap cache set, otherwise it is a shared instance of the default
 382       * cache object.
 383       *
 384       * @return {(WeakMap|Object)} Root cache object.
 385       */
 386  	function getRootCache() {
 387          return rootCache;
 388      }
 389  
 390      /**
 391       * Returns the cache for a given dependants array. When possible, a WeakMap
 392       * will be used to create a unique cache for each set of dependants. This
 393       * is feasible due to the nature of WeakMap in allowing garbage collection
 394       * to occur on entries where the key object is no longer referenced. Since
 395       * WeakMap requires the key to be an object, this is only possible when the
 396       * dependant is object-like. The root cache is created as a hierarchy where
 397       * each top-level key is the first entry in a dependants set, the value a
 398       * WeakMap where each key is the next dependant, and so on. This continues
 399       * so long as the dependants are object-like. If no dependants are object-
 400       * like, then the cache is shared across all invocations.
 401       *
 402       * @see isObjectLike
 403       *
 404       * @param {Array} dependants Selector dependants.
 405       *
 406       * @return {Object} Cache object.
 407       */
 408  	function getWeakMapCache( dependants ) {
 409          var caches = rootCache,
 410              isUniqueByDependants = true,
 411              i, dependant, map, cache;
 412  
 413          for ( i = 0; i < dependants.length; i++ ) {
 414              dependant = dependants[ i ];
 415  
 416              // Can only compose WeakMap from object-like key.
 417              if ( ! isObjectLike( dependant ) ) {
 418                  isUniqueByDependants = false;
 419                  break;
 420              }
 421  
 422              // Does current segment of cache already have a WeakMap?
 423              if ( caches.has( dependant ) ) {
 424                  // Traverse into nested WeakMap.
 425                  caches = caches.get( dependant );
 426              } else {
 427                  // Create, set, and traverse into a new one.
 428                  map = new WeakMap();
 429                  caches.set( dependant, map );
 430                  caches = map;
 431              }
 432          }
 433  
 434          // We use an arbitrary (but consistent) object as key for the last item
 435          // in the WeakMap to serve as our running cache.
 436          if ( ! caches.has( LEAF_KEY ) ) {
 437              cache = createCache();
 438              cache.isUniqueByDependants = isUniqueByDependants;
 439              caches.set( LEAF_KEY, cache );
 440          }
 441  
 442          return caches.get( LEAF_KEY );
 443      }
 444  
 445      // Assign cache handler by availability of WeakMap
 446      getCache = hasWeakMap ? getWeakMapCache : getRootCache;
 447  
 448      /**
 449       * Resets root memoization cache.
 450       */
 451  	function clear() {
 452          rootCache = hasWeakMap ? new WeakMap() : createCache();
 453      }
 454  
 455      // eslint-disable-next-line jsdoc/check-param-names
 456      /**
 457       * The augmented selector call, considering first whether dependants have
 458       * changed before passing it to underlying memoize function.
 459       *
 460       * @param {Object} source    Source object for derivation.
 461       * @param {...*}   extraArgs Additional arguments to pass to selector.
 462       *
 463       * @return {*} Selector result.
 464       */
 465  	function callSelector( /* source, ...extraArgs */ ) {
 466          var len = arguments.length,
 467              cache, node, i, args, dependants;
 468  
 469          // Create copy of arguments (avoid leaking deoptimization).
 470          args = new Array( len );
 471          for ( i = 0; i < len; i++ ) {
 472              args[ i ] = arguments[ i ];
 473          }
 474  
 475          dependants = getDependants.apply( null, args );
 476          cache = getCache( dependants );
 477  
 478          // If not guaranteed uniqueness by dependants (primitive type or lack
 479          // of WeakMap support), shallow compare against last dependants and, if
 480          // references have changed, destroy cache to recalculate result.
 481          if ( ! cache.isUniqueByDependants ) {
 482              if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
 483                  cache.clear();
 484              }
 485  
 486              cache.lastDependants = dependants;
 487          }
 488  
 489          node = cache.head;
 490          while ( node ) {
 491              // Check whether node arguments match arguments
 492              if ( ! isShallowEqual( node.args, args, 1 ) ) {
 493                  node = node.next;
 494                  continue;
 495              }
 496  
 497              // At this point we can assume we've found a match
 498  
 499              // Surface matched node to head if not already
 500              if ( node !== cache.head ) {
 501                  // Adjust siblings to point to each other.
 502                  node.prev.next = node.next;
 503                  if ( node.next ) {
 504                      node.next.prev = node.prev;
 505                  }
 506  
 507                  node.next = cache.head;
 508                  node.prev = null;
 509                  cache.head.prev = node;
 510                  cache.head = node;
 511              }
 512  
 513              // Return immediately
 514              return node.val;
 515          }
 516  
 517          // No cached value found. Continue to insertion phase:
 518  
 519          node = {
 520              // Generate the result from original function
 521              val: selector.apply( null, args ),
 522          };
 523  
 524          // Avoid including the source object in the cache.
 525          args[ 0 ] = null;
 526          node.args = args;
 527  
 528          // Don't need to check whether node is already head, since it would
 529          // have been returned above already if it was
 530  
 531          // Shift existing head down list
 532          if ( cache.head ) {
 533              cache.head.prev = node;
 534              node.next = cache.head;
 535          }
 536  
 537          cache.head = node;
 538  
 539          return node.val;
 540      }
 541  
 542      callSelector.getDependants = getDependants;
 543      callSelector.clear = clear;
 544      clear();
 545  
 546      return callSelector;
 547  });
 548  
 549  
 550  /***/ }),
 551  
 552  /***/ 42:
 553  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 554  
 555  "use strict";
 556  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 557  function _iterableToArray(iter) {
 558    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
 559  }
 560  
 561  /***/ }),
 562  
 563  /***/ 471:
 564  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 565  
 566  "use strict";
 567  // ESM COMPAT FLAG
 568  __webpack_require__.r(__webpack_exports__);
 569  
 570  // EXPORTS
 571  __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
 572  __webpack_require__.d(__webpack_exports__, "useShortcut", function() { return /* reexport */ use_shortcut; });
 573  
 574  // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
 575  var actions_namespaceObject = {};
 576  __webpack_require__.r(actions_namespaceObject);
 577  __webpack_require__.d(actions_namespaceObject, "registerShortcut", function() { return registerShortcut; });
 578  __webpack_require__.d(actions_namespaceObject, "unregisterShortcut", function() { return unregisterShortcut; });
 579  
 580  // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
 581  var selectors_namespaceObject = {};
 582  __webpack_require__.r(selectors_namespaceObject);
 583  __webpack_require__.d(selectors_namespaceObject, "getShortcutKeyCombination", function() { return getShortcutKeyCombination; });
 584  __webpack_require__.d(selectors_namespaceObject, "getShortcutRepresentation", function() { return getShortcutRepresentation; });
 585  __webpack_require__.d(selectors_namespaceObject, "getShortcutDescription", function() { return getShortcutDescription; });
 586  __webpack_require__.d(selectors_namespaceObject, "getShortcutAliases", function() { return getShortcutAliases; });
 587  __webpack_require__.d(selectors_namespaceObject, "getAllShortcutRawKeyCombinations", function() { return getAllShortcutRawKeyCombinations; });
 588  __webpack_require__.d(selectors_namespaceObject, "getCategoryShortcuts", function() { return getCategoryShortcuts; });
 589  
 590  // EXTERNAL MODULE: external ["wp","data"]
 591  var external_wp_data_ = __webpack_require__(4);
 592  
 593  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 594  var defineProperty = __webpack_require__(5);
 595  
 596  // EXTERNAL MODULE: external "lodash"
 597  var external_lodash_ = __webpack_require__(2);
 598  
 599  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
 600  
 601  
 602  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
 603  
 604  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
 605  
 606  /**
 607   * External dependencies
 608   */
 609  
 610  /**
 611   * Reducer returning the registered shortcuts
 612   *
 613   * @param {Object} state  Current state.
 614   * @param {Object} action Dispatched action.
 615   *
 616   * @return {Object} Updated state.
 617   */
 618  
 619  function reducer() {
 620    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 621    var action = arguments.length > 1 ? arguments[1] : undefined;
 622  
 623    switch (action.type) {
 624      case 'REGISTER_SHORTCUT':
 625        return _objectSpread(_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.name, {
 626          category: action.category,
 627          keyCombination: action.keyCombination,
 628          aliases: action.aliases,
 629          description: action.description
 630        }));
 631  
 632      case 'UNREGISTER_SHORTCUT':
 633        return Object(external_lodash_["omit"])(state, action.name);
 634    }
 635  
 636    return state;
 637  }
 638  
 639  /* harmony default export */ var store_reducer = (reducer);
 640  
 641  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
 642  /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
 643  
 644  /**
 645   * Keyboard key combination.
 646   *
 647   * @typedef {Object} WPShortcutKeyCombination
 648   *
 649   * @property {string}                      character Character.
 650   * @property {WPKeycodeModifier|undefined} modifier  Modifier.
 651   */
 652  
 653  /**
 654   * Configuration of a registered keyboard shortcut.
 655   *
 656   * @typedef {Object} WPShortcutConfig
 657   *
 658   * @property {string}                     name           Shortcut name.
 659   * @property {string}                     category       Shortcut category.
 660   * @property {string}                     description    Shortcut description.
 661   * @property {WPShortcutKeyCombination}   keyCombination Shortcut key combination.
 662   * @property {WPShortcutKeyCombination[]} [aliases]      Shortcut aliases.
 663   */
 664  
 665  /**
 666   * Returns an action object used to register a new keyboard shortcut.
 667   *
 668   * @param {WPShortcutConfig} config Shortcut config.
 669   *
 670   * @return {Object} action.
 671   */
 672  function registerShortcut(_ref) {
 673    var name = _ref.name,
 674        category = _ref.category,
 675        description = _ref.description,
 676        keyCombination = _ref.keyCombination,
 677        aliases = _ref.aliases;
 678    return {
 679      type: 'REGISTER_SHORTCUT',
 680      name: name,
 681      category: category,
 682      keyCombination: keyCombination,
 683      aliases: aliases,
 684      description: description
 685    };
 686  }
 687  /**
 688   * Returns an action object used to unregister a keyboard shortcut.
 689   *
 690   * @param {string} name Shortcut name.
 691   *
 692   * @return {Object} action.
 693   */
 694  
 695  function unregisterShortcut(name) {
 696    return {
 697      type: 'UNREGISTER_SHORTCUT',
 698      name: name
 699    };
 700  }
 701  
 702  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
 703  var slicedToArray = __webpack_require__(12);
 704  
 705  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 706  var toConsumableArray = __webpack_require__(15);
 707  
 708  // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
 709  var rememo = __webpack_require__(40);
 710  
 711  // EXTERNAL MODULE: external ["wp","keycodes"]
 712  var external_wp_keycodes_ = __webpack_require__(17);
 713  
 714  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
 715  
 716  
 717  
 718  /**
 719   * External dependencies
 720   */
 721  
 722  
 723  /**
 724   * WordPress dependencies
 725   */
 726  
 727  
 728  /** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
 729  
 730  /** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
 731  
 732  /**
 733   * Shared reference to an empty array for cases where it is important to avoid
 734   * returning a new array reference on every invocation.
 735   *
 736   * @type {Array<any>}
 737   */
 738  
 739  var EMPTY_ARRAY = [];
 740  /**
 741   * Shortcut formatting methods.
 742   *
 743   * @property {WPKeycodeHandlerByModifier} display     Display formatting.
 744   * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
 745   * @property {WPKeycodeHandlerByModifier} ariaLabel   ARIA label formatting.
 746   */
 747  
 748  var FORMATTING_METHODS = {
 749    display: external_wp_keycodes_["displayShortcut"],
 750    raw: external_wp_keycodes_["rawShortcut"],
 751    ariaLabel: external_wp_keycodes_["shortcutAriaLabel"]
 752  };
 753  /**
 754   * Returns a string representing the key combination.
 755   *
 756   * @param {?WPShortcutKeyCombination} shortcut       Key combination.
 757   * @param {keyof FORMATTING_METHODS}  representation Type of representation
 758   *                                                   (display, raw, ariaLabel).
 759   *
 760   * @return {string?} Shortcut representation.
 761   */
 762  
 763  function getKeyCombinationRepresentation(shortcut, representation) {
 764    if (!shortcut) {
 765      return null;
 766    }
 767  
 768    return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
 769  }
 770  /**
 771   * Returns the main key combination for a given shortcut name.
 772   *
 773   * @param {Object} state Global state.
 774   * @param {string} name  Shortcut name.
 775   *
 776   * @return {WPShortcutKeyCombination?} Key combination.
 777   */
 778  
 779  
 780  function getShortcutKeyCombination(state, name) {
 781    return state[name] ? state[name].keyCombination : null;
 782  }
 783  /**
 784   * Returns a string representing the main key combination for a given shortcut name.
 785   *
 786   * @param {Object}                   state          Global state.
 787   * @param {string}                   name           Shortcut name.
 788   * @param {keyof FORMATTING_METHODS} representation Type of representation
 789   *                                                  (display, raw, ariaLabel).
 790   *
 791   * @return {string?} Shortcut representation.
 792   */
 793  
 794  function getShortcutRepresentation(state, name) {
 795    var representation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'display';
 796    var shortcut = getShortcutKeyCombination(state, name);
 797    return getKeyCombinationRepresentation(shortcut, representation);
 798  }
 799  /**
 800   * Returns the shortcut description given its name.
 801   *
 802   * @param {Object} state Global state.
 803   * @param {string} name  Shortcut name.
 804   *
 805   * @return {string?} Shortcut description.
 806   */
 807  
 808  function getShortcutDescription(state, name) {
 809    return state[name] ? state[name].description : null;
 810  }
 811  /**
 812   * Returns the aliases for a given shortcut name.
 813   *
 814   * @param {Object} state Global state.
 815   * @param {string} name  Shortcut name.
 816   *
 817   * @return {WPShortcutKeyCombination[]} Key combinations.
 818   */
 819  
 820  function getShortcutAliases(state, name) {
 821    return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
 822  }
 823  /**
 824   * Returns the raw representation of all the keyboard combinations of a given shortcut name.
 825   *
 826   * @param {Object} state Global state.
 827   * @param {string} name  Shortcut name.
 828   *
 829   * @return {string[]} Shortcuts.
 830   */
 831  
 832  var getAllShortcutRawKeyCombinations = Object(rememo["a" /* default */])(function (state, name) {
 833    return Object(external_lodash_["compact"])([getKeyCombinationRepresentation(getShortcutKeyCombination(state, name), 'raw')].concat(Object(toConsumableArray["a" /* default */])(getShortcutAliases(state, name).map(function (combination) {
 834      return getKeyCombinationRepresentation(combination, 'raw');
 835    }))));
 836  }, function (state, name) {
 837    return [state[name]];
 838  });
 839  /**
 840   * Returns the shortcut names list for a given category name.
 841   *
 842   * @param {Object} state Global state.
 843   * @param {string} name  Category name.
 844   *
 845   * @return {string[]} Shortcut names.
 846   */
 847  
 848  var getCategoryShortcuts = Object(rememo["a" /* default */])(function (state, categoryName) {
 849    return Object.entries(state).filter(function (_ref) {
 850      var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
 851          shortcut = _ref2[1];
 852  
 853      return shortcut.category === categoryName;
 854    }).map(function (_ref3) {
 855      var _ref4 = Object(slicedToArray["a" /* default */])(_ref3, 1),
 856          name = _ref4[0];
 857  
 858      return name;
 859    });
 860  }, function (state) {
 861    return [state];
 862  });
 863  
 864  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
 865  /**
 866   * WordPress dependencies
 867   */
 868  
 869  /**
 870   * Internal dependencies
 871   */
 872  
 873  
 874  
 875  
 876  var STORE_NAME = 'core/keyboard-shortcuts';
 877  /**
 878   * Store definition for the keyboard shortcuts namespace.
 879   *
 880   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 881   *
 882   * @type {Object}
 883   */
 884  
 885  var store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
 886    reducer: store_reducer,
 887    actions: actions_namespaceObject,
 888    selectors: selectors_namespaceObject
 889  });
 890  Object(external_wp_data_["register"])(store);
 891  
 892  // EXTERNAL MODULE: external ["wp","compose"]
 893  var external_wp_compose_ = __webpack_require__(11);
 894  
 895  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
 896  /**
 897   * WordPress dependencies
 898   */
 899  
 900  
 901  /**
 902   * Internal dependencies
 903   */
 904  
 905  
 906  /**
 907   * Attach a keyboard shortcut handler.
 908   *
 909   * @param {string} name       Shortcut name.
 910   * @param {Function} callback Shortcut callback.
 911   * @param {Object} options    Shortcut options.
 912   */
 913  
 914  function useShortcut(name, callback, options) {
 915    var shortcuts = Object(external_wp_data_["useSelect"])(function (select) {
 916      return select(store).getAllShortcutRawKeyCombinations(name);
 917    }, [name]);
 918    Object(external_wp_compose_["useKeyboardShortcut"])(shortcuts, callback, options);
 919  }
 920  
 921  /* harmony default export */ var use_shortcut = (useShortcut);
 922  
 923  // CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
 924  
 925  
 926  
 927  
 928  /***/ }),
 929  
 930  /***/ 5:
 931  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 932  
 933  "use strict";
 934  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 935  function _defineProperty(obj, key, value) {
 936    if (key in obj) {
 937      Object.defineProperty(obj, key, {
 938        value: value,
 939        enumerable: true,
 940        configurable: true,
 941        writable: true
 942      });
 943    } else {
 944      obj[key] = value;
 945    }
 946  
 947    return obj;
 948  }
 949  
 950  /***/ })
 951  
 952  /******/ });


Generated: Sat May 15 01:00:05 2021 Cross-referenced by PHPXref 0.7.1