@wordpress/keycodes 3.14.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.15.0 (2022-08-10)
6
+
5
7
  ## 3.14.0 (2022-07-27)
6
8
 
7
9
  ## 3.13.0 (2022-07-13)
package/README.md CHANGED
@@ -114,6 +114,18 @@ Keycode for F10 key.
114
114
 
115
115
  Keycode for HOME key.
116
116
 
117
+ ### isAppleOS
118
+
119
+ Return true if platform is MacOS.
120
+
121
+ _Parameters_
122
+
123
+ - _\_window_ `Window?`: window object by default; used for DI testing.
124
+
125
+ _Returns_
126
+
127
+ - `boolean`: True if MacOS; false otherwise.
128
+
117
129
  ### isKeyboardEvent
118
130
 
119
131
  An object that contains functions to check if a keyboard event matches a
package/build/index.js CHANGED
@@ -3,7 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.shortcutAriaLabel = exports.rawShortcut = exports.modifiers = exports.isKeyboardEvent = exports.displayShortcutList = exports.displayShortcut = exports.ZERO = exports.UP = exports.TAB = exports.SPACE = exports.SHIFT = exports.RIGHT = exports.PAGEUP = exports.PAGEDOWN = exports.LEFT = exports.HOME = exports.F10 = exports.ESCAPE = exports.ENTER = exports.END = exports.DOWN = exports.DELETE = exports.CTRL = exports.COMMAND = exports.BACKSPACE = exports.ALT = void 0;
6
+ exports.displayShortcutList = exports.displayShortcut = exports.ZERO = exports.UP = exports.TAB = exports.SPACE = exports.SHIFT = exports.RIGHT = exports.PAGEUP = exports.PAGEDOWN = exports.LEFT = exports.HOME = exports.F10 = exports.ESCAPE = exports.ENTER = exports.END = exports.DOWN = exports.DELETE = exports.CTRL = exports.COMMAND = exports.BACKSPACE = exports.ALT = void 0;
7
+ Object.defineProperty(exports, "isAppleOS", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _platform.isAppleOS;
11
+ }
12
+ });
13
+ exports.shortcutAriaLabel = exports.rawShortcut = exports.modifiers = exports.isKeyboardEvent = void 0;
7
14
 
8
15
  var _lodash = require("lodash");
9
16
 
@@ -173,14 +180,14 @@ const SHIFT = 'shift';
173
180
 
174
181
  exports.SHIFT = SHIFT;
175
182
  const ZERO = 48;
183
+ exports.ZERO = ZERO;
184
+
176
185
  /**
177
186
  * Object that contains functions that return the available modifier
178
187
  * depending on platform.
179
188
  *
180
189
  * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}
181
190
  */
182
-
183
- exports.ZERO = ZERO;
184
191
  const modifiers = {
185
192
  primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
186
193
  primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keycodes/src/index.js"],"names":["BACKSPACE","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","modifier","character","isAppleOS","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","key","replacementKey","capitalizedCharacter","displayShortcut","shortcutList","shortcutAriaLabel","map","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","length","altKey","String","fromCharCode","keyCode"],"mappings":";;;;;;;AAcA;;AAKA;;AAKA;;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACO,MAAMA,SAAS,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iC,cACvCH,KADuC,EAEvClB,SAFuC,EAInC;AAAA,UADJb,QACI,uEADOc,mBACP;;AACJ,YAAMqB,IAAI,GAAGD,YAAY,CAAElC,QAAF,CAAzB;AACA,YAAMoC,SAAS,GAAGN,iBAAiB,CAAEC,KAAF,CAAnC;;AAEA,UAAK,iBAAKI,IAAL,EAAWC,SAAX,EAAuBC,MAA5B,EAAqC;AACpC,eAAO,KAAP;AACA;;AAED,UAAId,GAAG,GAAGQ,KAAK,CAACR,GAAN,CAAUR,WAAV,EAAV;;AAEA,UAAK,CAAEF,SAAP,EAAmB;AAClB,eAAO,sBAAUsB,IAAV,EAAgBZ,GAAhB,CAAP;AACA;;AAED,UAAKQ,KAAK,CAACO,MAAN,IAAgBzB,SAAS,CAACwB,MAAV,KAAqB,CAA1C,EAA8C;AAC7Cd,QAAAA,GAAG,GAAGgB,MAAM,CAACC,YAAP,CAAqBT,KAAK,CAACU,OAA3B,EAAqC1B,WAArC,EAAN;AACA,OAhBG,CAkBJ;;;AACA,UAAKF,SAAS,KAAK,KAAnB,EAA2B;AAC1BA,QAAAA,SAAS,GAAG,QAAZ;AACA;;AAED,aAAOU,GAAG,KAAKV,SAAS,CAACE,WAAV,EAAf;AACA;AA5BD;AA6BA,CA9B8B,CAAxB","sourcesContent":["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * External dependencies\n */\nimport { get, mapValues, includes, capitalize, xor } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join( '+' );\n\t};\n} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t[ COMMAND ]: '⌘',\n\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t};\n\n\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t( accumulator, key ) => {\n\t\t\t\tconst replacementKey = get( replacementKeyMap, key, key );\n\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\tif ( isApple ) {\n\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t}\n\n\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t},\n\t\t\t/** @type {string[]} */ ( [] )\n\t\t);\n\n\t\tconst capitalizedCharacter = capitalize( character );\n\t\treturn [ ...modifierKeys, capitalizedCharacter ];\n\t};\n} );\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t[ CTRL ]: 'Control',\n\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t/* translators: comma as in the character ',' */\n\t\t\t',': __( 'Comma' ),\n\t\t\t/* translators: period as in the character '.' */\n\t\t\t'.': __( 'Period' ),\n\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t'`': __( 'Backtick' ),\n\t\t};\n\n\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t.map( ( key ) => capitalize( get( replacementKeyMap, key, key ) ) )\n\t\t\t.join( isApple ? ' ' : ' + ' );\n\t};\n} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues( modifiers, ( getModifiers ) => {\n\treturn /** @type {WPEventKeyHandler} */ (\n\t\tevent,\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst mods = getModifiers( _isApple );\n\t\tconst eventMods = getEventModifiers( event );\n\n\t\tif ( xor( mods, eventMods ).length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet key = event.key.toLowerCase();\n\n\t\tif ( ! character ) {\n\t\t\treturn includes( mods, key );\n\t\t}\n\n\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t}\n\n\t\t// For backwards compatibility.\n\t\tif ( character === 'del' ) {\n\t\t\tcharacter = 'delete';\n\t\t}\n\n\t\treturn key === character.toLowerCase();\n\t};\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/keycodes/src/index.js"],"names":["BACKSPACE","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","modifier","character","isAppleOS","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","key","replacementKey","capitalizedCharacter","displayShortcut","shortcutList","shortcutAriaLabel","map","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","length","altKey","String","fromCharCode","keyCode"],"mappings":";;;;;;;;;;;;;;AAcA;;AAKA;;AAKA;;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CAAlB;AAEP;AACA;AACA;;;AACO,MAAMC,GAAG,GAAG,CAAZ;AAEP;AACA;AACA;;;AACO,MAAMC,KAAK,GAAG,EAAd;AAEP;AACA;AACA;;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,YAAMoC,SAAS,GAAGN,iBAAiB,CAAEC,KAAF,CAAnC;;AAEA,UAAK,iBAAKI,IAAL,EAAWC,SAAX,EAAuBC,MAA5B,EAAqC;AACpC,eAAO,KAAP;AACA;;AAED,UAAId,GAAG,GAAGQ,KAAK,CAACR,GAAN,CAAUR,WAAV,EAAV;;AAEA,UAAK,CAAEF,SAAP,EAAmB;AAClB,eAAO,sBAAUsB,IAAV,EAAgBZ,GAAhB,CAAP;AACA;;AAED,UAAKQ,KAAK,CAACO,MAAN,IAAgBzB,SAAS,CAACwB,MAAV,KAAqB,CAA1C,EAA8C;AAC7Cd,QAAAA,GAAG,GAAGgB,MAAM,CAACC,YAAP,CAAqBT,KAAK,CAACU,OAA3B,EAAqC1B,WAArC,EAAN;AACA,OAhBG,CAkBJ;;;AACA,UAAKF,SAAS,KAAK,KAAnB,EAA2B;AAC1BA,QAAAA,SAAS,GAAG,QAAZ;AACA;;AAED,aAAOU,GAAG,KAAKV,SAAS,CAACE,WAAV,EAAf;AACA;AA5BD;AA6BA,CA9B8B,CAAxB","sourcesContent":["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * External dependencies\n */\nimport { get, mapValues, includes, capitalize, xor } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\nexport { isAppleOS };\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join( '+' );\n\t};\n} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t[ COMMAND ]: '⌘',\n\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t};\n\n\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t( accumulator, key ) => {\n\t\t\t\tconst replacementKey = get( replacementKeyMap, key, key );\n\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\tif ( isApple ) {\n\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t}\n\n\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t},\n\t\t\t/** @type {string[]} */ ( [] )\n\t\t);\n\n\t\tconst capitalizedCharacter = capitalize( character );\n\t\treturn [ ...modifierKeys, capitalizedCharacter ];\n\t};\n} );\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t[ CTRL ]: 'Control',\n\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t/* translators: comma as in the character ',' */\n\t\t\t',': __( 'Comma' ),\n\t\t\t/* translators: period as in the character '.' */\n\t\t\t'.': __( 'Period' ),\n\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t'`': __( 'Backtick' ),\n\t\t};\n\n\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t.map( ( key ) => capitalize( get( replacementKeyMap, key, key ) ) )\n\t\t\t.join( isApple ? ' ' : ' + ' );\n\t};\n} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues( modifiers, ( getModifiers ) => {\n\treturn /** @type {WPEventKeyHandler} */ (\n\t\tevent,\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst mods = getModifiers( _isApple );\n\t\tconst eventMods = getEventModifiers( event );\n\n\t\tif ( xor( mods, eventMods ).length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet key = event.key.toLowerCase();\n\n\t\tif ( ! character ) {\n\t\t\treturn includes( mods, key );\n\t\t}\n\n\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t}\n\n\t\t// For backwards compatibility.\n\t\tif ( character === 'del' ) {\n\t\t\tcharacter = 'delete';\n\t\t}\n\n\t\treturn key === character.toLowerCase();\n\t};\n} );\n"]}
@@ -144,6 +144,7 @@ export const SHIFT = 'shift';
144
144
  */
145
145
 
146
146
  export const ZERO = 48;
147
+ export { isAppleOS };
147
148
  /**
148
149
  * Object that contains functions that return the available modifier
149
150
  * depending on platform.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keycodes/src/index.js"],"names":["get","mapValues","includes","capitalize","xor","__","isAppleOS","BACKSPACE","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","modifier","character","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","key","replacementKey","capitalizedCharacter","displayShortcut","shortcutList","shortcutAriaLabel","map","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","length","altKey","String","fromCharCode","keyCode"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,SAAd,EAAyBC,QAAzB,EAAmCC,UAAnC,EAA+CC,GAA/C,QAA0D,QAA1D;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,YAA1B;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AAC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CAKnCmC,MALmC,CAMpCT,GAAF,IACCQ,KAAK;AACJ;AACE,OAAGR,GAAK,KAFN,CAPgC;AAAvC;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMU,eAAe,GAAG5D,SAAS,CAAE0B,SAAF,EAAemC,YAAF,IAAoB;AACxE;AAAO;AAAiC,cACvCH,KADuC,EAEvCjB,SAFuC,EAInC;AAAA,UADJb,QACI,uEADOvB,SACP;;AACJ,YAAMyD,IAAI,GAAGD,YAAY,CAAEjC,QAAF,CAAzB;AACA,YAAMmC,SAAS,GAAGN,iBAAiB,CAAEC,KAAF,CAAnC;;AAEA,UAAKvD,GAAG,CAAE2D,IAAF,EAAQC,SAAR,CAAH,CAAuBC,MAA5B,EAAqC;AACpC,eAAO,KAAP;AACA;;AAED,UAAId,GAAG,GAAGQ,KAAK,CAACR,GAAN,CAAUR,WAAV,EAAV;;AAEA,UAAK,CAAED,SAAP,EAAmB;AAClB,eAAOxC,QAAQ,CAAE6D,IAAF,EAAQZ,GAAR,CAAf;AACA;;AAED,UAAKQ,KAAK,CAACO,MAAN,IAAgBxB,SAAS,CAACuB,MAAV,KAAqB,CAA1C,EAA8C;AAC7Cd,QAAAA,GAAG,GAAGgB,MAAM,CAACC,YAAP,CAAqBT,KAAK,CAACU,OAA3B,EAAqC1B,WAArC,EAAN;AACA,OAhBG,CAkBJ;;;AACA,UAAKD,SAAS,KAAK,KAAnB,EAA2B;AAC1BA,QAAAA,SAAS,GAAG,QAAZ;AACA;;AAED,aAAOS,GAAG,KAAKT,SAAS,CAACC,WAAV,EAAf;AACA;AA5BD;AA6BA,CA9BuC,CAAjC","sourcesContent":["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * External dependencies\n */\nimport { get, mapValues, includes, capitalize, xor } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join( '+' );\n\t};\n} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t[ COMMAND ]: '⌘',\n\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t};\n\n\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t( accumulator, key ) => {\n\t\t\t\tconst replacementKey = get( replacementKeyMap, key, key );\n\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\tif ( isApple ) {\n\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t}\n\n\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t},\n\t\t\t/** @type {string[]} */ ( [] )\n\t\t);\n\n\t\tconst capitalizedCharacter = capitalize( character );\n\t\treturn [ ...modifierKeys, capitalizedCharacter ];\n\t};\n} );\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t[ CTRL ]: 'Control',\n\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t/* translators: comma as in the character ',' */\n\t\t\t',': __( 'Comma' ),\n\t\t\t/* translators: period as in the character '.' */\n\t\t\t'.': __( 'Period' ),\n\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t'`': __( 'Backtick' ),\n\t\t};\n\n\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t.map( ( key ) => capitalize( get( replacementKeyMap, key, key ) ) )\n\t\t\t.join( isApple ? ' ' : ' + ' );\n\t};\n} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues( modifiers, ( getModifiers ) => {\n\treturn /** @type {WPEventKeyHandler} */ (\n\t\tevent,\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst mods = getModifiers( _isApple );\n\t\tconst eventMods = getEventModifiers( event );\n\n\t\tif ( xor( mods, eventMods ).length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet key = event.key.toLowerCase();\n\n\t\tif ( ! character ) {\n\t\t\treturn includes( mods, key );\n\t\t}\n\n\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t}\n\n\t\t// For backwards compatibility.\n\t\tif ( character === 'del' ) {\n\t\t\tcharacter = 'delete';\n\t\t}\n\n\t\treturn key === character.toLowerCase();\n\t};\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/keycodes/src/index.js"],"names":["get","mapValues","includes","capitalize","xor","__","isAppleOS","BACKSPACE","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","modifier","character","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","key","replacementKey","capitalizedCharacter","displayShortcut","shortcutList","shortcutAriaLabel","map","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","length","altKey","String","fromCharCode","keyCode"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,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AED,aAAOS,GAAG,KAAKT,SAAS,CAACC,WAAV,EAAf;AACA;AA5BD;AA6BA,CA9BuC,CAAjC","sourcesContent":["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * External dependencies\n */\nimport { get, mapValues, includes, capitalize, xor } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\nexport { isAppleOS };\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join( '+' );\n\t};\n} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t[ COMMAND ]: '⌘',\n\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t};\n\n\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t( accumulator, key ) => {\n\t\t\t\tconst replacementKey = get( replacementKeyMap, key, key );\n\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\tif ( isApple ) {\n\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t}\n\n\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t},\n\t\t\t/** @type {string[]} */ ( [] )\n\t\t);\n\n\t\tconst capitalizedCharacter = capitalize( character );\n\t\treturn [ ...modifierKeys, capitalizedCharacter ];\n\t};\n} );\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler<string>} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t[ CTRL ]: 'Control',\n\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t/* translators: comma as in the character ',' */\n\t\t\t',': __( 'Comma' ),\n\t\t\t/* translators: period as in the character '.' */\n\t\t\t'.': __( 'Period' ),\n\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t'`': __( 'Backtick' ),\n\t\t};\n\n\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t.map( ( key ) => capitalize( get( replacementKeyMap, key, key ) ) )\n\t\t\t.join( isApple ? ' ' : ' + ' );\n\t};\n} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues( modifiers, ( getModifiers ) => {\n\treturn /** @type {WPEventKeyHandler} */ (\n\t\tevent,\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst mods = getModifiers( _isApple );\n\t\tconst eventMods = getEventModifiers( event );\n\n\t\tif ( xor( mods, eventMods ).length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet key = event.key.toLowerCase();\n\n\t\tif ( ! character ) {\n\t\t\treturn includes( mods, key );\n\t\t}\n\n\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t}\n\n\t\t// For backwards compatibility.\n\t\tif ( character === 'del' ) {\n\t\t\tcharacter = 'delete';\n\t\t}\n\n\t\treturn key === character.toLowerCase();\n\t};\n} );\n"]}
@@ -94,6 +94,7 @@ export const SHIFT: "shift";
94
94
  * Keycode for ZERO key.
95
95
  */
96
96
  export const ZERO: 48;
97
+ export { isAppleOS };
97
98
  /**
98
99
  * Object that contains functions that return the available modifier
99
100
  * depending on platform.
@@ -184,4 +185,5 @@ export type WPKeycodeModifier = 'primary' | 'primaryShift' | 'primaryAlt' | 'sec
184
185
  export type WPModifierHandler<T> = Record<WPKeycodeModifier, T>;
185
186
  export type WPKeyHandler<T> = (character: string, isApple?: (() => boolean) | undefined) => T;
186
187
  export type WPEventKeyHandler = (event: KeyboardEvent, character: string, isApple?: (() => boolean) | undefined) => boolean;
188
+ import { isAppleOS } from "./platform";
187
189
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA0BA,qEAAqE;AAErE,0KAA0K;AAE1K;;;;;;;GAOG;AAEH;;;;GAIG;AACH,iHAAiH;AAEjH;;GAEG;AACH,0BAA2B;AAE3B;;GAEG;AACH,oBAAqB;AAErB;;GAEG;AACH,uBAAwB;AAExB;;GAEG;AACH,wBAAyB;AAEzB;;GAEG;AACH,uBAAwB;AAExB;;GAEG;AACH,wBAAyB;AAEzB;;GAEG;AACH,0BAA2B;AAE3B;;GAEG;AACH,qBAAsB;AAEtB;;GAEG;AACH,sBAAuB;AAEvB;;GAEG;AACH,sBAAuB;AAEvB;;GAEG;AACH,oBAAqB;AAErB;;GAEG;AACH,uBAAwB;AAExB;;GAEG;AACH,sBAAuB;AAEvB;;GAEG;AACH,wBAAyB;AAEzB;;GAEG;AACH,sBAAuB;AAEvB;;GAEG;AACH,wBAAyB;AAEzB;;GAEG;AACH,0BAA2B;AAE3B;;GAEG;AACH,6BAA8B;AAE9B;;GAEG;AACH,4BAA6B;AAE7B;;GAEG;AACH,sBAAuB;AAEvB;;;;;GAKG;AACH,oDAFwC,MAAM,OAAO,KAAM,cAAc,EAAE,EAiBzE;AAEF;;;;;;;;;;;;;;GAcG;AACH,0BAHU,kBAAkB,aAAa,MAAM,CAAC,CAAC,CAU7C;AAEJ;;;;;;;;;;;;GAYG;AACH,kCAHU,kBAAkB,aAAa,MAAM,EAAE,CAAC,CAAC,CAgC/C;AAEJ;;;;;;;;;;;;GAYG;AACH,8BAHU,kBAAkB,aAAa,MAAM,CAAC,CAAC,CAW/C;AAEF;;;;;;;;;;;;;GAaG;AACH,gCAHU,kBAAkB,aAAa,MAAM,CAAC,CA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;;;;;;;;;;;;GAYG;AACH,kCAHU,kBAAkB,aAAa,MAAM,EAAE,CAAC,CAAC,CAgC/C;AAEJ;;;;;;;;;;;;GAYG;AACH,8BAHU,kBAAkB,aAAa,MAAM,CAAC,CAAC,CAW/C;AAEF;;;;;;;;;;;;;GAaG;AACH,gCAHU,kBAAkB,aAAa,MAAM,CAAC,CAAC,CA0B7C;AA0BJ;;;;;;;;;;;;;GAaG;AACH,8BAHU,kBAAkB,iBAAiB,CAAC,CAiC1C;6BAvVU,UAAU,4BAAyB;gCAEnC,SAAS,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW;;;;;mCAQvI,OAAO,iBAAiB,EAAE,CAAC,CAAC;0CAMhB,MAAM,mBAAkB,OAAO,kBAAK,CAAC;wCAExC,aAAa,aAAa,MAAM,mBAAkB,OAAO,kBAAK,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keycodes",
3
- "version": "3.14.0",
3
+ "version": "3.15.0",
4
4
  "description": "Keycodes utilities for WordPress. Used to check for keyboard events across browsers/operating systems.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,11 +28,11 @@
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.16.0",
31
- "@wordpress/i18n": "^4.14.0",
31
+ "@wordpress/i18n": "^4.15.0",
32
32
  "lodash": "^4.17.21"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "0315dbc240cb2aa146d7c1bafd251f004b88300e"
37
+ "gitHead": "08358f53b627a15148c3a3e433cdf58cf8714aa4"
38
38
  }
package/src/index.js CHANGED
@@ -144,6 +144,8 @@ export const SHIFT = 'shift';
144
144
  */
145
145
  export const ZERO = 48;
146
146
 
147
+ export { isAppleOS };
148
+
147
149
  /**
148
150
  * Object that contains functions that return the available modifier
149
151
  * depending on platform.
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","../i18n/build-types/sprintf.d.ts","../hooks/build-types/createAddHook.d.ts","../hooks/build-types/createRemoveHook.d.ts","../hooks/build-types/createHasHook.d.ts","../hooks/build-types/createDoingHook.d.ts","../hooks/build-types/createDidHook.d.ts","../hooks/build-types/index.d.ts","../hooks/build-types/createHooks.d.ts","../i18n/build-types/create-i18n.d.ts","../i18n/build-types/default-i18n.d.ts","../i18n/build-types/index.d.ts","./src/platform.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"762bc52248d3fab9873c7af564caf622358312cb35de42a4393b71cc36e14621","d02ec79cefaf292fae64b3be5a4416e64b4e420a6429fd458fac6e1bb4c7950e","27abed653f600ea0d5c86e94181beb42824e0f3f16337e2f9e7e9e9c2c392edf","d7871e0e653aa7197fee88886db5678bee6d42164c1f36e4bce9421ddfa7ca49","11ed10bdb3bcc99893570507eac8fece4840add97ee1d4f5a7fbf41cbfdea0d4","429fb571d3db07d3eaa2e74d43eb4190ece3e0de832ed564aeeaf08873e598eb","406d52bf33d618d846aa0d831ee004290567e328edcd4517bbff2937cc977abf","d3060e0810fc0d0dc009e6f086ef413d3c8aeaaf07da25c8d25fd4e181646acf","c0306658efb85764bb6d8d55097007c68a70539b24d0e18fb6edd6eb1778f632","08f7e6ffa66c66a636aecc5acbeb998215d9d09ccba0c558afb7df7e218edeaf","f829eb39aea4487f0ff94a42c56a1a73bc5202bbdeb03f7a638e4ab3e290d017","75daf26e18c08e0a3c298e7f11d4c7bcbe758c7cded880114bffcd3e65b0c8f8","a5d2aa5539a549470dd98395980e3dd46c48224064348ff5353f63c7a146d188"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[45,47,48,49,50,51,52,53,54,55,56,57],[45,46,48,49,50,51,52,53,54,55,56,57],[46,47,48,49,50,51,52,53,54,55,56,57],[45,46,47,49,50,51,52,53,54,55,56,57],[45,46,47,48,50,51,52,53,54,55,56,57],[45,46,47,48,49,51,52,53,54,55,56,57],[45,46,47,48,49,50,52,53,54,55,56,57],[45,46,47,48,49,50,51,53,54,55,56,57],[45,46,47,48,49,50,51,52,54,55,56,57],[45,46,47,48,49,50,51,52,53,55,56,57],[45,46,47,48,49,50,51,52,53,54,56,57],[45,46,47,48,49,50,51,52,53,54,55,57],[45,46,47,48,49,50,51,52,53,54,55,56],[64],[59,60,61,62,63,64],[59,60,61,62,63,65],[64,65],[66],[58,66,67],[57,68,69],[57]],"referencedMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[57,13],[59,14],[63,14],[62,14],[61,14],[65,15],[60,14],[64,16],[66,17],[67,18],[68,19],[70,20],[69,21]],"exportedModulesMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[57,13],[59,14],[63,14],[62,14],[61,14],[65,15],[60,14],[64,16],[66,17],[67,18],[68,19],[70,20],[69,21]],"semanticDiagnosticsPerFile":[46,47,45,48,49,50,51,52,53,54,55,56,57,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,59,63,62,61,65,60,64,66,67,68,58,70,69]},"version":"4.4.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","../i18n/build-types/sprintf.d.ts","../hooks/build-types/createaddhook.d.ts","../hooks/build-types/createremovehook.d.ts","../hooks/build-types/createhashook.d.ts","../hooks/build-types/createdoinghook.d.ts","../hooks/build-types/createdidhook.d.ts","../hooks/build-types/index.d.ts","../hooks/build-types/createhooks.d.ts","../i18n/build-types/create-i18n.d.ts","../i18n/build-types/default-i18n.d.ts","../i18n/build-types/index.d.ts","./src/platform.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"762bc52248d3fab9873c7af564caf622358312cb35de42a4393b71cc36e14621","d02ec79cefaf292fae64b3be5a4416e64b4e420a6429fd458fac6e1bb4c7950e","27abed653f600ea0d5c86e94181beb42824e0f3f16337e2f9e7e9e9c2c392edf","d7871e0e653aa7197fee88886db5678bee6d42164c1f36e4bce9421ddfa7ca49","11ed10bdb3bcc99893570507eac8fece4840add97ee1d4f5a7fbf41cbfdea0d4","429fb571d3db07d3eaa2e74d43eb4190ece3e0de832ed564aeeaf08873e598eb","406d52bf33d618d846aa0d831ee004290567e328edcd4517bbff2937cc977abf","d3060e0810fc0d0dc009e6f086ef413d3c8aeaaf07da25c8d25fd4e181646acf","c0306658efb85764bb6d8d55097007c68a70539b24d0e18fb6edd6eb1778f632","08f7e6ffa66c66a636aecc5acbeb998215d9d09ccba0c558afb7df7e218edeaf","f829eb39aea4487f0ff94a42c56a1a73bc5202bbdeb03f7a638e4ab3e290d017","75daf26e18c08e0a3c298e7f11d4c7bcbe758c7cded880114bffcd3e65b0c8f8","a7755de9c0f46de867db8dee30dd8670f55d9a0ed161c3a9393b611f7585ec3e"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[45,47,48,49,50,51,52,53,54,55,56,57],[45,46,48,49,50,51,52,53,54,55,56,57],[46,47,48,49,50,51,52,53,54,55,56,57],[45,46,47,49,50,51,52,53,54,55,56,57],[45,46,47,48,50,51,52,53,54,55,56,57],[45,46,47,48,49,51,52,53,54,55,56,57],[45,46,47,48,49,50,52,53,54,55,56,57],[45,46,47,48,49,50,51,53,54,55,56,57],[45,46,47,48,49,50,51,52,54,55,56,57],[45,46,47,48,49,50,51,52,53,55,56,57],[45,46,47,48,49,50,51,52,53,54,56,57],[45,46,47,48,49,50,51,52,53,54,55,57],[45,46,47,48,49,50,51,52,53,54,55,56],[64],[59,60,61,62,63,64],[59,60,61,62,63,65],[64,65],[66],[58,66,67],[57,68,69],[57]],"referencedMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[57,13],[59,14],[63,14],[62,14],[61,14],[65,15],[60,14],[64,16],[66,17],[67,18],[68,19],[70,20],[69,21]],"exportedModulesMap":[[46,1],[47,2],[45,3],[48,4],[49,5],[50,6],[51,7],[52,8],[53,9],[54,10],[55,11],[56,12],[57,13],[59,14],[63,14],[62,14],[61,14],[65,15],[60,14],[64,16],[66,17],[67,18],[68,19],[70,20],[69,21]],"semanticDiagnosticsPerFile":[46,47,45,48,49,50,51,52,53,54,55,56,57,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,59,63,62,61,65,60,64,66,67,68,58,70,69]},"version":"4.4.2"}