[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["i18n"] = 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 = 476); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 203: 91 /***/ (function(module, exports, __webpack_require__) { 92 93 var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ 94 95 !function() { 96 'use strict' 97 98 var re = { 99 not_string: /[^s]/, 100 not_bool: /[^t]/, 101 not_type: /[^T]/, 102 not_primitive: /[^v]/, 103 number: /[diefg]/, 104 numeric_arg: /[bcdiefguxX]/, 105 json: /[j]/, 106 not_json: /[^j]/, 107 text: /^[^\x25]+/, 108 modulo: /^\x25{2}/, 109 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, 110 key: /^([a-z_][a-z_\d]*)/i, 111 key_access: /^\.([a-z_][a-z_\d]*)/i, 112 index_access: /^\[(\d+)\]/, 113 sign: /^[+-]/ 114 } 115 116 function sprintf(key) { 117 // `arguments` is not an array, but should be fine for this call 118 return sprintf_format(sprintf_parse(key), arguments) 119 } 120 121 function vsprintf(fmt, argv) { 122 return sprintf.apply(null, [fmt].concat(argv || [])) 123 } 124 125 function sprintf_format(parse_tree, argv) { 126 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign 127 for (i = 0; i < tree_length; i++) { 128 if (typeof parse_tree[i] === 'string') { 129 output += parse_tree[i] 130 } 131 else if (typeof parse_tree[i] === 'object') { 132 ph = parse_tree[i] // convenience purposes only 133 if (ph.keys) { // keyword argument 134 arg = argv[cursor] 135 for (k = 0; k < ph.keys.length; k++) { 136 if (arg == undefined) { 137 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) 138 } 139 arg = arg[ph.keys[k]] 140 } 141 } 142 else if (ph.param_no) { // positional argument (explicit) 143 arg = argv[ph.param_no] 144 } 145 else { // positional argument (implicit) 146 arg = argv[cursor++] 147 } 148 149 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { 150 arg = arg() 151 } 152 153 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { 154 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) 155 } 156 157 if (re.number.test(ph.type)) { 158 is_positive = arg >= 0 159 } 160 161 switch (ph.type) { 162 case 'b': 163 arg = parseInt(arg, 10).toString(2) 164 break 165 case 'c': 166 arg = String.fromCharCode(parseInt(arg, 10)) 167 break 168 case 'd': 169 case 'i': 170 arg = parseInt(arg, 10) 171 break 172 case 'j': 173 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0) 174 break 175 case 'e': 176 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential() 177 break 178 case 'f': 179 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg) 180 break 181 case 'g': 182 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg) 183 break 184 case 'o': 185 arg = (parseInt(arg, 10) >>> 0).toString(8) 186 break 187 case 's': 188 arg = String(arg) 189 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 190 break 191 case 't': 192 arg = String(!!arg) 193 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 194 break 195 case 'T': 196 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() 197 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 198 break 199 case 'u': 200 arg = parseInt(arg, 10) >>> 0 201 break 202 case 'v': 203 arg = arg.valueOf() 204 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) 205 break 206 case 'x': 207 arg = (parseInt(arg, 10) >>> 0).toString(16) 208 break 209 case 'X': 210 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() 211 break 212 } 213 if (re.json.test(ph.type)) { 214 output += arg 215 } 216 else { 217 if (re.number.test(ph.type) && (!is_positive || ph.sign)) { 218 sign = is_positive ? '+' : '-' 219 arg = arg.toString().replace(re.sign, '') 220 } 221 else { 222 sign = '' 223 } 224 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' 225 pad_length = ph.width - (sign + arg).length 226 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' 227 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) 228 } 229 } 230 } 231 return output 232 } 233 234 var sprintf_cache = Object.create(null) 235 236 function sprintf_parse(fmt) { 237 if (sprintf_cache[fmt]) { 238 return sprintf_cache[fmt] 239 } 240 241 var _fmt = fmt, match, parse_tree = [], arg_names = 0 242 while (_fmt) { 243 if ((match = re.text.exec(_fmt)) !== null) { 244 parse_tree.push(match[0]) 245 } 246 else if ((match = re.modulo.exec(_fmt)) !== null) { 247 parse_tree.push('%') 248 } 249 else if ((match = re.placeholder.exec(_fmt)) !== null) { 250 if (match[2]) { 251 arg_names |= 1 252 var field_list = [], replacement_field = match[2], field_match = [] 253 if ((field_match = re.key.exec(replacement_field)) !== null) { 254 field_list.push(field_match[1]) 255 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { 256 if ((field_match = re.key_access.exec(replacement_field)) !== null) { 257 field_list.push(field_match[1]) 258 } 259 else if ((field_match = re.index_access.exec(replacement_field)) !== null) { 260 field_list.push(field_match[1]) 261 } 262 else { 263 throw new SyntaxError('[sprintf] failed to parse named argument key') 264 } 265 } 266 } 267 else { 268 throw new SyntaxError('[sprintf] failed to parse named argument key') 269 } 270 match[2] = field_list 271 } 272 else { 273 arg_names |= 2 274 } 275 if (arg_names === 3) { 276 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') 277 } 278 279 parse_tree.push( 280 { 281 placeholder: match[0], 282 param_no: match[1], 283 keys: match[2], 284 sign: match[3], 285 pad_char: match[4], 286 align: match[5], 287 width: match[6], 288 precision: match[7], 289 type: match[8] 290 } 291 ) 292 } 293 else { 294 throw new SyntaxError('[sprintf] unexpected placeholder') 295 } 296 _fmt = _fmt.substring(match[0].length) 297 } 298 return sprintf_cache[fmt] = parse_tree 299 } 300 301 /** 302 * export to either browser or node.js 303 */ 304 /* eslint-disable quote-props */ 305 if (true) { 306 exports['sprintf'] = sprintf 307 exports['vsprintf'] = vsprintf 308 } 309 if (typeof window !== 'undefined') { 310 window['sprintf'] = sprintf 311 window['vsprintf'] = vsprintf 312 313 if (true) { 314 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 315 return { 316 'sprintf': sprintf, 317 'vsprintf': vsprintf 318 } 319 }).call(exports, __webpack_require__, exports, module), 320 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) 321 } 322 } 323 /* eslint-enable quote-props */ 324 }(); // eslint-disable-line 325 326 327 /***/ }), 328 329 /***/ 476: 330 /***/ (function(module, __webpack_exports__, __webpack_require__) { 331 332 "use strict"; 333 // ESM COMPAT FLAG 334 __webpack_require__.r(__webpack_exports__); 335 336 // EXPORTS 337 __webpack_require__.d(__webpack_exports__, "sprintf", function() { return /* reexport */ sprintf_sprintf; }); 338 __webpack_require__.d(__webpack_exports__, "createI18n", function() { return /* reexport */ create_i18n_createI18n; }); 339 __webpack_require__.d(__webpack_exports__, "setLocaleData", function() { return /* reexport */ default_i18n_setLocaleData; }); 340 __webpack_require__.d(__webpack_exports__, "__", function() { return /* reexport */ default_i18n_; }); 341 __webpack_require__.d(__webpack_exports__, "_x", function() { return /* reexport */ default_i18n_x; }); 342 __webpack_require__.d(__webpack_exports__, "_n", function() { return /* reexport */ default_i18n_n; }); 343 __webpack_require__.d(__webpack_exports__, "_nx", function() { return /* reexport */ default_i18n_nx; }); 344 __webpack_require__.d(__webpack_exports__, "isRTL", function() { return /* reexport */ default_i18n_isRTL; }); 345 346 // EXTERNAL MODULE: ./node_modules/memize/index.js 347 var memize = __webpack_require__(60); 348 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); 349 350 // EXTERNAL MODULE: ./node_modules/sprintf-js/src/sprintf.js 351 var sprintf = __webpack_require__(203); 352 var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf); 353 354 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/sprintf.js 355 /** 356 * External dependencies 357 */ 358 359 360 /** 361 * Log to console, once per message; or more precisely, per referentially equal 362 * argument set. Because Jed throws errors, we log these to the console instead 363 * to avoid crashing the application. 364 * 365 * @param {...*} args Arguments to pass to `console.error` 366 */ 367 368 var logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console 369 370 /** 371 * Returns a formatted string. If an error occurs in applying the format, the 372 * original format string is returned. 373 * 374 * @param {string} format The format of the string to generate. 375 * @param {...*} args Arguments to apply to the format. 376 * 377 * @see http://www.diveintojavascript.com/projects/javascript-sprintf 378 * 379 * @return {string} The formatted string. 380 */ 381 382 function sprintf_sprintf(format) { 383 try { 384 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 385 args[_key - 1] = arguments[_key]; 386 } 387 388 return sprintf_default.a.sprintf.apply(sprintf_default.a, [format].concat(args)); 389 } catch (error) { 390 logErrorOnce('sprintf error: \n\n' + error.toString()); 391 return format; 392 } 393 } 394 395 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 396 var defineProperty = __webpack_require__(5); 397 398 // CONCATENATED MODULE: ./node_modules/@tannin/postfix/index.js 399 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN; 400 401 /** 402 * Operator precedence mapping. 403 * 404 * @type {Object} 405 */ 406 PRECEDENCE = { 407 '(': 9, 408 '!': 8, 409 '*': 7, 410 '/': 7, 411 '%': 7, 412 '+': 6, 413 '-': 6, 414 '<': 5, 415 '<=': 5, 416 '>': 5, 417 '>=': 5, 418 '==': 4, 419 '!=': 4, 420 '&&': 3, 421 '||': 2, 422 '?': 1, 423 '?:': 1, 424 }; 425 426 /** 427 * Characters which signal pair opening, to be terminated by terminators. 428 * 429 * @type {string[]} 430 */ 431 OPENERS = [ '(', '?' ]; 432 433 /** 434 * Characters which signal pair termination, the value an array with the 435 * opener as its first member. The second member is an optional operator 436 * replacement to push to the stack. 437 * 438 * @type {string[]} 439 */ 440 TERMINATORS = { 441 ')': [ '(' ], 442 ':': [ '?', '?:' ], 443 }; 444 445 /** 446 * Pattern matching operators and openers. 447 * 448 * @type {RegExp} 449 */ 450 PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/; 451 452 /** 453 * Given a C expression, returns the equivalent postfix (Reverse Polish) 454 * notation terms as an array. 455 * 456 * If a postfix string is desired, simply `.join( ' ' )` the result. 457 * 458 * @example 459 * 460 * ```js 461 * import postfix from '@tannin/postfix'; 462 * 463 * postfix( 'n > 1' ); 464 * // ⇒ [ 'n', '1', '>' ] 465 * ``` 466 * 467 * @param {string} expression C expression. 468 * 469 * @return {string[]} Postfix terms. 470 */ 471 function postfix( expression ) { 472 var terms = [], 473 stack = [], 474 match, operator, term, element; 475 476 while ( ( match = expression.match( PATTERN ) ) ) { 477 operator = match[ 0 ]; 478 479 // Term is the string preceding the operator match. It may contain 480 // whitespace, and may be empty (if operator is at beginning). 481 term = expression.substr( 0, match.index ).trim(); 482 if ( term ) { 483 terms.push( term ); 484 } 485 486 while ( ( element = stack.pop() ) ) { 487 if ( TERMINATORS[ operator ] ) { 488 if ( TERMINATORS[ operator ][ 0 ] === element ) { 489 // Substitution works here under assumption that because 490 // the assigned operator will no longer be a terminator, it 491 // will be pushed to the stack during the condition below. 492 operator = TERMINATORS[ operator ][ 1 ] || operator; 493 break; 494 } 495 } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) { 496 // Push to stack if either an opener or when pop reveals an 497 // element of lower precedence. 498 stack.push( element ); 499 break; 500 } 501 502 // For each popped from stack, push to terms. 503 terms.push( element ); 504 } 505 506 if ( ! TERMINATORS[ operator ] ) { 507 stack.push( operator ); 508 } 509 510 // Slice matched fragment from expression to continue match. 511 expression = expression.substr( match.index + operator.length ); 512 } 513 514 // Push remainder of operand, if exists, to terms. 515 expression = expression.trim(); 516 if ( expression ) { 517 terms.push( expression ); 518 } 519 520 // Pop remaining items from stack into terms. 521 return terms.concat( stack.reverse() ); 522 } 523 524 // CONCATENATED MODULE: ./node_modules/@tannin/evaluate/index.js 525 /** 526 * Operator callback functions. 527 * 528 * @type {Object} 529 */ 530 var OPERATORS = { 531 '!': function( a ) { 532 return ! a; 533 }, 534 '*': function( a, b ) { 535 return a * b; 536 }, 537 '/': function( a, b ) { 538 return a / b; 539 }, 540 '%': function( a, b ) { 541 return a % b; 542 }, 543 '+': function( a, b ) { 544 return a + b; 545 }, 546 '-': function( a, b ) { 547 return a - b; 548 }, 549 '<': function( a, b ) { 550 return a < b; 551 }, 552 '<=': function( a, b ) { 553 return a <= b; 554 }, 555 '>': function( a, b ) { 556 return a > b; 557 }, 558 '>=': function( a, b ) { 559 return a >= b; 560 }, 561 '==': function( a, b ) { 562 return a === b; 563 }, 564 '!=': function( a, b ) { 565 return a !== b; 566 }, 567 '&&': function( a, b ) { 568 return a && b; 569 }, 570 '||': function( a, b ) { 571 return a || b; 572 }, 573 '?:': function( a, b, c ) { 574 if ( a ) { 575 throw b; 576 } 577 578 return c; 579 }, 580 }; 581 582 /** 583 * Given an array of postfix terms and operand variables, returns the result of 584 * the postfix evaluation. 585 * 586 * @example 587 * 588 * ```js 589 * import evaluate from '@tannin/evaluate'; 590 * 591 * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +' 592 * const terms = [ '3', '4', '5', '*', '6', '/', '+' ]; 593 * 594 * evaluate( terms, {} ); 595 * // ⇒ 6.333333333333334 596 * ``` 597 * 598 * @param {string[]} postfix Postfix terms. 599 * @param {Object} variables Operand variables. 600 * 601 * @return {*} Result of evaluation. 602 */ 603 function evaluate_evaluate( postfix, variables ) { 604 var stack = [], 605 i, j, args, getOperatorResult, term, value; 606 607 for ( i = 0; i < postfix.length; i++ ) { 608 term = postfix[ i ]; 609 610 getOperatorResult = OPERATORS[ term ]; 611 if ( getOperatorResult ) { 612 // Pop from stack by number of function arguments. 613 j = getOperatorResult.length; 614 args = Array( j ); 615 while ( j-- ) { 616 args[ j ] = stack.pop(); 617 } 618 619 try { 620 value = getOperatorResult.apply( null, args ); 621 } catch ( earlyReturn ) { 622 return earlyReturn; 623 } 624 } else if ( variables.hasOwnProperty( term ) ) { 625 value = variables[ term ]; 626 } else { 627 value = +term; 628 } 629 630 stack.push( value ); 631 } 632 633 return stack[ 0 ]; 634 } 635 636 // CONCATENATED MODULE: ./node_modules/@tannin/compile/index.js 637 638 639 640 /** 641 * Given a C expression, returns a function which can be called to evaluate its 642 * result. 643 * 644 * @example 645 * 646 * ```js 647 * import compile from '@tannin/compile'; 648 * 649 * const evaluate = compile( 'n > 1' ); 650 * 651 * evaluate( { n: 2 } ); 652 * // ⇒ true 653 * ``` 654 * 655 * @param {string} expression C expression. 656 * 657 * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator. 658 */ 659 function compile( expression ) { 660 var terms = postfix( expression ); 661 662 return function( variables ) { 663 return evaluate_evaluate( terms, variables ); 664 }; 665 } 666 667 // CONCATENATED MODULE: ./node_modules/@tannin/plural-forms/index.js 668 669 670 /** 671 * Given a C expression, returns a function which, when called with a value, 672 * evaluates the result with the value assumed to be the "n" variable of the 673 * expression. The result will be coerced to its numeric equivalent. 674 * 675 * @param {string} expression C expression. 676 * 677 * @return {Function} Evaluator function. 678 */ 679 function pluralForms( expression ) { 680 var evaluate = compile( expression ); 681 682 return function( n ) { 683 return +evaluate( { n: n } ); 684 }; 685 } 686 687 // CONCATENATED MODULE: ./node_modules/tannin/index.js 688 689 690 /** 691 * Tannin constructor options. 692 * 693 * @typedef {Object} TanninOptions 694 * 695 * @property {string} [contextDelimiter] Joiner in string lookup with context. 696 * @property {Function} [onMissingKey] Callback to invoke when key missing. 697 */ 698 699 /** 700 * Domain metadata. 701 * 702 * @typedef {Object} TanninDomainMetadata 703 * 704 * @property {string} [domain] Domain name. 705 * @property {string} [lang] Language code. 706 * @property {(string|Function)} [plural_forms] Plural forms expression or 707 * function evaluator. 708 */ 709 710 /** 711 * Domain translation pair respectively representing the singular and plural 712 * translation. 713 * 714 * @typedef {[string,string]} TanninTranslation 715 */ 716 717 /** 718 * Locale data domain. The key is used as reference for lookup, the value an 719 * array of two string entries respectively representing the singular and plural 720 * translation. 721 * 722 * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain 723 */ 724 725 /** 726 * Jed-formatted locale data. 727 * 728 * @see http://messageformat.github.io/Jed/ 729 * 730 * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData 731 */ 732 733 /** 734 * Default Tannin constructor options. 735 * 736 * @type {TanninOptions} 737 */ 738 var DEFAULT_OPTIONS = { 739 contextDelimiter: '\u0004', 740 onMissingKey: null, 741 }; 742 743 /** 744 * Given a specific locale data's config `plural_forms` value, returns the 745 * expression. 746 * 747 * @example 748 * 749 * ``` 750 * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)' 751 * ``` 752 * 753 * @param {string} pf Locale data plural forms. 754 * 755 * @return {string} Plural forms expression. 756 */ 757 function getPluralExpression( pf ) { 758 var parts, i, part; 759 760 parts = pf.split( ';' ); 761 762 for ( i = 0; i < parts.length; i++ ) { 763 part = parts[ i ].trim(); 764 if ( part.indexOf( 'plural=' ) === 0 ) { 765 return part.substr( 7 ); 766 } 767 } 768 } 769 770 /** 771 * Tannin constructor. 772 * 773 * @class 774 * 775 * @param {TanninLocaleData} data Jed-formatted locale data. 776 * @param {TanninOptions} [options] Tannin options. 777 */ 778 function Tannin( data, options ) { 779 var key; 780 781 /** 782 * Jed-formatted locale data. 783 * 784 * @name Tannin#data 785 * @type {TanninLocaleData} 786 */ 787 this.data = data; 788 789 /** 790 * Plural forms function cache, keyed by plural forms string. 791 * 792 * @name Tannin#pluralForms 793 * @type {Object<string,Function>} 794 */ 795 this.pluralForms = {}; 796 797 /** 798 * Effective options for instance, including defaults. 799 * 800 * @name Tannin#options 801 * @type {TanninOptions} 802 */ 803 this.options = {}; 804 805 for ( key in DEFAULT_OPTIONS ) { 806 this.options[ key ] = options !== undefined && key in options 807 ? options[ key ] 808 : DEFAULT_OPTIONS[ key ]; 809 } 810 } 811 812 /** 813 * Returns the plural form index for the given domain and value. 814 * 815 * @param {string} domain Domain on which to calculate plural form. 816 * @param {number} n Value for which plural form is to be calculated. 817 * 818 * @return {number} Plural form index. 819 */ 820 Tannin.prototype.getPluralForm = function( domain, n ) { 821 var getPluralForm = this.pluralForms[ domain ], 822 config, plural, pf; 823 824 if ( ! getPluralForm ) { 825 config = this.data[ domain ][ '' ]; 826 827 pf = ( 828 config[ 'Plural-Forms' ] || 829 config[ 'plural-forms' ] || 830 // Ignore reason: As known, there's no way to document the empty 831 // string property on a key to guarantee this as metadata. 832 // @ts-ignore 833 config.plural_forms 834 ); 835 836 if ( typeof pf !== 'function' ) { 837 plural = getPluralExpression( 838 config[ 'Plural-Forms' ] || 839 config[ 'plural-forms' ] || 840 // Ignore reason: As known, there's no way to document the empty 841 // string property on a key to guarantee this as metadata. 842 // @ts-ignore 843 config.plural_forms 844 ); 845 846 pf = pluralForms( plural ); 847 } 848 849 getPluralForm = this.pluralForms[ domain ] = pf; 850 } 851 852 return getPluralForm( n ); 853 }; 854 855 /** 856 * Translate a string. 857 * 858 * @param {string} domain Translation domain. 859 * @param {string|void} context Context distinguishing terms of the same name. 860 * @param {string} singular Primary key for translation lookup. 861 * @param {string=} plural Fallback value used for non-zero plural 862 * form index. 863 * @param {number=} n Value to use in calculating plural form. 864 * 865 * @return {string} Translated string. 866 */ 867 Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) { 868 var index, key, entry; 869 870 if ( n === undefined ) { 871 // Default to singular. 872 index = 0; 873 } else { 874 // Find index by evaluating plural form for value. 875 index = this.getPluralForm( domain, n ); 876 } 877 878 key = singular; 879 880 // If provided, context is prepended to key with delimiter. 881 if ( context ) { 882 key = context + this.options.contextDelimiter + singular; 883 } 884 885 entry = this.data[ domain ][ key ]; 886 887 // Verify not only that entry exists, but that the intended index is within 888 // range and non-empty. 889 if ( entry && entry[ index ] ) { 890 return entry[ index ]; 891 } 892 893 if ( this.options.onMissingKey ) { 894 this.options.onMissingKey( singular, domain ); 895 } 896 897 // If entry not found, fall back to singular vs. plural with zero index 898 // representing the singular value. 899 return index === 0 ? singular : plural; 900 }; 901 902 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/create-i18n.js 903 904 905 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; } 906 907 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; } 908 909 /** 910 * External dependencies 911 */ 912 913 /** 914 * @typedef {Record<string,any>} LocaleData 915 */ 916 917 /** 918 * Default locale data to use for Tannin domain when not otherwise provided. 919 * Assumes an English plural forms expression. 920 * 921 * @type {LocaleData} 922 */ 923 924 var DEFAULT_LOCALE_DATA = { 925 '': { 926 /** @param {number} n */ 927 plural_forms: function plural_forms(n) { 928 return n === 1 ? 0 : 1; 929 } 930 } 931 }; 932 /** 933 * An i18n instance 934 * 935 * @typedef {Object} I18n 936 * @property {Function} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a 937 * Jed-formatted JSON object shape. 938 * @property {Function} __ Retrieve the translation of text. 939 * @property {Function} _x Retrieve translated string with gettext context. 940 * @property {Function} _n Translates and retrieves the singular or plural form based on the supplied 941 * number. 942 * @property {Function} _nx Translates and retrieves the singular or plural form based on the supplied 943 * number, with gettext context. 944 * @property {Function} isRTL Check if current locale is RTL. 945 */ 946 947 /** 948 * Create an i18n instance 949 * 950 * @param {LocaleData} [initialData] Locale data configuration. 951 * @param {string} [initialDomain] Domain for which configuration applies. 952 * @return {I18n} I18n instance 953 */ 954 955 var create_i18n_createI18n = function createI18n(initialData, initialDomain) { 956 /** 957 * The underlying instance of Tannin to which exported functions interface. 958 * 959 * @type {Tannin} 960 */ 961 var tannin = new Tannin({}); 962 /** 963 * Merges locale data into the Tannin instance by domain. Accepts data in a 964 * Jed-formatted JSON object shape. 965 * 966 * @see http://messageformat.github.io/Jed/ 967 * 968 * @param {LocaleData} [data] Locale data configuration. 969 * @param {string} [domain] Domain for which configuration applies. 970 */ 971 972 var setLocaleData = function setLocaleData(data) { 973 var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; 974 tannin.data[domain] = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA), tannin.data[domain]), data); // Populate default domain configuration (supported locale date which omits 975 // a plural forms expression). 976 977 tannin.data[domain][''] = _objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA['']), tannin.data[domain]['']); 978 }; 979 /** 980 * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not 981 * otherwise previously assigned. 982 * 983 * @param {string|undefined} domain Domain to retrieve the translated text. 984 * @param {string|undefined} context Context information for the translators. 985 * @param {string} single Text to translate if non-plural. Used as 986 * fallback return value on a caught error. 987 * @param {string} [plural] The text to be used if the number is 988 * plural. 989 * @param {number} [number] The number to compare against to use 990 * either the singular or plural form. 991 * 992 * @return {string} The translated string. 993 */ 994 995 996 var dcnpgettext = function dcnpgettext() { 997 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; 998 var context = arguments.length > 1 ? arguments[1] : undefined; 999 var single = arguments.length > 2 ? arguments[2] : undefined; 1000 var plural = arguments.length > 3 ? arguments[3] : undefined; 1001 var number = arguments.length > 4 ? arguments[4] : undefined; 1002 1003 if (!tannin.data[domain]) { 1004 setLocaleData(undefined, domain); 1005 } 1006 1007 return tannin.dcnpgettext(domain, context, single, plural, number); 1008 }; 1009 /** 1010 * Retrieve the translation of text. 1011 * 1012 * @see https://developer.wordpress.org/reference/functions/__/ 1013 * 1014 * @param {string} text Text to translate. 1015 * @param {string} [domain] Domain to retrieve the translated text. 1016 * 1017 * @return {string} Translated text. 1018 */ 1019 1020 1021 var __ = function __(text, domain) { 1022 return dcnpgettext(domain, undefined, text); 1023 }; 1024 /** 1025 * Retrieve translated string with gettext context. 1026 * 1027 * @see https://developer.wordpress.org/reference/functions/_x/ 1028 * 1029 * @param {string} text Text to translate. 1030 * @param {string} context Context information for the translators. 1031 * @param {string} [domain] Domain to retrieve the translated text. 1032 * 1033 * @return {string} Translated context string without pipe. 1034 */ 1035 1036 1037 var _x = function _x(text, context, domain) { 1038 return dcnpgettext(domain, context, text); 1039 }; 1040 /** 1041 * Translates and retrieves the singular or plural form based on the supplied 1042 * number. 1043 * 1044 * @see https://developer.wordpress.org/reference/functions/_n/ 1045 * 1046 * @param {string} single The text to be used if the number is singular. 1047 * @param {string} plural The text to be used if the number is plural. 1048 * @param {number} number The number to compare against to use either the 1049 * singular or plural form. 1050 * @param {string} [domain] Domain to retrieve the translated text. 1051 * 1052 * @return {string} The translated singular or plural form. 1053 */ 1054 1055 1056 var _n = function _n(single, plural, number, domain) { 1057 return dcnpgettext(domain, undefined, single, plural, number); 1058 }; 1059 /** 1060 * Translates and retrieves the singular or plural form based on the supplied 1061 * number, with gettext context. 1062 * 1063 * @see https://developer.wordpress.org/reference/functions/_nx/ 1064 * 1065 * @param {string} single The text to be used if the number is singular. 1066 * @param {string} plural The text to be used if the number is plural. 1067 * @param {number} number The number to compare against to use either the 1068 * singular or plural form. 1069 * @param {string} context Context information for the translators. 1070 * @param {string} [domain] Domain to retrieve the translated text. 1071 * 1072 * @return {string} The translated singular or plural form. 1073 */ 1074 1075 1076 var _nx = function _nx(single, plural, number, context, domain) { 1077 return dcnpgettext(domain, context, single, plural, number); 1078 }; 1079 /** 1080 * Check if current locale is RTL. 1081 * 1082 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. 1083 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common 1084 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, 1085 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). 1086 * 1087 * @return {boolean} Whether locale is RTL. 1088 */ 1089 1090 1091 var isRTL = function isRTL() { 1092 return 'rtl' === _x('ltr', 'text direction'); 1093 }; 1094 1095 if (initialData) { 1096 setLocaleData(initialData, initialDomain); 1097 } 1098 1099 return { 1100 setLocaleData: setLocaleData, 1101 __: __, 1102 _x: _x, 1103 _n: _n, 1104 _nx: _nx, 1105 isRTL: isRTL 1106 }; 1107 }; 1108 1109 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/default-i18n.js 1110 /** 1111 * Internal dependencies 1112 */ 1113 1114 var i18n = create_i18n_createI18n(); 1115 /* 1116 * Comments in this file are duplicated from ./i18n due to 1117 * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722 1118 */ 1119 1120 /** 1121 * @typedef {import('./create-i18n').LocaleData} LocaleData 1122 */ 1123 1124 /** 1125 * Merges locale data into the Tannin instance by domain. Accepts data in a 1126 * Jed-formatted JSON object shape. 1127 * 1128 * @see http://messageformat.github.io/Jed/ 1129 * 1130 * @param {LocaleData} [data] Locale data configuration. 1131 * @param {string} [domain] Domain for which configuration applies. 1132 */ 1133 1134 var default_i18n_setLocaleData = i18n.setLocaleData.bind(i18n); 1135 /** 1136 * Retrieve the translation of text. 1137 * 1138 * @see https://developer.wordpress.org/reference/functions/__/ 1139 * 1140 * @param {string} text Text to translate. 1141 * @param {string} [domain] Domain to retrieve the translated text. 1142 * 1143 * @return {string} Translated text. 1144 */ 1145 1146 var default_i18n_ = i18n.__.bind(i18n); 1147 /** 1148 * Retrieve translated string with gettext context. 1149 * 1150 * @see https://developer.wordpress.org/reference/functions/_x/ 1151 * 1152 * @param {string} text Text to translate. 1153 * @param {string} context Context information for the translators. 1154 * @param {string} [domain] Domain to retrieve the translated text. 1155 * 1156 * @return {string} Translated context string without pipe. 1157 */ 1158 1159 var default_i18n_x = i18n._x.bind(i18n); 1160 /** 1161 * Translates and retrieves the singular or plural form based on the supplied 1162 * number. 1163 * 1164 * @see https://developer.wordpress.org/reference/functions/_n/ 1165 * 1166 * @param {string} single The text to be used if the number is singular. 1167 * @param {string} plural The text to be used if the number is plural. 1168 * @param {number} number The number to compare against to use either the 1169 * singular or plural form. 1170 * @param {string} [domain] Domain to retrieve the translated text. 1171 * 1172 * @return {string} The translated singular or plural form. 1173 */ 1174 1175 var default_i18n_n = i18n._n.bind(i18n); 1176 /** 1177 * Translates and retrieves the singular or plural form based on the supplied 1178 * number, with gettext context. 1179 * 1180 * @see https://developer.wordpress.org/reference/functions/_nx/ 1181 * 1182 * @param {string} single The text to be used if the number is singular. 1183 * @param {string} plural The text to be used if the number is plural. 1184 * @param {number} number The number to compare against to use either the 1185 * singular or plural form. 1186 * @param {string} context Context information for the translators. 1187 * @param {string} [domain] Domain to retrieve the translated text. 1188 * 1189 * @return {string} The translated singular or plural form. 1190 */ 1191 1192 var default_i18n_nx = i18n._nx.bind(i18n); 1193 /** 1194 * Check if current locale is RTL. 1195 * 1196 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. 1197 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common 1198 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, 1199 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). 1200 * 1201 * @return {boolean} Whether locale is RTL. 1202 */ 1203 1204 var default_i18n_isRTL = i18n.isRTL.bind(i18n); 1205 1206 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/index.js 1207 1208 1209 1210 1211 1212 /***/ }), 1213 1214 /***/ 5: 1215 /***/ (function(module, __webpack_exports__, __webpack_require__) { 1216 1217 "use strict"; 1218 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); 1219 function _defineProperty(obj, key, value) { 1220 if (key in obj) { 1221 Object.defineProperty(obj, key, { 1222 value: value, 1223 enumerable: true, 1224 configurable: true, 1225 writable: true 1226 }); 1227 } else { 1228 obj[key] = value; 1229 } 1230 1231 return obj; 1232 } 1233 1234 /***/ }), 1235 1236 /***/ 60: 1237 /***/ (function(module, exports, __webpack_require__) { 1238 1239 /** 1240 * Memize options object. 1241 * 1242 * @typedef MemizeOptions 1243 * 1244 * @property {number} [maxSize] Maximum size of the cache. 1245 */ 1246 1247 /** 1248 * Internal cache entry. 1249 * 1250 * @typedef MemizeCacheNode 1251 * 1252 * @property {?MemizeCacheNode|undefined} [prev] Previous node. 1253 * @property {?MemizeCacheNode|undefined} [next] Next node. 1254 * @property {Array<*>} args Function arguments for cache 1255 * entry. 1256 * @property {*} val Function result. 1257 */ 1258 1259 /** 1260 * Properties of the enhanced function for controlling cache. 1261 * 1262 * @typedef MemizeMemoizedFunction 1263 * 1264 * @property {()=>void} clear Clear the cache. 1265 */ 1266 1267 /** 1268 * Accepts a function to be memoized, and returns a new memoized function, with 1269 * optional options. 1270 * 1271 * @template {Function} F 1272 * 1273 * @param {F} fn Function to memoize. 1274 * @param {MemizeOptions} [options] Options object. 1275 * 1276 * @return {F & MemizeMemoizedFunction} Memoized function. 1277 */ 1278 function memize( fn, options ) { 1279 var size = 0; 1280 1281 /** @type {?MemizeCacheNode|undefined} */ 1282 var head; 1283 1284 /** @type {?MemizeCacheNode|undefined} */ 1285 var tail; 1286 1287 options = options || {}; 1288 1289 function memoized( /* ...args */ ) { 1290 var node = head, 1291 len = arguments.length, 1292 args, i; 1293 1294 searchCache: while ( node ) { 1295 // Perform a shallow equality test to confirm that whether the node 1296 // under test is a candidate for the arguments passed. Two arrays 1297 // are shallowly equal if their length matches and each entry is 1298 // strictly equal between the two sets. Avoid abstracting to a 1299 // function which could incur an arguments leaking deoptimization. 1300 1301 // Check whether node arguments match arguments length 1302 if ( node.args.length !== arguments.length ) { 1303 node = node.next; 1304 continue; 1305 } 1306 1307 // Check whether node arguments match arguments values 1308 for ( i = 0; i < len; i++ ) { 1309 if ( node.args[ i ] !== arguments[ i ] ) { 1310 node = node.next; 1311 continue searchCache; 1312 } 1313 } 1314 1315 // At this point we can assume we've found a match 1316 1317 // Surface matched node to head if not already 1318 if ( node !== head ) { 1319 // As tail, shift to previous. Must only shift if not also 1320 // head, since if both head and tail, there is no previous. 1321 if ( node === tail ) { 1322 tail = node.prev; 1323 } 1324 1325 // Adjust siblings to point to each other. If node was tail, 1326 // this also handles new tail's empty `next` assignment. 1327 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; 1328 if ( node.next ) { 1329 node.next.prev = node.prev; 1330 } 1331 1332 node.next = head; 1333 node.prev = null; 1334 /** @type {MemizeCacheNode} */ ( head ).prev = node; 1335 head = node; 1336 } 1337 1338 // Return immediately 1339 return node.val; 1340 } 1341 1342 // No cached value found. Continue to insertion phase: 1343 1344 // Create a copy of arguments (avoid leaking deoptimization) 1345 args = new Array( len ); 1346 for ( i = 0; i < len; i++ ) { 1347 args[ i ] = arguments[ i ]; 1348 } 1349 1350 node = { 1351 args: args, 1352 1353 // Generate the result from original function 1354 val: fn.apply( null, args ), 1355 }; 1356 1357 // Don't need to check whether node is already head, since it would 1358 // have been returned above already if it was 1359 1360 // Shift existing head down list 1361 if ( head ) { 1362 head.prev = node; 1363 node.next = head; 1364 } else { 1365 // If no head, follows that there's no tail (at initial or reset) 1366 tail = node; 1367 } 1368 1369 // Trim tail if we're reached max size and are pending cache insertion 1370 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { 1371 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; 1372 /** @type {MemizeCacheNode} */ ( tail ).next = null; 1373 } else { 1374 size++; 1375 } 1376 1377 head = node; 1378 1379 return node.val; 1380 } 1381 1382 memoized.clear = function() { 1383 head = null; 1384 tail = null; 1385 size = 0; 1386 }; 1387 1388 if ( false ) {} 1389 1390 // Ignore reason: There's not a clear solution to create an intersection of 1391 // the function with additional properties, where the goal is to retain the 1392 // function signature of the incoming argument and add control properties 1393 // on the return value. 1394 1395 // @ts-ignore 1396 return memoized; 1397 } 1398 1399 module.exports = memize; 1400 1401 1402 /***/ }) 1403 1404 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Jan 23 01:00:05 2021 | Cross-referenced by PHPXref 0.7.1 |