[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /** 2 * Copyright (c) 2014-present, Facebook, Inc. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8 var runtime = (function (exports) { 9 "use strict"; 10 11 var Op = Object.prototype; 12 var hasOwn = Op.hasOwnProperty; 13 var defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }; 14 var undefined; // More compressible than void 0. 15 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 16 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 17 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 18 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 19 20 function define(obj, key, value) { 21 Object.defineProperty(obj, key, { 22 value: value, 23 enumerable: true, 24 configurable: true, 25 writable: true 26 }); 27 return obj[key]; 28 } 29 try { 30 // IE 8 has a broken Object.defineProperty that only works on DOM objects. 31 define({}, ""); 32 } catch (err) { 33 define = function(obj, key, value) { 34 return obj[key] = value; 35 }; 36 } 37 38 function wrap(innerFn, outerFn, self, tryLocsList) { 39 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 40 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 41 var generator = Object.create(protoGenerator.prototype); 42 var context = new Context(tryLocsList || []); 43 44 // The ._invoke method unifies the implementations of the .next, 45 // .throw, and .return methods. 46 defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }); 47 48 return generator; 49 } 50 exports.wrap = wrap; 51 52 // Try/catch helper to minimize deoptimizations. Returns a completion 53 // record like context.tryEntries[i].completion. This interface could 54 // have been (and was previously) designed to take a closure to be 55 // invoked without arguments, but in all the cases we care about we 56 // already have an existing method we want to call, so there's no need 57 // to create a new function object. We can even get away with assuming 58 // the method takes exactly one argument, since that happens to be true 59 // in every case, so we don't have to touch the arguments object. The 60 // only additional allocation required is the completion record, which 61 // has a stable shape and so hopefully should be cheap to allocate. 62 function tryCatch(fn, obj, arg) { 63 try { 64 return { type: "normal", arg: fn.call(obj, arg) }; 65 } catch (err) { 66 return { type: "throw", arg: err }; 67 } 68 } 69 70 var GenStateSuspendedStart = "suspendedStart"; 71 var GenStateSuspendedYield = "suspendedYield"; 72 var GenStateExecuting = "executing"; 73 var GenStateCompleted = "completed"; 74 75 // Returning this object from the innerFn has the same effect as 76 // breaking out of the dispatch switch statement. 77 var ContinueSentinel = {}; 78 79 // Dummy constructor functions that we use as the .constructor and 80 // .constructor.prototype properties for functions that return Generator 81 // objects. For full spec compliance, you may wish to configure your 82 // minifier not to mangle the names of these two functions. 83 function Generator() {} 84 function GeneratorFunction() {} 85 function GeneratorFunctionPrototype() {} 86 87 // This is a polyfill for %IteratorPrototype% for environments that 88 // don't natively support it. 89 var IteratorPrototype = {}; 90 define(IteratorPrototype, iteratorSymbol, function () { 91 return this; 92 }); 93 94 var getProto = Object.getPrototypeOf; 95 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 96 if (NativeIteratorPrototype && 97 NativeIteratorPrototype !== Op && 98 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 99 // This environment has a native %IteratorPrototype%; use it instead 100 // of the polyfill. 101 IteratorPrototype = NativeIteratorPrototype; 102 } 103 104 var Gp = GeneratorFunctionPrototype.prototype = 105 Generator.prototype = Object.create(IteratorPrototype); 106 GeneratorFunction.prototype = GeneratorFunctionPrototype; 107 defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true }); 108 defineProperty( 109 GeneratorFunctionPrototype, 110 "constructor", 111 { value: GeneratorFunction, configurable: true } 112 ); 113 GeneratorFunction.displayName = define( 114 GeneratorFunctionPrototype, 115 toStringTagSymbol, 116 "GeneratorFunction" 117 ); 118 119 // Helper for defining the .next, .throw, and .return methods of the 120 // Iterator interface in terms of a single ._invoke method. 121 function defineIteratorMethods(prototype) { 122 ["next", "throw", "return"].forEach(function(method) { 123 define(prototype, method, function(arg) { 124 return this._invoke(method, arg); 125 }); 126 }); 127 } 128 129 exports.isGeneratorFunction = function(genFun) { 130 var ctor = typeof genFun === "function" && genFun.constructor; 131 return ctor 132 ? ctor === GeneratorFunction || 133 // For the native GeneratorFunction constructor, the best we can 134 // do is to check its .name property. 135 (ctor.displayName || ctor.name) === "GeneratorFunction" 136 : false; 137 }; 138 139 exports.mark = function(genFun) { 140 if (Object.setPrototypeOf) { 141 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 142 } else { 143 genFun.__proto__ = GeneratorFunctionPrototype; 144 define(genFun, toStringTagSymbol, "GeneratorFunction"); 145 } 146 genFun.prototype = Object.create(Gp); 147 return genFun; 148 }; 149 150 // Within the body of any async function, `await x` is transformed to 151 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 152 // `hasOwn.call(value, "__await")` to determine if the yielded value is 153 // meant to be awaited. 154 exports.awrap = function(arg) { 155 return { __await: arg }; 156 }; 157 158 function AsyncIterator(generator, PromiseImpl) { 159 function invoke(method, arg, resolve, reject) { 160 var record = tryCatch(generator[method], generator, arg); 161 if (record.type === "throw") { 162 reject(record.arg); 163 } else { 164 var result = record.arg; 165 var value = result.value; 166 if (value && 167 typeof value === "object" && 168 hasOwn.call(value, "__await")) { 169 return PromiseImpl.resolve(value.__await).then(function(value) { 170 invoke("next", value, resolve, reject); 171 }, function(err) { 172 invoke("throw", err, resolve, reject); 173 }); 174 } 175 176 return PromiseImpl.resolve(value).then(function(unwrapped) { 177 // When a yielded Promise is resolved, its final value becomes 178 // the .value of the Promise<{value,done}> result for the 179 // current iteration. 180 result.value = unwrapped; 181 resolve(result); 182 }, function(error) { 183 // If a rejected Promise was yielded, throw the rejection back 184 // into the async generator function so it can be handled there. 185 return invoke("throw", error, resolve, reject); 186 }); 187 } 188 } 189 190 var previousPromise; 191 192 function enqueue(method, arg) { 193 function callInvokeWithMethodAndArg() { 194 return new PromiseImpl(function(resolve, reject) { 195 invoke(method, arg, resolve, reject); 196 }); 197 } 198 199 return previousPromise = 200 // If enqueue has been called before, then we want to wait until 201 // all previous Promises have been resolved before calling invoke, 202 // so that results are always delivered in the correct order. If 203 // enqueue has not been called before, then it is important to 204 // call invoke immediately, without waiting on a callback to fire, 205 // so that the async generator function has the opportunity to do 206 // any necessary setup in a predictable way. This predictability 207 // is why the Promise constructor synchronously invokes its 208 // executor callback, and why async functions synchronously 209 // execute code before the first await. Since we implement simple 210 // async functions in terms of async generators, it is especially 211 // important to get this right, even though it requires care. 212 previousPromise ? previousPromise.then( 213 callInvokeWithMethodAndArg, 214 // Avoid propagating failures to Promises returned by later 215 // invocations of the iterator. 216 callInvokeWithMethodAndArg 217 ) : callInvokeWithMethodAndArg(); 218 } 219 220 // Define the unified helper method that is used to implement .next, 221 // .throw, and .return (see defineIteratorMethods). 222 defineProperty(this, "_invoke", { value: enqueue }); 223 } 224 225 defineIteratorMethods(AsyncIterator.prototype); 226 define(AsyncIterator.prototype, asyncIteratorSymbol, function () { 227 return this; 228 }); 229 exports.AsyncIterator = AsyncIterator; 230 231 // Note that simple async functions are implemented on top of 232 // AsyncIterator objects; they just return a Promise for the value of 233 // the final result produced by the iterator. 234 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { 235 if (PromiseImpl === void 0) PromiseImpl = Promise; 236 237 var iter = new AsyncIterator( 238 wrap(innerFn, outerFn, self, tryLocsList), 239 PromiseImpl 240 ); 241 242 return exports.isGeneratorFunction(outerFn) 243 ? iter // If outerFn is a generator, return the full iterator. 244 : iter.next().then(function(result) { 245 return result.done ? result.value : iter.next(); 246 }); 247 }; 248 249 function makeInvokeMethod(innerFn, self, context) { 250 var state = GenStateSuspendedStart; 251 252 return function invoke(method, arg) { 253 if (state === GenStateExecuting) { 254 throw new Error("Generator is already running"); 255 } 256 257 if (state === GenStateCompleted) { 258 if (method === "throw") { 259 throw arg; 260 } 261 262 // Be forgiving, per 25.3.3.3.3 of the spec: 263 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 264 return doneResult(); 265 } 266 267 context.method = method; 268 context.arg = arg; 269 270 while (true) { 271 var delegate = context.delegate; 272 if (delegate) { 273 var delegateResult = maybeInvokeDelegate(delegate, context); 274 if (delegateResult) { 275 if (delegateResult === ContinueSentinel) continue; 276 return delegateResult; 277 } 278 } 279 280 if (context.method === "next") { 281 // Setting context._sent for legacy support of Babel's 282 // function.sent implementation. 283 context.sent = context._sent = context.arg; 284 285 } else if (context.method === "throw") { 286 if (state === GenStateSuspendedStart) { 287 state = GenStateCompleted; 288 throw context.arg; 289 } 290 291 context.dispatchException(context.arg); 292 293 } else if (context.method === "return") { 294 context.abrupt("return", context.arg); 295 } 296 297 state = GenStateExecuting; 298 299 var record = tryCatch(innerFn, self, context); 300 if (record.type === "normal") { 301 // If an exception is thrown from innerFn, we leave state === 302 // GenStateExecuting and loop back for another invocation. 303 state = context.done 304 ? GenStateCompleted 305 : GenStateSuspendedYield; 306 307 if (record.arg === ContinueSentinel) { 308 continue; 309 } 310 311 return { 312 value: record.arg, 313 done: context.done 314 }; 315 316 } else if (record.type === "throw") { 317 state = GenStateCompleted; 318 // Dispatch the exception by looping back around to the 319 // context.dispatchException(context.arg) call above. 320 context.method = "throw"; 321 context.arg = record.arg; 322 } 323 } 324 }; 325 } 326 327 // Call delegate.iterator[context.method](context.arg) and handle the 328 // result, either by returning a { value, done } result from the 329 // delegate iterator, or by modifying context.method and context.arg, 330 // setting context.delegate to null, and returning the ContinueSentinel. 331 function maybeInvokeDelegate(delegate, context) { 332 var methodName = context.method; 333 var method = delegate.iterator[methodName]; 334 if (method === undefined) { 335 // A .throw or .return when the delegate iterator has no .throw 336 // method, or a missing .next mehtod, always terminate the 337 // yield* loop. 338 context.delegate = null; 339 340 // Note: ["return"] must be used for ES3 parsing compatibility. 341 if (methodName === "throw" && delegate.iterator["return"]) { 342 // If the delegate iterator has a return method, give it a 343 // chance to clean up. 344 context.method = "return"; 345 context.arg = undefined; 346 maybeInvokeDelegate(delegate, context); 347 348 if (context.method === "throw") { 349 // If maybeInvokeDelegate(context) changed context.method from 350 // "return" to "throw", let that override the TypeError below. 351 return ContinueSentinel; 352 } 353 } 354 if (methodName !== "return") { 355 context.method = "throw"; 356 context.arg = new TypeError( 357 "The iterator does not provide a '" + methodName + "' method"); 358 } 359 360 return ContinueSentinel; 361 } 362 363 var record = tryCatch(method, delegate.iterator, context.arg); 364 365 if (record.type === "throw") { 366 context.method = "throw"; 367 context.arg = record.arg; 368 context.delegate = null; 369 return ContinueSentinel; 370 } 371 372 var info = record.arg; 373 374 if (! info) { 375 context.method = "throw"; 376 context.arg = new TypeError("iterator result is not an object"); 377 context.delegate = null; 378 return ContinueSentinel; 379 } 380 381 if (info.done) { 382 // Assign the result of the finished delegate to the temporary 383 // variable specified by delegate.resultName (see delegateYield). 384 context[delegate.resultName] = info.value; 385 386 // Resume execution at the desired location (see delegateYield). 387 context.next = delegate.nextLoc; 388 389 // If context.method was "throw" but the delegate handled the 390 // exception, let the outer generator proceed normally. If 391 // context.method was "next", forget context.arg since it has been 392 // "consumed" by the delegate iterator. If context.method was 393 // "return", allow the original .return call to continue in the 394 // outer generator. 395 if (context.method !== "return") { 396 context.method = "next"; 397 context.arg = undefined; 398 } 399 400 } else { 401 // Re-yield the result returned by the delegate method. 402 return info; 403 } 404 405 // The delegate iterator is finished, so forget it and continue with 406 // the outer generator. 407 context.delegate = null; 408 return ContinueSentinel; 409 } 410 411 // Define Generator.prototype.{next,throw,return} in terms of the 412 // unified ._invoke helper method. 413 defineIteratorMethods(Gp); 414 415 define(Gp, toStringTagSymbol, "Generator"); 416 417 // A Generator should always return itself as the iterator object when the 418 // @@iterator function is called on it. Some browsers' implementations of the 419 // iterator prototype chain incorrectly implement this, causing the Generator 420 // object to not be returned from this call. This ensures that doesn't happen. 421 // See https://github.com/facebook/regenerator/issues/274 for more details. 422 define(Gp, iteratorSymbol, function() { 423 return this; 424 }); 425 426 define(Gp, "toString", function() { 427 return "[object Generator]"; 428 }); 429 430 function pushTryEntry(locs) { 431 var entry = { tryLoc: locs[0] }; 432 433 if (1 in locs) { 434 entry.catchLoc = locs[1]; 435 } 436 437 if (2 in locs) { 438 entry.finallyLoc = locs[2]; 439 entry.afterLoc = locs[3]; 440 } 441 442 this.tryEntries.push(entry); 443 } 444 445 function resetTryEntry(entry) { 446 var record = entry.completion || {}; 447 record.type = "normal"; 448 delete record.arg; 449 entry.completion = record; 450 } 451 452 function Context(tryLocsList) { 453 // The root entry object (effectively a try statement without a catch 454 // or a finally block) gives us a place to store values thrown from 455 // locations where there is no enclosing try statement. 456 this.tryEntries = [{ tryLoc: "root" }]; 457 tryLocsList.forEach(pushTryEntry, this); 458 this.reset(true); 459 } 460 461 exports.keys = function(val) { 462 var object = Object(val); 463 var keys = []; 464 for (var key in object) { 465 keys.push(key); 466 } 467 keys.reverse(); 468 469 // Rather than returning an object with a next method, we keep 470 // things simple and return the next function itself. 471 return function next() { 472 while (keys.length) { 473 var key = keys.pop(); 474 if (key in object) { 475 next.value = key; 476 next.done = false; 477 return next; 478 } 479 } 480 481 // To avoid creating an additional object, we just hang the .value 482 // and .done properties off the next function object itself. This 483 // also ensures that the minifier will not anonymize the function. 484 next.done = true; 485 return next; 486 }; 487 }; 488 489 function values(iterable) { 490 if (iterable || iterable === "") { 491 var iteratorMethod = iterable[iteratorSymbol]; 492 if (iteratorMethod) { 493 return iteratorMethod.call(iterable); 494 } 495 496 if (typeof iterable.next === "function") { 497 return iterable; 498 } 499 500 if (!isNaN(iterable.length)) { 501 var i = -1, next = function next() { 502 while (++i < iterable.length) { 503 if (hasOwn.call(iterable, i)) { 504 next.value = iterable[i]; 505 next.done = false; 506 return next; 507 } 508 } 509 510 next.value = undefined; 511 next.done = true; 512 513 return next; 514 }; 515 516 return next.next = next; 517 } 518 } 519 520 throw new TypeError(typeof iterable + " is not iterable"); 521 } 522 exports.values = values; 523 524 function doneResult() { 525 return { value: undefined, done: true }; 526 } 527 528 Context.prototype = { 529 constructor: Context, 530 531 reset: function(skipTempReset) { 532 this.prev = 0; 533 this.next = 0; 534 // Resetting context._sent for legacy support of Babel's 535 // function.sent implementation. 536 this.sent = this._sent = undefined; 537 this.done = false; 538 this.delegate = null; 539 540 this.method = "next"; 541 this.arg = undefined; 542 543 this.tryEntries.forEach(resetTryEntry); 544 545 if (!skipTempReset) { 546 for (var name in this) { 547 // Not sure about the optimal order of these conditions: 548 if (name.charAt(0) === "t" && 549 hasOwn.call(this, name) && 550 !isNaN(+name.slice(1))) { 551 this[name] = undefined; 552 } 553 } 554 } 555 }, 556 557 stop: function() { 558 this.done = true; 559 560 var rootEntry = this.tryEntries[0]; 561 var rootRecord = rootEntry.completion; 562 if (rootRecord.type === "throw") { 563 throw rootRecord.arg; 564 } 565 566 return this.rval; 567 }, 568 569 dispatchException: function(exception) { 570 if (this.done) { 571 throw exception; 572 } 573 574 var context = this; 575 function handle(loc, caught) { 576 record.type = "throw"; 577 record.arg = exception; 578 context.next = loc; 579 580 if (caught) { 581 // If the dispatched exception was caught by a catch block, 582 // then let that catch block handle the exception normally. 583 context.method = "next"; 584 context.arg = undefined; 585 } 586 587 return !! caught; 588 } 589 590 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 591 var entry = this.tryEntries[i]; 592 var record = entry.completion; 593 594 if (entry.tryLoc === "root") { 595 // Exception thrown outside of any try block that could handle 596 // it, so set the completion value of the entire function to 597 // throw the exception. 598 return handle("end"); 599 } 600 601 if (entry.tryLoc <= this.prev) { 602 var hasCatch = hasOwn.call(entry, "catchLoc"); 603 var hasFinally = hasOwn.call(entry, "finallyLoc"); 604 605 if (hasCatch && hasFinally) { 606 if (this.prev < entry.catchLoc) { 607 return handle(entry.catchLoc, true); 608 } else if (this.prev < entry.finallyLoc) { 609 return handle(entry.finallyLoc); 610 } 611 612 } else if (hasCatch) { 613 if (this.prev < entry.catchLoc) { 614 return handle(entry.catchLoc, true); 615 } 616 617 } else if (hasFinally) { 618 if (this.prev < entry.finallyLoc) { 619 return handle(entry.finallyLoc); 620 } 621 622 } else { 623 throw new Error("try statement without catch or finally"); 624 } 625 } 626 } 627 }, 628 629 abrupt: function(type, arg) { 630 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 631 var entry = this.tryEntries[i]; 632 if (entry.tryLoc <= this.prev && 633 hasOwn.call(entry, "finallyLoc") && 634 this.prev < entry.finallyLoc) { 635 var finallyEntry = entry; 636 break; 637 } 638 } 639 640 if (finallyEntry && 641 (type === "break" || 642 type === "continue") && 643 finallyEntry.tryLoc <= arg && 644 arg <= finallyEntry.finallyLoc) { 645 // Ignore the finally entry if control is not jumping to a 646 // location outside the try/catch block. 647 finallyEntry = null; 648 } 649 650 var record = finallyEntry ? finallyEntry.completion : {}; 651 record.type = type; 652 record.arg = arg; 653 654 if (finallyEntry) { 655 this.method = "next"; 656 this.next = finallyEntry.finallyLoc; 657 return ContinueSentinel; 658 } 659 660 return this.complete(record); 661 }, 662 663 complete: function(record, afterLoc) { 664 if (record.type === "throw") { 665 throw record.arg; 666 } 667 668 if (record.type === "break" || 669 record.type === "continue") { 670 this.next = record.arg; 671 } else if (record.type === "return") { 672 this.rval = this.arg = record.arg; 673 this.method = "return"; 674 this.next = "end"; 675 } else if (record.type === "normal" && afterLoc) { 676 this.next = afterLoc; 677 } 678 679 return ContinueSentinel; 680 }, 681 682 finish: function(finallyLoc) { 683 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 684 var entry = this.tryEntries[i]; 685 if (entry.finallyLoc === finallyLoc) { 686 this.complete(entry.completion, entry.afterLoc); 687 resetTryEntry(entry); 688 return ContinueSentinel; 689 } 690 } 691 }, 692 693 "catch": function(tryLoc) { 694 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 695 var entry = this.tryEntries[i]; 696 if (entry.tryLoc === tryLoc) { 697 var record = entry.completion; 698 if (record.type === "throw") { 699 var thrown = record.arg; 700 resetTryEntry(entry); 701 } 702 return thrown; 703 } 704 } 705 706 // The context.catch method must only be called with a location 707 // argument that corresponds to a known catch block. 708 throw new Error("illegal catch attempt"); 709 }, 710 711 delegateYield: function(iterable, resultName, nextLoc) { 712 this.delegate = { 713 iterator: values(iterable), 714 resultName: resultName, 715 nextLoc: nextLoc 716 }; 717 718 if (this.method === "next") { 719 // Deliberately forget the last sent value so that we don't 720 // accidentally pass it on to the delegate. 721 this.arg = undefined; 722 } 723 724 return ContinueSentinel; 725 } 726 }; 727 728 // Regardless of whether this script is executing as a CommonJS module 729 // or not, return the runtime object so that we can declare the variable 730 // regeneratorRuntime in the outer scope, which allows this module to be 731 // injected easily by `bin/regenerator --include-runtime script.js`. 732 return exports; 733 734 }( 735 // If this script is executing as a CommonJS module, use module.exports 736 // as the regeneratorRuntime namespace. Otherwise create a new empty 737 // object. Either way, the resulting object will be used to initialize 738 // the regeneratorRuntime variable at the top of this file. 739 typeof module === "object" ? module.exports : {} 740 )); 741 742 try { 743 regeneratorRuntime = runtime; 744 } catch (accidentalStrictMode) { 745 // This module should not be running in strict mode, so the above 746 // assignment should always work unless something is misconfigured. Just 747 // in case runtime.js accidentally runs in strict mode, in modern engines 748 // we can explicitly access globalThis. In older engines we can escape 749 // strict mode using a global Function call. This could conceivably fail 750 // if a Content Security Policy forbids using Function, but in that case 751 // the proper solution is to fix the accidental strict mode problem. If 752 // you've misconfigured your bundler to force strict mode and applied a 753 // CSP to forbid Function, and you're not willing to fix either of those 754 // problems, please detail your unique predicament in a GitHub issue. 755 if (typeof globalThis === "object") { 756 globalThis.regeneratorRuntime = runtime; 757 } else { 758 Function("r", "regeneratorRuntime = r")(runtime); 759 } 760 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat May 11 08:20:01 2024 | Cross-referenced by PHPXref |