| @@ -1,5 +1,5 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 1 | +/******/ (() => { // webpackBootstrap | |
| 2 | 2 | /******/ "use strict"; |
| 3 | 3 | /******/ // The require scope |
| 4 | 4 | /******/ var __webpack_require__ = {}; |
| 5 | 5 | /******/ |
| @@ -4,11 +4,11 @@ | ||
| 4 | 4 | /******/ var __webpack_require__ = {}; |
| 5 | 5 | /******/ |
| 6 | 6 | /************************************************************************/ |
| 7 | 7 | /******/ /* webpack/runtime/define property getters */ |
| 8 | -/******/ !function() { | |
| 8 | +/******/ (() => { | |
| 9 | 9 | /******/ // define getter functions for harmony exports |
| 10 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 10 | +/******/ __webpack_require__.d = (exports, definition) => { | |
| 11 | 11 | /******/ for(var key in definition) { |
| 12 | 12 | /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 13 | 13 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 14 | 14 | /******/ } |
| @@ -13,25 +13,25 @@ | ||
| 13 | 13 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 14 | 14 | /******/ } |
| 15 | 15 | /******/ } |
| 16 | 16 | /******/ }; |
| 17 | -/******/ }(); | |
| 17 | +/******/ })(); | |
| 18 | 18 | /******/ |
| 19 | 19 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 20 | -/******/ !function() { | |
| 21 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 22 | -/******/ }(); | |
| 20 | +/******/ (() => { | |
| 21 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 22 | +/******/ })(); | |
| 23 | 23 | /******/ |
| 24 | 24 | /******/ /* webpack/runtime/make namespace object */ |
| 25 | -/******/ !function() { | |
| 25 | +/******/ (() => { | |
| 26 | 26 | /******/ // define __esModule on exports |
| 27 | -/******/ __webpack_require__.r = function(exports) { | |
| 27 | +/******/ __webpack_require__.r = (exports) => { | |
| 28 | 28 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 29 | 29 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 30 | 30 | /******/ } |
| 31 | 31 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 32 | 32 | /******/ }; |
| 33 | -/******/ }(); | |
| 33 | +/******/ })(); | |
| 34 | 34 | /******/ |
| 35 | 35 | /************************************************************************/ |
| 36 | 36 | var __webpack_exports__ = {}; |
| 37 | 37 | // ESM COMPAT FLAG |
| @@ -38,9 +38,9 @@ | ||
| 38 | 38 | __webpack_require__.r(__webpack_exports__); |
| 39 | 39 | |
| 40 | 40 | // EXPORTS |
| 41 | 41 | __webpack_require__.d(__webpack_exports__, { |
| 42 | - "store": function() { return /* reexport */ store; } | |
| 42 | + "store": () => (/* reexport */ store) | |
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | 45 | // NAMESPACE OBJECT: ./packages/annotations/build-module/store/selectors.js |
| 46 | 46 | var selectors_namespaceObject = {}; |
| @@ -45,12 +45,12 @@ | ||
| 45 | 45 | // NAMESPACE OBJECT: ./packages/annotations/build-module/store/selectors.js |
| 46 | 46 | var selectors_namespaceObject = {}; |
| 47 | 47 | __webpack_require__.r(selectors_namespaceObject); |
| 48 | 48 | __webpack_require__.d(selectors_namespaceObject, { |
| 49 | - "__experimentalGetAllAnnotationsForBlock": function() { return __experimentalGetAllAnnotationsForBlock; }, | |
| 50 | - "__experimentalGetAnnotations": function() { return __experimentalGetAnnotations; }, | |
| 51 | - "__experimentalGetAnnotationsForBlock": function() { return __experimentalGetAnnotationsForBlock; }, | |
| 52 | - "__experimentalGetAnnotationsForRichText": function() { return __experimentalGetAnnotationsForRichText; } | |
| 49 | + "__experimentalGetAllAnnotationsForBlock": () => (__experimentalGetAllAnnotationsForBlock), | |
| 50 | + "__experimentalGetAnnotations": () => (__experimentalGetAnnotations), | |
| 51 | + "__experimentalGetAnnotationsForBlock": () => (__experimentalGetAnnotationsForBlock), | |
| 52 | + "__experimentalGetAnnotationsForRichText": () => (__experimentalGetAnnotationsForRichText) | |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | // NAMESPACE OBJECT: ./packages/annotations/build-module/store/actions.js |
| 56 | 56 | var actions_namespaceObject = {}; |
| @@ -55,18 +55,18 @@ | ||
| 55 | 55 | // NAMESPACE OBJECT: ./packages/annotations/build-module/store/actions.js |
| 56 | 56 | var actions_namespaceObject = {}; |
| 57 | 57 | __webpack_require__.r(actions_namespaceObject); |
| 58 | 58 | __webpack_require__.d(actions_namespaceObject, { |
| 59 | - "__experimentalAddAnnotation": function() { return __experimentalAddAnnotation; }, | |
| 60 | - "__experimentalRemoveAnnotation": function() { return __experimentalRemoveAnnotation; }, | |
| 61 | - "__experimentalRemoveAnnotationsBySource": function() { return __experimentalRemoveAnnotationsBySource; }, | |
| 62 | - "__experimentalUpdateAnnotationRange": function() { return __experimentalUpdateAnnotationRange; } | |
| 59 | + "__experimentalAddAnnotation": () => (__experimentalAddAnnotation), | |
| 60 | + "__experimentalRemoveAnnotation": () => (__experimentalRemoveAnnotation), | |
| 61 | + "__experimentalRemoveAnnotationsBySource": () => (__experimentalRemoveAnnotationsBySource), | |
| 62 | + "__experimentalUpdateAnnotationRange": () => (__experimentalUpdateAnnotationRange) | |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | ;// CONCATENATED MODULE: external ["wp","richText"] |
| 66 | -var external_wp_richText_namespaceObject = window["wp"]["richText"]; | |
| 66 | +const external_wp_richText_namespaceObject = window["wp"]["richText"]; | |
| 67 | 67 | ;// CONCATENATED MODULE: external ["wp","i18n"] |
| 68 | -var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; | |
| 68 | +const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; | |
| 69 | 69 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/store/constants.js |
| 70 | 70 | /** |
| 71 | 71 | * The identifier for the data store. |
| 72 | 72 | * |
| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | * |
| 73 | 73 | * @type {string} |
| 74 | 74 | */ |
| 75 | 75 | const STORE_NAME = 'core/annotations'; |
| 76 | -//# sourceMappingURL=constants.js.map | |
| 76 | + | |
| 77 | 77 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/format/annotation.js |
| 78 | 78 | /** |
| 79 | 79 | * WordPress dependencies |
| 80 | 80 | */ |
| @@ -266,9 +266,9 @@ | ||
| 266 | 266 | }; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | }; |
| 270 | -//# sourceMappingURL=annotation.js.map | |
| 270 | + | |
| 271 | 271 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/format/index.js |
| 272 | 272 | /** |
| 273 | 273 | * WordPress dependencies |
| 274 | 274 | */ |
| @@ -282,13 +282,13 @@ | ||
| 282 | 282 | name: format_name, |
| 283 | 283 | ...settings |
| 284 | 284 | } = annotation; |
| 285 | 285 | (0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings); |
| 286 | -//# sourceMappingURL=index.js.map | |
| 286 | + | |
| 287 | 287 | ;// CONCATENATED MODULE: external ["wp","hooks"] |
| 288 | -var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; | |
| 288 | +const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; | |
| 289 | 289 | ;// CONCATENATED MODULE: external ["wp","data"] |
| 290 | -var external_wp_data_namespaceObject = window["wp"]["data"]; | |
| 290 | +const external_wp_data_namespaceObject = window["wp"]["data"]; | |
| 291 | 291 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/block/index.js |
| 292 | 292 | /** |
| 293 | 293 | * WordPress dependencies |
| 294 | 294 | */ |
| @@ -323,17 +323,11 @@ | ||
| 323 | 323 | })(OriginalComponent); |
| 324 | 324 | }; |
| 325 | 325 | |
| 326 | 326 | (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName); |
| 327 | -//# sourceMappingURL=index.js.map | |
| 328 | -;// CONCATENATED MODULE: external "lodash" | |
| 329 | -var external_lodash_namespaceObject = window["lodash"]; | |
| 327 | + | |
| 330 | 328 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/store/reducer.js |
| 331 | 329 | /** |
| 332 | - * External dependencies | |
| 333 | - */ | |
| 334 | - | |
| 335 | -/** | |
| 336 | 330 | * Filters an array based on the predicate, but keeps the reference the same if |
| 337 | 331 | * the array hasn't changed. |
| 338 | 332 | * |
| 339 | 333 | * @param {Array} collection The collection to filter. |
| @@ -340,14 +334,29 @@ | ||
| 340 | 334 | * @param {Function} predicate Function that determines if the item should stay |
| 341 | 335 | * in the array. |
| 342 | 336 | * @return {Array} Filtered array. |
| 343 | 337 | */ |
| 344 | - | |
| 345 | 338 | function filterWithReference(collection, predicate) { |
| 346 | 339 | const filteredCollection = collection.filter(predicate); |
| 347 | 340 | return collection.length === filteredCollection.length ? collection : filteredCollection; |
| 348 | 341 | } |
| 349 | 342 | /** |
| 343 | + * Creates a new object with the same keys, but with `callback()` called as | |
| 344 | + * a transformer function on each of the values. | |
| 345 | + * | |
| 346 | + * @param {Object} obj The object to transform. | |
| 347 | + * @param {Function} callback The function to transform each object value. | |
| 348 | + * @return {Array} Transformed object. | |
| 349 | + */ | |
| 350 | + | |
| 351 | + | |
| 352 | +const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, _ref) => { | |
| 353 | + let [key, value] = _ref; | |
| 354 | + return { ...acc, | |
| 355 | + [key]: callback(value) | |
| 356 | + }; | |
| 357 | +}, {}); | |
| 358 | +/** | |
| 350 | 359 | * Verifies whether the given annotations is a valid annotation. |
| 351 | 360 | * |
| 352 | 361 | * @param {Object} annotation The annotation to verify. |
| 353 | 362 | * @return {boolean} Whether the given annotation is valid. |
| @@ -354,9 +363,9 @@ | ||
| 354 | 363 | */ |
| 355 | 364 | |
| 356 | 365 | |
| 357 | 366 | function isValidAnnotationRange(annotation) { |
| 358 | - return (0,external_lodash_namespaceObject.isNumber)(annotation.start) && (0,external_lodash_namespaceObject.isNumber)(annotation.end) && annotation.start <= annotation.end; | |
| 367 | + return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end; | |
| 359 | 368 | } |
| 360 | 369 | /** |
| 361 | 370 | * Reducer managing annotations. |
| 362 | 371 | * |
| @@ -394,9 +403,9 @@ | ||
| 394 | 403 | [blockClientId]: [...previousAnnotationsForBlock, newAnnotation] |
| 395 | 404 | }; |
| 396 | 405 | |
| 397 | 406 | case 'ANNOTATION_REMOVE': |
| 398 | - return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { | |
| 407 | + return mapValues(state, annotationsForBlock => { | |
| 399 | 408 | return filterWithReference(annotationsForBlock, annotation => { |
| 400 | 409 | return annotation.id !== action.annotationId; |
| 401 | 410 | }); |
| 402 | 411 | }); |
| @@ -401,9 +410,9 @@ | ||
| 401 | 410 | }); |
| 402 | 411 | }); |
| 403 | 412 | |
| 404 | 413 | case 'ANNOTATION_UPDATE_RANGE': |
| 405 | - return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { | |
| 414 | + return mapValues(state, annotationsForBlock => { | |
| 406 | 415 | let hasChangedRange = false; |
| 407 | 416 | const newAnnotations = annotationsForBlock.map(annotation => { |
| 408 | 417 | if (annotation.id === action.annotationId) { |
| 409 | 418 | hasChangedRange = true; |
| @@ -420,9 +429,9 @@ | ||
| 420 | 429 | return hasChangedRange ? newAnnotations : annotationsForBlock; |
| 421 | 430 | }); |
| 422 | 431 | |
| 423 | 432 | case 'ANNOTATION_REMOVE_SOURCE': |
| 424 | - return (0,external_lodash_namespaceObject.mapValues)(state, annotationsForBlock => { | |
| 433 | + return mapValues(state, annotationsForBlock => { | |
| 425 | 434 | return filterWithReference(annotationsForBlock, annotation => { |
| 426 | 435 | return annotation.source !== action.source; |
| 427 | 436 | }); |
| 428 | 437 | }); |
| @@ -429,38 +438,64 @@ | ||
| 429 | 438 | } |
| 430 | 439 | |
| 431 | 440 | return state; |
| 432 | 441 | } |
| 433 | -/* harmony default export */ var reducer = (annotations); | |
| 434 | -//# sourceMappingURL=reducer.js.map | |
| 442 | +/* harmony default export */ const reducer = (annotations); | |
| 443 | + | |
| 435 | 444 | ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
| 436 | 445 | |
| 437 | 446 | |
| 438 | -var LEAF_KEY, hasWeakMap; | |
| 447 | +/** @typedef {(...args: any[]) => *[]} GetDependants */ | |
| 439 | 448 | |
| 449 | +/** @typedef {() => void} Clear */ | |
| 450 | + | |
| 440 | 451 | /** |
| 441 | - * Arbitrary value used as key for referencing cache object in WeakMap tree. | |
| 452 | + * @typedef {{ | |
| 453 | + * getDependants: GetDependants, | |
| 454 | + * clear: Clear | |
| 455 | + * }} EnhancedSelector | |
| 456 | + */ | |
| 457 | + | |
| 458 | +/** | |
| 459 | + * Internal cache entry. | |
| 442 | 460 | * |
| 443 | - * @type {Object} | |
| 461 | + * @typedef CacheNode | |
| 462 | + * | |
| 463 | + * @property {?CacheNode|undefined} [prev] Previous node. | |
| 464 | + * @property {?CacheNode|undefined} [next] Next node. | |
| 465 | + * @property {*[]} args Function arguments for cache entry. | |
| 466 | + * @property {*} val Function result. | |
| 444 | 467 | */ |
| 445 | -LEAF_KEY = {}; | |
| 446 | 468 | |
| 447 | 469 | /** |
| 448 | - * Whether environment supports WeakMap. | |
| 470 | + * @typedef Cache | |
| 449 | 471 | * |
| 450 | - * @type {boolean} | |
| 472 | + * @property {Clear} clear Function to clear cache. | |
| 473 | + * @property {boolean} [isUniqueByDependants] Whether dependants are valid in | |
| 474 | + * considering cache uniqueness. A cache is unique if dependents are all arrays | |
| 475 | + * or objects. | |
| 476 | + * @property {CacheNode?} [head] Cache head. | |
| 477 | + * @property {*[]} [lastDependants] Dependants from previous invocation. | |
| 451 | 478 | */ |
| 452 | -hasWeakMap = typeof WeakMap !== 'undefined'; | |
| 453 | 479 | |
| 454 | 480 | /** |
| 481 | + * Arbitrary value used as key for referencing cache object in WeakMap tree. | |
| 482 | + * | |
| 483 | + * @type {{}} | |
| 484 | + */ | |
| 485 | +var LEAF_KEY = {}; | |
| 486 | + | |
| 487 | +/** | |
| 455 | 488 | * Returns the first argument as the sole entry in an array. |
| 456 | 489 | * |
| 457 | - * @param {*} value Value to return. | |
| 490 | + * @template T | |
| 458 | 491 | * |
| 459 | - * @return {Array} Value returned as entry in array. | |
| 492 | + * @param {T} value Value to return. | |
| 493 | + * | |
| 494 | + * @return {[T]} Value returned as entry in array. | |
| 460 | 495 | */ |
| 461 | -function arrayOf( value ) { | |
| 462 | - return [ value ]; | |
| 496 | +function arrayOf(value) { | |
| 497 | + return [value]; | |
| 463 | 498 | } |
| 464 | 499 | |
| 465 | 500 | /** |
| 466 | 501 | * Returns true if the value passed is object-like, or false otherwise. A value |
| @@ -469,20 +504,21 @@ | ||
| 469 | 504 | * @param {*} value Value to test. |
| 470 | 505 | * |
| 471 | 506 | * @return {boolean} Whether value is object-like. |
| 472 | 507 | */ |
| 473 | -function isObjectLike( value ) { | |
| 474 | - return !! value && 'object' === typeof value; | |
| 508 | +function isObjectLike(value) { | |
| 509 | + return !!value && 'object' === typeof value; | |
| 475 | 510 | } |
| 476 | 511 | |
| 477 | 512 | /** |
| 478 | 513 | * Creates and returns a new cache object. |
| 479 | 514 | * |
| 480 | - * @return {Object} Cache object. | |
| 515 | + * @return {Cache} Cache object. | |
| 481 | 516 | */ |
| 482 | 517 | function createCache() { |
| 518 | + /** @type {Cache} */ | |
| 483 | 519 | var cache = { |
| 484 | - clear: function() { | |
| 520 | + clear: function () { | |
| 485 | 521 | cache.head = null; |
| 486 | 522 | }, |
| 487 | 523 | }; |
| 488 | 524 | |
| @@ -492,23 +528,23 @@ | ||
| 492 | 528 | /** |
| 493 | 529 | * Returns true if entries within the two arrays are strictly equal by |
| 494 | 530 | * reference from a starting index. |
| 495 | 531 | * |
| 496 | - * @param {Array} a First array. | |
| 497 | - * @param {Array} b Second array. | |
| 532 | + * @param {*[]} a First array. | |
| 533 | + * @param {*[]} b Second array. | |
| 498 | 534 | * @param {number} fromIndex Index from which to start comparison. |
| 499 | 535 | * |
| 500 | 536 | * @return {boolean} Whether arrays are shallowly equal. |
| 501 | 537 | */ |
| 502 | -function isShallowEqual( a, b, fromIndex ) { | |
| 538 | +function isShallowEqual(a, b, fromIndex) { | |
| 503 | 539 | var i; |
| 504 | 540 | |
| 505 | - if ( a.length !== b.length ) { | |
| 541 | + if (a.length !== b.length) { | |
| 506 | 542 | return false; |
| 507 | 543 | } |
| 508 | 544 | |
| 509 | - for ( i = fromIndex; i < a.length; i++ ) { | |
| 510 | - if ( a[ i ] !== b[ i ] ) { | |
| 545 | + for (i = fromIndex; i < a.length; i++) { | |
| 546 | + if (a[i] !== b[i]) { | |
| 511 | 547 | return false; |
| 512 | 548 | } |
| 513 | 549 | } |
| 514 | 550 | |
| @@ -522,35 +558,22 @@ | ||
| 522 | 558 | * its own return value. The memoize cache is preserved only as long as those |
| 523 | 559 | * dependant references remain the same. If getDependants returns a different |
| 524 | 560 | * reference(s), the cache is cleared and the selector value regenerated. |
| 525 | 561 | * |
| 526 | - * @param {Function} selector Selector function. | |
| 527 | - * @param {Function} getDependants Dependant getter returning an immutable | |
| 528 | - * reference or array of reference used in | |
| 529 | - * cache bust consideration. | |
| 562 | + * @template {(...args: *[]) => *} S | |
| 530 | 563 | * |
| 531 | - * @return {Function} Memoized selector. | |
| 564 | + * @param {S} selector Selector function. | |
| 565 | + * @param {GetDependants=} getDependants Dependant getter returning an array of | |
| 566 | + * references used in cache bust consideration. | |
| 532 | 567 | */ |
| 533 | -/* harmony default export */ function rememo(selector, getDependants ) { | |
| 534 | - var rootCache, getCache; | |
| 568 | +/* harmony default export */ function rememo(selector, getDependants) { | |
| 569 | + /** @type {WeakMap<*,*>} */ | |
| 570 | + var rootCache; | |
| 535 | 571 | |
| 536 | - // Use object source as dependant if getter not provided | |
| 537 | - if ( ! getDependants ) { | |
| 538 | - getDependants = arrayOf; | |
| 539 | - } | |
| 572 | + /** @type {GetDependants} */ | |
| 573 | + var normalizedGetDependants = getDependants ? getDependants : arrayOf; | |
| 540 | 574 | |
| 541 | 575 | /** |
| 542 | - * Returns the root cache. If WeakMap is supported, this is assigned to the | |
| 543 | - * root WeakMap cache set, otherwise it is a shared instance of the default | |
| 544 | - * cache object. | |
| 545 | - * | |
| 546 | - * @return {(WeakMap|Object)} Root cache object. | |
| 547 | - */ | |
| 548 | - function getRootCache() { | |
| 549 | - return rootCache; | |
| 550 | - } | |
| 551 | - | |
| 552 | - /** | |
| 553 | 576 | * Returns the cache for a given dependants array. When possible, a WeakMap |
| 554 | 577 | * will be used to create a unique cache for each set of dependants. This |
| 555 | 578 | * is feasible due to the nature of WeakMap in allowing garbage collection |
| 556 | 579 | * to occur on entries where the key object is no longer referenced. Since |
| @@ -562,34 +585,37 @@ | ||
| 562 | 585 | * like, then the cache is shared across all invocations. |
| 563 | 586 | * |
| 564 | 587 | * @see isObjectLike |
| 565 | 588 | * |
| 566 | - * @param {Array} dependants Selector dependants. | |
| 589 | + * @param {*[]} dependants Selector dependants. | |
| 567 | 590 | * |
| 568 | - * @return {Object} Cache object. | |
| 591 | + * @return {Cache} Cache object. | |
| 569 | 592 | */ |
| 570 | - function getWeakMapCache( dependants ) { | |
| 593 | + function getCache(dependants) { | |
| 571 | 594 | var caches = rootCache, |
| 572 | 595 | isUniqueByDependants = true, |
| 573 | - i, dependant, map, cache; | |
| 596 | + i, | |
| 597 | + dependant, | |
| 598 | + map, | |
| 599 | + cache; | |
| 574 | 600 | |
| 575 | - for ( i = 0; i < dependants.length; i++ ) { | |
| 576 | - dependant = dependants[ i ]; | |
| 601 | + for (i = 0; i < dependants.length; i++) { | |
| 602 | + dependant = dependants[i]; | |
| 577 | 603 | |
| 578 | 604 | // Can only compose WeakMap from object-like key. |
| 579 | - if ( ! isObjectLike( dependant ) ) { | |
| 605 | + if (!isObjectLike(dependant)) { | |
| 580 | 606 | isUniqueByDependants = false; |
| 581 | 607 | break; |
| 582 | 608 | } |
| 583 | 609 | |
| 584 | 610 | // Does current segment of cache already have a WeakMap? |
| 585 | - if ( caches.has( dependant ) ) { | |
| 611 | + if (caches.has(dependant)) { | |
| 586 | 612 | // Traverse into nested WeakMap. |
| 587 | - caches = caches.get( dependant ); | |
| 613 | + caches = caches.get(dependant); | |
| 588 | 614 | } else { |
| 589 | 615 | // Create, set, and traverse into a new one. |
| 590 | 616 | map = new WeakMap(); |
| 591 | - caches.set( dependant, map ); | |
| 617 | + caches.set(dependant, map); | |
| 592 | 618 | caches = map; |
| 593 | 619 | } |
| 594 | 620 | } |
| 595 | 621 | |
| @@ -594,55 +620,60 @@ | ||
| 594 | 620 | } |
| 595 | 621 | |
| 596 | 622 | // We use an arbitrary (but consistent) object as key for the last item |
| 597 | 623 | // in the WeakMap to serve as our running cache. |
| 598 | - if ( ! caches.has( LEAF_KEY ) ) { | |
| 624 | + if (!caches.has(LEAF_KEY)) { | |
| 599 | 625 | cache = createCache(); |
| 600 | 626 | cache.isUniqueByDependants = isUniqueByDependants; |
| 601 | - caches.set( LEAF_KEY, cache ); | |
| 627 | + caches.set(LEAF_KEY, cache); | |
| 602 | 628 | } |
| 603 | 629 | |
| 604 | - return caches.get( LEAF_KEY ); | |
| 630 | + return caches.get(LEAF_KEY); | |
| 605 | 631 | } |
| 606 | 632 | |
| 607 | - // Assign cache handler by availability of WeakMap | |
| 608 | - getCache = hasWeakMap ? getWeakMapCache : getRootCache; | |
| 609 | - | |
| 610 | 633 | /** |
| 611 | 634 | * Resets root memoization cache. |
| 612 | 635 | */ |
| 613 | 636 | function clear() { |
| 614 | - rootCache = hasWeakMap ? new WeakMap() : createCache(); | |
| 637 | + rootCache = new WeakMap(); | |
| 615 | 638 | } |
| 616 | 639 | |
| 617 | - // eslint-disable-next-line jsdoc/check-param-names | |
| 640 | + /* eslint-disable jsdoc/check-param-names */ | |
| 618 | 641 | /** |
| 619 | 642 | * The augmented selector call, considering first whether dependants have |
| 620 | 643 | * changed before passing it to underlying memoize function. |
| 621 | 644 | * |
| 622 | - * @param {Object} source Source object for derivation. | |
| 623 | - * @param {...*} extraArgs Additional arguments to pass to selector. | |
| 645 | + * @param {*} source Source object for derivation. | |
| 646 | + * @param {...*} extraArgs Additional arguments to pass to selector. | |
| 624 | 647 | * |
| 625 | 648 | * @return {*} Selector result. |
| 626 | 649 | */ |
| 627 | - function callSelector( /* source, ...extraArgs */ ) { | |
| 650 | + /* eslint-enable jsdoc/check-param-names */ | |
| 651 | + function callSelector(/* source, ...extraArgs */) { | |
| 628 | 652 | var len = arguments.length, |
| 629 | - cache, node, i, args, dependants; | |
| 653 | + cache, | |
| 654 | + node, | |
| 655 | + i, | |
| 656 | + args, | |
| 657 | + dependants; | |
| 630 | 658 | |
| 631 | 659 | // Create copy of arguments (avoid leaking deoptimization). |
| 632 | - args = new Array( len ); | |
| 633 | - for ( i = 0; i < len; i++ ) { | |
| 634 | - args[ i ] = arguments[ i ]; | |
| 660 | + args = new Array(len); | |
| 661 | + for (i = 0; i < len; i++) { | |
| 662 | + args[i] = arguments[i]; | |
| 635 | 663 | } |
| 636 | 664 | |
| 637 | - dependants = getDependants.apply( null, args ); | |
| 638 | - cache = getCache( dependants ); | |
| 665 | + dependants = normalizedGetDependants.apply(null, args); | |
| 666 | + cache = getCache(dependants); | |
| 639 | 667 | |
| 640 | - // If not guaranteed uniqueness by dependants (primitive type or lack | |
| 641 | - // of WeakMap support), shallow compare against last dependants and, if | |
| 642 | - // references have changed, destroy cache to recalculate result. | |
| 643 | - if ( ! cache.isUniqueByDependants ) { | |
| 644 | - if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { | |
| 668 | + // If not guaranteed uniqueness by dependants (primitive type), shallow | |
| 669 | + // compare against last dependants and, if references have changed, | |
| 670 | + // destroy cache to recalculate result. | |
| 671 | + if (!cache.isUniqueByDependants) { | |
| 672 | + if ( | |
| 673 | + cache.lastDependants && | |
| 674 | + !isShallowEqual(dependants, cache.lastDependants, 0) | |
| 675 | + ) { | |
| 645 | 676 | cache.clear(); |
| 646 | 677 | } |
| 647 | 678 | |
| 648 | 679 | cache.lastDependants = dependants; |
| @@ -648,11 +679,11 @@ | ||
| 648 | 679 | cache.lastDependants = dependants; |
| 649 | 680 | } |
| 650 | 681 | |
| 651 | 682 | node = cache.head; |
| 652 | - while ( node ) { | |
| 683 | + while (node) { | |
| 653 | 684 | // Check whether node arguments match arguments |
| 654 | - if ( ! isShallowEqual( node.args, args, 1 ) ) { | |
| 685 | + if (!isShallowEqual(node.args, args, 1)) { | |
| 655 | 686 | node = node.next; |
| 656 | 687 | continue; |
| 657 | 688 | } |
| 658 | 689 | |
| @@ -658,18 +689,18 @@ | ||
| 658 | 689 | |
| 659 | 690 | // At this point we can assume we've found a match |
| 660 | 691 | |
| 661 | 692 | // Surface matched node to head if not already |
| 662 | - if ( node !== cache.head ) { | |
| 693 | + if (node !== cache.head) { | |
| 663 | 694 | // Adjust siblings to point to each other. |
| 664 | - node.prev.next = node.next; | |
| 665 | - if ( node.next ) { | |
| 695 | + /** @type {CacheNode} */ (node.prev).next = node.next; | |
| 696 | + if (node.next) { | |
| 666 | 697 | node.next.prev = node.prev; |
| 667 | 698 | } |
| 668 | 699 | |
| 669 | 700 | node.next = cache.head; |
| 670 | 701 | node.prev = null; |
| 671 | - cache.head.prev = node; | |
| 702 | + /** @type {CacheNode} */ (cache.head).prev = node; | |
| 672 | 703 | cache.head = node; |
| 673 | 704 | } |
| 674 | 705 | |
| 675 | 706 | // Return immediately |
| @@ -677,15 +708,15 @@ | ||
| 677 | 708 | } |
| 678 | 709 | |
| 679 | 710 | // No cached value found. Continue to insertion phase: |
| 680 | 711 | |
| 681 | - node = { | |
| 712 | + node = /** @type {CacheNode} */ ({ | |
| 682 | 713 | // Generate the result from original function |
| 683 | - val: selector.apply( null, args ), | |
| 684 | - }; | |
| 714 | + val: selector.apply(null, args), | |
| 715 | + }); | |
| 685 | 716 | |
| 686 | 717 | // Avoid including the source object in the cache. |
| 687 | - args[ 0 ] = null; | |
| 718 | + args[0] = null; | |
| 688 | 719 | node.args = args; |
| 689 | 720 | |
| 690 | 721 | // Don't need to check whether node is already head, since it would |
| 691 | 722 | // have been returned above already if it was |
| @@ -690,9 +721,9 @@ | ||
| 690 | 721 | // Don't need to check whether node is already head, since it would |
| 691 | 722 | // have been returned above already if it was |
| 692 | 723 | |
| 693 | 724 | // Shift existing head down list |
| 694 | - if ( cache.head ) { | |
| 725 | + if (cache.head) { | |
| 695 | 726 | cache.head.prev = node; |
| 696 | 727 | node.next = cache.head; |
| 697 | 728 | } |
| 698 | 729 | |
| @@ -700,13 +731,13 @@ | ||
| 700 | 731 | |
| 701 | 732 | return node.val; |
| 702 | 733 | } |
| 703 | 734 | |
| 704 | - callSelector.getDependants = getDependants; | |
| 735 | + callSelector.getDependants = normalizedGetDependants; | |
| 705 | 736 | callSelector.clear = clear; |
| 706 | 737 | clear(); |
| 707 | 738 | |
| 708 | - return callSelector; | |
| 739 | + return /** @type {S & EnhancedSelector} */ (callSelector); | |
| 709 | 740 | } |
| 710 | 741 | |
| 711 | 742 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/store/selectors.js |
| 712 | 743 | /** |
| @@ -712,9 +743,8 @@ | ||
| 712 | 743 | /** |
| 713 | 744 | * External dependencies |
| 714 | 745 | */ |
| 715 | 746 | |
| 716 | - | |
| 717 | 747 | /** |
| 718 | 748 | * Shared reference to an empty array for cases where it is important to avoid |
| 719 | 749 | * returning a new array reference on every invocation, as in a connected or |
| 720 | 750 | * other pure component which performs `shouldComponentUpdate` check on props. |
| @@ -789,13 +819,11 @@ | ||
| 789 | 819 | * @return {Array} All annotations currently applied. |
| 790 | 820 | */ |
| 791 | 821 | |
| 792 | 822 | function __experimentalGetAnnotations(state) { |
| 793 | - return (0,external_lodash_namespaceObject.flatMap)(state, annotations => { | |
| 794 | - return annotations; | |
| 795 | - }); | |
| 823 | + return Object.values(state).flat(); | |
| 796 | 824 | } |
| 797 | -//# sourceMappingURL=selectors.js.map | |
| 825 | + | |
| 798 | 826 | ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
| 799 | 827 | // Unique ID creation requires a high quality random # generator. In the browser we therefore |
| 800 | 828 | // require the crypto API and do not support built-in fallback to lower quality random number |
| 801 | 829 | // generators (like Math.random()). |
| @@ -810,9 +838,9 @@ | ||
| 810 | 838 | |
| 811 | 839 | return getRandomValues(rnds8); |
| 812 | 840 | } |
| 813 | 841 | ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js |
| 814 | -/* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); | |
| 842 | +/* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); | |
| 815 | 843 | ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js |
| 816 | 844 | |
| 817 | 845 | |
| 818 | 846 | function validate(uuid) { |
| @@ -818,9 +846,9 @@ | ||
| 818 | 846 | function validate(uuid) { |
| 819 | 847 | return typeof uuid === 'string' && regex.test(uuid); |
| 820 | 848 | } |
| 821 | 849 | |
| 822 | -/* harmony default export */ var esm_browser_validate = (validate); | |
| 850 | +/* harmony default export */ const esm_browser_validate = (validate); | |
| 823 | 851 | ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
| 824 | 852 | |
| 825 | 853 | /** |
| 826 | 854 | * Convert array of 16 byte values to UUID string format of the form: |
| @@ -849,9 +877,9 @@ | ||
| 849 | 877 | |
| 850 | 878 | return uuid; |
| 851 | 879 | } |
| 852 | 880 | |
| 853 | -/* harmony default export */ var esm_browser_stringify = (stringify); | |
| 881 | +/* harmony default export */ const esm_browser_stringify = (stringify); | |
| 854 | 882 | ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
| 855 | 883 | |
| 856 | 884 | |
| 857 | 885 | |
| @@ -874,9 +902,9 @@ | ||
| 874 | 902 | |
| 875 | 903 | return esm_browser_stringify(rnds); |
| 876 | 904 | } |
| 877 | 905 | |
| 878 | -/* harmony default export */ var esm_browser_v4 = (v4); | |
| 906 | +/* harmony default export */ const esm_browser_v4 = (v4); | |
| 879 | 907 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/store/actions.js |
| 880 | 908 | /** |
| 881 | 909 | * External dependencies |
| 882 | 910 | */ |
| @@ -978,9 +1006,9 @@ | ||
| 978 | 1006 | type: 'ANNOTATION_REMOVE_SOURCE', |
| 979 | 1007 | source |
| 980 | 1008 | }; |
| 981 | 1009 | } |
| 982 | -//# sourceMappingURL=actions.js.map | |
| 1010 | + | |
| 983 | 1011 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/store/index.js |
| 984 | 1012 | /** |
| 985 | 1013 | * WordPress dependencies |
| 986 | 1014 | */ |
| @@ -1010,9 +1038,9 @@ | ||
| 1010 | 1038 | selectors: selectors_namespaceObject, |
| 1011 | 1039 | actions: actions_namespaceObject |
| 1012 | 1040 | }); |
| 1013 | 1041 | (0,external_wp_data_namespaceObject.register)(store); |
| 1014 | -//# sourceMappingURL=index.js.map | |
| 1042 | + | |
| 1015 | 1043 | ;// CONCATENATED MODULE: ./packages/annotations/build-module/index.js |
| 1016 | 1044 | /** |
| 1017 | 1045 | * Internal dependencies |
| 1018 | 1046 | */ |
| @@ -1018,8 +1046,8 @@ | ||
| 1018 | 1046 | */ |
| 1019 | 1047 | |
| 1020 | 1048 | |
| 1021 | 1049 | |
| 1022 | -//# sourceMappingURL=index.js.map | |
| 1050 | + | |
| 1023 | 1051 | (window.wp = window.wp || {}).annotations = __webpack_exports__; |
| 1024 | 1052 | /******/ })() |
| 1025 | 1053 | ; |