WordPress/wp-includes/js/dist/viewport.js.map

1 line
15 KiB
Plaintext

{"version":3,"sources":["webpack://wp.[name]/webpack/bootstrap","webpack://wp.[name]/./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js","webpack://wp.[name]/./node_modules/@babel/runtime/helpers/esm/iterableToArray.js","webpack://wp.[name]/./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js","webpack://wp.[name]/./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/if-viewport-matches.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/index.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/store/actions.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/store/index.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/store/reducer.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/store/selectors.js","webpack://wp.[name]//Users/robert/projects/gutenberg/packages/viewport/src/with-viewport-match.js","webpack://wp.[name]/external {\"this\":[\"wp\",\"compose\"]}","webpack://wp.[name]/external {\"this\":[\"wp\",\"data\"]}","webpack://wp.[name]/external \"lodash\""],"names":["ifViewportMatches","query","createHigherOrderComponent","compose","withViewportMatch","isViewportMatch","ifCondition","props","BREAKPOINTS","huge","wide","large","medium","small","mobile","OPERATORS","setIsMatching","debounce","values","mapValues","queries","matches","dispatch","leading","reduce","result","width","name","forEach","condition","operator","list","window","matchMedia","addListener","key","join","addEventListener","type","registerStore","reducer","actions","selectors","state","action","takeRight","split","withSelect","select"],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAk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MlE,mBANkE,CAAzC;AAAA,CAA1B;;AASeG,gFAAf;;;;;;;;;;;;AC/BA,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,iCAAiC,EAAE,I","file":"viewport.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./node_modules/@wordpress/viewport/build-module/index.js\");\n","export default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}","export default function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}","import arrayWithoutHoles from \"./arrayWithoutHoles\";\nimport iterableToArray from \"./iterableToArray\";\nimport nonIterableSpread from \"./nonIterableSpread\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}","/**\n * WordPress dependencies\n */\nimport { ifCondition, compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport withViewportMatch from './with-viewport-match';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the viewport query is satisfied.\n *\n * @param {string} query Viewport query.\n *\n * @see withViewportMatches\n *\n * @return {Function} Higher-order component.\n */\nconst ifViewportMatches = ( query ) => createHigherOrderComponent(\n\tcompose( [\n\t\twithViewportMatch( {\n\t\t\tisViewportMatch: query,\n\t\t} ),\n\t\tifCondition( ( props ) => props.isViewportMatch ),\n\t] ),\n\t'ifViewportMatches'\n);\n\nexport default ifViewportMatches;\n","/**\n * External dependencies\n */\nimport { reduce, forEach, debounce, mapValues } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport './store';\n\nexport { default as ifViewportMatches } from './if-viewport-matches';\nexport { default as withViewportMatch } from './with-viewport-match';\n\n/**\n * Hash of breakpoint names with pixel width at which it becomes effective.\n *\n * @see _breakpoints.scss\n *\n * @type {Object}\n */\nconst BREAKPOINTS = {\n\thuge: 1440,\n\twide: 1280,\n\tlarge: 960,\n\tmedium: 782,\n\tsmall: 600,\n\tmobile: 480,\n};\n\n/**\n * Hash of query operators with corresponding condition for media query.\n *\n * @type {Object}\n */\nconst OPERATORS = {\n\t'<': 'max-width',\n\t'>=': 'min-width',\n};\n\n/**\n * Callback invoked when media query state should be updated. Is invoked a\n * maximum of one time per call stack.\n */\nconst setIsMatching = debounce( () => {\n\tconst values = mapValues( queries, ( query ) => query.matches );\n\tdispatch( 'core/viewport' ).setIsMatching( values );\n}, { leading: true } );\n\n/**\n * Hash of breakpoint names with generated MediaQueryList for corresponding\n * media query.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList\n *\n * @type {Object<string,MediaQueryList>}\n */\nconst queries = reduce( BREAKPOINTS, ( result, width, name ) => {\n\tforEach( OPERATORS, ( condition, operator ) => {\n\t\tconst list = window.matchMedia( `(${ condition }: ${ width }px)` );\n\t\tlist.addListener( setIsMatching );\n\n\t\tconst key = [ operator, name ].join( ' ' );\n\t\tresult[ key ] = list;\n\t} );\n\n\treturn result;\n}, {} );\n\nwindow.addEventListener( 'orientationchange', setIsMatching );\n\n// Set initial values\nsetIsMatching();\n","/**\n * Returns an action object used in signalling that viewport queries have been\n * updated. Values are specified as an object of breakpoint query keys where\n * value represents whether query matches.\n *\n * @param {Object} values Breakpoint query matches.\n *\n * @return {Object} Action object.\n */\nexport function setIsMatching( values ) {\n\treturn {\n\t\ttype: 'SET_IS_MATCHING',\n\t\tvalues,\n\t};\n}\n","/**\n * WordPress dependencies\n */\nimport { registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nexport default registerStore( 'core/viewport', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n","/**\n * Reducer returning the viewport state, as keys of breakpoint queries with\n * boolean value representing whether query is matched.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_MATCHING':\n\t\t\treturn action.values;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n","/**\n * External dependencies\n */\nimport { takeRight } from 'lodash';\n\n/**\n * Returns true if the viewport matches the given query, or false otherwise.\n *\n * @param {Object} state Viewport state object.\n * @param {string} query Query string. Includes operator and breakpoint name,\n * space separated. Operator defaults to >=.\n *\n * @example\n *\n * ```js\n * isViewportMatch( state, '< huge' );\n * isViewPortMatch( state, 'medium' );\n * ```\n *\n * @return {boolean} Whether viewport matches query.\n */\nexport function isViewportMatch( state, query ) {\n\t// Pad to _at least_ two elements to take from the right, effectively\n\t// defaulting the left-most value.\n\tconst key = takeRight( [ '>=', ...query.split( ' ' ) ], 2 ).join( ' ' );\n\n\treturn !! state[ key ];\n}\n","/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Higher-order component creator, creating a new component which renders with\n * the given prop names, where the value passed to the underlying component is\n * the result of the query assigned as the object's value.\n *\n * @param {Object} queries Object of prop name to viewport query.\n *\n * @see isViewportMatch\n *\n * @return {Function} Higher-order component.\n */\nconst withViewportMatch = ( queries ) => createHigherOrderComponent(\n\twithSelect( ( select ) => {\n\t\treturn mapValues( queries, ( query ) => {\n\t\t\treturn select( 'core/viewport' ).isViewportMatch( query );\n\t\t} );\n\t} ),\n\t'withViewportMatch'\n);\n\nexport default withViewportMatch;\n","(function() { module.exports = this[\"wp\"][\"compose\"]; }());","(function() { module.exports = this[\"wp\"][\"data\"]; }());","(function() { module.exports = this[\"lodash\"]; }());"],"sourceRoot":""}