PageSourceSearch

https://missdream.org/wp-includes/js/dist/keycodes.js

js missdream.org collected 2026-09-24 20:40:45 UTC 8,564 bytes, 250 lines download raw bytes

1(function() {
2"use strict";
3var wp;
4(wp ||= {}).keycodes = (() => {
5  var __create = Object.create;
6  var __defProp = Object.defineProperty;
7  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8  var __getOwnPropNames = Object.getOwnPropertyNames;
9  var __getProtoOf = Object.getPrototypeOf;
10  var __hasOwnProp = Object.prototype.hasOwnProperty;
11  var __commonJS = (cb, mod) => function __require() {
12    return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13  };
14  var __export = (target, all) => {
15    for (var name in all)
16      __defProp(target, name, { get: all[name], enumerable: true });
17  };
18  var __copyProps = (to, from, except, desc) => {
19    if (from && typeof from === "object" || typeof from === "function") {
20      for (let key of __getOwnPropNames(from))
21        if (!__hasOwnProp.call(to, key) && key !== except)
22          __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23    }
24    return to;
25  };
26  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27    // If the importer is in node compatibility mode or this is not an ESM
28    // file that has been converted to a CommonJS file using a Babel-
29    // compatible transform (i.e. "__esModule" has not been set), then set
30    // "default" to the CommonJS "module.exports" for node compatibility.
31    isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32    mod
33  ));
34  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36  // package-external:@wordpress/i18n
37  var require_i18n = __commonJS({
38    "package-external:@wordpress/i18n"(exports, module) {
39      module.exports = window.wp.i18n;
40    }
41  });
42
43  
43// packages/keycodes/build-module/index.mjs
44  var index_exports = {};
45  __export(index_exports, {
46    ALT: () => ALT,
47    BACKSPACE: () => BACKSPACE,
48    COMMAND: () => COMMAND,
49    CTRL: () => CTRL,
50    DELETE: () => DELETE,
51    DOWN: () => DOWN,
52    END: () => END,
53    ENTER: () => ENTER,
54    ESCAPE: () => ESCAPE,
55    F10: () => F10,
56    HOME: () => HOME,
57    LEFT: () => LEFT,
58    PAGEDOWN: () => PAGEDOWN,
59    PAGEUP: () => PAGEUP,
60    RIGHT: () => RIGHT,
61    SHIFT: () => SHIFT,
62    SPACE: () => SPACE,
63    TAB: () => TAB,
64    UP: () => UP,
65    ZERO: () => ZERO,
66    ariaKeyShortcut: () => ariaKeyShortcut,
67    displayShortcut: () => displayShortcut,
68    displayShortcutList: () => displayShortcutList,
69    isAppleOS: () => isAppleOS,
70    isKeyboardEvent: () => isKeyboardEvent,
71    modifiers: () => modifiers,
72    rawShortcut: () => rawShortcut,
73    shortcutAriaLabel: () => shortcutAriaLabel
74  });
75  var import_i18n = __toESM(require_i18n(), 1);
76
77  
77// packages/keycodes/build-module/platform.mjs
78  function isAppleOS(_window) {
79    if (!_window) {
80      if (typeof window === "undefined") {
81        return false;
82      }
83      _window = window;
84    }
85    const { platform } = _window.navigator;
86    return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform);
87  }
88
89  
89// packages/keycodes/build-module/index.mjs
90  var BACKSPACE = 8;
91  var TAB = 9;
92  var ENTER = 13;
93  var ESCAPE = 27;
94  var SPACE = 32;
95  var PAGEUP = 33;
96  var PAGEDOWN = 34;
97  var END = 35;
98  var HOME = 36;
99  var LEFT = 37;
100  var UP = 38;
101  var RIGHT = 39;
102  var DOWN = 40;
103  var DELETE = 46;
104  var F10 = 121;
105  var ALT = "alt";
106  var CTRL = "ctrl";
107  var COMMAND = "meta";
108  var SHIFT = "shift";
109  var ZERO = 48;
110  function capitaliseFirstCharacter(string) {
111    return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1);
112  }
113  function mapValues(object, mapFn) {
114    return Object.fromEntries(
115      Object.entries(object).map(([key, value]) => [
116        key,
117        mapFn(value)
118      ])
119    );
120  }
121  var modifiers = {
122    primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL],
123    primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
124    primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
125    secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
126    access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
127    ctrl: () => [CTRL],
128    alt: () => [ALT],
129    ctrlShift: () => [CTRL, SHIFT],
130    shift: () => [SHIFT],
131    shiftAlt: () => [SHIFT, ALT],
132    undefined: () => []
133  };
134  var rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
135    return (character, _isApple = isAppleOS) => {
136      return [...modifier(_isApple), character.toLowerCase()].join(
137        "+"
138      );
139    };
140  });
141  var ariaKeyShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
142    return (character, _isApple = isAppleOS) => {
143      return [
144        ...modifier(_isApple).map((key) => key === CTRL ? "Control" : key).map((key) => capitaliseFirstCharacter(key)),
145        capitaliseFirstCharacter(character)
146      ].join("+");
147    };
148  });
149  var displayShortcutList = /* @__PURE__ */ mapValues(
150    modifiers,
151    (modifier) => {
152      return (character, _isApple = isAppleOS) => {
153        const isApple = _isApple();
154        const replacementKeyMap = {
155          [ALT]: isApple ? "\u2325" : "Alt",
156          [CTRL]: isApple ? "\u2303" : "Ctrl",
157          // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
158          [COMMAND]: "\u2318",
159          [SHIFT]: isApple ? "\u21E7" : "Shift"
160        };
161        const modifierKeys = modifier(_isApple).reduce(
162          (accumulator, key) => {
163            const replacementKey = replacementKeyMap[key] ?? key;
164            if (isApple) {
165              return [...accumulator, replacementKey];
166            }
167            return [...accumulator, replacementKey, "+"];
168          },
169          []
170        );
171        return [
172          ...modifierKeys,
173          capitaliseFirstCharacter(character)
174        ];
175      };
176    }
177  );
178  var displayShortcut = /* @__PURE__ */ mapValues(
179    displayShortcutList,
180    (shortcutList) => {
181      return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join("");
182    }
183  );
184  var shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
185    return (character, _isApple = isAppleOS) => {
186      const isApple = _isApple();
187      const replacementKeyMap = {
188        [SHIFT]: "Shift",
189        [COMMAND]: isApple ? "Command" : "Control",
190        [CTRL]: "Control",
191        [ALT]: isApple ? "Option" : "Alt",
192        /* translators: comma as in the character ',' */
193        ",": (0, import_i18n.__)("Comma"),
194        /* translators: period as in the character '.' */
195        ".": (0, import_i18n.__)("Period"),
196        /* translators: backtick as in the character '`' */
197        "`": (0, import_i18n.__)("Backtick"),
198        /* translators: tilde as in the character '~' */
199        "~": (0, import_i18n.__)("Tilde")
200      };
201      return [...modifier(_isApple), character].map(
202        (key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key)
203      ).join(isApple ? " " : " + ");
204    };
205  });
206  function getEventModifiers(event) {
207    return [ALT, CTRL, COMMAND, SHIFT].filter(
208      (key) => event[`${key}Key`]
209    );
210  }
211  var isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
212    return (event, character, _isApple = isAppleOS) => {
213      const mods = getModifiers(_isApple);
214      const eventMods = getEventModifiers(event);
215      const replacementWithShiftKeyMap = {
216        Comma: ",",
217        Backslash: "\\",
218        // Windows returns `\` for both IntlRo and IntlYen.
219        IntlRo: "\\",
220        IntlYen: "\\"
221      };
222      const modsDiff = mods.filter(
223        (mod) => !eventMods.includes(mod)
224      );
225      const eventModsDiff = eventMods.filter(
226        (mod) => !mods.includes(mod)
227      );
228      if (modsDiff.length > 0 || eventModsDiff.length > 0) {
229        return false;
230      }
231      let key = event.key.toLowerCase();
232      if (!character) {
233        return mods.includes(key);
234      }
235      if (event.altKey && character.length === 1) {
236        key = String.fromCharCode(event.keyCode).toLowerCase();
237      }
238      if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
239        key = replacementWithShiftKeyMap[event.code];
240      }
241      if (character === "del") {
242        character = "delete";
243      }
244      return key === character.toLowerCase();
245    };
246  });
247  return __toCommonJS(index_exports);
248})();
249(window.wp ||= {}).keycodes = wp.keycodes;
250})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.