vendor: 4,154 bytes, lines 1-82
1/******/ (function() { // webpackBootstrap 2/******/ "use strict"; 3/******/ // The require scope 4/******/ var __webpack_require__ = {}; 5/******/ 6/************************************************************************/ 7/******/ /* webpack/runtime/define property getters */ 8/******/ !function() { 9/******/ // define getter functions for harmony exports 10/******/ __webpack_require__.d = function(exports, definition) { 11/******/ for(var key in definition) { 12/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14/******/ } 15/******/ } 16/******/ }; 17/******/ }(); 18/******/ 19/******/ /* webpack/runtime/hasOwnProperty shorthand */ 20/******/ !function() { 21/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 22/******/ }(); 23/******/ 24/******/ /* webpack/runtime/make namespace object */ 25/******/ !function() { 26/******/ // define __esModule on exports 27/******/ __webpack_require__.r = function(exports) { 28/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30/******/ } 31/******/ Object.defineProperty(exports, '__esModule', { value: true }); 32/******/ }; 33/******/ }(); 34/******/ 35/************************************************************************/ 36var __webpack_exports__ = {}; 37// ESM COMPAT FLAG 38__webpack_require__.r(__webpack_exports__); 39 40// EXPORTS 41__webpack_require__.d(__webpack_exports__, { 42 "count": function() { return /* binding */ count; } 43}); 44 45;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/defaultSettings.js 46/** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */ 47 48/** @typedef {Partial<{type: WPWordCountStrategy, shortcodes: string[]}>} WPWordCountL10n */ 49 50/** 51 * @typedef WPWordCountSettingsFields 52 * @property {RegExp} HTMLRegExp Regular expression that matches HTML tags 53 * @property {RegExp} HTMLcommentRegExp Regular expression that matches HTML comments 54 * @property {RegExp} spaceRegExp Regular expression that matches spaces in HTML 55 * @property {RegExp} HTMLEntityRegExp Regular expression that matches HTML entities 56 * @property {RegExp} connectorRegExp Regular expression that matches word connectors, like em-dash 57 * @property {RegExp} removeRegExp Regular expression that matches various characters to be removed when counting 58 * @property {RegExp} astralRegExp Regular expression that matches astral UTF-16 code points 59 * @property {RegExp} wordsRegExp Regular expression that matches words 60 * @property {RegExp} characters_excluding_spacesRegExp Regular expression that matches characters excluding spaces 61 * @property {RegExp} characters_including_spacesRegExp Regular expression that matches characters including spaces 62 * @property {RegExp} shortcodesRegExp Regular expression that matches WordPress shortcodes 63 * @property {string[]} shortcodes List of all shortcodes 64 * @property {WPWordCountStrategy} type Describes what and how are we counting 65 * @property {WPWordCountL10n} l10n Object with human translations 66 */ 67 68/** 69 * Lower-level settings for word counting that can be overridden. 70 * 71 * @typedef {Partial<WPWordCountSettingsFields>} WPWordCountUserSettings 72 */ 73// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly: https://github.com/jsdoc/jsdoc/issues/1285 74 75/* eslint-disable jsdoc/valid-types */ 76 77/** 78 * Word counting settings that include non-optional values we set if missing 79 * 80 * @typedef {WPWordCountUserSettings & typeof defaultSettings} WPWordCountDefaultSettings 81 */ 82
83/* eslint-enable jsdoc/valid-types */ 84const defaultSettings = { 85 HTMLRegExp: /<\/?[a-z][^>]*?>/gi, 86 HTMLcommentRegExp: /<!--[\s\S]*?-->/g, 87 spaceRegExp: / | /gi, 88 HTMLEntityRegExp: /&\S+?;/g, 89 // \u2014 = em-dash. 90 connectorRegExp: /--|\u2014/g, 91 // Characters to be removed from input text. 92 removeRegExp: new RegExp(['[', // Basic Latin (extract) 93 '\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E', // Latin-1 Supplement (extract) 94 '\u0080-\u00BF\u00D7\u00F7', 95 /* 96 * The following range consists of: 97 * General Punctuation 98 * Superscripts and Subscripts 99 * Currency Symbols 100 * Combining Diacritical Marks for Symbols 101 * Letterlike Symbols 102 * Number Forms 103 * Arrows 104 * Mathematical Operators 105 * Miscellaneous Technical 106 * Control Pictures 107 * Optical Character Recognition 108 * Enclosed Alphanumerics 109 * Box Drawing 110 * Block Elements 111 * Geometric Shapes 112 * Miscellaneous Symbols 113 * Dingbats 114 * Miscellaneous Mathematical Symbols-A 115 * Supplemental Arrows-A 116 * Braille Patterns 117 * Supplemental Arrows-B 118 * Miscellaneous Mathematical Symbols-B 119 * Supplemental Mathematical Operators 120 * Miscellaneous Symbols and Arrows 121 */ 122 '\u2000-\u2BFF', // Supplemental Punctuation. 123 '\u2E00-\u2E7F', ']'].join(''), 'g'), 124 // Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF 125 astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 126 wordsRegExp: /\S\s+/g, 127 characters_excluding_spacesRegExp: /\S/g, 128 129 /* 130 * Match anything that is not a formatting character, excluding: 131 * \f = form feed 132 * \n = new line 133 * \r = carriage return 134 * \t = tab 135 * \v = vertical tab 136 * \u00AD = soft hyphen 137 * \u2028 = line separator 138 * \u2029 = paragraph separator 139 */ 140 characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g, 141 l10n: { 142 type: 'words' 143 } 144}; 145 146;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripTags.js 147/** 148 * Replaces items matched in the regex with new line 149 * 150 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 151 * @param {string} text The string being counted. 152 * 153 * @return {string} The manipulated text. 154 */ 155function stripTags(settings, text) { 156 return text.replace(settings.HTMLRegExp, '\n'); 157} 158 159;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeAstralsToCountableChar.js 160/** 161 * Replaces items matched in the regex with character. 162 * 163 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 164 * @param {string} text The string being counted. 165 * 166 * @return {string} The manipulated text. 167 */ 168function transposeAstralsToCountableChar(settings, text) { 169 return text.replace(settings.astralRegExp, 'a'); 170} 171 172;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLEntities.js 173/** 174 * Removes items matched in the regex. 175 * 176 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 177 * @param {string} text The string being counted. 178 * 179 * @return {string} The manipulated text. 180 */ 181function stripHTMLEntities(settings, text) { 182 return text.replace(settings.HTMLEntityRegExp, ''); 183} 184 185;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripConnectors.js 186/** 187 * Replaces items matched in the regex with spaces. 188 * 189 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 190 * @param {string} text The string being counted. 191 * 192 * @return {string} The manipulated text. 193 */ 194function stripConnectors(settings, text) { 195 return text.replace(settings.connectorRegExp, ' '); 196} 197 198;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripRemovables.js 199/** 200 * Removes items matched in the regex. 201 * 202 * @param {import('./index').WPWordCountSettings}
202 settings The main settings object containing regular expressions 203 * @param {string} text The string being counted. 204 * 205 * @return {string} The manipulated text. 206 */ 207function stripRemovables(settings, text) { 208 return text.replace(settings.removeRegExp, ''); 209} 210 211;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLComments.js 212/** 213 * Removes items matched in the regex. 214 * 215 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 216 * @param {string} text The string being counted. 217 * 218 * @return {string} The manipulated text. 219 */ 220function stripHTMLComments(settings, text) { 221 return text.replace(settings.HTMLcommentRegExp, ''); 222} 223 224;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripShortcodes.js 225/** 226 * Replaces items matched in the regex with a new line. 227 * 228 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 229 * @param {string} text The string being counted. 230 * 231 * @return {string} The manipulated text. 232 */ 233function stripShortcodes(settings, text) { 234 if (settings.shortcodesRegExp) { 235 return text.replace(settings.shortcodesRegExp, '\n'); 236 } 237 238 return text; 239} 240 241;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripSpaces.js 242/** 243 * Replaces items matched in the regex with spaces. 244 * 245 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 246 * @param {string} text The string being counted. 247 * 248 * @return {string} The manipulated text. 249 */ 250function stripSpaces(settings, text) { 251 return text.replace(settings.spaceRegExp, ' '); 252} 253 254;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeHTMLEntitiesToCountableChars.js 255/** 256 * Replaces items matched in the regex with a single character. 257 * 258 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions 259 * @param {string} text The string being counted. 260 * 261 * @return {string} The manipulated text. 262 */ 263function transposeHTMLEntitiesToCountableChars(settings, text) { 264 return text.replace(settings.HTMLEntityRegExp, 'a'); 265} 266 267;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/index.js 268/** 269 * Internal dependencies 270 */ 271 272 273 274 275 276 277 278 279 280 281/** 282 * @typedef {import('./defaultSettings').WPWordCountDefaultSettings} WPWordCountSettings 283 * @typedef {import('./defaultSettings').WPWordCountUserSettings} WPWordCountUserSettings 284 */ 285
286/** 287 * Possible ways of counting. 288 * 289 * @typedef {'words'|'characters_excluding_spaces'|'characters_including_spaces'} WPWordCountStrategy 290 */ 291 292/** 293 * Private function to manage the settings. 294 * 295 * @param {WPWordCountStrategy} type The type of count to be done. 296 * @param {WPWordCountUserSettings} userSettings Custom settings for the count. 297 * 298 * @return {WPWordCountSettings} The combined settings object to be used. 299 */ 300 301function loadSettings(type, userSettings) { 302 var _settings$l10n$shortc; 303 304 const settings = Object.assign({}, defaultSettings, userSettings); 305 settings.shortcodes = (_settings$l10n$shortc = settings.l10n?.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : []; 306 307 if (settings.shortcodes && settings.shortcodes.length) { 308 settings.shortcodesRegExp = new RegExp('\\[\\/?(?:' + settings.shortcodes.join('|') + ')[^\\]]*?\\]', 'g'); 309 } 310 311 settings.type = type; 312 313 if (settings.type !== 'characters_excluding_spaces' && settings.type !== 'characters_including_spaces') { 314 settings.type = 'words'; 315 } 316 317 return settings; 318} 319/** 320 * Count the words in text 321 * 322 * @param {string} text The text being processed 323 * @param {RegExp} regex The regular expression pattern being matched 324 * @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function 325 * 326 * @return {number} Count of words. 327 */ 328 329 330function countWords(text, regex, settings) { 331 var _text$match$length; 332 333 text = [stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), stripSpaces.bind(null, settings), stripHTMLEntities.bind(null, settings), stripConnectors.bind(null, settings), stripRemovables.bind(null, settings)].reduce((result, fn) => fn(result), text); 334 text = text + '\n'; 335 return (_text$match$length = text.match(regex)?.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0; 336} 337/** 338 * Count the characters in text 339 * 340 * @param {string} text The text being processed 341 * @param {RegExp} regex The regular expression pattern being matched 342 * @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function 343 * 344 * @return {number} Count of characters. 345 */ 346 347 348function countCharacters(text, regex, settings) { 349 var _text$match$length2; 350 351 text = [stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), transposeAstralsToCountableChar.bind(null, settings), stripSpaces.bind(null, settings), transposeHTMLEntitiesToCountableChars.bind(null, settings)].reduce((result, fn) => fn(result), text); 352 text = text + '\n'; 353 return (_text$match$length2 = text.match(regex)?.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0; 354} 355/** 356 * Count some words. 357 * 358 * @param {string} text The text being processed 359 * @param {WPWordCountStrategy} type The type of count. Accepts 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. 360 * @param {WPWordCountUserSettings} userSettings Custom settings object. 361 * 362 * @example 363 * ```js 364 * import { count } from '@wordpress/wordcount'; 365 * const numberOfWords = count( 'Words to count', 'words', {} ) 366 * ``` 367 * 368 * @return {number} The word or character count. 369 */ 370 371 372function count(text, type, userSettings) { 373 const settings = loadSettings(type, userSettings); 374 let matchRegExp; 375 376 switch (settings.type) { 377 case 'words': 378 matchRegExp = settings.wordsRegExp; 379 return countWords(text, matchRegExp, settings); 380 381 case 'characters_including_spaces': 382 matchRegExp = settings.characters_including_spacesRegExp; 383 return countCharacters(text, matchRegExp, settings); 384 385 case 'characters_excluding_spaces': 386 matchRegExp = settings.characters_excluding_spacesRegExp; 387 return countCharacters(text, matchRegExp, settings); 388 389 default: 390 return 0; 391 } 392} 393 394(window.wp = window.wp || {}).wordcount = __webpack_exports__; 395/******/ })() 396;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.