@jupyterlab/apputils
Advanced tools
Comparing version 2.2.0-alpha.0 to 2.2.0-alpha.2
@@ -61,2 +61,3 @@ // Copyright (c) Jupyter Development Team. | ||
// http://stackoverflow.com/a/5210367 | ||
var _a; | ||
// Identify selected text. | ||
@@ -66,3 +67,3 @@ let sel = window.getSelection(); | ||
const savedRanges = []; | ||
for (let i = 0, len = (sel === null || sel === void 0 ? void 0 : sel.rangeCount) || 0; i < len; ++i) { | ||
for (let i = 0, len = ((_a = sel) === null || _a === void 0 ? void 0 : _a.rangeCount) || 0; i < len; ++i) { | ||
savedRanges[i] = sel.getRangeAt(i).cloneRange(); | ||
@@ -69,0 +70,0 @@ } |
@@ -188,2 +188,3 @@ // Copyright (c) Jupyter Development Team. | ||
onAfterAttach(msg) { | ||
var _a; | ||
const node = this.node; | ||
@@ -198,3 +199,3 @@ node.addEventListener('keydown', this, true); | ||
const body = this.node.querySelector('.jp-Dialog-body'); | ||
const el = body === null || body === void 0 ? void 0 : body.querySelector(this._focusNodeSelector); | ||
const el = (_a = body) === null || _a === void 0 ? void 0 : _a.querySelector(this._focusNodeSelector); | ||
if (el) { | ||
@@ -259,4 +260,3 @@ this._primary = el; | ||
break; | ||
case 9: { | ||
// Tab. | ||
case 9: // Tab. | ||
// Handle a tab on the last button. | ||
@@ -270,3 +270,2 @@ const node = this._buttonNodes[this._buttons.length - 1]; | ||
break; | ||
} | ||
case 13: // Enter. | ||
@@ -273,0 +272,0 @@ event.stopPropagation(); |
@@ -13,379 +13,376 @@ // Copyright (c) Jupyter Development Team. | ||
*/ | ||
let CssProp = /** @class */ (() => { | ||
class CssProp { | ||
static reg(r) { | ||
return new RegExp('^' + r + '$', 'i'); | ||
} | ||
class CssProp { | ||
static reg(r) { | ||
return new RegExp('^' + r + '$', 'i'); | ||
} | ||
/* | ||
* Numeric base expressions used to help build more complex regular expressions | ||
*/ | ||
CssProp.N = { | ||
integer: `[+-]?[0-9]+`, | ||
integer_pos: `[+]?[0-9]+`, | ||
integer_zero_ff: `([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`, | ||
number: `[+-]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`, | ||
number_pos: `[+]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`, | ||
number_zero_hundred: `[+]?(([0-9]|[1-9][0-9])([.][0-9]+)?|100)`, | ||
number_zero_one: `[+]?(1([.][0]+)?|0([.][0-9]+)?)` | ||
}; | ||
/* | ||
* Base expressions of common CSS syntax elements | ||
*/ | ||
CssProp.B = { | ||
angle: `(${CssProp.N.number}(deg|rad|grad|turn)|0)`, | ||
frequency: `${CssProp.N.number}(Hz|kHz)`, | ||
ident: String.raw `-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`, | ||
len_or_perc: `(0|${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc|%))`, | ||
length: `(${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`, | ||
length_pos: `(${CssProp.N.number_pos}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`, | ||
percentage: `${CssProp.N.number}%`, | ||
percentage_pos: `${CssProp.N.number_pos}%`, | ||
percentage_zero_hundred: `${CssProp.N.number_zero_hundred}%`, | ||
string: String.raw `(\"([^\n\r\f\\"]|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\")|(\'([^\n\r\f\\']|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\')`, | ||
time: `${CssProp.N.number}(s|ms)`, | ||
url: `url\\(.*?\\)`, | ||
z_index: `[+-]?[0-9]{1,7}` | ||
}; | ||
/* | ||
* Atomic (i.e. not dependant on other regular expresions) sub RegEx segments | ||
*/ | ||
CssProp.A = { | ||
absolute_size: `xx-small|x-small|small|medium|large|x-large|xx-large`, | ||
attachment: `scroll|fixed|local`, | ||
bg_origin: `border-box|padding-box|content-box`, | ||
border_style: `none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset`, | ||
box: `border-box|padding-box|content-box`, | ||
display_inside: `auto|block|table|flex|grid`, | ||
display_outside: `block-level|inline-level|none|table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption`, | ||
ending_shape: `circle|ellipse`, | ||
generic_family: `serif|sans-serif|cursive|fantasy|monospace`, | ||
generic_voice: `male|female|child`, | ||
relative_size: `smaller|larger`, | ||
repeat_style: `repeat-x|repeat-y|((?:repeat|space|round|no-repeat)(?:\\s*(?:repeat|space|round|no-repeat))?)`, | ||
side_or_corner: `(left|right)?\\s*(top|bottom)?`, | ||
single_animation_direction: `normal|reverse|alternate|alternate-reverse`, | ||
single_animation_fill_mode: `none|forwards|backwards|both`, | ||
single_animation_play_state: `running|paused` | ||
}; | ||
/* | ||
* Color definition sub expressions | ||
*/ | ||
CssProp._COLOR = { | ||
hex: `\\#(0x)?[0-9a-f]+`, | ||
name: `aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|transparent|violet|wheat|white|whitesmoke|yellow|yellowgreen`, | ||
rgb: String.raw `rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)`, | ||
rgba: String.raw `rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(${CssProp.N.integer_zero_ff}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred})\s*\)` | ||
}; | ||
/* | ||
* Compound (i.e. dependant on other (sub) regular expresions) sub RegEx segments | ||
*/ | ||
CssProp._C = { | ||
alpha: `${CssProp.N.integer_zero_ff}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred}`, | ||
alphavalue: CssProp.N.number_zero_one, | ||
bg_position: `((${CssProp.B.len_or_perc}|left|center|right|top|bottom)\\s*){1,4}`, | ||
bg_size: `(${CssProp.B.length_pos}|${CssProp.B.percentage}|auto){1,2}|cover|contain`, | ||
border_width: `thin|medium|thick|${CssProp.B.length}`, | ||
bottom: `${CssProp.B.length}|auto`, | ||
color: `${CssProp._COLOR.hex}|${CssProp._COLOR.rgb}|${CssProp._COLOR.rgba}|${CssProp._COLOR.name}`, | ||
family_name: `${CssProp.B.string}|(${CssProp.B.ident}\\s*)+`, | ||
image_decl: CssProp.B.url, | ||
left: `${CssProp.B.length}|auto`, | ||
loose_quotable_words: `(${CssProp.B.ident})+`, | ||
margin_width: `${CssProp.B.len_or_perc}|auto`, | ||
padding_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
page_url: CssProp.B.url, | ||
position: `((${CssProp.B.len_or_perc}|left|center|right|top|bottom)\\s*){1,4}`, | ||
right: `${CssProp.B.length}|auto`, | ||
shadow: '', | ||
size: `closest-side|farthest-side|closest-corner|farthest-corner|${CssProp.B.length}|(${CssProp.B.len_or_perc})\\s+(${CssProp.B.len_or_perc})`, | ||
top: `${CssProp.B.length}|auto` | ||
}; | ||
CssProp._C1 = { | ||
image_list: `image\\(\\s*(${CssProp.B.url})*\\s*(${CssProp.B.url}|${CssProp._C.color})\\s*\\)`, | ||
shadow: `((${CssProp._C.color})\\s+((${CssProp.B.length})\\s*){2,4}(\s+inset)?)|((inset\\s+)?((${CssProp.B.length})\\s*){2,4}\\s*(${CssProp._C.color})?)` | ||
}; | ||
CssProp._C2 = { | ||
bg_image: `(${CssProp.B.url}|${CssProp._C1.image_list})|none`, | ||
image: `${CssProp.B.url}|${CssProp._C1.image_list}`, | ||
shape: `rect\\(\\s*(${CssProp._C.top})\\s*,\\s*(${CssProp._C.right})\\s*,\\s*(${CssProp._C.bottom})\\s*,\\s*(${CssProp._C.left})\\s*\\)` | ||
}; | ||
CssProp.C = Object.assign(Object.assign(Object.assign({}, CssProp._C), CssProp._C1), CssProp._C2); | ||
/* | ||
* Property value regular expressions not dependant on other sub expressions | ||
*/ | ||
CssProp.AP = { | ||
border_collapse: `collapse|separate`, | ||
box: `normal|none|contents`, | ||
box_sizing: `content-box|padding-box|border-box`, | ||
caption_side: `top|bottom`, | ||
clear: `none|left|right|both`, | ||
direction: `ltr|rtl`, | ||
empty_cells: `show|hide`, | ||
float: `left|right|none`, | ||
font_stretch: `normal|wider|narrower|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded`, | ||
font_style: `normal|italic|oblique`, | ||
font_variant: `normal|small-caps`, | ||
font_weight: `normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900`, | ||
list_style_position: `inside|outside`, | ||
list_style_type: `disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-latin|upper-latin|armenian|georgian|lower-alpha|upper-alpha|none`, | ||
overflow: `visible|hidden|scroll|auto`, | ||
overflow_wrap: `normal|break-word`, | ||
overflow_x: `visible|hidden|scroll|auto|no-display|no-content`, | ||
page_break_after: `auto|always|avoid|left|right`, | ||
page_break_before: `auto|always|avoid|left|right`, | ||
page_break_inside: `avoid|auto`, | ||
position: `static|relative|absolute`, | ||
resize: `none|both|horizontal|vertical`, | ||
speak: `normal|none|spell-out`, | ||
speak_header: `once|always`, | ||
speak_numeral: `digits|continuous`, | ||
speak_punctuation: `code|none`, | ||
table_layout: `auto|fixed`, | ||
text_align: `left|right|center|justify`, | ||
text_decoration: `none|((underline|overline|line-through|blink)\\s*)+`, | ||
text_transform: `capitalize|uppercase|lowercase|none`, | ||
text_wrap: `normal|unrestricted|none|suppress`, | ||
unicode_bidi: `normal|embed|bidi-override`, | ||
visibility: `visible|hidden|collapse`, | ||
white_space: `normal|pre|nowrap|pre-wrap|pre-line`, | ||
word_break: `normal|keep-all|break-all` | ||
}; | ||
/* | ||
* Compound propertiy value regular expressions (i.e. dependant on other sub expressions) | ||
*/ | ||
CssProp._CP = { | ||
background_attachment: `${CssProp.A.attachment}(,\\s*${CssProp.A.attachment})*`, | ||
background_color: CssProp.C.color, | ||
background_origin: `${CssProp.A.box}(,\\s*${CssProp.A.box})*`, | ||
background_repeat: `${CssProp.A.repeat_style}(,\\s*${CssProp.A.repeat_style})*`, | ||
border: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
border_radius: `((${CssProp.B.len_or_perc})\\s*){1,4}(\\/\\s*((${CssProp.B.len_or_perc})\\s*){1,4})?`, | ||
border_spacing: `${CssProp.B.length}\\s*(${CssProp.B.length})?`, | ||
border_top_color: CssProp.C.color, | ||
border_top_style: CssProp.A.border_style, | ||
border_width: `((${CssProp.C.border_width})\\s*){1,4}`, | ||
color: CssProp.C.color, | ||
cursor: `(${CssProp.B.url}(\\s*,\\s*)?)*(auto|crosshair|default|pointer|move|e-resize|ne-resize|nw-resize|n-resize|se-resize|sw-resize|s-resize|w-resize|text|wait|help|progress|all-scroll|col-resize|hand|no-drop|not-allowed|row-resize|vertical-text)`, | ||
display: `inline|block|list-item|run-in|inline-list-item|inline-block|table|inline-table|table-cell|table-caption|flex|inline-flex|grid|inline-grid|${CssProp.A.display_inside}|${CssProp.A.display_outside}|inherit|inline-box|inline-stack`, | ||
display_outside: CssProp.A.display_outside, | ||
elevation: `${CssProp.B.angle}|below|level|above|higher|lower`, | ||
font_family: `(${CssProp.C.family_name}|${CssProp.A.generic_family})(,\\s*(${CssProp.C.family_name}|${CssProp.A.generic_family}))*`, | ||
height: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
letter_spacing: `normal|${CssProp.B.length}`, | ||
list_style_image: `${CssProp.C.image}|none`, | ||
margin_right: CssProp.C.margin_width, | ||
max_height: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|none|auto`, | ||
min_height: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`, | ||
opacity: CssProp.C.alphavalue, | ||
outline_color: `${CssProp.C.color}|invert`, | ||
outline_width: CssProp.C.border_width, | ||
padding: `((${CssProp.C.padding_width})\\s*){1,4}`, | ||
padding_top: CssProp.C.padding_width, | ||
pitch_range: CssProp.N.number, | ||
right: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
stress: CssProp.N.number, | ||
text_indent: `${CssProp.B.length}|${CssProp.B.percentage}`, | ||
text_shadow: `none|${CssProp.C.shadow}(,\\s*(${CssProp.C.shadow}))*`, | ||
volume: `${CssProp.N.number_pos}|${CssProp.B.percentage_pos}|silent|x-soft|soft|medium|loud|x-loud`, | ||
word_wrap: CssProp.AP.overflow_wrap, | ||
zoom: `normal|${CssProp.N.number_pos}|${CssProp.B.percentage_pos}`, | ||
backface_visibility: CssProp.AP.visibility, | ||
background_clip: `${CssProp.A.box}(,\\s*(${CssProp.A.box}))*`, | ||
background_position: `${CssProp.C.bg_position}(,\\s*(${CssProp.C.bg_position}))*`, | ||
border_bottom_color: CssProp.C.color, | ||
border_bottom_style: CssProp.A.border_style, | ||
border_color: `((${CssProp.C.color})\\s*){1,4}`, | ||
border_left_color: CssProp.C.color, | ||
border_right_color: CssProp.C.color, | ||
border_style: `((${CssProp.A.border_style})\\s*){1,4}`, | ||
border_top_left_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_top_width: CssProp.C.border_width, | ||
box_shadow: `none|${CssProp.C.shadow}(,\\s*(${CssProp.C.shadow}))*`, | ||
clip: `${CssProp.C.shape}|auto`, | ||
display_inside: CssProp.A.display_inside, | ||
font_size: `${CssProp.A.absolute_size}|${CssProp.A.relative_size}|${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
line_height: `normal|${CssProp.N.number_pos}|${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
margin_left: CssProp.C.margin_width, | ||
max_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|none|auto`, | ||
outline_style: CssProp.A.border_style, | ||
padding_bottom: CssProp.C.padding_width, | ||
padding_right: CssProp.C.padding_width, | ||
perspective: `none|${CssProp.B.length}`, | ||
richness: CssProp.N.number, | ||
text_overflow: `((clip|ellipsis|${CssProp.B.string})\\s*){1,2}`, | ||
top: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`, | ||
z_index: `auto|${CssProp.B.z_index}`, | ||
// Simplified background | ||
background: `(((${CssProp.C.bg_position}\\s*(\\/\\s*${CssProp.C.bg_size})?)|(${CssProp.A.repeat_style})|(${CssProp.A.attachment})|(${CssProp.A.bg_origin})|(${CssProp.C.bg_image})|(${CssProp.C.color}))\\s*)+`, | ||
background_size: `${CssProp.C.bg_size}(,\\s*${CssProp.C.bg_size})*`, | ||
border_bottom_left_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_bottom_width: CssProp.C.border_width, | ||
border_left_style: CssProp.A.border_style, | ||
border_right_style: CssProp.A.border_style, | ||
border_top: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
bottom: `${CssProp.B.len_or_perc}|auto`, | ||
list_style: `((${CssProp.AP.list_style_type}|${CssProp.AP.list_style_position}|${CssProp.C.image}|none})\\s*){1,3}`, | ||
margin_top: CssProp.C.margin_width, | ||
outline: `((${CssProp.C.color}|invert|${CssProp.A.border_style}|${CssProp.C.border_width})\\s*){1,3}`, | ||
overflow_y: CssProp.AP.overflow_x, | ||
pitch: `${CssProp.B.frequency}|x-low|low|medium|high|x-high`, | ||
vertical_align: `baseline|sub|super|top|text-top|middle|bottom|text-bottom|${CssProp.B.len_or_perc}`, | ||
word_spacing: `normal|${CssProp.B.length}`, | ||
background_image: `${CssProp.C.bg_image}(,\\s*${CssProp.C.bg_image})*`, | ||
border_bottom_right_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_left_width: CssProp.C.border_width, | ||
border_right_width: CssProp.C.border_width, | ||
left: `${CssProp.B.len_or_perc}|auto`, | ||
margin_bottom: CssProp.C.margin_width, | ||
pause_after: `${CssProp.B.time}|${CssProp.B.percentage}`, | ||
speech_rate: `${CssProp.N.number}|x-slow|slow|medium|fast|x-fast|faster|slower`, | ||
transition_duration: `${CssProp.B.time}(,\\s*${CssProp.B.time})*`, | ||
border_bottom: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
border_right: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
margin: `((${CssProp.C.margin_width})\\s*){1,4}`, | ||
padding_left: CssProp.C.padding_width, | ||
border_left: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
quotes: `(${CssProp.B.string}\\s*${CssProp.B.string})+|none`, | ||
border_top_right_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
min_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto` | ||
}; | ||
CssProp._CP1 = { | ||
font: `(((((${CssProp.AP.font_style}|${CssProp.AP.font_variant}|${CssProp.AP.font_weight})\\s*){1,3})?\\s*(${CssProp._CP.font_size})\\s*(\\/\\s*(${CssProp._CP.line_height}))?\\s+(${CssProp._CP.font_family}))|caption|icon|menu|message-box|small-caption|status-bar)` | ||
}; | ||
CssProp.CP = Object.assign(Object.assign({}, CssProp._CP), CssProp._CP1); | ||
// CSS Property value validation regular expressions for use with sanitize-html | ||
CssProp.BORDER_COLLAPSE = CssProp.reg(CssProp.AP.border_collapse); | ||
CssProp.BOX = CssProp.reg(CssProp.AP.box); | ||
CssProp.BOX_SIZING = CssProp.reg(CssProp.AP.box_sizing); | ||
CssProp.CAPTION_SIDE = CssProp.reg(CssProp.AP.caption_side); | ||
CssProp.CLEAR = CssProp.reg(CssProp.AP.clear); | ||
CssProp.DIRECTION = CssProp.reg(CssProp.AP.direction); | ||
CssProp.EMPTY_CELLS = CssProp.reg(CssProp.AP.empty_cells); | ||
CssProp.FLOAT = CssProp.reg(CssProp.AP.float); | ||
CssProp.FONT_STRETCH = CssProp.reg(CssProp.AP.font_stretch); | ||
CssProp.FONT_STYLE = CssProp.reg(CssProp.AP.font_style); | ||
CssProp.FONT_VARIANT = CssProp.reg(CssProp.AP.font_variant); | ||
CssProp.FONT_WEIGHT = CssProp.reg(CssProp.AP.font_weight); | ||
CssProp.LIST_STYLE_POSITION = CssProp.reg(CssProp.AP.list_style_position); | ||
CssProp.LIST_STYLE_TYPE = CssProp.reg(CssProp.AP.list_style_type); | ||
CssProp.OVERFLOW = CssProp.reg(CssProp.AP.overflow); | ||
CssProp.OVERFLOW_WRAP = CssProp.reg(CssProp.AP.overflow_wrap); | ||
CssProp.OVERFLOW_X = CssProp.reg(CssProp.AP.overflow_x); | ||
CssProp.PAGE_BREAK_AFTER = CssProp.reg(CssProp.AP.page_break_after); | ||
CssProp.PAGE_BREAK_BEFORE = CssProp.reg(CssProp.AP.page_break_before); | ||
CssProp.PAGE_BREAK_INSIDE = CssProp.reg(CssProp.AP.page_break_inside); | ||
CssProp.POSITION = CssProp.reg(CssProp.AP.position); | ||
CssProp.RESIZE = CssProp.reg(CssProp.AP.resize); | ||
CssProp.SPEAK = CssProp.reg(CssProp.AP.speak); | ||
CssProp.SPEAK_HEADER = CssProp.reg(CssProp.AP.speak_header); | ||
CssProp.SPEAK_NUMERAL = CssProp.reg(CssProp.AP.speak_numeral); | ||
CssProp.SPEAK_PUNCTUATION = CssProp.reg(CssProp.AP.speak_punctuation); | ||
CssProp.TABLE_LAYOUT = CssProp.reg(CssProp.AP.table_layout); | ||
CssProp.TEXT_ALIGN = CssProp.reg(CssProp.AP.text_align); | ||
CssProp.TEXT_DECORATION = CssProp.reg(CssProp.AP.text_decoration); | ||
CssProp.TEXT_TRANSFORM = CssProp.reg(CssProp.AP.text_transform); | ||
CssProp.TEXT_WRAP = CssProp.reg(CssProp.AP.text_wrap); | ||
CssProp.UNICODE_BIDI = CssProp.reg(CssProp.AP.unicode_bidi); | ||
CssProp.VISIBILITY = CssProp.reg(CssProp.AP.visibility); | ||
CssProp.WHITE_SPACE = CssProp.reg(CssProp.AP.white_space); | ||
CssProp.WORD_BREAK = CssProp.reg(CssProp.AP.word_break); | ||
CssProp.BACKGROUND_ATTACHMENT = CssProp.reg(CssProp.CP.background_attachment); | ||
CssProp.BACKGROUND_COLOR = CssProp.reg(CssProp.CP.background_color); | ||
CssProp.BACKGROUND_ORIGIN = CssProp.reg(CssProp.CP.background_origin); | ||
CssProp.BACKGROUND_REPEAT = CssProp.reg(CssProp.CP.background_repeat); | ||
CssProp.BORDER = CssProp.reg(CssProp.CP.border); | ||
CssProp.BORDER_RADIUS = CssProp.reg(CssProp.CP.border_radius); | ||
CssProp.BORDER_SPACING = CssProp.reg(CssProp.CP.border_spacing); | ||
CssProp.BORDER_TOP_COLOR = CssProp.reg(CssProp.CP.border_top_color); | ||
CssProp.BORDER_TOP_STYLE = CssProp.reg(CssProp.CP.border_top_style); | ||
CssProp.BORDER_WIDTH = CssProp.reg(CssProp.CP.border_width); | ||
CssProp.COLOR = CssProp.reg(CssProp.CP.color); | ||
CssProp.CURSOR = CssProp.reg(CssProp.CP.cursor); | ||
CssProp.DISPLAY = CssProp.reg(CssProp.CP.display); | ||
CssProp.DISPLAY_OUTSIDE = CssProp.reg(CssProp.CP.display_outside); | ||
CssProp.ELEVATION = CssProp.reg(CssProp.CP.elevation); | ||
CssProp.FONT_FAMILY = CssProp.reg(CssProp.CP.font_family); | ||
CssProp.HEIGHT = CssProp.reg(CssProp.CP.height); | ||
CssProp.LETTER_SPACING = CssProp.reg(CssProp.CP.letter_spacing); | ||
CssProp.LIST_STYLE_IMAGE = CssProp.reg(CssProp.CP.list_style_image); | ||
CssProp.MARGIN_RIGHT = CssProp.reg(CssProp.CP.margin_right); | ||
CssProp.MAX_HEIGHT = CssProp.reg(CssProp.CP.max_height); | ||
CssProp.MIN_HEIGHT = CssProp.reg(CssProp.CP.min_height); | ||
CssProp.OPACITY = CssProp.reg(CssProp.CP.opacity); | ||
CssProp.OUTLINE_COLOR = CssProp.reg(CssProp.CP.outline_color); | ||
CssProp.OUTLINE_WIDTH = CssProp.reg(CssProp.CP.outline_width); | ||
CssProp.PADDING = CssProp.reg(CssProp.CP.padding); | ||
CssProp.PADDING_TOP = CssProp.reg(CssProp.CP.padding_top); | ||
CssProp.PITCH_RANGE = CssProp.reg(CssProp.CP.pitch_range); | ||
CssProp.RIGHT = CssProp.reg(CssProp.CP.right); | ||
CssProp.STRESS = CssProp.reg(CssProp.CP.stress); | ||
CssProp.TEXT_INDENT = CssProp.reg(CssProp.CP.text_indent); | ||
CssProp.TEXT_SHADOW = CssProp.reg(CssProp.CP.text_shadow); | ||
CssProp.VOLUME = CssProp.reg(CssProp.CP.volume); | ||
CssProp.WORD_WRAP = CssProp.reg(CssProp.CP.word_wrap); | ||
CssProp.ZOOM = CssProp.reg(CssProp.CP.zoom); | ||
CssProp.BACKFACE_VISIBILITY = CssProp.reg(CssProp.CP.backface_visibility); | ||
CssProp.BACKGROUND_CLIP = CssProp.reg(CssProp.CP.background_clip); | ||
CssProp.BACKGROUND_POSITION = CssProp.reg(CssProp.CP.background_position); | ||
CssProp.BORDER_BOTTOM_COLOR = CssProp.reg(CssProp.CP.border_bottom_color); | ||
CssProp.BORDER_BOTTOM_STYLE = CssProp.reg(CssProp.CP.border_bottom_style); | ||
CssProp.BORDER_COLOR = CssProp.reg(CssProp.CP.border_color); | ||
CssProp.BORDER_LEFT_COLOR = CssProp.reg(CssProp.CP.border_left_color); | ||
CssProp.BORDER_RIGHT_COLOR = CssProp.reg(CssProp.CP.border_right_color); | ||
CssProp.BORDER_STYLE = CssProp.reg(CssProp.CP.border_style); | ||
CssProp.BORDER_TOP_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_top_left_radius); | ||
CssProp.BORDER_TOP_WIDTH = CssProp.reg(CssProp.CP.border_top_width); | ||
CssProp.BOX_SHADOW = CssProp.reg(CssProp.CP.box_shadow); | ||
CssProp.CLIP = CssProp.reg(CssProp.CP.clip); | ||
CssProp.DISPLAY_INSIDE = CssProp.reg(CssProp.CP.display_inside); | ||
CssProp.FONT_SIZE = CssProp.reg(CssProp.CP.font_size); | ||
CssProp.LINE_HEIGHT = CssProp.reg(CssProp.CP.line_height); | ||
CssProp.MARGIN_LEFT = CssProp.reg(CssProp.CP.margin_left); | ||
CssProp.MAX_WIDTH = CssProp.reg(CssProp.CP.max_width); | ||
CssProp.OUTLINE_STYLE = CssProp.reg(CssProp.CP.outline_style); | ||
CssProp.PADDING_BOTTOM = CssProp.reg(CssProp.CP.padding_bottom); | ||
CssProp.PADDING_RIGHT = CssProp.reg(CssProp.CP.padding_right); | ||
CssProp.PERSPECTIVE = CssProp.reg(CssProp.CP.perspective); | ||
CssProp.RICHNESS = CssProp.reg(CssProp.CP.richness); | ||
CssProp.TEXT_OVERFLOW = CssProp.reg(CssProp.CP.text_overflow); | ||
CssProp.TOP = CssProp.reg(CssProp.CP.top); | ||
CssProp.WIDTH = CssProp.reg(CssProp.CP.width); | ||
CssProp.Z_INDEX = CssProp.reg(CssProp.CP.z_index); | ||
CssProp.BACKGROUND = CssProp.reg(CssProp.CP.background); | ||
CssProp.BACKGROUND_SIZE = CssProp.reg(CssProp.CP.background_size); | ||
CssProp.BORDER_BOTTOM_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_bottom_left_radius); | ||
CssProp.BORDER_BOTTOM_WIDTH = CssProp.reg(CssProp.CP.border_bottom_width); | ||
CssProp.BORDER_LEFT_STYLE = CssProp.reg(CssProp.CP.border_left_style); | ||
CssProp.BORDER_RIGHT_STYLE = CssProp.reg(CssProp.CP.border_right_style); | ||
CssProp.BORDER_TOP = CssProp.reg(CssProp.CP.border_top); | ||
CssProp.BOTTOM = CssProp.reg(CssProp.CP.bottom); | ||
CssProp.LIST_STYLE = CssProp.reg(CssProp.CP.list_style); | ||
CssProp.MARGIN_TOP = CssProp.reg(CssProp.CP.margin_top); | ||
CssProp.OUTLINE = CssProp.reg(CssProp.CP.outline); | ||
CssProp.OVERFLOW_Y = CssProp.reg(CssProp.CP.overflow_y); | ||
CssProp.PITCH = CssProp.reg(CssProp.CP.pitch); | ||
CssProp.VERTICAL_ALIGN = CssProp.reg(CssProp.CP.vertical_align); | ||
CssProp.WORD_SPACING = CssProp.reg(CssProp.CP.word_spacing); | ||
CssProp.BACKGROUND_IMAGE = CssProp.reg(CssProp.CP.background_image); | ||
CssProp.BORDER_BOTTOM_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_bottom_right_radius); | ||
CssProp.BORDER_LEFT_WIDTH = CssProp.reg(CssProp.CP.border_left_width); | ||
CssProp.BORDER_RIGHT_WIDTH = CssProp.reg(CssProp.CP.border_right_width); | ||
CssProp.LEFT = CssProp.reg(CssProp.CP.left); | ||
CssProp.MARGIN_BOTTOM = CssProp.reg(CssProp.CP.margin_bottom); | ||
CssProp.PAUSE_AFTER = CssProp.reg(CssProp.CP.pause_after); | ||
CssProp.SPEECH_RATE = CssProp.reg(CssProp.CP.speech_rate); | ||
CssProp.TRANSITION_DURATION = CssProp.reg(CssProp.CP.transition_duration); | ||
CssProp.BORDER_BOTTOM = CssProp.reg(CssProp.CP.border_bottom); | ||
CssProp.BORDER_RIGHT = CssProp.reg(CssProp.CP.border_right); | ||
CssProp.MARGIN = CssProp.reg(CssProp.CP.margin); | ||
CssProp.PADDING_LEFT = CssProp.reg(CssProp.CP.padding_left); | ||
CssProp.BORDER_LEFT = CssProp.reg(CssProp.CP.border_left); | ||
CssProp.FONT = CssProp.reg(CssProp.CP.font); | ||
CssProp.QUOTES = CssProp.reg(CssProp.CP.quotes); | ||
CssProp.BORDER_TOP_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_top_right_radius); | ||
CssProp.MIN_WIDTH = CssProp.reg(CssProp.CP.min_width); | ||
return CssProp; | ||
})(); | ||
} | ||
/* | ||
* Numeric base expressions used to help build more complex regular expressions | ||
*/ | ||
CssProp.N = { | ||
integer: `[+-]?[0-9]+`, | ||
integer_pos: `[+]?[0-9]+`, | ||
integer_zero_ff: `([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`, | ||
number: `[+-]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`, | ||
number_pos: `[+]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`, | ||
number_zero_hundred: `[+]?(([0-9]|[1-9][0-9])([.][0-9]+)?|100)`, | ||
number_zero_one: `[+]?(1([.][0]+)?|0([.][0-9]+)?)` | ||
}; | ||
/* | ||
* Base expressions of common CSS syntax elements | ||
*/ | ||
CssProp.B = { | ||
angle: `(${CssProp.N.number}(deg|rad|grad|turn)|0)`, | ||
frequency: `${CssProp.N.number}(Hz|kHz)`, | ||
ident: String.raw `-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`, | ||
len_or_perc: `(0|${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc|%))`, | ||
length: `(${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`, | ||
length_pos: `(${CssProp.N.number_pos}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`, | ||
percentage: `${CssProp.N.number}%`, | ||
percentage_pos: `${CssProp.N.number_pos}%`, | ||
percentage_zero_hundred: `${CssProp.N.number_zero_hundred}%`, | ||
string: String.raw `(\"([^\n\r\f\\"]|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\")|(\'([^\n\r\f\\']|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\')`, | ||
time: `${CssProp.N.number}(s|ms)`, | ||
url: `url\\(.*?\\)`, | ||
z_index: `[+-]?[0-9]{1,7}` | ||
}; | ||
/* | ||
* Atomic (i.e. not dependant on other regular expresions) sub RegEx segments | ||
*/ | ||
CssProp.A = { | ||
absolute_size: `xx-small|x-small|small|medium|large|x-large|xx-large`, | ||
attachment: `scroll|fixed|local`, | ||
bg_origin: `border-box|padding-box|content-box`, | ||
border_style: `none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset`, | ||
box: `border-box|padding-box|content-box`, | ||
display_inside: `auto|block|table|flex|grid`, | ||
display_outside: `block-level|inline-level|none|table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption`, | ||
ending_shape: `circle|ellipse`, | ||
generic_family: `serif|sans-serif|cursive|fantasy|monospace`, | ||
generic_voice: `male|female|child`, | ||
relative_size: `smaller|larger`, | ||
repeat_style: `repeat-x|repeat-y|((?:repeat|space|round|no-repeat)(?:\\s*(?:repeat|space|round|no-repeat))?)`, | ||
side_or_corner: `(left|right)?\\s*(top|bottom)?`, | ||
single_animation_direction: `normal|reverse|alternate|alternate-reverse`, | ||
single_animation_fill_mode: `none|forwards|backwards|both`, | ||
single_animation_play_state: `running|paused` | ||
}; | ||
/* | ||
* Color definition sub expressions | ||
*/ | ||
CssProp._COLOR = { | ||
hex: `\\#(0x)?[0-9a-f]+`, | ||
name: `aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|transparent|violet|wheat|white|whitesmoke|yellow|yellowgreen`, | ||
rgb: String.raw `rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)`, | ||
rgba: String.raw `rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(${CssProp.N.integer_zero_ff}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred})\s*\)` | ||
}; | ||
/* | ||
* Compound (i.e. dependant on other (sub) regular expresions) sub RegEx segments | ||
*/ | ||
CssProp._C = { | ||
alpha: `${CssProp.N.integer_zero_ff}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred}`, | ||
alphavalue: CssProp.N.number_zero_one, | ||
bg_position: `((${CssProp.B.len_or_perc}|left|center|right|top|bottom)\\s*){1,4}`, | ||
bg_size: `(${CssProp.B.length_pos}|${CssProp.B.percentage}|auto){1,2}|cover|contain`, | ||
border_width: `thin|medium|thick|${CssProp.B.length}`, | ||
bottom: `${CssProp.B.length}|auto`, | ||
color: `${CssProp._COLOR.hex}|${CssProp._COLOR.rgb}|${CssProp._COLOR.rgba}|${CssProp._COLOR.name}`, | ||
family_name: `${CssProp.B.string}|(${CssProp.B.ident}\\s*)+`, | ||
image_decl: CssProp.B.url, | ||
left: `${CssProp.B.length}|auto`, | ||
loose_quotable_words: `(${CssProp.B.ident})+`, | ||
margin_width: `${CssProp.B.len_or_perc}|auto`, | ||
padding_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
page_url: CssProp.B.url, | ||
position: `((${CssProp.B.len_or_perc}|left|center|right|top|bottom)\\s*){1,4}`, | ||
right: `${CssProp.B.length}|auto`, | ||
shadow: '', | ||
size: `closest-side|farthest-side|closest-corner|farthest-corner|${CssProp.B.length}|(${CssProp.B.len_or_perc})\\s+(${CssProp.B.len_or_perc})`, | ||
top: `${CssProp.B.length}|auto` | ||
}; | ||
CssProp._C1 = { | ||
image_list: `image\\(\\s*(${CssProp.B.url})*\\s*(${CssProp.B.url}|${CssProp._C.color})\\s*\\)`, | ||
shadow: `((${CssProp._C.color})\\s+((${CssProp.B.length})\\s*){2,4}(\s+inset)?)|((inset\\s+)?((${CssProp.B.length})\\s*){2,4}\\s*(${CssProp._C.color})?)` | ||
}; | ||
CssProp._C2 = { | ||
bg_image: `(${CssProp.B.url}|${CssProp._C1.image_list})|none`, | ||
image: `${CssProp.B.url}|${CssProp._C1.image_list}`, | ||
shape: `rect\\(\\s*(${CssProp._C.top})\\s*,\\s*(${CssProp._C.right})\\s*,\\s*(${CssProp._C.bottom})\\s*,\\s*(${CssProp._C.left})\\s*\\)` | ||
}; | ||
CssProp.C = Object.assign(Object.assign(Object.assign({}, CssProp._C), CssProp._C1), CssProp._C2); | ||
/* | ||
* Property value regular expressions not dependant on other sub expressions | ||
*/ | ||
CssProp.AP = { | ||
border_collapse: `collapse|separate`, | ||
box: `normal|none|contents`, | ||
box_sizing: `content-box|padding-box|border-box`, | ||
caption_side: `top|bottom`, | ||
clear: `none|left|right|both`, | ||
direction: `ltr|rtl`, | ||
empty_cells: `show|hide`, | ||
float: `left|right|none`, | ||
font_stretch: `normal|wider|narrower|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded`, | ||
font_style: `normal|italic|oblique`, | ||
font_variant: `normal|small-caps`, | ||
font_weight: `normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900`, | ||
list_style_position: `inside|outside`, | ||
list_style_type: `disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-latin|upper-latin|armenian|georgian|lower-alpha|upper-alpha|none`, | ||
overflow: `visible|hidden|scroll|auto`, | ||
overflow_wrap: `normal|break-word`, | ||
overflow_x: `visible|hidden|scroll|auto|no-display|no-content`, | ||
page_break_after: `auto|always|avoid|left|right`, | ||
page_break_before: `auto|always|avoid|left|right`, | ||
page_break_inside: `avoid|auto`, | ||
position: `static|relative|absolute`, | ||
resize: `none|both|horizontal|vertical`, | ||
speak: `normal|none|spell-out`, | ||
speak_header: `once|always`, | ||
speak_numeral: `digits|continuous`, | ||
speak_punctuation: `code|none`, | ||
table_layout: `auto|fixed`, | ||
text_align: `left|right|center|justify`, | ||
text_decoration: `none|((underline|overline|line-through|blink)\\s*)+`, | ||
text_transform: `capitalize|uppercase|lowercase|none`, | ||
text_wrap: `normal|unrestricted|none|suppress`, | ||
unicode_bidi: `normal|embed|bidi-override`, | ||
visibility: `visible|hidden|collapse`, | ||
white_space: `normal|pre|nowrap|pre-wrap|pre-line`, | ||
word_break: `normal|keep-all|break-all` | ||
}; | ||
/* | ||
* Compound propertiy value regular expressions (i.e. dependant on other sub expressions) | ||
*/ | ||
CssProp._CP = { | ||
background_attachment: `${CssProp.A.attachment}(,\\s*${CssProp.A.attachment})*`, | ||
background_color: CssProp.C.color, | ||
background_origin: `${CssProp.A.box}(,\\s*${CssProp.A.box})*`, | ||
background_repeat: `${CssProp.A.repeat_style}(,\\s*${CssProp.A.repeat_style})*`, | ||
border: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
border_radius: `((${CssProp.B.len_or_perc})\\s*){1,4}(\\/\\s*((${CssProp.B.len_or_perc})\\s*){1,4})?`, | ||
border_spacing: `${CssProp.B.length}\\s*(${CssProp.B.length})?`, | ||
border_top_color: CssProp.C.color, | ||
border_top_style: CssProp.A.border_style, | ||
border_width: `((${CssProp.C.border_width})\\s*){1,4}`, | ||
color: CssProp.C.color, | ||
cursor: `(${CssProp.B.url}(\\s*,\\s*)?)*(auto|crosshair|default|pointer|move|e-resize|ne-resize|nw-resize|n-resize|se-resize|sw-resize|s-resize|w-resize|text|wait|help|progress|all-scroll|col-resize|hand|no-drop|not-allowed|row-resize|vertical-text)`, | ||
display: `inline|block|list-item|run-in|inline-list-item|inline-block|table|inline-table|table-cell|table-caption|flex|inline-flex|grid|inline-grid|${CssProp.A.display_inside}|${CssProp.A.display_outside}|inherit|inline-box|inline-stack`, | ||
display_outside: CssProp.A.display_outside, | ||
elevation: `${CssProp.B.angle}|below|level|above|higher|lower`, | ||
font_family: `(${CssProp.C.family_name}|${CssProp.A.generic_family})(,\\s*(${CssProp.C.family_name}|${CssProp.A.generic_family}))*`, | ||
height: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
letter_spacing: `normal|${CssProp.B.length}`, | ||
list_style_image: `${CssProp.C.image}|none`, | ||
margin_right: CssProp.C.margin_width, | ||
max_height: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|none|auto`, | ||
min_height: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`, | ||
opacity: CssProp.C.alphavalue, | ||
outline_color: `${CssProp.C.color}|invert`, | ||
outline_width: CssProp.C.border_width, | ||
padding: `((${CssProp.C.padding_width})\\s*){1,4}`, | ||
padding_top: CssProp.C.padding_width, | ||
pitch_range: CssProp.N.number, | ||
right: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
stress: CssProp.N.number, | ||
text_indent: `${CssProp.B.length}|${CssProp.B.percentage}`, | ||
text_shadow: `none|${CssProp.C.shadow}(,\\s*(${CssProp.C.shadow}))*`, | ||
volume: `${CssProp.N.number_pos}|${CssProp.B.percentage_pos}|silent|x-soft|soft|medium|loud|x-loud`, | ||
word_wrap: CssProp.AP.overflow_wrap, | ||
zoom: `normal|${CssProp.N.number_pos}|${CssProp.B.percentage_pos}`, | ||
backface_visibility: CssProp.AP.visibility, | ||
background_clip: `${CssProp.A.box}(,\\s*(${CssProp.A.box}))*`, | ||
background_position: `${CssProp.C.bg_position}(,\\s*(${CssProp.C.bg_position}))*`, | ||
border_bottom_color: CssProp.C.color, | ||
border_bottom_style: CssProp.A.border_style, | ||
border_color: `((${CssProp.C.color})\\s*){1,4}`, | ||
border_left_color: CssProp.C.color, | ||
border_right_color: CssProp.C.color, | ||
border_style: `((${CssProp.A.border_style})\\s*){1,4}`, | ||
border_top_left_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_top_width: CssProp.C.border_width, | ||
box_shadow: `none|${CssProp.C.shadow}(,\\s*(${CssProp.C.shadow}))*`, | ||
clip: `${CssProp.C.shape}|auto`, | ||
display_inside: CssProp.A.display_inside, | ||
font_size: `${CssProp.A.absolute_size}|${CssProp.A.relative_size}|${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
line_height: `normal|${CssProp.N.number_pos}|${CssProp.B.length_pos}|${CssProp.B.percentage_pos}`, | ||
margin_left: CssProp.C.margin_width, | ||
max_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|none|auto`, | ||
outline_style: CssProp.A.border_style, | ||
padding_bottom: CssProp.C.padding_width, | ||
padding_right: CssProp.C.padding_width, | ||
perspective: `none|${CssProp.B.length}`, | ||
richness: CssProp.N.number, | ||
text_overflow: `((clip|ellipsis|${CssProp.B.string})\\s*){1,2}`, | ||
top: `${CssProp.B.length}|${CssProp.B.percentage}|auto`, | ||
width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`, | ||
z_index: `auto|${CssProp.B.z_index}`, | ||
// Simplified background | ||
background: `(((${CssProp.C.bg_position}\\s*(\\/\\s*${CssProp.C.bg_size})?)|(${CssProp.A.repeat_style})|(${CssProp.A.attachment})|(${CssProp.A.bg_origin})|(${CssProp.C.bg_image})|(${CssProp.C.color}))\\s*)+`, | ||
background_size: `${CssProp.C.bg_size}(,\\s*${CssProp.C.bg_size})*`, | ||
border_bottom_left_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_bottom_width: CssProp.C.border_width, | ||
border_left_style: CssProp.A.border_style, | ||
border_right_style: CssProp.A.border_style, | ||
border_top: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
bottom: `${CssProp.B.len_or_perc}|auto`, | ||
list_style: `((${CssProp.AP.list_style_type}|${CssProp.AP.list_style_position}|${CssProp.C.image}|none})\\s*){1,3}`, | ||
margin_top: CssProp.C.margin_width, | ||
outline: `((${CssProp.C.color}|invert|${CssProp.A.border_style}|${CssProp.C.border_width})\\s*){1,3}`, | ||
overflow_y: CssProp.AP.overflow_x, | ||
pitch: `${CssProp.B.frequency}|x-low|low|medium|high|x-high`, | ||
vertical_align: `baseline|sub|super|top|text-top|middle|bottom|text-bottom|${CssProp.B.len_or_perc}`, | ||
word_spacing: `normal|${CssProp.B.length}`, | ||
background_image: `${CssProp.C.bg_image}(,\\s*${CssProp.C.bg_image})*`, | ||
border_bottom_right_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
border_left_width: CssProp.C.border_width, | ||
border_right_width: CssProp.C.border_width, | ||
left: `${CssProp.B.len_or_perc}|auto`, | ||
margin_bottom: CssProp.C.margin_width, | ||
pause_after: `${CssProp.B.time}|${CssProp.B.percentage}`, | ||
speech_rate: `${CssProp.N.number}|x-slow|slow|medium|fast|x-fast|faster|slower`, | ||
transition_duration: `${CssProp.B.time}(,\\s*${CssProp.B.time})*`, | ||
border_bottom: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
border_right: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
margin: `((${CssProp.C.margin_width})\\s*){1,4}`, | ||
padding_left: CssProp.C.padding_width, | ||
border_left: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`, | ||
quotes: `(${CssProp.B.string}\\s*${CssProp.B.string})+|none`, | ||
border_top_right_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`, | ||
min_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto` | ||
}; | ||
CssProp._CP1 = { | ||
font: `(((((${CssProp.AP.font_style}|${CssProp.AP.font_variant}|${CssProp.AP.font_weight})\\s*){1,3})?\\s*(${CssProp._CP.font_size})\\s*(\\/\\s*(${CssProp._CP.line_height}))?\\s+(${CssProp._CP.font_family}))|caption|icon|menu|message-box|small-caption|status-bar)` | ||
}; | ||
CssProp.CP = Object.assign(Object.assign({}, CssProp._CP), CssProp._CP1); | ||
// CSS Property value validation regular expressions for use with sanitize-html | ||
CssProp.BORDER_COLLAPSE = CssProp.reg(CssProp.AP.border_collapse); | ||
CssProp.BOX = CssProp.reg(CssProp.AP.box); | ||
CssProp.BOX_SIZING = CssProp.reg(CssProp.AP.box_sizing); | ||
CssProp.CAPTION_SIDE = CssProp.reg(CssProp.AP.caption_side); | ||
CssProp.CLEAR = CssProp.reg(CssProp.AP.clear); | ||
CssProp.DIRECTION = CssProp.reg(CssProp.AP.direction); | ||
CssProp.EMPTY_CELLS = CssProp.reg(CssProp.AP.empty_cells); | ||
CssProp.FLOAT = CssProp.reg(CssProp.AP.float); | ||
CssProp.FONT_STRETCH = CssProp.reg(CssProp.AP.font_stretch); | ||
CssProp.FONT_STYLE = CssProp.reg(CssProp.AP.font_style); | ||
CssProp.FONT_VARIANT = CssProp.reg(CssProp.AP.font_variant); | ||
CssProp.FONT_WEIGHT = CssProp.reg(CssProp.AP.font_weight); | ||
CssProp.LIST_STYLE_POSITION = CssProp.reg(CssProp.AP.list_style_position); | ||
CssProp.LIST_STYLE_TYPE = CssProp.reg(CssProp.AP.list_style_type); | ||
CssProp.OVERFLOW = CssProp.reg(CssProp.AP.overflow); | ||
CssProp.OVERFLOW_WRAP = CssProp.reg(CssProp.AP.overflow_wrap); | ||
CssProp.OVERFLOW_X = CssProp.reg(CssProp.AP.overflow_x); | ||
CssProp.PAGE_BREAK_AFTER = CssProp.reg(CssProp.AP.page_break_after); | ||
CssProp.PAGE_BREAK_BEFORE = CssProp.reg(CssProp.AP.page_break_before); | ||
CssProp.PAGE_BREAK_INSIDE = CssProp.reg(CssProp.AP.page_break_inside); | ||
CssProp.POSITION = CssProp.reg(CssProp.AP.position); | ||
CssProp.RESIZE = CssProp.reg(CssProp.AP.resize); | ||
CssProp.SPEAK = CssProp.reg(CssProp.AP.speak); | ||
CssProp.SPEAK_HEADER = CssProp.reg(CssProp.AP.speak_header); | ||
CssProp.SPEAK_NUMERAL = CssProp.reg(CssProp.AP.speak_numeral); | ||
CssProp.SPEAK_PUNCTUATION = CssProp.reg(CssProp.AP.speak_punctuation); | ||
CssProp.TABLE_LAYOUT = CssProp.reg(CssProp.AP.table_layout); | ||
CssProp.TEXT_ALIGN = CssProp.reg(CssProp.AP.text_align); | ||
CssProp.TEXT_DECORATION = CssProp.reg(CssProp.AP.text_decoration); | ||
CssProp.TEXT_TRANSFORM = CssProp.reg(CssProp.AP.text_transform); | ||
CssProp.TEXT_WRAP = CssProp.reg(CssProp.AP.text_wrap); | ||
CssProp.UNICODE_BIDI = CssProp.reg(CssProp.AP.unicode_bidi); | ||
CssProp.VISIBILITY = CssProp.reg(CssProp.AP.visibility); | ||
CssProp.WHITE_SPACE = CssProp.reg(CssProp.AP.white_space); | ||
CssProp.WORD_BREAK = CssProp.reg(CssProp.AP.word_break); | ||
CssProp.BACKGROUND_ATTACHMENT = CssProp.reg(CssProp.CP.background_attachment); | ||
CssProp.BACKGROUND_COLOR = CssProp.reg(CssProp.CP.background_color); | ||
CssProp.BACKGROUND_ORIGIN = CssProp.reg(CssProp.CP.background_origin); | ||
CssProp.BACKGROUND_REPEAT = CssProp.reg(CssProp.CP.background_repeat); | ||
CssProp.BORDER = CssProp.reg(CssProp.CP.border); | ||
CssProp.BORDER_RADIUS = CssProp.reg(CssProp.CP.border_radius); | ||
CssProp.BORDER_SPACING = CssProp.reg(CssProp.CP.border_spacing); | ||
CssProp.BORDER_TOP_COLOR = CssProp.reg(CssProp.CP.border_top_color); | ||
CssProp.BORDER_TOP_STYLE = CssProp.reg(CssProp.CP.border_top_style); | ||
CssProp.BORDER_WIDTH = CssProp.reg(CssProp.CP.border_width); | ||
CssProp.COLOR = CssProp.reg(CssProp.CP.color); | ||
CssProp.CURSOR = CssProp.reg(CssProp.CP.cursor); | ||
CssProp.DISPLAY = CssProp.reg(CssProp.CP.display); | ||
CssProp.DISPLAY_OUTSIDE = CssProp.reg(CssProp.CP.display_outside); | ||
CssProp.ELEVATION = CssProp.reg(CssProp.CP.elevation); | ||
CssProp.FONT_FAMILY = CssProp.reg(CssProp.CP.font_family); | ||
CssProp.HEIGHT = CssProp.reg(CssProp.CP.height); | ||
CssProp.LETTER_SPACING = CssProp.reg(CssProp.CP.letter_spacing); | ||
CssProp.LIST_STYLE_IMAGE = CssProp.reg(CssProp.CP.list_style_image); | ||
CssProp.MARGIN_RIGHT = CssProp.reg(CssProp.CP.margin_right); | ||
CssProp.MAX_HEIGHT = CssProp.reg(CssProp.CP.max_height); | ||
CssProp.MIN_HEIGHT = CssProp.reg(CssProp.CP.min_height); | ||
CssProp.OPACITY = CssProp.reg(CssProp.CP.opacity); | ||
CssProp.OUTLINE_COLOR = CssProp.reg(CssProp.CP.outline_color); | ||
CssProp.OUTLINE_WIDTH = CssProp.reg(CssProp.CP.outline_width); | ||
CssProp.PADDING = CssProp.reg(CssProp.CP.padding); | ||
CssProp.PADDING_TOP = CssProp.reg(CssProp.CP.padding_top); | ||
CssProp.PITCH_RANGE = CssProp.reg(CssProp.CP.pitch_range); | ||
CssProp.RIGHT = CssProp.reg(CssProp.CP.right); | ||
CssProp.STRESS = CssProp.reg(CssProp.CP.stress); | ||
CssProp.TEXT_INDENT = CssProp.reg(CssProp.CP.text_indent); | ||
CssProp.TEXT_SHADOW = CssProp.reg(CssProp.CP.text_shadow); | ||
CssProp.VOLUME = CssProp.reg(CssProp.CP.volume); | ||
CssProp.WORD_WRAP = CssProp.reg(CssProp.CP.word_wrap); | ||
CssProp.ZOOM = CssProp.reg(CssProp.CP.zoom); | ||
CssProp.BACKFACE_VISIBILITY = CssProp.reg(CssProp.CP.backface_visibility); | ||
CssProp.BACKGROUND_CLIP = CssProp.reg(CssProp.CP.background_clip); | ||
CssProp.BACKGROUND_POSITION = CssProp.reg(CssProp.CP.background_position); | ||
CssProp.BORDER_BOTTOM_COLOR = CssProp.reg(CssProp.CP.border_bottom_color); | ||
CssProp.BORDER_BOTTOM_STYLE = CssProp.reg(CssProp.CP.border_bottom_style); | ||
CssProp.BORDER_COLOR = CssProp.reg(CssProp.CP.border_color); | ||
CssProp.BORDER_LEFT_COLOR = CssProp.reg(CssProp.CP.border_left_color); | ||
CssProp.BORDER_RIGHT_COLOR = CssProp.reg(CssProp.CP.border_right_color); | ||
CssProp.BORDER_STYLE = CssProp.reg(CssProp.CP.border_style); | ||
CssProp.BORDER_TOP_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_top_left_radius); | ||
CssProp.BORDER_TOP_WIDTH = CssProp.reg(CssProp.CP.border_top_width); | ||
CssProp.BOX_SHADOW = CssProp.reg(CssProp.CP.box_shadow); | ||
CssProp.CLIP = CssProp.reg(CssProp.CP.clip); | ||
CssProp.DISPLAY_INSIDE = CssProp.reg(CssProp.CP.display_inside); | ||
CssProp.FONT_SIZE = CssProp.reg(CssProp.CP.font_size); | ||
CssProp.LINE_HEIGHT = CssProp.reg(CssProp.CP.line_height); | ||
CssProp.MARGIN_LEFT = CssProp.reg(CssProp.CP.margin_left); | ||
CssProp.MAX_WIDTH = CssProp.reg(CssProp.CP.max_width); | ||
CssProp.OUTLINE_STYLE = CssProp.reg(CssProp.CP.outline_style); | ||
CssProp.PADDING_BOTTOM = CssProp.reg(CssProp.CP.padding_bottom); | ||
CssProp.PADDING_RIGHT = CssProp.reg(CssProp.CP.padding_right); | ||
CssProp.PERSPECTIVE = CssProp.reg(CssProp.CP.perspective); | ||
CssProp.RICHNESS = CssProp.reg(CssProp.CP.richness); | ||
CssProp.TEXT_OVERFLOW = CssProp.reg(CssProp.CP.text_overflow); | ||
CssProp.TOP = CssProp.reg(CssProp.CP.top); | ||
CssProp.WIDTH = CssProp.reg(CssProp.CP.width); | ||
CssProp.Z_INDEX = CssProp.reg(CssProp.CP.z_index); | ||
CssProp.BACKGROUND = CssProp.reg(CssProp.CP.background); | ||
CssProp.BACKGROUND_SIZE = CssProp.reg(CssProp.CP.background_size); | ||
CssProp.BORDER_BOTTOM_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_bottom_left_radius); | ||
CssProp.BORDER_BOTTOM_WIDTH = CssProp.reg(CssProp.CP.border_bottom_width); | ||
CssProp.BORDER_LEFT_STYLE = CssProp.reg(CssProp.CP.border_left_style); | ||
CssProp.BORDER_RIGHT_STYLE = CssProp.reg(CssProp.CP.border_right_style); | ||
CssProp.BORDER_TOP = CssProp.reg(CssProp.CP.border_top); | ||
CssProp.BOTTOM = CssProp.reg(CssProp.CP.bottom); | ||
CssProp.LIST_STYLE = CssProp.reg(CssProp.CP.list_style); | ||
CssProp.MARGIN_TOP = CssProp.reg(CssProp.CP.margin_top); | ||
CssProp.OUTLINE = CssProp.reg(CssProp.CP.outline); | ||
CssProp.OVERFLOW_Y = CssProp.reg(CssProp.CP.overflow_y); | ||
CssProp.PITCH = CssProp.reg(CssProp.CP.pitch); | ||
CssProp.VERTICAL_ALIGN = CssProp.reg(CssProp.CP.vertical_align); | ||
CssProp.WORD_SPACING = CssProp.reg(CssProp.CP.word_spacing); | ||
CssProp.BACKGROUND_IMAGE = CssProp.reg(CssProp.CP.background_image); | ||
CssProp.BORDER_BOTTOM_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_bottom_right_radius); | ||
CssProp.BORDER_LEFT_WIDTH = CssProp.reg(CssProp.CP.border_left_width); | ||
CssProp.BORDER_RIGHT_WIDTH = CssProp.reg(CssProp.CP.border_right_width); | ||
CssProp.LEFT = CssProp.reg(CssProp.CP.left); | ||
CssProp.MARGIN_BOTTOM = CssProp.reg(CssProp.CP.margin_bottom); | ||
CssProp.PAUSE_AFTER = CssProp.reg(CssProp.CP.pause_after); | ||
CssProp.SPEECH_RATE = CssProp.reg(CssProp.CP.speech_rate); | ||
CssProp.TRANSITION_DURATION = CssProp.reg(CssProp.CP.transition_duration); | ||
CssProp.BORDER_BOTTOM = CssProp.reg(CssProp.CP.border_bottom); | ||
CssProp.BORDER_RIGHT = CssProp.reg(CssProp.CP.border_right); | ||
CssProp.MARGIN = CssProp.reg(CssProp.CP.margin); | ||
CssProp.PADDING_LEFT = CssProp.reg(CssProp.CP.padding_left); | ||
CssProp.BORDER_LEFT = CssProp.reg(CssProp.CP.border_left); | ||
CssProp.FONT = CssProp.reg(CssProp.CP.font); | ||
CssProp.QUOTES = CssProp.reg(CssProp.CP.quotes); | ||
CssProp.BORDER_TOP_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_top_right_radius); | ||
CssProp.MIN_WIDTH = CssProp.reg(CssProp.CP.min_width); | ||
/** | ||
@@ -392,0 +389,0 @@ * A class to sanitize HTML strings. |
@@ -37,2 +37,10 @@ import { IChangedArgs } from '@jupyterlab/coreutils'; | ||
/** | ||
* Whether the session context is terminating. | ||
*/ | ||
readonly isTerminating: boolean; | ||
/** | ||
* Whether the session context is restarting. | ||
*/ | ||
readonly isRestarting: boolean; | ||
/** | ||
* A promise that is fulfilled when the session context is ready. | ||
@@ -125,2 +133,8 @@ */ | ||
/** | ||
* Restart the current Kernel. | ||
* | ||
* @returns A promise that resolves when the kernel is restarted. | ||
*/ | ||
restartKernel(): Promise<void>; | ||
/** | ||
* Kill the kernel and shutdown the session. | ||
@@ -287,2 +301,10 @@ * | ||
/** | ||
* Whether the context is terminating. | ||
*/ | ||
get isTerminating(): boolean; | ||
/** | ||
* Whether the context is restarting. | ||
*/ | ||
get isRestarting(): boolean; | ||
/** | ||
* The session manager used by the session. | ||
@@ -328,2 +350,8 @@ */ | ||
/** | ||
* Restart the current Kernel. | ||
* | ||
* @returns A promise that resolves when the kernel is restarted. | ||
*/ | ||
restartKernel(): Promise<void>; | ||
/** | ||
* Change the current kernel associated with the session. | ||
@@ -420,2 +448,4 @@ */ | ||
private _isReady; | ||
private _isTerminating; | ||
private _isRestarting; | ||
private _kernelChanged; | ||
@@ -422,0 +452,0 @@ private _sessionChanged; |
@@ -32,2 +32,4 @@ // Copyright (c) Jupyter Development Team. | ||
this._isReady = false; | ||
this._isTerminating = false; | ||
this._isRestarting = false; | ||
this._kernelChanged = new Signal(this); | ||
@@ -46,7 +48,7 @@ this._sessionChanged = new Signal(this); | ||
this.specsManager = options.specsManager; | ||
this._path = (_a = options.path) !== null && _a !== void 0 ? _a : UUID.uuid4(); | ||
this._type = (_b = options.type) !== null && _b !== void 0 ? _b : ''; | ||
this._name = (_c = options.name) !== null && _c !== void 0 ? _c : ''; | ||
this._path = (_a = options.path, (_a !== null && _a !== void 0 ? _a : UUID.uuid4())); | ||
this._type = (_b = options.type, (_b !== null && _b !== void 0 ? _b : '')); | ||
this._name = (_c = options.name, (_c !== null && _c !== void 0 ? _c : '')); | ||
this._setBusy = options.setBusy; | ||
this._kernelPreference = (_d = options.kernelPreference) !== null && _d !== void 0 ? _d : {}; | ||
this._kernelPreference = (_d = options.kernelPreference, (_d !== null && _d !== void 0 ? _d : {})); | ||
} | ||
@@ -58,3 +60,3 @@ /** | ||
var _a; | ||
return (_a = this._session) !== null && _a !== void 0 ? _a : null; | ||
return _a = this._session, (_a !== null && _a !== void 0 ? _a : null); | ||
} | ||
@@ -158,2 +160,14 @@ /** | ||
/** | ||
* Whether the context is terminating. | ||
*/ | ||
get isTerminating() { | ||
return this._isTerminating; | ||
} | ||
/** | ||
* Whether the context is restarting. | ||
*/ | ||
get isRestarting() { | ||
return this._isRestarting; | ||
} | ||
/** | ||
* The display name of the current kernel, or a sensible alternative. | ||
@@ -195,3 +209,3 @@ * | ||
} | ||
return ((_d = (_c = (_b = this.specsManager.specs) === null || _b === void 0 ? void 0 : _b.kernelspecs[kernel.name]) === null || _c === void 0 ? void 0 : _c.display_name) !== null && _d !== void 0 ? _d : kernel.name); | ||
return (_d = (_c = (_b = this.specsManager.specs) === null || _b === void 0 ? void 0 : _b.kernelspecs[kernel.name]) === null || _c === void 0 ? void 0 : _c.display_name, (_d !== null && _d !== void 0 ? _d : kernel.name)); | ||
} | ||
@@ -206,4 +220,10 @@ /** | ||
get kernelDisplayStatus() { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e; | ||
const kernel = (_a = this.session) === null || _a === void 0 ? void 0 : _a.kernel; | ||
if (this._isTerminating) { | ||
return 'terminating'; | ||
} | ||
if (this._isRestarting) { | ||
return 'restarting'; | ||
} | ||
if (this._pendingKernelName === Private.NO_KERNEL) { | ||
@@ -221,4 +241,4 @@ return 'idle'; | ||
} | ||
return ((_b = ((kernel === null || kernel === void 0 ? void 0 : kernel.connectionStatus) === 'connected' | ||
? kernel === null || kernel === void 0 ? void 0 : kernel.status : kernel === null || kernel === void 0 ? void 0 : kernel.connectionStatus)) !== null && _b !== void 0 ? _b : 'unknown'); | ||
return (_e = (((_b = kernel) === null || _b === void 0 ? void 0 : _b.connectionStatus) === 'connected' | ||
? (_c = kernel) === null || _c === void 0 ? void 0 : _c.status : (_d = kernel) === null || _d === void 0 ? void 0 : _d.connectionStatus), (_e !== null && _e !== void 0 ? _e : 'unknown')); | ||
} | ||
@@ -273,2 +293,23 @@ /** | ||
/** | ||
* Restart the current Kernel. | ||
* | ||
* @returns A promise that resolves when the kernel is restarted. | ||
*/ | ||
async restartKernel() { | ||
var _a, _b, _c, _d, _e, _f; | ||
const kernel = ((_a = this.session) === null || _a === void 0 ? void 0 : _a.kernel) || null; | ||
this._isRestarting = true; | ||
this._isReady = false; | ||
this._statusChanged.emit('restarting'); | ||
await ((_c = (_b = this.session) === null || _b === void 0 ? void 0 : _b.kernel) === null || _c === void 0 ? void 0 : _c.restart()); | ||
this._isRestarting = false; | ||
this._isReady = true; | ||
this._statusChanged.emit(((_e = (_d = this.session) === null || _d === void 0 ? void 0 : _d.kernel) === null || _e === void 0 ? void 0 : _e.status) || 'unknown'); | ||
this._kernelChanged.emit({ | ||
name: 'kernel', | ||
oldValue: kernel, | ||
newValue: ((_f = this.session) === null || _f === void 0 ? void 0 : _f.kernel) || null | ||
}); | ||
} | ||
/** | ||
* Change the current kernel associated with the session. | ||
@@ -356,5 +397,13 @@ */ | ||
async _shutdownSession() { | ||
var _a, _b, _c; | ||
const session = this._session; | ||
this._isTerminating = true; | ||
this._isReady = false; | ||
this._statusChanged.emit('terminating'); | ||
await ((_a = session) === null || _a === void 0 ? void 0 : _a.shutdown()); | ||
this._isTerminating = false; | ||
(_b = session) === null || _b === void 0 ? void 0 : _b.dispose(); | ||
this._session = null; | ||
const kernel = (session === null || session === void 0 ? void 0 : session.kernel) || null; | ||
const kernel = ((_c = session) === null || _c === void 0 ? void 0 : _c.kernel) || null; | ||
this._statusChanged.emit('unknown'); | ||
this._kernelChanged.emit({ | ||
@@ -365,5 +414,2 @@ name: 'kernel', | ||
}); | ||
this._statusChanged.emit('unknown'); | ||
await (session === null || session === void 0 ? void 0 : session.shutdown()); | ||
session === null || session === void 0 ? void 0 : session.dispose(); | ||
this._sessionChanged.emit({ | ||
@@ -476,3 +522,3 @@ name: 'session', | ||
_handleNewSession(session) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (this.isDisposed) { | ||
@@ -491,3 +537,3 @@ throw Error('Disposed'); | ||
if (session) { | ||
this._prevKernelName = (_b = (_a = session.kernel) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''; | ||
this._prevKernelName = (_b = (_a = session.kernel) === null || _a === void 0 ? void 0 : _a.name, (_b !== null && _b !== void 0 ? _b : '')); | ||
session.disposed.connect(this._onSessionDisposed, this); | ||
@@ -519,7 +565,7 @@ session.propertyChanged.connect(this._onPropertyChanged, this); | ||
oldValue: null, | ||
newValue: (session === null || session === void 0 ? void 0 : session.kernel) || null, | ||
newValue: ((_c = session) === null || _c === void 0 ? void 0 : _c.kernel) || null, | ||
name: 'kernel' | ||
}); | ||
this._statusChanged.emit(((_c = session === null || session === void 0 ? void 0 : session.kernel) === null || _c === void 0 ? void 0 : _c.status) || 'unknown'); | ||
return (session === null || session === void 0 ? void 0 : session.kernel) || null; | ||
this._statusChanged.emit(((_e = (_d = session) === null || _d === void 0 ? void 0 : _d.kernel) === null || _e === void 0 ? void 0 : _e.status) || 'unknown'); | ||
return ((_f = session) === null || _f === void 0 ? void 0 : _f.kernel) || null; | ||
} | ||
@@ -720,3 +766,3 @@ /** | ||
if (result.button.accept) { | ||
await kernel.restart(); | ||
await sessionContext.restartKernel(); | ||
return true; | ||
@@ -723,0 +769,0 @@ } |
@@ -336,3 +336,3 @@ // Copyright (c) Jupyter Development Team. | ||
onClick: () => { | ||
void (dialogs !== null && dialogs !== void 0 ? dialogs : sessionContextDialogs).restart(sessionContext); | ||
void ((dialogs !== null && dialogs !== void 0 ? dialogs : sessionContextDialogs)).restart(sessionContext); | ||
}, | ||
@@ -362,3 +362,3 @@ tooltip: 'Restart the kernel' | ||
function createKernelNameItem(sessionContext, dialogs) { | ||
const el = ReactWidget.create(React.createElement(Private.KernelNameComponent, { sessionContext: sessionContext, dialogs: dialogs !== null && dialogs !== void 0 ? dialogs : sessionContextDialogs })); | ||
const el = ReactWidget.create(React.createElement(Private.KernelNameComponent, { sessionContext: sessionContext, dialogs: (dialogs !== null && dialogs !== void 0 ? dialogs : sessionContextDialogs) })); | ||
el.addClass('jp-KernelName'); | ||
@@ -392,14 +392,14 @@ return el; | ||
const handleMouseDown = (event) => { | ||
var _a; | ||
var _a, _b; | ||
// Fire action only when left button is pressed. | ||
if (event.button === 0) { | ||
event.preventDefault(); | ||
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); | ||
(_b = (_a = props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
} | ||
}; | ||
const handleKeyDown = (event) => { | ||
var _a; | ||
var _a, _b; | ||
const { key } = event; | ||
if (key === 'Enter' || key === ' ') { | ||
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); | ||
(_b = (_a = props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
} | ||
@@ -542,3 +542,6 @@ }; | ||
}; | ||
return (React.createElement(UseSignal, { signal: props.sessionContext.kernelChanged, initialSender: props.sessionContext }, sessionContext => (React.createElement(ToolbarButtonComponent, { className: TOOLBAR_KERNEL_NAME_CLASS, onClick: callback, tooltip: 'Switch kernel', label: sessionContext === null || sessionContext === void 0 ? void 0 : sessionContext.kernelDisplayName })))); | ||
return (React.createElement(UseSignal, { signal: props.sessionContext.kernelChanged, initialSender: props.sessionContext }, sessionContext => { | ||
var _a; | ||
return (React.createElement(ToolbarButtonComponent, { className: TOOLBAR_KERNEL_NAME_CLASS, onClick: callback, tooltip: 'Switch kernel', label: (_a = sessionContext) === null || _a === void 0 ? void 0 : _a.kernelDisplayName })); | ||
})); | ||
} | ||
@@ -593,2 +596,3 @@ Private.KernelNameComponent = KernelNameComponent; | ||
status === 'starting' || | ||
status === 'terminating' || | ||
status === 'restarting' || | ||
@@ -595,0 +599,0 @@ status === 'initializing'); |
@@ -75,3 +75,3 @@ // Copyright (c) Jupyter Development Team. | ||
this._modelChanged = new Signal(this); | ||
this.model = (model !== null && model !== void 0 ? model : null); | ||
this.model = ((model !== null && model !== void 0 ? model : null)); | ||
} | ||
@@ -78,0 +78,0 @@ /** |
{ | ||
"name": "@jupyterlab/apputils", | ||
"version": "2.2.0-alpha.0", | ||
"version": "2.2.0-alpha.2", | ||
"description": "JupyterLab - Application Utilities", | ||
@@ -43,7 +43,7 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/coreutils": "^4.2.0-alpha.0", | ||
"@jupyterlab/services": "^5.2.0-alpha.0", | ||
"@jupyterlab/settingregistry": "^2.2.0-alpha.0", | ||
"@jupyterlab/statedb": "^2.2.0-alpha.0", | ||
"@jupyterlab/ui-components": "^2.2.0-alpha.0", | ||
"@jupyterlab/coreutils": "^4.2.0-alpha.2", | ||
"@jupyterlab/services": "^5.2.0-alpha.2", | ||
"@jupyterlab/settingregistry": "^2.2.0-alpha.2", | ||
"@jupyterlab/statedb": "^2.2.0-alpha.2", | ||
"@jupyterlab/ui-components": "^2.2.0-alpha.2", | ||
"@lumino/algorithm": "^1.2.3", | ||
@@ -65,3 +65,3 @@ "@lumino/commands": "^1.10.1", | ||
"devDependencies": { | ||
"@jupyterlab/testutils": "^2.2.0-alpha.0", | ||
"@jupyterlab/testutils": "^2.2.0-alpha.2", | ||
"@types/jest": "^24.0.23", | ||
@@ -73,4 +73,4 @@ "@types/react-dom": "~16.9.4", | ||
"ts-jest": "^25.2.1", | ||
"typedoc": "^0.17.7", | ||
"typescript": "~3.9.2" | ||
"typedoc": "^0.15.4", | ||
"typescript": "~3.7.3" | ||
}, | ||
@@ -80,3 +80,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "d6772c788e019a1db5abcb2ea1b7d40d2d8916b4" | ||
"gitHead": "9c7e07727190b625dda7575454fb7c90694f1485" | ||
} |
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
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
445607
9119