Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lumino/commands

Package Overview
Dependencies
Maintainers
6
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumino/commands - npm Package Compare versions

Comparing version 1.20.1 to 2.0.0-alpha.0

447

dist/index.es6.js

@@ -16,4 +16,4 @@ import { ArrayExt } from '@lumino/algorithm';

*/
var CommandRegistry = /** @class */ (function () {
function CommandRegistry() {
class CommandRegistry {
constructor() {
this._timerID = 0;

@@ -30,52 +30,36 @@ this._replaying = false;

}
Object.defineProperty(CommandRegistry.prototype, "commandChanged", {
/**
* A signal emitted when a command has changed.
*
* #### Notes
* This signal is useful for visual representations of commands which
* need to refresh when the state of a relevant command has changed.
*/
get: function () {
return this._commandChanged;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "commandExecuted", {
/**
* A signal emitted when a command has executed.
*
* #### Notes
* Care should be taken when consuming this signal. The command system is used
* by many components for many user actions. Handlers registered with this
* signal must return quickly to ensure the overall application remains responsive.
*/
get: function () {
return this._commandExecuted;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "keyBindingChanged", {
/**
* A signal emitted when a key binding is changed.
*/
get: function () {
return this._keyBindingChanged;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "keyBindings", {
/**
* A read-only array of the key bindings in the registry.
*/
get: function () {
return this._keyBindings;
},
enumerable: true,
configurable: true
});
/**
* A signal emitted when a command has changed.
*
* #### Notes
* This signal is useful for visual representations of commands which
* need to refresh when the state of a relevant command has changed.
*/
get commandChanged() {
return this._commandChanged;
}
/**
* A signal emitted when a command has executed.
*
* #### Notes
* Care should be taken when consuming this signal. The command system is used
* by many components for many user actions. Handlers registered with this
* signal must return quickly to ensure the overall application remains responsive.
*/
get commandExecuted() {
return this._commandExecuted;
}
/**
* A signal emitted when a key binding is changed.
*/
get keyBindingChanged() {
return this._keyBindingChanged;
}
/**
* A read-only array of the key bindings in the registry.
*/
get keyBindings() {
return this._keyBindings;
}
/**
* List the ids of the registered commands.

@@ -85,5 +69,5 @@ *

*/
CommandRegistry.prototype.listCommands = function () {
listCommands() {
return Object.keys(this._commands);
};
}
/**

@@ -96,5 +80,5 @@ * Test whether a specific command is registered.

*/
CommandRegistry.prototype.hasCommand = function (id) {
hasCommand(id) {
return id in this._commands;
};
}
/**

@@ -111,7 +95,6 @@ * Add a command to the registry.

*/
CommandRegistry.prototype.addCommand = function (id, options) {
var _this = this;
addCommand(id, options) {
// Throw an error if the id is already registered.
if (id in this._commands) {
throw new Error("Command '" + id + "' already registered.");
throw new Error(`Command '${id}' already registered.`);
}

@@ -121,11 +104,11 @@ // Add the command to the registry.

// Emit the `commandChanged` signal.
this._commandChanged.emit({ id: id, type: 'added' });
this._commandChanged.emit({ id, type: 'added' });
// Return a disposable which will remove the command.
return new DisposableDelegate(function () {
return new DisposableDelegate(() => {
// Remove the command from the registry.
delete _this._commands[id];
delete this._commands[id];
// Emit the `commandChanged` signal.
_this._commandChanged.emit({ id: id, type: 'removed' });
this._commandChanged.emit({ id, type: 'removed' });
});
};
}
/**

@@ -146,9 +129,23 @@ * Notify listeners that the state of a command has changed.

*/
CommandRegistry.prototype.notifyCommandChanged = function (id) {
notifyCommandChanged(id) {
if (id !== undefined && !(id in this._commands)) {
throw new Error("Command '" + id + "' is not registered.");
throw new Error(`Command '${id}' is not registered.`);
}
this._commandChanged.emit({ id: id, type: id ? 'changed' : 'many-changed' });
};
this._commandChanged.emit({ id, type: id ? 'changed' : 'many-changed' });
}
/**
* Get the description for a specific command.
*
* @param id - The id of the command of interest.
*
* @param args - The arguments for the command.
*
* @returns The description for the command.
*/
describedBy(id, args = JSONExt.emptyObject) {
var _a;
let cmd = this._commands[id];
return Promise.resolve((_a = cmd === null || cmd === void 0 ? void 0 : cmd.describedBy.call(undefined, args)) !== null && _a !== void 0 ? _a : { args: null });
}
/**
* Get the display label for a specific command.

@@ -163,7 +160,7 @@ *

*/
CommandRegistry.prototype.label = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
return cmd ? cmd.label.call(undefined, args) : '';
};
label(id, args = JSONExt.emptyObject) {
var _a;
let cmd = this._commands[id];
return (_a = cmd === null || cmd === void 0 ? void 0 : cmd.label.call(undefined, args)) !== null && _a !== void 0 ? _a : '';
}
/**

@@ -179,7 +176,6 @@ * Get the mnemonic index for a specific command.

*/
CommandRegistry.prototype.mnemonic = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
mnemonic(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.mnemonic.call(undefined, args) : -1;
};
}
/**

@@ -197,12 +193,8 @@ * Get the icon renderer for a specific command.

*
* @returns The icon renderer for the command, or
* an empty string if the command is not registered.
* @returns The icon renderer for the command or `undefined`.
*/
CommandRegistry.prototype.icon = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
return cmd
? cmd.icon.call(undefined, args)
: /* <DEPRECATED> */ '' /* </DEPRECATED> */ /* <FUTURE> undefined </FUTURE> */;
};
icon(id, args = JSONExt.emptyObject) {
var _a;
return (_a = this._commands[id]) === null || _a === void 0 ? void 0 : _a.icon.call(undefined, args);
}
/**

@@ -218,7 +210,6 @@ * Get the icon class for a specific command.

*/
CommandRegistry.prototype.iconClass = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
iconClass(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.iconClass.call(undefined, args) : '';
};
}
/**

@@ -234,7 +225,6 @@ * Get the icon label for a specific command.

*/
CommandRegistry.prototype.iconLabel = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
iconLabel(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.iconLabel.call(undefined, args) : '';
};
}
/**

@@ -250,7 +240,6 @@ * Get the short form caption for a specific command.

*/
CommandRegistry.prototype.caption = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
caption(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.caption.call(undefined, args) : '';
};
}
/**

@@ -266,7 +255,6 @@ * Get the usage help text for a specific command.

*/
CommandRegistry.prototype.usage = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
usage(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.usage.call(undefined, args) : '';
};
}
/**

@@ -282,7 +270,6 @@ * Get the extra class name for a specific command.

*/
CommandRegistry.prototype.className = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
className(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.className.call(undefined, args) : '';
};
}
/**

@@ -298,7 +285,6 @@ * Get the dataset for a specific command.

*/
CommandRegistry.prototype.dataset = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
dataset(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.dataset.call(undefined, args) : {};
};
}
/**

@@ -314,7 +300,6 @@ * Test whether a specific command is enabled.

*/
CommandRegistry.prototype.isEnabled = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
isEnabled(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isEnabled.call(undefined, args) : false;
};
}
/**

@@ -330,7 +315,6 @@ * Test whether a specific command is toggled.

*/
CommandRegistry.prototype.isToggled = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
isToggled(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isToggled.call(undefined, args) : false;
};
}
/**

@@ -346,6 +330,6 @@ * Test whether a specific command is toggleable.

*/
CommandRegistry.prototype.isToggleable = function (id, args) {
var cmd = this._commands[id];
isToggleable(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isToggleable : false;
};
}
/**

@@ -361,7 +345,6 @@ * Test whether a specific command is visible.

*/
CommandRegistry.prototype.isVisible = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
var cmd = this._commands[id];
isVisible(id, args = JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isVisible.call(undefined, args) : false;
};
}
/**

@@ -380,11 +363,10 @@ * Execute a specific command.

*/
CommandRegistry.prototype.execute = function (id, args) {
if (args === void 0) { args = JSONExt.emptyObject; }
execute(id, args = JSONExt.emptyObject) {
// Reject if the command is not registered.
var cmd = this._commands[id];
let cmd = this._commands[id];
if (!cmd) {
return Promise.reject(new Error("Command '" + id + "' not registered."));
return Promise.reject(new Error(`Command '${id}' not registered.`));
}
// Execute the command and reject if an exception is thrown.
var value;
let value;
try {

@@ -397,8 +379,8 @@ value = cmd.execute.call(undefined, args);

// Create the return promise which resolves the result.
var result = Promise.resolve(value);
let result = Promise.resolve(value);
// Emit the command executed signal.
this._commandExecuted.emit({ id: id, args: args, result: result });
this._commandExecuted.emit({ id, args, result });
// Return the result promise to the caller.
return result;
};
}
/**

@@ -425,18 +407,17 @@ * Add a key binding to the registry.

*/
CommandRegistry.prototype.addKeyBinding = function (options) {
var _this = this;
addKeyBinding(options) {
// Create the binding for the given options.
var binding = Private.createKeyBinding(options);
let binding = Private.createKeyBinding(options);
// Add the key binding to the bindings array.
this._keyBindings.push(binding);
// Emit the `bindingChanged` signal.
this._keyBindingChanged.emit({ binding: binding, type: 'added' });
this._keyBindingChanged.emit({ binding, type: 'added' });
// Return a disposable which will remove the binding.
return new DisposableDelegate(function () {
return new DisposableDelegate(() => {
// Remove the binding from the array.
ArrayExt.removeFirstOf(_this._keyBindings, binding);
ArrayExt.removeFirstOf(this._keyBindings, binding);
// Emit the `bindingChanged` signal.
_this._keyBindingChanged.emit({ binding: binding, type: 'removed' });
this._keyBindingChanged.emit({ binding, type: 'removed' });
});
};
}
/**

@@ -459,3 +440,3 @@ * Process a `'keydown'` event and invoke a matching key binding.

*/
CommandRegistry.prototype.processKeydownEvent = function (event) {
processKeydownEvent(event) {
// Bail immediately if playing back keystrokes.

@@ -466,3 +447,3 @@ if (this._replaying || CommandRegistry.isModifierKeyPressed(event)) {

// Get the normalized keystroke for the event.
var keystroke = CommandRegistry.keystrokeForKeydownEvent(event);
let keystroke = CommandRegistry.keystrokeForKeydownEvent(event);
// If the keystroke is not valid for the keyboard layout, replay

@@ -478,3 +459,3 @@ // any suppressed events and clear the pending state.

// Find the exact and partial matches for the key sequence.
var _a = Private.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
let { exact, partial } = Private.matchKeyBinding(this._keyBindings, this._keystrokes, event);
// If there is no exact match and no partial match, replay

@@ -510,17 +491,16 @@ // any suppressed events and clear the pending state.

this._startTimer();
};
}
/**
* Start or restart the pending timeout.
*/
CommandRegistry.prototype._startTimer = function () {
var _this = this;
_startTimer() {
this._clearTimer();
this._timerID = window.setTimeout(function () {
_this._onPendingTimeout();
this._timerID = window.setTimeout(() => {
this._onPendingTimeout();
}, Private.CHORD_TIMEOUT);
};
}
/**
* Clear the pending timeout.
*/
CommandRegistry.prototype._clearTimer = function () {
_clearTimer() {
if (this._timerID !== 0) {

@@ -530,7 +510,7 @@ clearTimeout(this._timerID);

}
};
}
/**
* Replay the keydown events which were suppressed.
*/
CommandRegistry.prototype._replayKeydownEvents = function () {
_replayKeydownEvents() {
if (this._keydownEvents.length === 0) {

@@ -542,3 +522,3 @@ return;

this._replaying = false;
};
}
/**

@@ -549,18 +529,18 @@ * Execute the command for the given key binding.

*/
CommandRegistry.prototype._executeKeyBinding = function (binding) {
var command = binding.command, args = binding.args;
_executeKeyBinding(binding) {
let { command, args } = binding;
if (!this.hasCommand(command) || !this.isEnabled(command, args)) {
var word = this.hasCommand(command) ? 'enabled' : 'registered';
var keys = binding.keys.join(', ');
var msg1 = "Cannot execute key binding '" + keys + "':";
var msg2 = "command '" + command + "' is not " + word + ".";
console.warn(msg1 + " " + msg2);
let word = this.hasCommand(command) ? 'enabled' : 'registered';
let keys = binding.keys.join(', ');
let msg1 = `Cannot execute key binding '${keys}':`;
let msg2 = `command '${command}' is not ${word}.`;
console.warn(`${msg1} ${msg2}`);
return;
}
this.execute(command, args);
};
}
/**
* Clear the internal pending state.
*/
CommandRegistry.prototype._clearPendingState = function () {
_clearPendingState() {
this._clearTimer();

@@ -570,7 +550,7 @@ this._exactKeyMatch = null;

this._keydownEvents.length = 0;
};
}
/**
* Handle the partial match timeout.
*/
CommandRegistry.prototype._onPendingTimeout = function () {
_onPendingTimeout() {
this._timerID = 0;

@@ -584,5 +564,4 @@ if (this._exactKeyMatch) {

this._clearPendingState();
};
return CommandRegistry;
}());
}
}
/**

@@ -615,9 +594,8 @@ * The namespace for the `CommandRegistry` class statics.

function parseKeystroke(keystroke) {
var key = '';
var alt = false;
var cmd = false;
var ctrl = false;
var shift = false;
for (var _i = 0, _a = keystroke.split(/\s+/); _i < _a.length; _i++) {
var token = _a[_i];
let key = '';
let alt = false;
let cmd = false;
let ctrl = false;
let shift = false;
for (let token of keystroke.split(/\s+/)) {
if (token === 'Accel') {

@@ -647,3 +625,3 @@ if (Platform.IS_MAC) {

}
return { cmd: cmd, ctrl: ctrl, alt: alt, shift: shift, key: key };
return { cmd, ctrl, alt, shift, key };
}

@@ -665,4 +643,4 @@ CommandRegistry.parseKeystroke = parseKeystroke;

function normalizeKeystroke(keystroke) {
var mods = '';
var parts = parseKeystroke(keystroke);
let mods = '';
let parts = parseKeystroke(keystroke);
if (parts.ctrl) {

@@ -691,3 +669,3 @@ mods += 'Ctrl ';

function normalizeKeys(options) {
var keys;
let keys;
if (Platform.IS_WIN) {

@@ -709,5 +687,5 @@ keys = options.winKeys || options.keys;

function formatKeystroke(keystroke) {
var mods = [];
var separator = Platform.IS_MAC ? ' ' : '+';
var parts = parseKeystroke(keystroke);
let mods = [];
let separator = Platform.IS_MAC ? ' ' : '+';
let parts = parseKeystroke(keystroke);
if (parts.ctrl) {

@@ -737,4 +715,4 @@ mods.push('Ctrl');

function isModifierKeyPressed(event) {
var layout = getKeyboardLayout();
var key = layout.keyForKeydownEvent(event);
let layout = getKeyboardLayout();
let key = layout.keyForKeydownEvent(event);
return layout.isModifierKey(key);

@@ -752,8 +730,8 @@ }

function keystrokeForKeydownEvent(event) {
var layout = getKeyboardLayout();
var key = layout.keyForKeydownEvent(event);
let layout = getKeyboardLayout();
let key = layout.keyForKeydownEvent(event);
if (!key || layout.isModifierKey(key)) {
return '';
}
var mods = [];
let mods = [];
if (event.ctrlKey) {

@@ -789,23 +767,13 @@ mods.push('Ctrl');

function createCommand(options) {
var icon;
var iconClass;
/* <DEPRECATED> */
if (!options.icon || typeof options.icon === 'string') {
// alias icon to iconClass
iconClass = asFunc(options.iconClass || options.icon, emptyStringFunc);
icon = iconClass;
}
else {
/* /<DEPRECATED> */
iconClass = asFunc(options.iconClass, emptyStringFunc);
icon = asFunc(options.icon, undefinedFunc);
/* <DEPRECATED> */
}
/* </DEPRECATED> */
return {
execute: options.execute,
describedBy: asFunc(typeof options.describedBy === 'function'
? options.describedBy
: Object.assign({ args: null }, options.describedBy), () => {
return { args: null };
}),
label: asFunc(options.label, emptyStringFunc),
mnemonic: asFunc(options.mnemonic, negativeOneFunc),
icon: icon,
iconClass: iconClass,
icon: asFunc(options.icon, undefinedFunc),
iconClass: asFunc(options.iconClass, emptyStringFunc),
iconLabel: asFunc(options.iconLabel, emptyStringFunc),

@@ -843,17 +811,17 @@ caption: asFunc(options.caption, emptyStringFunc),

// The current best exact match.
var exact = null;
let exact = null;
// Whether a partial match has been found.
var partial = false;
let partial = false;
// The match distance for the exact match.
var distance = Infinity;
let distance = Infinity;
// The specificity for the exact match.
var specificity = 0;
let specificity = 0;
// Iterate over the bindings and search for the best match.
for (var i = 0, n = bindings.length; i < n; ++i) {
for (let i = 0, n = bindings.length; i < n; ++i) {
// Lookup the current binding.
var binding = bindings[i];
let binding = bindings[i];
// Check whether the key binding sequence is a match.
var sqm = matchSequence(binding.keys, keys);
let sqm = matchSequence(binding.keys, keys);
// If there is no match, the binding is ignored.
if (sqm === 0 /* None */) {
if (sqm === 0 /* SequenceMatch.None */) {
continue;

@@ -863,3 +831,3 @@ }

// found, ensure the selector matches and set the partial flag.
if (sqm === 2 /* Partial */) {
if (sqm === 2 /* SequenceMatch.Partial */) {
if (!partial && targetDistance(binding.selector, event) !== -1) {

@@ -872,3 +840,3 @@ partial = true;

// matched node is farther away than the current best match.
var td = targetDistance(binding.selector, event);
let td = targetDistance(binding.selector, event);
if (td === -1 || td > distance) {

@@ -878,3 +846,3 @@ continue;

// Get the specificity for the selector.
var sp = Selector.calculateSpecificity(binding.selector);
let sp = Selector.calculateSpecificity(binding.selector);
// Update the best match if this match is stronger.

@@ -888,3 +856,3 @@ if (!exact || td < distance || sp >= specificity) {

// Return the match result.
return { exact: exact, partial: partial };
return { exact, partial };
}

@@ -910,3 +878,3 @@ Private.matchKeyBinding = matchKeyBinding;

Private.formatKey = formatKey;
var MAC_DISPLAY = {
const MAC_DISPLAY = {
Backspace: '⌫',

@@ -930,3 +898,3 @@ Tab: '⇥',

};
var WIN_DISPLAY = {
const WIN_DISPLAY = {
Escape: 'Esc',

@@ -944,23 +912,23 @@ PageUp: 'Page Up',

*/
var emptyStringFunc = function () { return ''; };
const emptyStringFunc = () => '';
/**
* A singleton `-1` number function
*/
var negativeOneFunc = function () { return -1; };
const negativeOneFunc = () => -1;
/**
* A singleton true boolean function.
*/
var trueFunc = function () { return true; };
const trueFunc = () => true;
/**
* A singleton false boolean function.
*/
var falseFunc = function () { return false; };
const falseFunc = () => false;
/**
* A singleton empty dataset function.
*/
var emptyDatasetFunc = function () { return ({}); };
const emptyDatasetFunc = () => ({});
/**
* A singleton undefined function
*/
var undefinedFunc = function () { return undefined; };
const undefinedFunc = () => undefined;
/**

@@ -976,3 +944,3 @@ * Cast a value or command func to a command func.

}
return function () { return value; };
return () => value;
}

@@ -987,6 +955,6 @@ /**

if (options.selector.indexOf(',') !== -1) {
throw new Error("Selector cannot contain commas: " + options.selector);
throw new Error(`Selector cannot contain commas: ${options.selector}`);
}
if (!Selector.isValid(options.selector)) {
throw new Error("Invalid selector: " + options.selector);
throw new Error(`Invalid selector: ${options.selector}`);
}

@@ -1002,13 +970,13 @@ return options.selector;

if (bindKeys.length < userKeys.length) {
return 0 /* None */;
return 0 /* SequenceMatch.None */;
}
for (var i = 0, n = userKeys.length; i < n; ++i) {
for (let i = 0, n = userKeys.length; i < n; ++i) {
if (bindKeys[i] !== userKeys[i]) {
return 0 /* None */;
return 0 /* SequenceMatch.None */;
}
}
if (bindKeys.length > userKeys.length) {
return 2 /* Partial */;
return 2 /* SequenceMatch.Partial */;
}
return 1 /* Exact */;
return 1 /* SequenceMatch.Exact */;
}

@@ -1023,13 +991,8 @@ /**

function targetDistance(selector, event) {
var targ = event.target;
var curr = event.currentTarget;
for (var dist = 0; targ !== null; targ = targ.parentElement, ++dist) {
let targ = event.target;
let curr = event.currentTarget;
for (let dist = 0; targ !== null; targ = targ.parentElement, ++dist) {
if (targ.hasAttribute('data-lm-suppress-shortcuts')) {
return -1;
}
/* <DEPRECATED> */
if (targ.hasAttribute('data-p-suppress-shortcuts')) {
return -1;
}
/* </DEPRECATED> */
if (Selector.matches(targ, selector)) {

@@ -1050,5 +1013,5 @@ return dist;

// `keyCode` field in user-generated `KeyboardEvent` types.
var clone = document.createEvent('Event');
var bubbles = event.bubbles || true;
var cancelable = event.cancelable || true;
let clone = document.createEvent('Event');
let bubbles = event.bubbles || true;
let cancelable = event.cancelable || true;
clone.initEvent(event.type || 'keydown', bubbles, cancelable);

@@ -1055,0 +1018,0 @@ clone.key = event.key || '';

@@ -5,3 +5,3 @@ (function (global, factory) {

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_commands = {}, global.lumino_algorithm, global.lumino_coreutils, global.lumino_disposable, global.lumino_domutils, global.lumino_keyboard, global.lumino_signaling));
}(this, (function (exports, algorithm, coreutils, disposable, domutils, keyboard, signaling) { 'use strict';
})(this, (function (exports, algorithm, coreutils, disposable, domutils, keyboard, signaling) { 'use strict';

@@ -16,4 +16,4 @@ // Copyright (c) Jupyter Development Team.

*/
exports.CommandRegistry = /** @class */ (function () {
function CommandRegistry() {
class CommandRegistry {
constructor() {
this._timerID = 0;

@@ -30,52 +30,36 @@ this._replaying = false;

}
Object.defineProperty(CommandRegistry.prototype, "commandChanged", {
/**
* A signal emitted when a command has changed.
*
* #### Notes
* This signal is useful for visual representations of commands which
* need to refresh when the state of a relevant command has changed.
*/
get: function () {
return this._commandChanged;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "commandExecuted", {
/**
* A signal emitted when a command has executed.
*
* #### Notes
* Care should be taken when consuming this signal. The command system is used
* by many components for many user actions. Handlers registered with this
* signal must return quickly to ensure the overall application remains responsive.
*/
get: function () {
return this._commandExecuted;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "keyBindingChanged", {
/**
* A signal emitted when a key binding is changed.
*/
get: function () {
return this._keyBindingChanged;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CommandRegistry.prototype, "keyBindings", {
/**
* A read-only array of the key bindings in the registry.
*/
get: function () {
return this._keyBindings;
},
enumerable: true,
configurable: true
});
/**
* A signal emitted when a command has changed.
*
* #### Notes
* This signal is useful for visual representations of commands which
* need to refresh when the state of a relevant command has changed.
*/
get commandChanged() {
return this._commandChanged;
}
/**
* A signal emitted when a command has executed.
*
* #### Notes
* Care should be taken when consuming this signal. The command system is used
* by many components for many user actions. Handlers registered with this
* signal must return quickly to ensure the overall application remains responsive.
*/
get commandExecuted() {
return this._commandExecuted;
}
/**
* A signal emitted when a key binding is changed.
*/
get keyBindingChanged() {
return this._keyBindingChanged;
}
/**
* A read-only array of the key bindings in the registry.
*/
get keyBindings() {
return this._keyBindings;
}
/**
* List the ids of the registered commands.

@@ -85,5 +69,5 @@ *

*/
CommandRegistry.prototype.listCommands = function () {
listCommands() {
return Object.keys(this._commands);
};
}
/**

@@ -96,5 +80,5 @@ * Test whether a specific command is registered.

*/
CommandRegistry.prototype.hasCommand = function (id) {
hasCommand(id) {
return id in this._commands;
};
}
/**

@@ -111,7 +95,6 @@ * Add a command to the registry.

*/
CommandRegistry.prototype.addCommand = function (id, options) {
var _this = this;
addCommand(id, options) {
// Throw an error if the id is already registered.
if (id in this._commands) {
throw new Error("Command '" + id + "' already registered.");
throw new Error(`Command '${id}' already registered.`);
}

@@ -121,11 +104,11 @@ // Add the command to the registry.

// Emit the `commandChanged` signal.
this._commandChanged.emit({ id: id, type: 'added' });
this._commandChanged.emit({ id, type: 'added' });
// Return a disposable which will remove the command.
return new disposable.DisposableDelegate(function () {
return new disposable.DisposableDelegate(() => {
// Remove the command from the registry.
delete _this._commands[id];
delete this._commands[id];
// Emit the `commandChanged` signal.
_this._commandChanged.emit({ id: id, type: 'removed' });
this._commandChanged.emit({ id, type: 'removed' });
});
};
}
/**

@@ -146,9 +129,23 @@ * Notify listeners that the state of a command has changed.

*/
CommandRegistry.prototype.notifyCommandChanged = function (id) {
notifyCommandChanged(id) {
if (id !== undefined && !(id in this._commands)) {
throw new Error("Command '" + id + "' is not registered.");
throw new Error(`Command '${id}' is not registered.`);
}
this._commandChanged.emit({ id: id, type: id ? 'changed' : 'many-changed' });
};
this._commandChanged.emit({ id, type: id ? 'changed' : 'many-changed' });
}
/**
* Get the description for a specific command.
*
* @param id - The id of the command of interest.
*
* @param args - The arguments for the command.
*
* @returns The description for the command.
*/
describedBy(id, args = coreutils.JSONExt.emptyObject) {
var _a;
let cmd = this._commands[id];
return Promise.resolve((_a = cmd === null || cmd === void 0 ? void 0 : cmd.describedBy.call(undefined, args)) !== null && _a !== void 0 ? _a : { args: null });
}
/**
* Get the display label for a specific command.

@@ -163,7 +160,7 @@ *

*/
CommandRegistry.prototype.label = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
return cmd ? cmd.label.call(undefined, args) : '';
};
label(id, args = coreutils.JSONExt.emptyObject) {
var _a;
let cmd = this._commands[id];
return (_a = cmd === null || cmd === void 0 ? void 0 : cmd.label.call(undefined, args)) !== null && _a !== void 0 ? _a : '';
}
/**

@@ -179,7 +176,6 @@ * Get the mnemonic index for a specific command.

*/
CommandRegistry.prototype.mnemonic = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
mnemonic(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.mnemonic.call(undefined, args) : -1;
};
}
/**

@@ -197,12 +193,8 @@ * Get the icon renderer for a specific command.

*
* @returns The icon renderer for the command, or
* an empty string if the command is not registered.
* @returns The icon renderer for the command or `undefined`.
*/
CommandRegistry.prototype.icon = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
return cmd
? cmd.icon.call(undefined, args)
: /* <DEPRECATED> */ '' /* </DEPRECATED> */ /* <FUTURE> undefined </FUTURE> */;
};
icon(id, args = coreutils.JSONExt.emptyObject) {
var _a;
return (_a = this._commands[id]) === null || _a === void 0 ? void 0 : _a.icon.call(undefined, args);
}
/**

@@ -218,7 +210,6 @@ * Get the icon class for a specific command.

*/
CommandRegistry.prototype.iconClass = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
iconClass(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.iconClass.call(undefined, args) : '';
};
}
/**

@@ -234,7 +225,6 @@ * Get the icon label for a specific command.

*/
CommandRegistry.prototype.iconLabel = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
iconLabel(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.iconLabel.call(undefined, args) : '';
};
}
/**

@@ -250,7 +240,6 @@ * Get the short form caption for a specific command.

*/
CommandRegistry.prototype.caption = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
caption(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.caption.call(undefined, args) : '';
};
}
/**

@@ -266,7 +255,6 @@ * Get the usage help text for a specific command.

*/
CommandRegistry.prototype.usage = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
usage(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.usage.call(undefined, args) : '';
};
}
/**

@@ -282,7 +270,6 @@ * Get the extra class name for a specific command.

*/
CommandRegistry.prototype.className = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
className(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.className.call(undefined, args) : '';
};
}
/**

@@ -298,7 +285,6 @@ * Get the dataset for a specific command.

*/
CommandRegistry.prototype.dataset = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
dataset(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.dataset.call(undefined, args) : {};
};
}
/**

@@ -314,7 +300,6 @@ * Test whether a specific command is enabled.

*/
CommandRegistry.prototype.isEnabled = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
isEnabled(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isEnabled.call(undefined, args) : false;
};
}
/**

@@ -330,7 +315,6 @@ * Test whether a specific command is toggled.

*/
CommandRegistry.prototype.isToggled = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
isToggled(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isToggled.call(undefined, args) : false;
};
}
/**

@@ -346,6 +330,6 @@ * Test whether a specific command is toggleable.

*/
CommandRegistry.prototype.isToggleable = function (id, args) {
var cmd = this._commands[id];
isToggleable(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isToggleable : false;
};
}
/**

@@ -361,7 +345,6 @@ * Test whether a specific command is visible.

*/
CommandRegistry.prototype.isVisible = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
var cmd = this._commands[id];
isVisible(id, args = coreutils.JSONExt.emptyObject) {
let cmd = this._commands[id];
return cmd ? cmd.isVisible.call(undefined, args) : false;
};
}
/**

@@ -380,11 +363,10 @@ * Execute a specific command.

*/
CommandRegistry.prototype.execute = function (id, args) {
if (args === void 0) { args = coreutils.JSONExt.emptyObject; }
execute(id, args = coreutils.JSONExt.emptyObject) {
// Reject if the command is not registered.
var cmd = this._commands[id];
let cmd = this._commands[id];
if (!cmd) {
return Promise.reject(new Error("Command '" + id + "' not registered."));
return Promise.reject(new Error(`Command '${id}' not registered.`));
}
// Execute the command and reject if an exception is thrown.
var value;
let value;
try {

@@ -397,8 +379,8 @@ value = cmd.execute.call(undefined, args);

// Create the return promise which resolves the result.
var result = Promise.resolve(value);
let result = Promise.resolve(value);
// Emit the command executed signal.
this._commandExecuted.emit({ id: id, args: args, result: result });
this._commandExecuted.emit({ id, args, result });
// Return the result promise to the caller.
return result;
};
}
/**

@@ -425,18 +407,17 @@ * Add a key binding to the registry.

*/
CommandRegistry.prototype.addKeyBinding = function (options) {
var _this = this;
addKeyBinding(options) {
// Create the binding for the given options.
var binding = Private.createKeyBinding(options);
let binding = Private.createKeyBinding(options);
// Add the key binding to the bindings array.
this._keyBindings.push(binding);
// Emit the `bindingChanged` signal.
this._keyBindingChanged.emit({ binding: binding, type: 'added' });
this._keyBindingChanged.emit({ binding, type: 'added' });
// Return a disposable which will remove the binding.
return new disposable.DisposableDelegate(function () {
return new disposable.DisposableDelegate(() => {
// Remove the binding from the array.
algorithm.ArrayExt.removeFirstOf(_this._keyBindings, binding);
algorithm.ArrayExt.removeFirstOf(this._keyBindings, binding);
// Emit the `bindingChanged` signal.
_this._keyBindingChanged.emit({ binding: binding, type: 'removed' });
this._keyBindingChanged.emit({ binding, type: 'removed' });
});
};
}
/**

@@ -459,3 +440,3 @@ * Process a `'keydown'` event and invoke a matching key binding.

*/
CommandRegistry.prototype.processKeydownEvent = function (event) {
processKeydownEvent(event) {
// Bail immediately if playing back keystrokes.

@@ -466,3 +447,3 @@ if (this._replaying || CommandRegistry.isModifierKeyPressed(event)) {

// Get the normalized keystroke for the event.
var keystroke = CommandRegistry.keystrokeForKeydownEvent(event);
let keystroke = CommandRegistry.keystrokeForKeydownEvent(event);
// If the keystroke is not valid for the keyboard layout, replay

@@ -478,3 +459,3 @@ // any suppressed events and clear the pending state.

// Find the exact and partial matches for the key sequence.
var _a = Private.matchKeyBinding(this._keyBindings, this._keystrokes, event), exact = _a.exact, partial = _a.partial;
let { exact, partial } = Private.matchKeyBinding(this._keyBindings, this._keystrokes, event);
// If there is no exact match and no partial match, replay

@@ -510,17 +491,16 @@ // any suppressed events and clear the pending state.

this._startTimer();
};
}
/**
* Start or restart the pending timeout.
*/
CommandRegistry.prototype._startTimer = function () {
var _this = this;
_startTimer() {
this._clearTimer();
this._timerID = window.setTimeout(function () {
_this._onPendingTimeout();
this._timerID = window.setTimeout(() => {
this._onPendingTimeout();
}, Private.CHORD_TIMEOUT);
};
}
/**
* Clear the pending timeout.
*/
CommandRegistry.prototype._clearTimer = function () {
_clearTimer() {
if (this._timerID !== 0) {

@@ -530,7 +510,7 @@ clearTimeout(this._timerID);

}
};
}
/**
* Replay the keydown events which were suppressed.
*/
CommandRegistry.prototype._replayKeydownEvents = function () {
_replayKeydownEvents() {
if (this._keydownEvents.length === 0) {

@@ -542,3 +522,3 @@ return;

this._replaying = false;
};
}
/**

@@ -549,18 +529,18 @@ * Execute the command for the given key binding.

*/
CommandRegistry.prototype._executeKeyBinding = function (binding) {
var command = binding.command, args = binding.args;
_executeKeyBinding(binding) {
let { command, args } = binding;
if (!this.hasCommand(command) || !this.isEnabled(command, args)) {
var word = this.hasCommand(command) ? 'enabled' : 'registered';
var keys = binding.keys.join(', ');
var msg1 = "Cannot execute key binding '" + keys + "':";
var msg2 = "command '" + command + "' is not " + word + ".";
console.warn(msg1 + " " + msg2);
let word = this.hasCommand(command) ? 'enabled' : 'registered';
let keys = binding.keys.join(', ');
let msg1 = `Cannot execute key binding '${keys}':`;
let msg2 = `command '${command}' is not ${word}.`;
console.warn(`${msg1} ${msg2}`);
return;
}
this.execute(command, args);
};
}
/**
* Clear the internal pending state.
*/
CommandRegistry.prototype._clearPendingState = function () {
_clearPendingState() {
this._clearTimer();

@@ -570,7 +550,7 @@ this._exactKeyMatch = null;

this._keydownEvents.length = 0;
};
}
/**
* Handle the partial match timeout.
*/
CommandRegistry.prototype._onPendingTimeout = function () {
_onPendingTimeout() {
this._timerID = 0;

@@ -584,5 +564,4 @@ if (this._exactKeyMatch) {

this._clearPendingState();
};
return CommandRegistry;
}());
}
}
/**

@@ -615,9 +594,8 @@ * The namespace for the `CommandRegistry` class statics.

function parseKeystroke(keystroke) {
var key = '';
var alt = false;
var cmd = false;
var ctrl = false;
var shift = false;
for (var _i = 0, _a = keystroke.split(/\s+/); _i < _a.length; _i++) {
var token = _a[_i];
let key = '';
let alt = false;
let cmd = false;
let ctrl = false;
let shift = false;
for (let token of keystroke.split(/\s+/)) {
if (token === 'Accel') {

@@ -647,3 +625,3 @@ if (domutils.Platform.IS_MAC) {

}
return { cmd: cmd, ctrl: ctrl, alt: alt, shift: shift, key: key };
return { cmd, ctrl, alt, shift, key };
}

@@ -665,4 +643,4 @@ CommandRegistry.parseKeystroke = parseKeystroke;

function normalizeKeystroke(keystroke) {
var mods = '';
var parts = parseKeystroke(keystroke);
let mods = '';
let parts = parseKeystroke(keystroke);
if (parts.ctrl) {

@@ -691,3 +669,3 @@ mods += 'Ctrl ';

function normalizeKeys(options) {
var keys;
let keys;
if (domutils.Platform.IS_WIN) {

@@ -709,5 +687,5 @@ keys = options.winKeys || options.keys;

function formatKeystroke(keystroke) {
var mods = [];
var separator = domutils.Platform.IS_MAC ? ' ' : '+';
var parts = parseKeystroke(keystroke);
let mods = [];
let separator = domutils.Platform.IS_MAC ? ' ' : '+';
let parts = parseKeystroke(keystroke);
if (parts.ctrl) {

@@ -737,4 +715,4 @@ mods.push('Ctrl');

function isModifierKeyPressed(event) {
var layout = keyboard.getKeyboardLayout();
var key = layout.keyForKeydownEvent(event);
let layout = keyboard.getKeyboardLayout();
let key = layout.keyForKeydownEvent(event);
return layout.isModifierKey(key);

@@ -752,8 +730,8 @@ }

function keystrokeForKeydownEvent(event) {
var layout = keyboard.getKeyboardLayout();
var key = layout.keyForKeydownEvent(event);
let layout = keyboard.getKeyboardLayout();
let key = layout.keyForKeydownEvent(event);
if (!key || layout.isModifierKey(key)) {
return '';
}
var mods = [];
let mods = [];
if (event.ctrlKey) {

@@ -775,3 +753,3 @@ mods.push('Ctrl');

CommandRegistry.keystrokeForKeydownEvent = keystrokeForKeydownEvent;
})(exports.CommandRegistry || (exports.CommandRegistry = {}));
})(CommandRegistry || (CommandRegistry = {}));
/**

@@ -790,23 +768,13 @@ * The namespace for the module implementation details.

function createCommand(options) {
var icon;
var iconClass;
/* <DEPRECATED> */
if (!options.icon || typeof options.icon === 'string') {
// alias icon to iconClass
iconClass = asFunc(options.iconClass || options.icon, emptyStringFunc);
icon = iconClass;
}
else {
/* /<DEPRECATED> */
iconClass = asFunc(options.iconClass, emptyStringFunc);
icon = asFunc(options.icon, undefinedFunc);
/* <DEPRECATED> */
}
/* </DEPRECATED> */
return {
execute: options.execute,
describedBy: asFunc(typeof options.describedBy === 'function'
? options.describedBy
: Object.assign({ args: null }, options.describedBy), () => {
return { args: null };
}),
label: asFunc(options.label, emptyStringFunc),
mnemonic: asFunc(options.mnemonic, negativeOneFunc),
icon: icon,
iconClass: iconClass,
icon: asFunc(options.icon, undefinedFunc),
iconClass: asFunc(options.iconClass, emptyStringFunc),
iconLabel: asFunc(options.iconLabel, emptyStringFunc),

@@ -829,3 +797,3 @@ caption: asFunc(options.caption, emptyStringFunc),

return {
keys: exports.CommandRegistry.normalizeKeys(options),
keys: CommandRegistry.normalizeKeys(options),
selector: validateSelector(options),

@@ -845,17 +813,17 @@ command: options.command,

// The current best exact match.
var exact = null;
let exact = null;
// Whether a partial match has been found.
var partial = false;
let partial = false;
// The match distance for the exact match.
var distance = Infinity;
let distance = Infinity;
// The specificity for the exact match.
var specificity = 0;
let specificity = 0;
// Iterate over the bindings and search for the best match.
for (var i = 0, n = bindings.length; i < n; ++i) {
for (let i = 0, n = bindings.length; i < n; ++i) {
// Lookup the current binding.
var binding = bindings[i];
let binding = bindings[i];
// Check whether the key binding sequence is a match.
var sqm = matchSequence(binding.keys, keys);
let sqm = matchSequence(binding.keys, keys);
// If there is no match, the binding is ignored.
if (sqm === 0 /* None */) {
if (sqm === 0 /* SequenceMatch.None */) {
continue;

@@ -865,3 +833,3 @@ }

// found, ensure the selector matches and set the partial flag.
if (sqm === 2 /* Partial */) {
if (sqm === 2 /* SequenceMatch.Partial */) {
if (!partial && targetDistance(binding.selector, event) !== -1) {

@@ -874,3 +842,3 @@ partial = true;

// matched node is farther away than the current best match.
var td = targetDistance(binding.selector, event);
let td = targetDistance(binding.selector, event);
if (td === -1 || td > distance) {

@@ -880,3 +848,3 @@ continue;

// Get the specificity for the selector.
var sp = domutils.Selector.calculateSpecificity(binding.selector);
let sp = domutils.Selector.calculateSpecificity(binding.selector);
// Update the best match if this match is stronger.

@@ -890,3 +858,3 @@ if (!exact || td < distance || sp >= specificity) {

// Return the match result.
return { exact: exact, partial: partial };
return { exact, partial };
}

@@ -912,3 +880,3 @@ Private.matchKeyBinding = matchKeyBinding;

Private.formatKey = formatKey;
var MAC_DISPLAY = {
const MAC_DISPLAY = {
Backspace: '⌫',

@@ -932,3 +900,3 @@ Tab: '⇥',

};
var WIN_DISPLAY = {
const WIN_DISPLAY = {
Escape: 'Esc',

@@ -946,23 +914,23 @@ PageUp: 'Page Up',

*/
var emptyStringFunc = function () { return ''; };
const emptyStringFunc = () => '';
/**
* A singleton `-1` number function
*/
var negativeOneFunc = function () { return -1; };
const negativeOneFunc = () => -1;
/**
* A singleton true boolean function.
*/
var trueFunc = function () { return true; };
const trueFunc = () => true;
/**
* A singleton false boolean function.
*/
var falseFunc = function () { return false; };
const falseFunc = () => false;
/**
* A singleton empty dataset function.
*/
var emptyDatasetFunc = function () { return ({}); };
const emptyDatasetFunc = () => ({});
/**
* A singleton undefined function
*/
var undefinedFunc = function () { return undefined; };
const undefinedFunc = () => undefined;
/**

@@ -978,3 +946,3 @@ * Cast a value or command func to a command func.

}
return function () { return value; };
return () => value;
}

@@ -989,6 +957,6 @@ /**

if (options.selector.indexOf(',') !== -1) {
throw new Error("Selector cannot contain commas: " + options.selector);
throw new Error(`Selector cannot contain commas: ${options.selector}`);
}
if (!domutils.Selector.isValid(options.selector)) {
throw new Error("Invalid selector: " + options.selector);
throw new Error(`Invalid selector: ${options.selector}`);
}

@@ -1004,13 +972,13 @@ return options.selector;

if (bindKeys.length < userKeys.length) {
return 0 /* None */;
return 0 /* SequenceMatch.None */;
}
for (var i = 0, n = userKeys.length; i < n; ++i) {
for (let i = 0, n = userKeys.length; i < n; ++i) {
if (bindKeys[i] !== userKeys[i]) {
return 0 /* None */;
return 0 /* SequenceMatch.None */;
}
}
if (bindKeys.length > userKeys.length) {
return 2 /* Partial */;
return 2 /* SequenceMatch.Partial */;
}
return 1 /* Exact */;
return 1 /* SequenceMatch.Exact */;
}

@@ -1025,13 +993,8 @@ /**

function targetDistance(selector, event) {
var targ = event.target;
var curr = event.currentTarget;
for (var dist = 0; targ !== null; targ = targ.parentElement, ++dist) {
let targ = event.target;
let curr = event.currentTarget;
for (let dist = 0; targ !== null; targ = targ.parentElement, ++dist) {
if (targ.hasAttribute('data-lm-suppress-shortcuts')) {
return -1;
}
/* <DEPRECATED> */
if (targ.hasAttribute('data-p-suppress-shortcuts')) {
return -1;
}
/* </DEPRECATED> */
if (domutils.Selector.matches(targ, selector)) {

@@ -1052,5 +1015,5 @@ return dist;

// `keyCode` field in user-generated `KeyboardEvent` types.
var clone = document.createEvent('Event');
var bubbles = event.bubbles || true;
var cancelable = event.cancelable || true;
let clone = document.createEvent('Event');
let bubbles = event.bubbles || true;
let cancelable = event.cancelable || true;
clone.initEvent(event.type || 'keydown', bubbles, cancelable);

@@ -1069,5 +1032,7 @@ clone.key = event.key || '';

exports.CommandRegistry = CommandRegistry;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lumino/algorithm"),require("@lumino/coreutils"),require("@lumino/disposable"),require("@lumino/domutils"),require("@lumino/keyboard"),require("@lumino/signaling")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils","@lumino/disposable","@lumino/domutils","@lumino/keyboard","@lumino/signaling"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_commands={},e.lumino_algorithm,e.lumino_coreutils,e.lumino_disposable,e.lumino_domutils,e.lumino_keyboard,e.lumino_signaling)}(this,(function(e,t,n,i,o,r,a){"use strict";var s;e.CommandRegistry=function(){function e(){this._timerID=0,this._replaying=!1,this._keystrokes=[],this._keydownEvents=[],this._keyBindings=[],this._exactKeyMatch=null,this._commands=Object.create(null),this._commandChanged=new a.Signal(this),this._commandExecuted=new a.Signal(this),this._keyBindingChanged=new a.Signal(this)}return Object.defineProperty(e.prototype,"commandChanged",{get:function(){return this._commandChanged},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"commandExecuted",{get:function(){return this._commandExecuted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"keyBindingChanged",{get:function(){return this._keyBindingChanged},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"keyBindings",{get:function(){return this._keyBindings},enumerable:!0,configurable:!0}),e.prototype.listCommands=function(){return Object.keys(this._commands)},e.prototype.hasCommand=function(e){return e in this._commands},e.prototype.addCommand=function(e,t){var n=this;if(e in this._commands)throw new Error("Command '"+e+"' already registered.");return this._commands[e]=s.createCommand(t),this._commandChanged.emit({id:e,type:"added"}),new i.DisposableDelegate((function(){delete n._commands[e],n._commandChanged.emit({id:e,type:"removed"})}))},e.prototype.notifyCommandChanged=function(e){if(void 0!==e&&!(e in this._commands))throw new Error("Command '"+e+"' is not registered.");this._commandChanged.emit({id:e,type:e?"changed":"many-changed"})},e.prototype.label=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.label.call(void 0,t):""},e.prototype.mnemonic=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.mnemonic.call(void 0,t):-1},e.prototype.icon=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.icon.call(void 0,t):""},e.prototype.iconClass=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.iconClass.call(void 0,t):""},e.prototype.iconLabel=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.iconLabel.call(void 0,t):""},e.prototype.caption=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.caption.call(void 0,t):""},e.prototype.usage=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.usage.call(void 0,t):""},e.prototype.className=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.className.call(void 0,t):""},e.prototype.dataset=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return i?i.dataset.call(void 0,t):{}},e.prototype.isEnabled=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return!!i&&i.isEnabled.call(void 0,t)},e.prototype.isToggled=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return!!i&&i.isToggled.call(void 0,t)},e.prototype.isToggleable=function(e,t){var n=this._commands[e];return!!n&&n.isToggleable},e.prototype.isVisible=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i=this._commands[e];return!!i&&i.isVisible.call(void 0,t)},e.prototype.execute=function(e,t){void 0===t&&(t=n.JSONExt.emptyObject);var i,o=this._commands[e];if(!o)return Promise.reject(new Error("Command '"+e+"' not registered."));try{i=o.execute.call(void 0,t)}catch(e){i=Promise.reject(e)}var r=Promise.resolve(i);return this._commandExecuted.emit({id:e,args:t,result:r}),r},e.prototype.addKeyBinding=function(e){var n=this,o=s.createKeyBinding(e);return this._keyBindings.push(o),this._keyBindingChanged.emit({binding:o,type:"added"}),new i.DisposableDelegate((function(){t.ArrayExt.removeFirstOf(n._keyBindings,o),n._keyBindingChanged.emit({binding:o,type:"removed"})}))},e.prototype.processKeydownEvent=function(t){if(!this._replaying&&!e.isModifierKeyPressed(t)){var n=e.keystrokeForKeydownEvent(t);if(!n)return this._replayKeydownEvents(),void this._clearPendingState();this._keystrokes.push(n);var i=s.matchKeyBinding(this._keyBindings,this._keystrokes,t),o=i.exact,r=i.partial;if(!o&&!r)return this._replayKeydownEvents(),void this._clearPendingState();if(t.preventDefault(),t.stopPropagation(),o&&!r)return this._executeKeyBinding(o),void this._clearPendingState();o&&(this._exactKeyMatch=o),this._keydownEvents.push(t),this._startTimer()}},e.prototype._startTimer=function(){var e=this;this._clearTimer(),this._timerID=window.setTimeout((function(){e._onPendingTimeout()}),s.CHORD_TIMEOUT)},e.prototype._clearTimer=function(){0!==this._timerID&&(clearTimeout(this._timerID),this._timerID=0)},e.prototype._replayKeydownEvents=function(){0!==this._keydownEvents.length&&(this._replaying=!0,this._keydownEvents.forEach(s.replayKeyEvent),this._replaying=!1)},e.prototype._executeKeyBinding=function(e){var t=e.command,n=e.args;if(this.hasCommand(t)&&this.isEnabled(t,n))this.execute(t,n);else{var i=this.hasCommand(t)?"enabled":"registered",o="Cannot execute key binding '"+e.keys.join(", ")+"':",r="command '"+t+"' is not "+i+".";console.warn(o+" "+r)}},e.prototype._clearPendingState=function(){this._clearTimer(),this._exactKeyMatch=null,this._keystrokes.length=0,this._keydownEvents.length=0},e.prototype._onPendingTimeout=function(){this._timerID=0,this._exactKeyMatch?this._executeKeyBinding(this._exactKeyMatch):this._replayKeydownEvents(),this._clearPendingState()},e}(),function(e){function t(e){for(var t="",n=!1,i=!1,r=!1,a=!1,s=0,c=e.split(/\s+/);s<c.length;s++){var l=c[s];"Accel"===l?o.Platform.IS_MAC?i=!0:r=!0:"Alt"===l?n=!0:"Cmd"===l?i=!0:"Ctrl"===l?r=!0:"Shift"===l?a=!0:l.length>0&&(t=l)}return{cmd:i,ctrl:r,alt:n,shift:a,key:t}}function n(e){var n="",i=t(e);return i.ctrl&&(n+="Ctrl "),i.alt&&(n+="Alt "),i.shift&&(n+="Shift "),i.cmd&&o.Platform.IS_MAC&&(n+="Cmd "),n+i.key}e.parseKeystroke=t,e.normalizeKeystroke=n,e.normalizeKeys=function(e){return(o.Platform.IS_WIN?e.winKeys||e.keys:o.Platform.IS_MAC?e.macKeys||e.keys:e.linuxKeys||e.keys).map(n)},e.formatKeystroke=function(e){var n=[],i=o.Platform.IS_MAC?" ":"+",r=t(e);return r.ctrl&&n.push("Ctrl"),r.alt&&n.push("Alt"),r.shift&&n.push("Shift"),o.Platform.IS_MAC&&r.cmd&&n.push("Cmd"),n.push(r.key),n.map(s.formatKey).join(i)},e.isModifierKeyPressed=function(e){var t=r.getKeyboardLayout(),n=t.keyForKeydownEvent(e);return t.isModifierKey(n)},e.keystrokeForKeydownEvent=function(e){var t=r.getKeyboardLayout(),n=t.keyForKeydownEvent(e);if(!n||t.isModifierKey(n))return"";var i=[];return e.ctrlKey&&i.push("Ctrl"),e.altKey&&i.push("Alt"),e.shiftKey&&i.push("Shift"),e.metaKey&&o.Platform.IS_MAC&&i.push("Cmd"),i.push(n),i.join(" ")}}(e.CommandRegistry||(e.CommandRegistry={})),function(t){t.CHORD_TIMEOUT=1e3,t.createCommand=function(e){var t,n;return e.icon&&"string"!=typeof e.icon?(n=u(e.iconClass,a),t=u(e.icon,m)):t=n=u(e.iconClass||e.icon,a),{execute:e.execute,label:u(e.label,a),mnemonic:u(e.mnemonic,s),icon:t,iconClass:n,iconLabel:u(e.iconLabel,a),caption:u(e.caption,a),usage:u(e.usage,a),className:u(e.className,a),dataset:u(e.dataset,d),isEnabled:e.isEnabled||c,isToggled:e.isToggled||l,isToggleable:e.isToggleable||!!e.isToggled,isVisible:e.isVisible||c}},t.createKeyBinding=function(t){return{keys:e.CommandRegistry.normalizeKeys(t),selector:y(t),command:t.command,args:t.args||n.JSONExt.emptyObject}},t.matchKeyBinding=function(e,t,n){for(var i=null,r=!1,a=1/0,s=0,c=0,l=e.length;c<l;++c){var d=e[c],m=h(d.keys,t);if(0!==m)if(2!==m){var u=p(d.selector,n);if(!(-1===u||u>a)){var y=o.Selector.calculateSpecificity(d.selector);(!i||u<a||y>=s)&&(i=d,a=u,s=y)}}else r||-1===p(d.selector,n)||(r=!0)}return{exact:i,partial:r}},t.replayKeyEvent=function(e){e.target.dispatchEvent(function(e){var t=document.createEvent("Event"),n=e.bubbles||!0,i=e.cancelable||!0;return t.initEvent(e.type||"keydown",n,i),t.key=e.key||"",t.keyCode=e.keyCode||0,t.which=e.keyCode||0,t.ctrlKey=e.ctrlKey||!1,t.altKey=e.altKey||!1,t.shiftKey=e.shiftKey||!1,t.metaKey=e.metaKey||!1,t.view=e.view||window,t}(e))},t.formatKey=function(e){return o.Platform.IS_MAC?i.hasOwnProperty(e)?i[e]:e:r.hasOwnProperty(e)?r[e]:e};var i={Backspace:"⌫",Tab:"⇥",Enter:"↩",Shift:"⇧",Ctrl:"⌃",Alt:"⌥",Escape:"⎋",PageUp:"⇞",PageDown:"⇟",End:"↘",Home:"↖",ArrowLeft:"←",ArrowUp:"↑",ArrowRight:"→",ArrowDown:"↓",Delete:"⌦",Cmd:"⌘"},r={Escape:"Esc",PageUp:"Page Up",PageDown:"Page Down",ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",Delete:"Del"},a=function(){return""},s=function(){return-1},c=function(){return!0},l=function(){return!1},d=function(){return{}},m=function(){};function u(e,t){return void 0===e?t:"function"==typeof e?e:function(){return e}}function y(e){if(-1!==e.selector.indexOf(","))throw new Error("Selector cannot contain commas: "+e.selector);if(!o.Selector.isValid(e.selector))throw new Error("Invalid selector: "+e.selector);return e.selector}function h(e,t){if(e.length<t.length)return 0;for(var n=0,i=t.length;n<i;++n)if(e[n]!==t[n])return 0;return e.length>t.length?2:1}function p(e,t){for(var n=t.target,i=t.currentTarget,r=0;null!==n;n=n.parentElement,++r){if(n.hasAttribute("data-lm-suppress-shortcuts"))return-1;if(n.hasAttribute("data-p-suppress-shortcuts"))return-1;if(o.Selector.matches(n,e))return r;if(n===i)return-1}return-1}}(s||(s={})),Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lumino/algorithm"),require("@lumino/coreutils"),require("@lumino/disposable"),require("@lumino/domutils"),require("@lumino/keyboard"),require("@lumino/signaling")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils","@lumino/disposable","@lumino/domutils","@lumino/keyboard","@lumino/signaling"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_commands={},e.lumino_algorithm,e.lumino_coreutils,e.lumino_disposable,e.lumino_domutils,e.lumino_keyboard,e.lumino_signaling)}(this,(function(e,t,i,n,r,s,o){"use strict";class a{constructor(){this._timerID=0,this._replaying=!1,this._keystrokes=[],this._keydownEvents=[],this._keyBindings=[],this._exactKeyMatch=null,this._commands=Object.create(null),this._commandChanged=new o.Signal(this),this._commandExecuted=new o.Signal(this),this._keyBindingChanged=new o.Signal(this)}get commandChanged(){return this._commandChanged}get commandExecuted(){return this._commandExecuted}get keyBindingChanged(){return this._keyBindingChanged}get keyBindings(){return this._keyBindings}listCommands(){return Object.keys(this._commands)}hasCommand(e){return e in this._commands}addCommand(e,t){if(e in this._commands)throw new Error(`Command '${e}' already registered.`);return this._commands[e]=l.createCommand(t),this._commandChanged.emit({id:e,type:"added"}),new n.DisposableDelegate((()=>{delete this._commands[e],this._commandChanged.emit({id:e,type:"removed"})}))}notifyCommandChanged(e){if(void 0!==e&&!(e in this._commands))throw new Error(`Command '${e}' is not registered.`);this._commandChanged.emit({id:e,type:e?"changed":"many-changed"})}describedBy(e,t=i.JSONExt.emptyObject){var n;let r=this._commands[e];return Promise.resolve(null!==(n=null==r?void 0:r.describedBy.call(void 0,t))&&void 0!==n?n:{args:null})}label(e,t=i.JSONExt.emptyObject){var n;let r=this._commands[e];return null!==(n=null==r?void 0:r.label.call(void 0,t))&&void 0!==n?n:""}mnemonic(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.mnemonic.call(void 0,t):-1}icon(e,t=i.JSONExt.emptyObject){var n;return null===(n=this._commands[e])||void 0===n?void 0:n.icon.call(void 0,t)}iconClass(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.iconClass.call(void 0,t):""}iconLabel(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.iconLabel.call(void 0,t):""}caption(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.caption.call(void 0,t):""}usage(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.usage.call(void 0,t):""}className(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.className.call(void 0,t):""}dataset(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return n?n.dataset.call(void 0,t):{}}isEnabled(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return!!n&&n.isEnabled.call(void 0,t)}isToggled(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return!!n&&n.isToggled.call(void 0,t)}isToggleable(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return!!n&&n.isToggleable}isVisible(e,t=i.JSONExt.emptyObject){let n=this._commands[e];return!!n&&n.isVisible.call(void 0,t)}execute(e,t=i.JSONExt.emptyObject){let n,r=this._commands[e];if(!r)return Promise.reject(new Error(`Command '${e}' not registered.`));try{n=r.execute.call(void 0,t)}catch(e){n=Promise.reject(e)}let s=Promise.resolve(n);return this._commandExecuted.emit({id:e,args:t,result:s}),s}addKeyBinding(e){let i=l.createKeyBinding(e);return this._keyBindings.push(i),this._keyBindingChanged.emit({binding:i,type:"added"}),new n.DisposableDelegate((()=>{t.ArrayExt.removeFirstOf(this._keyBindings,i),this._keyBindingChanged.emit({binding:i,type:"removed"})}))}processKeydownEvent(e){if(this._replaying||a.isModifierKeyPressed(e))return;let t=a.keystrokeForKeydownEvent(e);if(!t)return this._replayKeydownEvents(),void this._clearPendingState();this._keystrokes.push(t);let{exact:i,partial:n}=l.matchKeyBinding(this._keyBindings,this._keystrokes,e);return i||n?(e.preventDefault(),e.stopPropagation(),i&&!n?(this._executeKeyBinding(i),void this._clearPendingState()):(i&&(this._exactKeyMatch=i),this._keydownEvents.push(e),void this._startTimer())):(this._replayKeydownEvents(),void this._clearPendingState())}_startTimer(){this._clearTimer(),this._timerID=window.setTimeout((()=>{this._onPendingTimeout()}),l.CHORD_TIMEOUT)}_clearTimer(){0!==this._timerID&&(clearTimeout(this._timerID),this._timerID=0)}_replayKeydownEvents(){0!==this._keydownEvents.length&&(this._replaying=!0,this._keydownEvents.forEach(l.replayKeyEvent),this._replaying=!1)}_executeKeyBinding(e){let{command:t,args:i}=e;if(this.hasCommand(t)&&this.isEnabled(t,i))this.execute(t,i);else{let i=this.hasCommand(t)?"enabled":"registered",n=`Cannot execute key binding '${e.keys.join(", ")}':`,r=`command '${t}' is not ${i}.`;console.warn(`${n} ${r}`)}}_clearPendingState(){this._clearTimer(),this._exactKeyMatch=null,this._keystrokes.length=0,this._keydownEvents.length=0}_onPendingTimeout(){this._timerID=0,this._exactKeyMatch?this._executeKeyBinding(this._exactKeyMatch):this._replayKeydownEvents(),this._clearPendingState()}}var l;!function(e){function t(e){let t="",i=!1,n=!1,s=!1,o=!1;for(let a of e.split(/\s+/))"Accel"===a?r.Platform.IS_MAC?n=!0:s=!0:"Alt"===a?i=!0:"Cmd"===a?n=!0:"Ctrl"===a?s=!0:"Shift"===a?o=!0:a.length>0&&(t=a);return{cmd:n,ctrl:s,alt:i,shift:o,key:t}}function i(e){let i="",n=t(e);return n.ctrl&&(i+="Ctrl "),n.alt&&(i+="Alt "),n.shift&&(i+="Shift "),n.cmd&&r.Platform.IS_MAC&&(i+="Cmd "),i+n.key}e.parseKeystroke=t,e.normalizeKeystroke=i,e.normalizeKeys=function(e){let t;return t=r.Platform.IS_WIN?e.winKeys||e.keys:r.Platform.IS_MAC?e.macKeys||e.keys:e.linuxKeys||e.keys,t.map(i)},e.formatKeystroke=function(e){let i=[],n=r.Platform.IS_MAC?" ":"+",s=t(e);return s.ctrl&&i.push("Ctrl"),s.alt&&i.push("Alt"),s.shift&&i.push("Shift"),r.Platform.IS_MAC&&s.cmd&&i.push("Cmd"),i.push(s.key),i.map(l.formatKey).join(n)},e.isModifierKeyPressed=function(e){let t=s.getKeyboardLayout(),i=t.keyForKeydownEvent(e);return t.isModifierKey(i)},e.keystrokeForKeydownEvent=function(e){let t=s.getKeyboardLayout(),i=t.keyForKeydownEvent(e);if(!i||t.isModifierKey(i))return"";let n=[];return e.ctrlKey&&n.push("Ctrl"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),e.metaKey&&r.Platform.IS_MAC&&n.push("Cmd"),n.push(i),n.join(" ")}}(a||(a={})),function(e){e.CHORD_TIMEOUT=1e3,e.createCommand=function(e){return{execute:e.execute,describedBy:u("function"==typeof e.describedBy?e.describedBy:Object.assign({args:null},e.describedBy),(()=>({args:null}))),label:u(e.label,s),mnemonic:u(e.mnemonic,o),icon:u(e.icon,m),iconClass:u(e.iconClass,s),iconLabel:u(e.iconLabel,s),caption:u(e.caption,s),usage:u(e.usage,s),className:u(e.className,s),dataset:u(e.dataset,c),isEnabled:e.isEnabled||l,isToggled:e.isToggled||d,isToggleable:e.isToggleable||!!e.isToggled,isVisible:e.isVisible||l}},e.createKeyBinding=function(e){return{keys:a.normalizeKeys(e),selector:h(e),command:e.command,args:e.args||i.JSONExt.emptyObject}},e.matchKeyBinding=function(e,t,i){let n=null,s=!1,o=1/0,a=0;for(let l=0,d=e.length;l<d;++l){let d=e[l],c=y(d.keys,t);if(0===c)continue;if(2===c){s||-1===g(d.selector,i)||(s=!0);continue}let m=g(d.selector,i);if(-1===m||m>o)continue;let u=r.Selector.calculateSpecificity(d.selector);(!n||m<o||u>=a)&&(n=d,o=m,a=u)}return{exact:n,partial:s}},e.replayKeyEvent=function(e){e.target.dispatchEvent(function(e){let t=document.createEvent("Event"),i=e.bubbles||!0,n=e.cancelable||!0;return t.initEvent(e.type||"keydown",i,n),t.key=e.key||"",t.keyCode=e.keyCode||0,t.which=e.keyCode||0,t.ctrlKey=e.ctrlKey||!1,t.altKey=e.altKey||!1,t.shiftKey=e.shiftKey||!1,t.metaKey=e.metaKey||!1,t.view=e.view||window,t}(e))},e.formatKey=function(e){return r.Platform.IS_MAC?t.hasOwnProperty(e)?t[e]:e:n.hasOwnProperty(e)?n[e]:e};const t={Backspace:"⌫",Tab:"⇥",Enter:"↩",Shift:"⇧",Ctrl:"⌃",Alt:"⌥",Escape:"⎋",PageUp:"⇞",PageDown:"⇟",End:"↘",Home:"↖",ArrowLeft:"←",ArrowUp:"↑",ArrowRight:"→",ArrowDown:"↓",Delete:"⌦",Cmd:"⌘"},n={Escape:"Esc",PageUp:"Page Up",PageDown:"Page Down",ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",Delete:"Del"},s=()=>"",o=()=>-1,l=()=>!0,d=()=>!1,c=()=>({}),m=()=>{};function u(e,t){return void 0===e?t:"function"==typeof e?e:()=>e}function h(e){if(-1!==e.selector.indexOf(","))throw new Error(`Selector cannot contain commas: ${e.selector}`);if(!r.Selector.isValid(e.selector))throw new Error(`Invalid selector: ${e.selector}`);return e.selector}function y(e,t){if(e.length<t.length)return 0;for(let i=0,n=t.length;i<n;++i)if(e[i]!==t[i])return 0;return e.length>t.length?2:1}function g(e,t){let i=t.target,n=t.currentTarget;for(let t=0;null!==i;i=i.parentElement,++t){if(i.hasAttribute("data-lm-suppress-shortcuts"))return-1;if(r.Selector.matches(i,e))return t;if(i===n)return-1}return-1}}(l||(l={})),e.CommandRegistry=a,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.min.js.map
{
"name": "@lumino/commands",
"version": "1.20.1",
"version": "2.0.0-alpha.0",
"description": "Lumino Commands",

@@ -14,9 +14,3 @@ "homepage": "https://github.com/jupyterlab/lumino",

"license": "BSD-3-Clause",
"author": "S. Chris Colbert <sccolbert@gmail.com>",
"contributors": [
"A. T. Darian <git@darian.email>",
"Dave Willmer <dave.willmer@gmail.com>",
"S. Chris Colbert <sccolbert@gmail.com>",
"Steven Silvester <steven.silvester@gmail.com>"
],
"author": "Project Jupyter",
"main": "dist/index.js",

@@ -39,3 +33,2 @@ "jsdelivr": "dist/index.min.js",

"clean:test": "rimraf tests/build",
"docs": "typedoc --options tdoptions.json src",
"minimize": "terser dist/index.js -c -m --source-map \"content='dist/index.js.map',url='index.min.js.map'\" -o dist/index.min.js",

@@ -57,17 +50,21 @@ "test": "npm run test:firefox-headless",

},
"typedoc": {
"entryPoint": "./src/index.ts",
"displayName": "commands"
},
"dependencies": {
"@lumino/algorithm": "^1.9.2",
"@lumino/coreutils": "^1.12.1",
"@lumino/disposable": "^1.10.2",
"@lumino/domutils": "^1.8.2",
"@lumino/keyboard": "^1.8.2",
"@lumino/signaling": "^1.10.2",
"@lumino/virtualdom": "^1.14.2"
"@lumino/algorithm": "^2.0.0-alpha.0",
"@lumino/coreutils": "^2.0.0-alpha.0",
"@lumino/disposable": "^2.0.0-alpha.0",
"@lumino/domutils": "^2.0.0-alpha.0",
"@lumino/keyboard": "^2.0.0-alpha.0",
"@lumino/signaling": "^2.0.0-alpha.0",
"@lumino/virtualdom": "^2.0.0-alpha.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.6.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/chai": "^3.4.35",
"@types/mocha": "^2.2.39",
"chai": "^4.3.4",
"es6-promise": "^4.0.5",
"karma": "^6.3.4",

@@ -80,14 +77,13 @@ "karma-chrome-launcher": "^3.1.0",

"mocha": "^9.0.3",
"postcss": "^8.4.14",
"rimraf": "^3.0.2",
"rollup": "^2.56.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^4.0.0",
"rollup": "^2.77.2",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"simulate-event": "^1.4.0",
"terser": "^5.7.1",
"tslib": "^2.3.0",
"typedoc": "~0.15.0",
"typescript": "~3.6.0",
"webpack": "^4.41.3",
"webpack-cli": "^3.3.10"
"tslib": "^2.4.0",
"typedoc": "~0.23.9",
"typescript": "~4.7.3",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},

@@ -94,0 +90,0 @@ "publishConfig": {

@@ -155,2 +155,21 @@ // Copyright (c) Jupyter Development Team.

/**
* Get the description for a specific command.
*
* @param id - The id of the command of interest.
*
* @param args - The arguments for the command.
*
* @returns The description for the command.
*/
describedBy(
id: string,
args: ReadonlyPartialJSONObject = JSONExt.emptyObject
): Promise<CommandRegistry.Description> {
let cmd = this._commands[id];
return Promise.resolve(
cmd?.describedBy.call(undefined, args) ?? { args: null }
);
}
/**
* Get the display label for a specific command.

@@ -170,3 +189,3 @@ *

let cmd = this._commands[id];
return cmd ? cmd.label.call(undefined, args) : '';
return cmd?.label.call(undefined, args) ?? '';
}

@@ -204,4 +223,3 @@

*
* @returns The icon renderer for the command, or
* an empty string if the command is not registered.
* @returns The icon renderer for the command or `undefined`.
*/

@@ -211,11 +229,4 @@ icon(

args: ReadonlyPartialJSONObject = JSONExt.emptyObject
):
| VirtualElement.IRenderer
| undefined
/* <DEPRECATED> */
| string /* </DEPRECATED> */ {
let cmd = this._commands[id];
return cmd
? cmd.icon.call(undefined, args)
: /* <DEPRECATED> */ '' /* </DEPRECATED> */ /* <FUTURE> undefined </FUTURE> */;
): VirtualElement.IRenderer | undefined {
return this._commands[id]?.icon.call(undefined, args);
}

@@ -675,2 +686,7 @@

/**
* Commands description.
*/
export type Description = { args: ReadonlyJSONObject | null };
/**
* An options object for creating a command.

@@ -702,2 +718,13 @@ *

/**
* JSON Schemas describing the command.
*
* #### Notes
* For now, the command arguments are the only one that can be
* described.
*/
describedBy?:
| Partial<Description>
| CommandFunc<Partial<Description> | Promise<Partial<Description>>>;
/**
* The label for the command.

@@ -737,6 +764,3 @@ *

*
* The default value is undefined.
*
* DEPRECATED: if set to a string value, the .icon field will function as
* an alias for the .iconClass field, for backwards compatibility
* The default value is `undefined`.
*/

@@ -746,10 +770,3 @@ icon?:

| undefined
/* <DEPRECATED> */
| string /* </DEPRECATED> */
| CommandFunc<
| VirtualElement.IRenderer
| undefined
/* <DEPRECATED> */
| string /* </DEPRECATED> */
>;
| CommandFunc<VirtualElement.IRenderer | undefined>;

@@ -1271,12 +1288,8 @@ /**

readonly execute: CommandFunc<any>;
readonly describedBy: CommandFunc<
CommandRegistry.Description | Promise<CommandRegistry.Description>
>;
readonly label: CommandFunc<string>;
readonly mnemonic: CommandFunc<number>;
readonly icon: CommandFunc<
| VirtualElement.IRenderer
| undefined
/* <DEPRECATED> */
| string /* </DEPRECATED> */
>;
readonly icon: CommandFunc<VirtualElement.IRenderer | undefined>;
readonly iconClass: CommandFunc<string>;

@@ -1300,26 +1313,20 @@ readonly iconLabel: CommandFunc<string>;

): ICommand {
let icon;
let iconClass;
/* <DEPRECATED> */
if (!options.icon || typeof options.icon === 'string') {
// alias icon to iconClass
iconClass = asFunc(options.iconClass || options.icon, emptyStringFunc);
icon = iconClass;
} else {
/* /<DEPRECATED> */
iconClass = asFunc(options.iconClass, emptyStringFunc);
icon = asFunc(options.icon, undefinedFunc);
/* <DEPRECATED> */
}
/* </DEPRECATED> */
return {
execute: options.execute,
describedBy: asFunc<
CommandRegistry.Description | Promise<CommandRegistry.Description>
>(
typeof options.describedBy === 'function'
? (options.describedBy as CommandFunc<
CommandRegistry.Description | Promise<CommandRegistry.Description>
>)
: { args: null, ...options.describedBy },
() => {
return { args: null };
}
),
label: asFunc(options.label, emptyStringFunc),
mnemonic: asFunc(options.mnemonic, negativeOneFunc),
icon,
iconClass,
icon: asFunc(options.icon, undefinedFunc),
iconClass: asFunc(options.iconClass, emptyStringFunc),
iconLabel: asFunc(options.iconLabel, emptyStringFunc),

@@ -1591,7 +1598,2 @@ caption: asFunc(options.caption, emptyStringFunc),

}
/* <DEPRECATED> */
if (targ.hasAttribute('data-p-suppress-shortcuts')) {
return -1;
}
/* </DEPRECATED> */
if (Selector.matches(targ, selector)) {

@@ -1598,0 +1600,0 @@ return dist;

@@ -20,3 +20,3 @@ import { ReadonlyJSONObject, ReadonlyPartialJSONObject } from '@lumino/coreutils';

*/
readonly commandChanged: ISignal<this, CommandRegistry.ICommandChangedArgs>;
get commandChanged(): ISignal<this, CommandRegistry.ICommandChangedArgs>;
/**

@@ -30,11 +30,11 @@ * A signal emitted when a command has executed.

*/
readonly commandExecuted: ISignal<this, CommandRegistry.ICommandExecutedArgs>;
get commandExecuted(): ISignal<this, CommandRegistry.ICommandExecutedArgs>;
/**
* A signal emitted when a key binding is changed.
*/
readonly keyBindingChanged: ISignal<this, CommandRegistry.IKeyBindingChangedArgs>;
get keyBindingChanged(): ISignal<this, CommandRegistry.IKeyBindingChangedArgs>;
/**
* A read-only array of the key bindings in the registry.
*/
readonly keyBindings: ReadonlyArray<CommandRegistry.IKeyBinding>;
get keyBindings(): ReadonlyArray<CommandRegistry.IKeyBinding>;
/**

@@ -83,2 +83,12 @@ * List the ids of the registered commands.

/**
* Get the description for a specific command.
*
* @param id - The id of the command of interest.
*
* @param args - The arguments for the command.
*
* @returns The description for the command.
*/
describedBy(id: string, args?: ReadonlyPartialJSONObject): Promise<CommandRegistry.Description>;
/**
* Get the display label for a specific command.

@@ -117,6 +127,5 @@ *

*
* @returns The icon renderer for the command, or
* an empty string if the command is not registered.
* @returns The icon renderer for the command or `undefined`.
*/
icon(id: string, args?: ReadonlyPartialJSONObject): VirtualElement.IRenderer | undefined | string;
icon(id: string, args?: ReadonlyPartialJSONObject): VirtualElement.IRenderer | undefined;
/**

@@ -338,2 +347,8 @@ * Get the icon class for a specific command.

/**
* Commands description.
*/
type Description = {
args: ReadonlyJSONObject | null;
};
/**
* An options object for creating a command.

@@ -364,2 +379,10 @@ *

/**
* JSON Schemas describing the command.
*
* #### Notes
* For now, the command arguments are the only one that can be
* described.
*/
describedBy?: Partial<Description> | CommandFunc<Partial<Description> | Promise<Partial<Description>>>;
/**
* The label for the command.

@@ -397,8 +420,5 @@ *

*
* The default value is undefined.
*
* DEPRECATED: if set to a string value, the .icon field will function as
* an alias for the .iconClass field, for backwards compatibility
* The default value is `undefined`.
*/
icon?: VirtualElement.IRenderer | undefined | string | CommandFunc<VirtualElement.IRenderer | undefined | string>;
icon?: VirtualElement.IRenderer | undefined | CommandFunc<VirtualElement.IRenderer | undefined>;
/**

@@ -761,2 +781,1 @@ * The icon class for the command.

}
//# sourceMappingURL=index.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc