[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> redux-routine.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     var __webpack_modules__ = ({
   4  
   5  /***/ 6910:
   6  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
   7  
   8  
   9  
  10  Object.defineProperty(exports, "__esModule", ({
  11    value: true
  12  }));
  13  exports.race = exports.join = exports.fork = exports.promise = undefined;
  14  
  15  var _is = __webpack_require__(6921);
  16  
  17  var _is2 = _interopRequireDefault(_is);
  18  
  19  var _helpers = __webpack_require__(3524);
  20  
  21  var _dispatcher = __webpack_require__(5136);
  22  
  23  var _dispatcher2 = _interopRequireDefault(_dispatcher);
  24  
  25  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26  
  27  var promise = exports.promise = function promise(value, next, rungen, yieldNext, raiseNext) {
  28    if (!_is2.default.promise(value)) return false;
  29    value.then(next, raiseNext);
  30    return true;
  31  };
  32  
  33  var forkedTasks = new Map();
  34  var fork = exports.fork = function fork(value, next, rungen) {
  35    if (!_is2.default.fork(value)) return false;
  36    var task = Symbol('fork');
  37    var dispatcher = (0, _dispatcher2.default)();
  38    forkedTasks.set(task, dispatcher);
  39    rungen(value.iterator.apply(null, value.args), function (result) {
  40      return dispatcher.dispatch(result);
  41    }, function (err) {
  42      return dispatcher.dispatch((0, _helpers.error)(err));
  43    });
  44    var unsubscribe = dispatcher.subscribe(function () {
  45      unsubscribe();
  46      forkedTasks.delete(task);
  47    });
  48    next(task);
  49    return true;
  50  };
  51  
  52  var join = exports.join = function join(value, next, rungen, yieldNext, raiseNext) {
  53    if (!_is2.default.join(value)) return false;
  54    var dispatcher = forkedTasks.get(value.task);
  55    if (!dispatcher) {
  56      raiseNext('join error : task not found');
  57    } else {
  58      (function () {
  59        var unsubscribe = dispatcher.subscribe(function (result) {
  60          unsubscribe();
  61          next(result);
  62        });
  63      })();
  64    }
  65    return true;
  66  };
  67  
  68  var race = exports.race = function race(value, next, rungen, yieldNext, raiseNext) {
  69    if (!_is2.default.race(value)) return false;
  70    var finished = false;
  71    var success = function success(result, k, v) {
  72      if (finished) return;
  73      finished = true;
  74      result[k] = v;
  75      next(result);
  76    };
  77  
  78    var fail = function fail(err) {
  79      if (finished) return;
  80      raiseNext(err);
  81    };
  82    if (_is2.default.array(value.competitors)) {
  83      (function () {
  84        var result = value.competitors.map(function () {
  85          return false;
  86        });
  87        value.competitors.forEach(function (competitor, index) {
  88          rungen(competitor, function (output) {
  89            return success(result, index, output);
  90          }, fail);
  91        });
  92      })();
  93    } else {
  94      (function () {
  95        var result = Object.keys(value.competitors).reduce(function (p, c) {
  96          p[c] = false;
  97          return p;
  98        }, {});
  99        Object.keys(value.competitors).forEach(function (index) {
 100          rungen(value.competitors[index], function (output) {
 101            return success(result, index, output);
 102          }, fail);
 103        });
 104      })();
 105    }
 106    return true;
 107  };
 108  
 109  var subscribe = function subscribe(value, next) {
 110    if (!_is2.default.subscribe(value)) return false;
 111    if (!_is2.default.channel(value.channel)) {
 112      throw new Error('the first argument of "subscribe" must be a valid channel');
 113    }
 114    var unsubscribe = value.channel.subscribe(function (ret) {
 115      unsubscribe && unsubscribe();
 116      next(ret);
 117    });
 118  
 119    return true;
 120  };
 121  
 122  exports["default"] = [promise, fork, join, race, subscribe];
 123  
 124  /***/ }),
 125  
 126  /***/ 5357:
 127  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 128  
 129  
 130  
 131  Object.defineProperty(exports, "__esModule", ({
 132    value: true
 133  }));
 134  exports.iterator = exports.array = exports.object = exports.error = exports.any = undefined;
 135  
 136  var _is = __webpack_require__(6921);
 137  
 138  var _is2 = _interopRequireDefault(_is);
 139  
 140  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 141  
 142  var any = exports.any = function any(value, next, rungen, yieldNext) {
 143    yieldNext(value);
 144    return true;
 145  };
 146  
 147  var error = exports.error = function error(value, next, rungen, yieldNext, raiseNext) {
 148    if (!_is2.default.error(value)) return false;
 149    raiseNext(value.error);
 150    return true;
 151  };
 152  
 153  var object = exports.object = function object(value, next, rungen, yieldNext, raiseNext) {
 154    if (!_is2.default.all(value) || !_is2.default.obj(value.value)) return false;
 155    var result = {};
 156    var keys = Object.keys(value.value);
 157    var count = 0;
 158    var hasError = false;
 159    var gotResultSuccess = function gotResultSuccess(key, ret) {
 160      if (hasError) return;
 161      result[key] = ret;
 162      count++;
 163      if (count === keys.length) {
 164        yieldNext(result);
 165      }
 166    };
 167  
 168    var gotResultError = function gotResultError(key, error) {
 169      if (hasError) return;
 170      hasError = true;
 171      raiseNext(error);
 172    };
 173  
 174    keys.map(function (key) {
 175      rungen(value.value[key], function (ret) {
 176        return gotResultSuccess(key, ret);
 177      }, function (err) {
 178        return gotResultError(key, err);
 179      });
 180    });
 181  
 182    return true;
 183  };
 184  
 185  var array = exports.array = function array(value, next, rungen, yieldNext, raiseNext) {
 186    if (!_is2.default.all(value) || !_is2.default.array(value.value)) return false;
 187    var result = [];
 188    var count = 0;
 189    var hasError = false;
 190    var gotResultSuccess = function gotResultSuccess(key, ret) {
 191      if (hasError) return;
 192      result[key] = ret;
 193      count++;
 194      if (count === value.value.length) {
 195        yieldNext(result);
 196      }
 197    };
 198  
 199    var gotResultError = function gotResultError(key, error) {
 200      if (hasError) return;
 201      hasError = true;
 202      raiseNext(error);
 203    };
 204  
 205    value.value.map(function (v, key) {
 206      rungen(v, function (ret) {
 207        return gotResultSuccess(key, ret);
 208      }, function (err) {
 209        return gotResultError(key, err);
 210      });
 211    });
 212  
 213    return true;
 214  };
 215  
 216  var iterator = exports.iterator = function iterator(value, next, rungen, yieldNext, raiseNext) {
 217    if (!_is2.default.iterator(value)) return false;
 218    rungen(value, next, raiseNext);
 219    return true;
 220  };
 221  
 222  exports["default"] = [error, iterator, array, object, any];
 223  
 224  /***/ }),
 225  
 226  /***/ 3304:
 227  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 228  
 229  
 230  
 231  Object.defineProperty(exports, "__esModule", ({
 232    value: true
 233  }));
 234  exports.cps = exports.call = undefined;
 235  
 236  var _is = __webpack_require__(6921);
 237  
 238  var _is2 = _interopRequireDefault(_is);
 239  
 240  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 241  
 242  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
 243  
 244  var call = exports.call = function call(value, next, rungen, yieldNext, raiseNext) {
 245    if (!_is2.default.call(value)) return false;
 246    try {
 247      next(value.func.apply(value.context, value.args));
 248    } catch (err) {
 249      raiseNext(err);
 250    }
 251    return true;
 252  };
 253  
 254  var cps = exports.cps = function cps(value, next, rungen, yieldNext, raiseNext) {
 255    var _value$func;
 256  
 257    if (!_is2.default.cps(value)) return false;
 258    (_value$func = value.func).call.apply(_value$func, [null].concat(_toConsumableArray(value.args), [function (err, result) {
 259      if (err) raiseNext(err);else next(result);
 260    }]));
 261    return true;
 262  };
 263  
 264  exports["default"] = [call, cps];
 265  
 266  /***/ }),
 267  
 268  /***/ 9127:
 269  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 270  
 271  
 272  
 273  Object.defineProperty(exports, "__esModule", ({
 274    value: true
 275  }));
 276  
 277  var _builtin = __webpack_require__(5357);
 278  
 279  var _builtin2 = _interopRequireDefault(_builtin);
 280  
 281  var _is = __webpack_require__(6921);
 282  
 283  var _is2 = _interopRequireDefault(_is);
 284  
 285  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 286  
 287  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
 288  
 289  var create = function create() {
 290    var userControls = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
 291  
 292    var controls = [].concat(_toConsumableArray(userControls), _toConsumableArray(_builtin2.default));
 293  
 294    var runtime = function runtime(input) {
 295      var success = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1];
 296      var error = arguments.length <= 2 || arguments[2] === undefined ? function () {} : arguments[2];
 297  
 298      var iterate = function iterate(gen) {
 299        var yieldValue = function yieldValue(isError) {
 300          return function (ret) {
 301            try {
 302              var _ref = isError ? gen.throw(ret) : gen.next(ret);
 303  
 304              var value = _ref.value;
 305              var done = _ref.done;
 306  
 307              if (done) return success(value);
 308              next(value);
 309            } catch (e) {
 310              return error(e);
 311            }
 312          };
 313        };
 314  
 315        var next = function next(ret) {
 316          controls.some(function (control) {
 317            return control(ret, next, runtime, yieldValue(false), yieldValue(true));
 318          });
 319        };
 320  
 321        yieldValue(false)();
 322      };
 323  
 324      var iterator = _is2.default.iterator(input) ? input : regeneratorRuntime.mark(function _callee() {
 325        return regeneratorRuntime.wrap(function _callee$(_context) {
 326          while (1) {
 327            switch (_context.prev = _context.next) {
 328              case 0:
 329                _context.next = 2;
 330                return input;
 331  
 332              case 2:
 333                return _context.abrupt('return', _context.sent);
 334  
 335              case 3:
 336              case 'end':
 337                return _context.stop();
 338            }
 339          }
 340        }, _callee, this);
 341      })();
 342  
 343      iterate(iterator, success, error);
 344    };
 345  
 346    return runtime;
 347  };
 348  
 349  exports["default"] = create;
 350  
 351  /***/ }),
 352  
 353  /***/ 8975:
 354  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 355  
 356  
 357  
 358  Object.defineProperty(exports, "__esModule", ({
 359    value: true
 360  }));
 361  exports.wrapControls = exports.asyncControls = exports.create = undefined;
 362  
 363  var _helpers = __webpack_require__(3524);
 364  
 365  Object.keys(_helpers).forEach(function (key) {
 366    if (key === "default") return;
 367    Object.defineProperty(exports, key, {
 368      enumerable: true,
 369      get: function get() {
 370        return _helpers[key];
 371      }
 372    });
 373  });
 374  
 375  var _create = __webpack_require__(9127);
 376  
 377  var _create2 = _interopRequireDefault(_create);
 378  
 379  var _async = __webpack_require__(6910);
 380  
 381  var _async2 = _interopRequireDefault(_async);
 382  
 383  var _wrap = __webpack_require__(3304);
 384  
 385  var _wrap2 = _interopRequireDefault(_wrap);
 386  
 387  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 388  
 389  exports.create = _create2.default;
 390  exports.asyncControls = _async2.default;
 391  exports.wrapControls = _wrap2.default;
 392  
 393  /***/ }),
 394  
 395  /***/ 5136:
 396  /***/ ((__unused_webpack_module, exports) => {
 397  
 398  
 399  
 400  Object.defineProperty(exports, "__esModule", ({
 401    value: true
 402  }));
 403  var createDispatcher = function createDispatcher() {
 404    var listeners = [];
 405  
 406    return {
 407      subscribe: function subscribe(listener) {
 408        listeners.push(listener);
 409        return function () {
 410          listeners = listeners.filter(function (l) {
 411            return l !== listener;
 412          });
 413        };
 414      },
 415      dispatch: function dispatch(action) {
 416        listeners.slice().forEach(function (listener) {
 417          return listener(action);
 418        });
 419      }
 420    };
 421  };
 422  
 423  exports["default"] = createDispatcher;
 424  
 425  /***/ }),
 426  
 427  /***/ 3524:
 428  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 429  
 430  
 431  
 432  Object.defineProperty(exports, "__esModule", ({
 433    value: true
 434  }));
 435  exports.createChannel = exports.subscribe = exports.cps = exports.apply = exports.call = exports.invoke = exports.delay = exports.race = exports.join = exports.fork = exports.error = exports.all = undefined;
 436  
 437  var _keys = __webpack_require__(4137);
 438  
 439  var _keys2 = _interopRequireDefault(_keys);
 440  
 441  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 442  
 443  var all = exports.all = function all(value) {
 444    return {
 445      type: _keys2.default.all,
 446      value: value
 447    };
 448  };
 449  
 450  var error = exports.error = function error(err) {
 451    return {
 452      type: _keys2.default.error,
 453      error: err
 454    };
 455  };
 456  
 457  var fork = exports.fork = function fork(iterator) {
 458    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
 459      args[_key - 1] = arguments[_key];
 460    }
 461  
 462    return {
 463      type: _keys2.default.fork,
 464      iterator: iterator,
 465      args: args
 466    };
 467  };
 468  
 469  var join = exports.join = function join(task) {
 470    return {
 471      type: _keys2.default.join,
 472      task: task
 473    };
 474  };
 475  
 476  var race = exports.race = function race(competitors) {
 477    return {
 478      type: _keys2.default.race,
 479      competitors: competitors
 480    };
 481  };
 482  
 483  var delay = exports.delay = function delay(timeout) {
 484    return new Promise(function (resolve) {
 485      setTimeout(function () {
 486        return resolve(true);
 487      }, timeout);
 488    });
 489  };
 490  
 491  var invoke = exports.invoke = function invoke(func) {
 492    for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
 493      args[_key2 - 1] = arguments[_key2];
 494    }
 495  
 496    return {
 497      type: _keys2.default.call,
 498      func: func,
 499      context: null,
 500      args: args
 501    };
 502  };
 503  
 504  var call = exports.call = function call(func, context) {
 505    for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
 506      args[_key3 - 2] = arguments[_key3];
 507    }
 508  
 509    return {
 510      type: _keys2.default.call,
 511      func: func,
 512      context: context,
 513      args: args
 514    };
 515  };
 516  
 517  var apply = exports.apply = function apply(func, context, args) {
 518    return {
 519      type: _keys2.default.call,
 520      func: func,
 521      context: context,
 522      args: args
 523    };
 524  };
 525  
 526  var cps = exports.cps = function cps(func) {
 527    for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
 528      args[_key4 - 1] = arguments[_key4];
 529    }
 530  
 531    return {
 532      type: _keys2.default.cps,
 533      func: func,
 534      args: args
 535    };
 536  };
 537  
 538  var subscribe = exports.subscribe = function subscribe(channel) {
 539    return {
 540      type: _keys2.default.subscribe,
 541      channel: channel
 542    };
 543  };
 544  
 545  var createChannel = exports.createChannel = function createChannel(callback) {
 546    var listeners = [];
 547    var subscribe = function subscribe(l) {
 548      listeners.push(l);
 549      return function () {
 550        return listeners.splice(listeners.indexOf(l), 1);
 551      };
 552    };
 553    var next = function next(val) {
 554      return listeners.forEach(function (l) {
 555        return l(val);
 556      });
 557    };
 558    callback(next);
 559  
 560    return {
 561      subscribe: subscribe
 562    };
 563  };
 564  
 565  /***/ }),
 566  
 567  /***/ 6921:
 568  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 569  
 570  
 571  
 572  Object.defineProperty(exports, "__esModule", ({
 573    value: true
 574  }));
 575  
 576  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
 577  
 578  var _keys = __webpack_require__(4137);
 579  
 580  var _keys2 = _interopRequireDefault(_keys);
 581  
 582  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 583  
 584  var is = {
 585    obj: function obj(value) {
 586      return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !!value;
 587    },
 588    all: function all(value) {
 589      return is.obj(value) && value.type === _keys2.default.all;
 590    },
 591    error: function error(value) {
 592      return is.obj(value) && value.type === _keys2.default.error;
 593    },
 594    array: Array.isArray,
 595    func: function func(value) {
 596      return typeof value === 'function';
 597    },
 598    promise: function promise(value) {
 599      return value && is.func(value.then);
 600    },
 601    iterator: function iterator(value) {
 602      return value && is.func(value.next) && is.func(value.throw);
 603    },
 604    fork: function fork(value) {
 605      return is.obj(value) && value.type === _keys2.default.fork;
 606    },
 607    join: function join(value) {
 608      return is.obj(value) && value.type === _keys2.default.join;
 609    },
 610    race: function race(value) {
 611      return is.obj(value) && value.type === _keys2.default.race;
 612    },
 613    call: function call(value) {
 614      return is.obj(value) && value.type === _keys2.default.call;
 615    },
 616    cps: function cps(value) {
 617      return is.obj(value) && value.type === _keys2.default.cps;
 618    },
 619    subscribe: function subscribe(value) {
 620      return is.obj(value) && value.type === _keys2.default.subscribe;
 621    },
 622    channel: function channel(value) {
 623      return is.obj(value) && is.func(value.subscribe);
 624    }
 625  };
 626  
 627  exports["default"] = is;
 628  
 629  /***/ }),
 630  
 631  /***/ 4137:
 632  /***/ ((__unused_webpack_module, exports) => {
 633  
 634  
 635  
 636  Object.defineProperty(exports, "__esModule", ({
 637    value: true
 638  }));
 639  var keys = {
 640    all: Symbol('all'),
 641    error: Symbol('error'),
 642    fork: Symbol('fork'),
 643    join: Symbol('join'),
 644    race: Symbol('race'),
 645    call: Symbol('call'),
 646    cps: Symbol('cps'),
 647    subscribe: Symbol('subscribe')
 648  };
 649  
 650  exports["default"] = keys;
 651  
 652  /***/ })
 653  
 654  /******/     });
 655  /************************************************************************/
 656  /******/     // The module cache
 657  /******/     var __webpack_module_cache__ = {};
 658  /******/     
 659  /******/     // The require function
 660  /******/ 	function __webpack_require__(moduleId) {
 661  /******/         // Check if module is in cache
 662  /******/         var cachedModule = __webpack_module_cache__[moduleId];
 663  /******/         if (cachedModule !== undefined) {
 664  /******/             return cachedModule.exports;
 665  /******/         }
 666  /******/         // Create a new module (and put it into the cache)
 667  /******/         var module = __webpack_module_cache__[moduleId] = {
 668  /******/             // no module.id needed
 669  /******/             // no module.loaded needed
 670  /******/             exports: {}
 671  /******/         };
 672  /******/     
 673  /******/         // Execute the module function
 674  /******/         __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
 675  /******/     
 676  /******/         // Return the exports of the module
 677  /******/         return module.exports;
 678  /******/     }
 679  /******/     
 680  /************************************************************************/
 681  /******/     /* webpack/runtime/define property getters */
 682  /******/     (() => {
 683  /******/         // define getter functions for harmony exports
 684  /******/         __webpack_require__.d = (exports, definition) => {
 685  /******/             for(var key in definition) {
 686  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
 687  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
 688  /******/                 }
 689  /******/             }
 690  /******/         };
 691  /******/     })();
 692  /******/     
 693  /******/     /* webpack/runtime/hasOwnProperty shorthand */
 694  /******/     (() => {
 695  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
 696  /******/     })();
 697  /******/     
 698  /************************************************************************/
 699  var __webpack_exports__ = {};
 700  
 701  // EXPORTS
 702  __webpack_require__.d(__webpack_exports__, {
 703    "default": () => (/* binding */ createMiddleware)
 704  });
 705  
 706  ;// ./node_modules/@wordpress/redux-routine/build-module/is-generator.js
 707  /* eslint-disable jsdoc/valid-types */
 708  /**
 709   * Returns true if the given object is a generator, or false otherwise.
 710   *
 711   * @see https://www.ecma-international.org/ecma-262/6.0/#sec-generator-objects
 712   *
 713   * @param {any} object Object to test.
 714   *
 715   * @return {object is Generator} Whether object is a generator.
 716   */
 717  function isGenerator(object) {
 718    /* eslint-enable jsdoc/valid-types */
 719    // Check that iterator (next) and iterable (Symbol.iterator) interfaces are satisfied.
 720    // These checks seem to be compatible with several generator helpers as well as the native implementation.
 721    return !!object && typeof object[Symbol.iterator] === 'function' && typeof object.next === 'function';
 722  }
 723  
 724  // EXTERNAL MODULE: ./node_modules/rungen/dist/index.js
 725  var dist = __webpack_require__(8975);
 726  ;// ./node_modules/is-promise/index.mjs
 727  function isPromise(obj) {
 728    return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
 729  }
 730  
 731  ;// ./node_modules/is-plain-object/dist/is-plain-object.mjs
 732  /*!
 733   * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
 734   *
 735   * Copyright (c) 2014-2017, Jon Schlinkert.
 736   * Released under the MIT License.
 737   */
 738  
 739  function isObject(o) {
 740    return Object.prototype.toString.call(o) === '[object Object]';
 741  }
 742  
 743  function isPlainObject(o) {
 744    var ctor,prot;
 745  
 746    if (isObject(o) === false) return false;
 747  
 748    // If has modified constructor
 749    ctor = o.constructor;
 750    if (ctor === undefined) return true;
 751  
 752    // If has modified prototype
 753    prot = ctor.prototype;
 754    if (isObject(prot) === false) return false;
 755  
 756    // If constructor does not have an Object-specific method
 757    if (prot.hasOwnProperty('isPrototypeOf') === false) {
 758      return false;
 759    }
 760  
 761    // Most likely a plain Object
 762    return true;
 763  }
 764  
 765  
 766  
 767  ;// ./node_modules/@wordpress/redux-routine/build-module/is-action.js
 768  /**
 769   * External dependencies
 770   */
 771  
 772  
 773  /* eslint-disable jsdoc/valid-types */
 774  /**
 775   * Returns true if the given object quacks like an action.
 776   *
 777   * @param {any} object Object to test
 778   *
 779   * @return {object is import('redux').AnyAction}  Whether object is an action.
 780   */
 781  function isAction(object) {
 782    return isPlainObject(object) && typeof object.type === 'string';
 783  }
 784  
 785  /**
 786   * Returns true if the given object quacks like an action and has a specific
 787   * action type
 788   *
 789   * @param {unknown} object       Object to test
 790   * @param {string}  expectedType The expected type for the action.
 791   *
 792   * @return {object is import('redux').AnyAction} Whether object is an action and is of specific type.
 793   */
 794  function isActionOfType(object, expectedType) {
 795    /* eslint-enable jsdoc/valid-types */
 796    return isAction(object) && object.type === expectedType;
 797  }
 798  
 799  ;// ./node_modules/@wordpress/redux-routine/build-module/runtime.js
 800  /**
 801   * External dependencies
 802   */
 803  
 804  
 805  
 806  /**
 807   * Internal dependencies
 808   */
 809  
 810  
 811  /**
 812   * Create a co-routine runtime.
 813   *
 814   * @param controls Object of control handlers.
 815   * @param dispatch Unhandled action dispatch.
 816   */
 817  function createRuntime(controls = {}, dispatch) {
 818    const rungenControls = Object.entries(controls).map(([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
 819      if (!isActionOfType(value, actionType)) {
 820        return false;
 821      }
 822      const routine = control(value);
 823      if (isPromise(routine)) {
 824        // Async control routine awaits resolution.
 825        routine.then(yieldNext, yieldError);
 826      } else {
 827        yieldNext(routine);
 828      }
 829      return true;
 830    });
 831    const unhandledActionControl = (value, next) => {
 832      if (!isAction(value)) {
 833        return false;
 834      }
 835      dispatch(value);
 836      next();
 837      return true;
 838    };
 839    rungenControls.push(unhandledActionControl);
 840    const rungenRuntime = (0,dist.create)(rungenControls);
 841    return action => new Promise((resolve, reject) => rungenRuntime(action, result => {
 842      if (isAction(result)) {
 843        dispatch(result);
 844      }
 845      resolve(result);
 846    }, reject));
 847  }
 848  
 849  ;// ./node_modules/@wordpress/redux-routine/build-module/index.js
 850  /**
 851   * Internal dependencies
 852   */
 853  
 854  
 855  
 856  /**
 857   * Creates a Redux middleware, given an object of controls where each key is an
 858   * action type for which to act upon, the value a function which returns either
 859   * a promise which is to resolve when evaluation of the action should continue,
 860   * or a value. The value or resolved promise value is assigned on the return
 861   * value of the yield assignment. If the control handler returns undefined, the
 862   * execution is not continued.
 863   *
 864   * @param {Record<string, (value: import('redux').AnyAction) => Promise<boolean> | boolean>} controls Object of control handlers.
 865   *
 866   * @return {import('redux').Middleware} Co-routine runtime
 867   */
 868  function createMiddleware(controls = {}) {
 869    return store => {
 870      const runtime = createRuntime(controls, store.dispatch);
 871      return next => action => {
 872        if (!isGenerator(action)) {
 873          return next(action);
 874        }
 875        return runtime(action);
 876      };
 877    };
 878  }
 879  
 880  (window.wp = window.wp || {}).reduxRoutine = __webpack_exports__["default"];
 881  /******/ })()
 882  ;


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref