You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

488 lines
24 KiB
JavaScript

"use strict";
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[4588],{
/***/ 64588:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
autoCloseTags: () => (/* binding */ autoCloseTags),
completeFromSchema: () => (/* binding */ completeFromSchema),
xml: () => (/* binding */ xml),
xmlLanguage: () => (/* binding */ xmlLanguage)
});
// EXTERNAL MODULE: ../node_modules/@lezer/lr/dist/index.js
var dist = __webpack_require__(49906);
// EXTERNAL MODULE: consume shared module (default) @lezer/highlight@~1.2.0 (singleton) (fallback: ../node_modules/@lezer/highlight/dist/index.js)
var index_js_ = __webpack_require__(92209);
;// CONCATENATED MODULE: ../node_modules/@lezer/xml/dist/index.js
// This file was generated by lezer-generator. You probably shouldn't edit it.
const StartTag = 1,
StartCloseTag = 2,
MissingCloseTag = 3,
mismatchedStartCloseTag = 4,
incompleteStartCloseTag = 5,
commentContent$1 = 35,
piContent$1 = 36,
cdataContent$1 = 37,
Element = 11,
OpenTag = 13;
/* Hand-written tokenizer for XML tag matching. */
function nameChar(ch) {
return ch == 45 || ch == 46 || ch == 58 || ch >= 65 && ch <= 90 || ch == 95 || ch >= 97 && ch <= 122 || ch >= 161
}
function isSpace(ch) {
return ch == 9 || ch == 10 || ch == 13 || ch == 32
}
let cachedName = null, cachedInput = null, cachedPos = 0;
function tagNameAfter(input, offset) {
let pos = input.pos + offset;
if (cachedInput == input && cachedPos == pos) return cachedName
while (isSpace(input.peek(offset))) offset++;
let name = "";
for (;;) {
let next = input.peek(offset);
if (!nameChar(next)) break
name += String.fromCharCode(next);
offset++;
}
cachedInput = input; cachedPos = pos;
return cachedName = name || null
}
function ElementContext(name, parent) {
this.name = name;
this.parent = parent;
this.hash = parent ? parent.hash : 0;
for (let i = 0; i < name.length; i++) this.hash += (this.hash << 4) + name.charCodeAt(i) + (name.charCodeAt(i) << 8);
}
const elementContext = new dist/* ContextTracker */.IK({
start: null,
shift(context, term, stack, input) {
return term == StartTag ? new ElementContext(tagNameAfter(input, 1) || "", context) : context
},
reduce(context, term) {
return term == Element && context ? context.parent : context
},
reuse(context, node, _stack, input) {
let type = node.type.id;
return type == StartTag || type == OpenTag
? new ElementContext(tagNameAfter(input, 1) || "", context) : context
},
hash(context) { return context ? context.hash : 0 },
strict: false
});
const startTag = new dist/* ExternalTokenizer */.Jq((input, stack) => {
if (input.next != 60 /* '<' */) return
input.advance();
if (input.next == 47 /* '/' */) {
input.advance();
let name = tagNameAfter(input, 0);
if (!name) return input.acceptToken(incompleteStartCloseTag)
if (stack.context && name == stack.context.name) return input.acceptToken(StartCloseTag)
for (let cx = stack.context; cx; cx = cx.parent) if (cx.name == name) return input.acceptToken(MissingCloseTag, -2)
input.acceptToken(mismatchedStartCloseTag);
} else if (input.next != 33 /* '!' */ && input.next != 63 /* '?' */) {
return input.acceptToken(StartTag)
}
}, {contextual: true});
function scanTo(type, end) {
return new dist/* ExternalTokenizer */.Jq(input => {
for (let endPos = 0, len = 0;; len++) {
if (input.next < 0) {
if (len) input.acceptToken(type);
break
}
if (input.next == end.charCodeAt(endPos)) {
endPos++;
if (endPos == end.length) {
if (len >= end.length) input.acceptToken(type, 1 - end.length);
break
}
} else {
endPos = input.next == end.charCodeAt(0) ? 1 : 0;
}
input.advance();
}
})
}
const commentContent = scanTo(commentContent$1, "-->");
const piContent = scanTo(piContent$1, "?>");
const cdataContent = scanTo(cdataContent$1, "]]>");
const xmlHighlighting = (0,index_js_.styleTags)({
Text: index_js_.tags.content,
"StartTag StartCloseTag EndTag SelfCloseEndTag": index_js_.tags.angleBracket,
TagName: index_js_.tags.tagName,
"MismatchedCloseTag/Tagname": [index_js_.tags.tagName, index_js_.tags.invalid],
AttributeName: index_js_.tags.attributeName,
AttributeValue: index_js_.tags.attributeValue,
Is: index_js_.tags.definitionOperator,
"EntityReference CharacterReference": index_js_.tags.character,
Comment: index_js_.tags.blockComment,
ProcessingInst: index_js_.tags.processingInstruction,
DoctypeDecl: index_js_.tags.documentMeta,
Cdata: index_js_.tags.special(index_js_.tags.string)
});
// This file was generated by lezer-generator. You probably shouldn't edit it.
const parser = dist/* LRParser */.WQ.deserialize({
version: 14,
states: ",SOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DS'#DSOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C{'#C{O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C|'#C|O$dOrO,59^OOOP,59^,59^OOOS'#C}'#C}O$lOtO,59_OOOP,59_,59_O$tOpO,59`O$|OpO,59`OOOP-E6t-E6tOOOW-E6u-E6uOOOP1G.l1G.lOOOO-E6v-E6vO%UO!bO1G.oO%UO!bO1G.oO%dOpO'#CkO%lO!bO'#CyO%zO!bO1G.oOOOP1G.o1G.oOOOP1G.w1G.wOOOP-E6y-E6yOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6z-E6zOOOP1G.x1G.xOOOS-E6{-E6{OOOP1G.y1G.yO&gOpO1G.zO&gOpO1G.zOOOP1G.z1G.zO&oO!bO7+$ZO&}O!bO7+$ZOOOP7+$Z7+$ZOOOP7+$c7+$cO'YOpO,59VO'bOpO,59VO'jO!bO,59eOOOO-E6w-E6wO'xOpO1G.uO'xOpO1G.uOOOP1G.u1G.uO(QOpO7+$fOOOP7+$f7+$fO(YO!bO<<GuOOOP<<Gu<<GuOOOP<<G}<<G}O'bOpO1G.qO'bOpO1G.qO(eO#tO'#CnOOOO1G.q1G.qO(sOpO7+$aOOOP7+$a7+$aOOOP<<HQ<<HQOOOPAN=aAN=aOOOPAN=iAN=iO'bOpO7+$]OOOO7+$]7+$]OOOO'#Cz'#CzO({O#tO,59YOOOO,59Y,59YOOOP<<G{<<G{OOOO<<Gw<<GwOOOO-E6x-E6xOOOO1G.t1G.t",
stateData: ")Z~OPQOSVOTWOVWOWWOXWOiXOxPO}TO!PUO~OuZOw]O~O^`Oy^O~OPQOQcOSVOTWOVWOWWOXWOxPO}TO!PUO~ORdO~P!SOseO|gO~OthO!OjO~O^lOy^O~OuZOwoO~O^qOy^O~O[vO`sOdwOy^O~ORyO~P!SO^{Oy^O~OseO|}O~OthO!O!PO~O^!QOy^O~O[!SOy^O~O[!VO`sOd!WOy^O~Oa!YOy^O~Oy^O[mX`mXdmX~O[!VO`sOd!WO~O^!]Oy^O~O[!_Oy^O~O[!aOy^O~O[!cO`sOd!dOy^O~O[!cO`sOd!dO~Oa!eOy^O~Oy^Oz!gO~Oy^O[ma`madma~O[!jOy^O~O[!kOy^O~O[!lO`sOd!mO~OW!pOX!pOz!rO{!pO~O[!sOy^O~OW!pOX!pOz!vO{!pO~O",
goto: "%[wPPPPPPPPPPxxP!OP!UPP!_!iP!oxxxP!u!{#R$Z$j$p$v$|PPPP%SXWORYbXRORYb_t`qru!T!U!bQ!h!YS!o!e!fR!t!nQdRRybXSORYbQYORmYQ[PRn[Q_QQkVjp_krz!R!T!X!Z!^!`!f!i!nQr`QzcQ!RlQ!TqQ!XsQ!ZtQ!^{Q!`!QQ!f!YQ!i!]R!n!eQu`S!UqrU![u!U!bR!b!TQ!q!gR!u!qQbRRxbQfTR|fQiUR!OiSXOYTaRb",
nodeNames: "⚠ StartTag StartCloseTag MissingCloseTag StartCloseTag StartCloseTag Document Text EntityReference CharacterReference Cdata Element EndTag OpenTag TagName Attribute AttributeName Is AttributeValue CloseTag SelfCloseEndTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag DoctypeDecl",
maxTerm: 47,
context: elementContext,
nodeProps: [
["closedBy", 1,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^!_%y!_;'S$n;'S;=`&e<%lO$n_DvW[UVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$nZEgYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_!`$n!`!aFV!a;'S$n;'S;=`&e<%lO$nZF`W!OQVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$nZGPYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_#P$n#P#QGo#Q;'S$n;'S;=`&e<%lO$nZGvYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_!`$n!`!aHf!a;'S$n;'S;=`&e<%lO$nZHoWwQVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$n",
tokenizers: [startTag, commentContent, piContent, cdataContent, 0, 1, 2, 3],
topRules: {"Document":[0,6]},
tokenPrec: 0
});
// EXTERNAL MODULE: consume shared module (default) @codemirror/language@^6.11.0 (strict) (fallback: ../node_modules/@codemirror/language/dist/index.js)
var dist_index_js_ = __webpack_require__(27914);
// EXTERNAL MODULE: consume shared module (default) @codemirror/state@~6.5.2 (singleton) (fallback: ../node_modules/@codemirror/state/dist/index.js)
var state_dist_index_js_ = __webpack_require__(82990);
// EXTERNAL MODULE: consume shared module (default) @codemirror/view@~6.38.1 (singleton) (fallback: ../node_modules/@codemirror/view/dist/index.js)
var view_dist_index_js_ = __webpack_require__(21486);
;// CONCATENATED MODULE: ../node_modules/@codemirror/lang-xml/dist/index.js
function tagName(doc, tag) {
let name = tag && tag.getChild("TagName");
return name ? doc.sliceString(name.from, name.to) : "";
}
function elementName$1(doc, tree) {
let tag = tree && tree.firstChild;
return !tag || tag.name != "OpenTag" ? "" : tagName(doc, tag);
}
function attrName(doc, tag, pos) {
let attr = tag && tag.getChildren("Attribute").find(a => a.from <= pos && a.to >= pos);
let name = attr && attr.getChild("AttributeName");
return name ? doc.sliceString(name.from, name.to) : "";
}
function findParentElement(tree) {
for (let cur = tree && tree.parent; cur; cur = cur.parent)
if (cur.name == "Element")
return cur;
return null;
}
function findLocation(state, pos) {
var _a;
let at = (0,dist_index_js_.syntaxTree)(state).resolveInner(pos, -1), inTag = null;
for (let cur = at; !inTag && cur.parent; cur = cur.parent)
if (cur.name == "OpenTag" || cur.name == "CloseTag" || cur.name == "SelfClosingTag" || cur.name == "MismatchedCloseTag")
inTag = cur;
if (inTag && (inTag.to > pos || inTag.lastChild.type.isError)) {
let elt = inTag.parent;
if (at.name == "TagName")
return inTag.name == "CloseTag" || inTag.name == "MismatchedCloseTag"
? { type: "closeTag", from: at.from, context: elt }
: { type: "openTag", from: at.from, context: findParentElement(elt) };
if (at.name == "AttributeName")
return { type: "attrName", from: at.from, context: inTag };
if (at.name == "AttributeValue")
return { type: "attrValue", from: at.from, context: inTag };
let before = at == inTag || at.name == "Attribute" ? at.childBefore(pos) : at;
if ((before === null || before === void 0 ? void 0 : before.name) == "StartTag")
return { type: "openTag", from: pos, context: findParentElement(elt) };
if ((before === null || before === void 0 ? void 0 : before.name) == "StartCloseTag" && before.to <= pos)
return { type: "closeTag", from: pos, context: elt };
if ((before === null || before === void 0 ? void 0 : before.name) == "Is")
return { type: "attrValue", from: pos, context: inTag };
if (before)
return { type: "attrName", from: pos, context: inTag };
return null;
}
else if (at.name == "StartCloseTag") {
return { type: "closeTag", from: pos, context: at.parent };
}
while (at.parent && at.to == pos && !((_a = at.lastChild) === null || _a === void 0 ? void 0 : _a.type.isError))
at = at.parent;
if (at.name == "Element" || at.name == "Text" || at.name == "Document")
return { type: "tag", from: pos, context: at.name == "Element" ? at : findParentElement(at) };
return null;
}
class dist_Element {
constructor(spec, attrs, attrValues) {
this.attrs = attrs;
this.attrValues = attrValues;
this.children = [];
this.name = spec.name;
this.completion = Object.assign(Object.assign({ type: "type" }, spec.completion || {}), { label: this.name });
this.openCompletion = Object.assign(Object.assign({}, this.completion), { label: "<" + this.name });
this.closeCompletion = Object.assign(Object.assign({}, this.completion), { label: "</" + this.name + ">", boost: 2 });
this.closeNameCompletion = Object.assign(Object.assign({}, this.completion), { label: this.name + ">" });
this.text = spec.textContent ? spec.textContent.map(s => ({ label: s, type: "text" })) : [];
}
}
const Identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
function attrCompletion(spec) {
return Object.assign(Object.assign({ type: "property" }, spec.completion || {}), { label: spec.name });
}
function valueCompletion(spec) {
return typeof spec == "string" ? { label: `"${spec}"`, type: "constant" }
: /^"/.test(spec.label) ? spec
: Object.assign(Object.assign({}, spec), { label: `"${spec.label}"` });
}
/**
Create a completion source for the given schema.
*/
function completeFromSchema(eltSpecs, attrSpecs) {
let allAttrs = [], globalAttrs = [];
let attrValues = Object.create(null);
for (let s of attrSpecs) {
let completion = attrCompletion(s);
allAttrs.push(completion);
if (s.global)
globalAttrs.push(completion);
if (s.values)
attrValues[s.name] = s.values.map(valueCompletion);
}
let allElements = [], topElements = [];
let byName = Object.create(null);
for (let s of eltSpecs) {
let attrs = globalAttrs, attrVals = attrValues;
if (s.attributes)
attrs = attrs.concat(s.attributes.map(s => {
if (typeof s == "string")
return allAttrs.find(a => a.label == s) || { label: s, type: "property" };
if (s.values) {
if (attrVals == attrValues)
attrVals = Object.create(attrVals);
attrVals[s.name] = s.values.map(valueCompletion);
}
return attrCompletion(s);
}));
let elt = new dist_Element(s, attrs, attrVals);
byName[elt.name] = elt;
allElements.push(elt);
if (s.top)
topElements.push(elt);
}
if (!topElements.length)
topElements = allElements;
for (let i = 0; i < allElements.length; i++) {
let s = eltSpecs[i], elt = allElements[i];
if (s.children) {
for (let ch of s.children)
if (byName[ch])
elt.children.push(byName[ch]);
}
else {
elt.children = allElements;
}
}
return cx => {
var _a;
let { doc } = cx.state, loc = findLocation(cx.state, cx.pos);
if (!loc || (loc.type == "tag" && !cx.explicit))
return null;
let { type, from, context } = loc;
if (type == "openTag") {
let children = topElements;
let parentName = elementName$1(doc, context);
if (parentName) {
let parent = byName[parentName];
children = (parent === null || parent === void 0 ? void 0 : parent.children) || allElements;
}
return {
from,
options: children.map(ch => ch.completion),
validFor: Identifier
};
}
else if (type == "closeTag") {
let parentName = elementName$1(doc, context);
return parentName ? {
from,
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == ">" ? 1 : 0),
options: [((_a = byName[parentName]) === null || _a === void 0 ? void 0 : _a.closeNameCompletion) || { label: parentName + ">", type: "type" }],
validFor: Identifier
} : null;
}
else if (type == "attrName") {
let parent = byName[tagName(doc, context)];
return {
from,
options: (parent === null || parent === void 0 ? void 0 : parent.attrs) || globalAttrs,
validFor: Identifier
};
}
else if (type == "attrValue") {
let attr = attrName(doc, context, from);
if (!attr)
return null;
let parent = byName[tagName(doc, context)];
let values = ((parent === null || parent === void 0 ? void 0 : parent.attrValues) || attrValues)[attr];
if (!values || !values.length)
return null;
return {
from,
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == '"' ? 1 : 0),
options: values,
validFor: /^"[^"]*"?$/
};
}
else if (type == "tag") {
let parentName = elementName$1(doc, context), parent = byName[parentName];
let closing = [], last = context && context.lastChild;
if (parentName && (!last || last.name != "CloseTag" || tagName(doc, last) != parentName))
closing.push(parent ? parent.closeCompletion : { label: "</" + parentName + ">", type: "type", boost: 2 });
let options = closing.concat(((parent === null || parent === void 0 ? void 0 : parent.children) || (context ? allElements : topElements)).map(e => e.openCompletion));
if (context && (parent === null || parent === void 0 ? void 0 : parent.text.length)) {
let openTag = context.firstChild;
if (openTag.to > cx.pos - 20 && !/\S/.test(cx.state.sliceDoc(openTag.to, cx.pos)))
options = options.concat(parent.text);
}
return {
from,
options,
validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
};
}
else {
return null;
}
};
}
/**
A language provider based on the [Lezer XML
parser](https://github.com/lezer-parser/xml), extended with
highlighting and indentation information.
*/
const xmlLanguage = /*@__PURE__*/dist_index_js_.LRLanguage.define({
name: "xml",
parser: /*@__PURE__*/parser.configure({
props: [
/*@__PURE__*/dist_index_js_.indentNodeProp.add({
Element(context) {
let closed = /^\s*<\//.test(context.textAfter);
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
},
"OpenTag CloseTag SelfClosingTag"(context) {
return context.column(context.node.from) + context.unit;
}
}),
/*@__PURE__*/dist_index_js_.foldNodeProp.add({
Element(subtree) {
let first = subtree.firstChild, last = subtree.lastChild;
if (!first || first.name != "OpenTag")
return null;
return { from: first.to, to: last.name == "CloseTag" ? last.from : subtree.to };
}
}),
/*@__PURE__*/dist_index_js_.bracketMatchingHandle.add({
"OpenTag CloseTag": node => node.getChild("TagName")
})
]
}),
languageData: {
commentTokens: { block: { open: "<!--", close: "-->" } },
indentOnInput: /^\s*<\/$/
}
});
/**
XML language support. Includes schema-based autocompletion when
configured.
*/
function xml(conf = {}) {
let support = [xmlLanguage.data.of({
autocomplete: completeFromSchema(conf.elements || [], conf.attributes || [])
})];
if (conf.autoCloseTags !== false)
support.push(autoCloseTags);
return new dist_index_js_.LanguageSupport(xmlLanguage, support);
}
function elementName(doc, tree, max = doc.length) {
if (!tree)
return "";
let tag = tree.firstChild;
let name = tag && tag.getChild("TagName");
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : "";
}
/**
Extension that will automatically insert close tags when a `>` or
`/` is typed.
*/
const autoCloseTags = /*@__PURE__*/view_dist_index_js_.EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") ||
!xmlLanguage.isActiveAt(view.state, from, -1))
return false;
let base = insertTransaction(), { state } = base;
let closeTags = state.changeByRange(range => {
var _a, _b, _c;
let { head } = range;
let didType = state.doc.sliceString(head - 1, head) == text;
let after = (0,dist_index_js_.syntaxTree)(state).resolveInner(head, -1), name;
if (didType && text == ">" && after.name == "EndTag") {
let tag = after.parent;
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" &&
(name = elementName(state.doc, tag.parent, head))) {
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
let insert = `</${name}>`;
return { range, changes: { from: head, to, insert } };
}
}
else if (didType && text == "/" && after.name == "StartCloseTag") {
let base = after.parent;
if (after.from == head - 2 && ((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" &&
(name = elementName(state.doc, base, head))) {
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
let insert = `${name}>`;
return {
range: state_dist_index_js_.EditorSelection.cursor(head + insert.length, -1),
changes: { from: head, to, insert }
};
}
}
return { range };
});
if (closeTags.changes.empty)
return false;
view.dispatch([
base,
state.update(closeTags, {
userEvent: "input.complete",
scrollIntoView: true
})
]);
return true;
});
/***/ })
}]);
//# sourceMappingURL=4588.46b592131684aa708905.js.map?v=46b592131684aa708905