mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
f1c224e62e
Closes https://github.com/enso-org/cloud-v2/issues/560 - New context menu - Global keyboard shortcut handler - Moves the existing "escape" keybindings (close modal, cancel editing names) to global keybind handlers # Important Notes - The "Upload To Cloud" action is not present in the Figma design. As such: - Its current icon is an edit of the "cloud_from" icon, with the arrow upside down - It does not have a corresponding keyboard shortcut
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
/** @file Debug-only functions, injected or stripped by the build tool as appropriate. */
|
|
|
|
/** The logger used by {@link assert}. */
|
|
interface Logger {
|
|
error: (message: string) => void
|
|
}
|
|
|
|
/** Logs an error . */
|
|
export function assert(invariant: boolean, message: string, logger: Logger = console) {
|
|
if (!invariant) {
|
|
logger.error('assertion failed: ' + message)
|
|
}
|
|
}
|
|
|
|
// This is required to make the definition `Object.prototype.d` not error.
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
declare global {
|
|
// Documentation is already inherited.
|
|
/** */
|
|
interface Object {
|
|
/** Log self and return self. */
|
|
$d$: <T>(this: T, message?: string) => T
|
|
}
|
|
}
|
|
|
|
if (!('$d$' in Object.prototype)) {
|
|
Object.defineProperty(Object.prototype, '$d$', {
|
|
/** Log self and return self. */
|
|
value: function <T>(this: T, message?: string) {
|
|
if (message != null) {
|
|
console.log(message, this)
|
|
} else {
|
|
console.log(this)
|
|
}
|
|
return this
|
|
},
|
|
enumerable: false,
|
|
writable: false,
|
|
configurable: false,
|
|
})
|
|
}
|