wp/wp-includes/js/dist/wordcount.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-includes/js/dist/wordcount.js	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/js/dist/wordcount.js	Fri Sep 05 18:40:08 2025 +0200
@@ -1,36 +1,36 @@
-/******/ (function() { // webpackBootstrap
+/******/ (() => { // webpackBootstrap
 /******/ 	"use strict";
 /******/ 	// The require scope
 /******/ 	var __webpack_require__ = {};
 /******/ 	
 /************************************************************************/
 /******/ 	/* webpack/runtime/define property getters */
-/******/ 	!function() {
+/******/ 	(() => {
 /******/ 		// define getter functions for harmony exports
-/******/ 		__webpack_require__.d = function(exports, definition) {
+/******/ 		__webpack_require__.d = (exports, definition) => {
 /******/ 			for(var key in definition) {
 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
 /******/ 				}
 /******/ 			}
 /******/ 		};
-/******/ 	}();
+/******/ 	})();
 /******/ 	
 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
-/******/ 	!function() {
-/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
-/******/ 	}();
+/******/ 	(() => {
+/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ 	})();
 /******/ 	
 /******/ 	/* webpack/runtime/make namespace object */
-/******/ 	!function() {
+/******/ 	(() => {
 /******/ 		// define __esModule on exports
-/******/ 		__webpack_require__.r = function(exports) {
+/******/ 		__webpack_require__.r = (exports) => {
 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
 /******/ 			}
 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
 /******/ 		};
-/******/ 	}();
+/******/ 	})();
 /******/ 	
 /************************************************************************/
 var __webpack_exports__ = {};
@@ -39,11 +39,9 @@
 
 // EXPORTS
 __webpack_require__.d(__webpack_exports__, {
-  "count": function() { return /* binding */ count; }
+  count: () => (/* binding */ count)
 });
 
-;// CONCATENATED MODULE: external "lodash"
-var external_lodash_namespaceObject = window["lodash"];
 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/defaultSettings.js
 /** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */
 
@@ -72,17 +70,16 @@
  *
  * @typedef {Partial<WPWordCountSettingsFields>} WPWordCountUserSettings
  */
+
 // Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly: https://github.com/jsdoc/jsdoc/issues/1285
-
 /* eslint-disable jsdoc/valid-types */
-
 /**
  * Word counting settings that include non-optional values we set if missing
  *
  * @typedef {WPWordCountUserSettings & typeof defaultSettings} WPWordCountDefaultSettings
  */
+/* eslint-enable jsdoc/valid-types */
 
-/* eslint-enable jsdoc/valid-types */
 const defaultSettings = {
   HTMLRegExp: /<\/?[a-z][^>]*?>/gi,
   HTMLcommentRegExp: /<!--[\s\S]*?-->/g,
@@ -91,8 +88,10 @@
   // \u2014 = em-dash.
   connectorRegExp: /--|\u2014/g,
   // Characters to be removed from input text.
-  removeRegExp: new RegExp(['[', // Basic Latin (extract)
-  '\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E', // Latin-1 Supplement (extract)
+  removeRegExp: new RegExp(['[',
+  // Basic Latin (extract)
+  '\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E',
+  // Latin-1 Supplement (extract)
   '\u0080-\u00BF\u00D7\u00F7',
   /*
    * The following range consists of:
@@ -121,13 +120,13 @@
    * Supplemental Mathematical Operators
    * Miscellaneous Symbols and Arrows
    */
-  '\u2000-\u2BFF', // Supplemental Punctuation.
+  '\u2000-\u2BFF',
+  // Supplemental Punctuation.
   '\u2E00-\u2E7F', ']'].join(''), 'g'),
   // Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
   astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
   wordsRegExp: /\S\s+/g,
   characters_excluding_spacesRegExp: /\S/g,
-
   /*
    * Match anything that is not a formatting character, excluding:
    * \f = form feed
@@ -236,7 +235,6 @@
   if (settings.shortcodesRegExp) {
     return text.replace(settings.shortcodesRegExp, '\n');
   }
-
   return text;
 }
 
@@ -268,10 +266,6 @@
 
 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/index.js
 /**
- * External dependencies
- */
-
-/**
  * Internal dependencies
  */
 
@@ -304,25 +298,20 @@
  *
  * @return {WPWordCountSettings} The combined settings object to be used.
  */
-
 function loadSettings(type, userSettings) {
-  var _settings$l10n$shortc, _settings$l10n;
-
-  const settings = (0,external_lodash_namespaceObject.extend)({}, defaultSettings, userSettings);
-  settings.shortcodes = (_settings$l10n$shortc = (_settings$l10n = settings.l10n) === null || _settings$l10n === void 0 ? void 0 : _settings$l10n.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : [];
-
+  var _settings$l10n$shortc;
+  const settings = Object.assign({}, defaultSettings, userSettings);
+  settings.shortcodes = (_settings$l10n$shortc = settings.l10n?.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : [];
   if (settings.shortcodes && settings.shortcodes.length) {
     settings.shortcodesRegExp = new RegExp('\\[\\/?(?:' + settings.shortcodes.join('|') + ')[^\\]]*?\\]', 'g');
   }
-
   settings.type = type;
-
   if (settings.type !== 'characters_excluding_spaces' && settings.type !== 'characters_including_spaces') {
     settings.type = 'words';
   }
-
   return settings;
 }
+
 /**
  * Count the words in text
  *
@@ -332,15 +321,13 @@
  *
  * @return {number} Count of words.
  */
-
-
 function countWords(text, regex, settings) {
-  var _text$match$length, _text$match;
+  var _text$match$length;
+  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);
+  text = text + '\n';
+  return (_text$match$length = text.match(regex)?.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0;
+}
 
-  text = (0,external_lodash_namespaceObject.flow)(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))(text);
-  text = text + '\n';
-  return (_text$match$length = (_text$match = text.match(regex)) === null || _text$match === void 0 ? void 0 : _text$match.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0;
-}
 /**
  * Count the characters in text
  *
@@ -350,15 +337,13 @@
  *
  * @return {number} Count of characters.
  */
-
-
 function countCharacters(text, regex, settings) {
-  var _text$match$length2, _text$match2;
+  var _text$match$length2;
+  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);
+  text = text + '\n';
+  return (_text$match$length2 = text.match(regex)?.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0;
+}
 
-  text = (0,external_lodash_namespaceObject.flow)(stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), transposeAstralsToCountableChar.bind(null, settings), stripSpaces.bind(null, settings), transposeHTMLEntitiesToCountableChars.bind(null, settings))(text);
-  text = text + '\n';
-  return (_text$match$length2 = (_text$match2 = text.match(regex)) === null || _text$match2 === void 0 ? void 0 : _text$match2.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0;
-}
 /**
  * Count some words.
  *
@@ -374,25 +359,19 @@
  *
  * @return {number} The word or character count.
  */
-
-
 function count(text, type, userSettings) {
   const settings = loadSettings(type, userSettings);
   let matchRegExp;
-
   switch (settings.type) {
     case 'words':
       matchRegExp = settings.wordsRegExp;
       return countWords(text, matchRegExp, settings);
-
     case 'characters_including_spaces':
       matchRegExp = settings.characters_including_spacesRegExp;
       return countCharacters(text, matchRegExp, settings);
-
     case 'characters_excluding_spaces':
       matchRegExp = settings.characters_excluding_spacesRegExp;
       return countCharacters(text, matchRegExp, settings);
-
     default:
       return 0;
   }