This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

444
node_modules/@babel/parser/lib/plugins/jsx/index.js generated vendored Normal file
View File

@ -0,0 +1,444 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _xhtml = require("./xhtml");
var _types = require("../../tokenizer/types");
var _context = require("../../tokenizer/context");
var _identifier = require("../../util/identifier");
var _whitespace = require("../../util/whitespace");
var _parseError = require("../../parse-error");
const JsxErrors = (0, _parseError.ParseErrorEnum)`jsx`({
AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
MissingClosingTagElement: ({
openingTagName
}) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
UnexpectedToken: ({
unexpected,
HTMLEntity
}) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
UnterminatedJsxContent: "Unterminated JSX contents.",
UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
});
function isFragment(object) {
return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
}
function getQualifiedJSXName(object) {
if (object.type === "JSXIdentifier") {
return object.name;
}
if (object.type === "JSXNamespacedName") {
return object.namespace.name + ":" + object.name.name;
}
if (object.type === "JSXMemberExpression") {
return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
}
throw new Error("Node had unexpected type: " + object.type);
}
var _default = superClass => class JSXParserMixin extends superClass {
jsxReadToken() {
let out = "";
let chunkStart = this.state.pos;
for (;;) {
if (this.state.pos >= this.length) {
throw this.raise(JsxErrors.UnterminatedJsxContent, {
at: this.state.startLoc
});
}
const ch = this.input.charCodeAt(this.state.pos);
switch (ch) {
case 60:
case 123:
if (this.state.pos === this.state.start) {
if (ch === 60 && this.state.canStartJSXElement) {
++this.state.pos;
this.finishToken(140);
} else {
super.getTokenFromCode(ch);
}
return;
}
out += this.input.slice(chunkStart, this.state.pos);
this.finishToken(139, out);
return;
case 38:
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadEntity();
chunkStart = this.state.pos;
break;
case 62:
case 125:
;
default:
if ((0, _whitespace.isNewLine)(ch)) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadNewLine(true);
chunkStart = this.state.pos;
} else {
++this.state.pos;
}
}
}
}
jsxReadNewLine(normalizeCRLF) {
const ch = this.input.charCodeAt(this.state.pos);
let out;
++this.state.pos;
if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
++this.state.pos;
out = normalizeCRLF ? "\n" : "\r\n";
} else {
out = String.fromCharCode(ch);
}
++this.state.curLine;
this.state.lineStart = this.state.pos;
return out;
}
jsxReadString(quote) {
let out = "";
let chunkStart = ++this.state.pos;
for (;;) {
if (this.state.pos >= this.length) {
throw this.raise(_parseError.Errors.UnterminatedString, {
at: this.state.startLoc
});
}
const ch = this.input.charCodeAt(this.state.pos);
if (ch === quote) break;
if (ch === 38) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadEntity();
chunkStart = this.state.pos;
} else if ((0, _whitespace.isNewLine)(ch)) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadNewLine(false);
chunkStart = this.state.pos;
} else {
++this.state.pos;
}
}
out += this.input.slice(chunkStart, this.state.pos++);
this.finishToken(131, out);
}
jsxReadEntity() {
const startPos = ++this.state.pos;
if (this.codePointAtPos(this.state.pos) === 35) {
++this.state.pos;
let radix = 10;
if (this.codePointAtPos(this.state.pos) === 120) {
radix = 16;
++this.state.pos;
}
const codePoint = this.readInt(radix, undefined, false, "bail");
if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
++this.state.pos;
return String.fromCodePoint(codePoint);
}
} else {
let count = 0;
let semi = false;
while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) == 59)) {
++this.state.pos;
}
if (semi) {
const desc = this.input.slice(startPos, this.state.pos);
const entity = _xhtml.default[desc];
++this.state.pos;
if (entity) {
return entity;
}
}
}
this.state.pos = startPos;
return "&";
}
jsxReadWord() {
let ch;
const start = this.state.pos;
do {
ch = this.input.charCodeAt(++this.state.pos);
} while ((0, _identifier.isIdentifierChar)(ch) || ch === 45);
this.finishToken(138, this.input.slice(start, this.state.pos));
}
jsxParseIdentifier() {
const node = this.startNode();
if (this.match(138)) {
node.name = this.state.value;
} else if ((0, _types.tokenIsKeyword)(this.state.type)) {
node.name = (0, _types.tokenLabelName)(this.state.type);
} else {
this.unexpected();
}
this.next();
return this.finishNode(node, "JSXIdentifier");
}
jsxParseNamespacedName() {
const startLoc = this.state.startLoc;
const name = this.jsxParseIdentifier();
if (!this.eat(14)) return name;
const node = this.startNodeAt(startLoc);
node.namespace = name;
node.name = this.jsxParseIdentifier();
return this.finishNode(node, "JSXNamespacedName");
}
jsxParseElementName() {
const startLoc = this.state.startLoc;
let node = this.jsxParseNamespacedName();
if (node.type === "JSXNamespacedName") {
return node;
}
while (this.eat(16)) {
const newNode = this.startNodeAt(startLoc);
newNode.object = node;
newNode.property = this.jsxParseIdentifier();
node = this.finishNode(newNode, "JSXMemberExpression");
}
return node;
}
jsxParseAttributeValue() {
let node;
switch (this.state.type) {
case 5:
node = this.startNode();
this.setContext(_context.types.brace);
this.next();
node = this.jsxParseExpressionContainer(node, _context.types.j_oTag);
if (node.expression.type === "JSXEmptyExpression") {
this.raise(JsxErrors.AttributeIsEmpty, {
at: node
});
}
return node;
case 140:
case 131:
return this.parseExprAtom();
default:
throw this.raise(JsxErrors.UnsupportedJsxValue, {
at: this.state.startLoc
});
}
}
jsxParseEmptyExpression() {
const node = this.startNodeAt(this.state.lastTokEndLoc);
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
}
jsxParseSpreadChild(node) {
this.next();
node.expression = this.parseExpression();
this.setContext(_context.types.j_expr);
this.state.canStartJSXElement = true;
this.expect(8);
return this.finishNode(node, "JSXSpreadChild");
}
jsxParseExpressionContainer(node, previousContext) {
if (this.match(8)) {
node.expression = this.jsxParseEmptyExpression();
} else {
const expression = this.parseExpression();
;
node.expression = expression;
}
this.setContext(previousContext);
this.state.canStartJSXElement = true;
this.expect(8);
return this.finishNode(node, "JSXExpressionContainer");
}
jsxParseAttribute() {
const node = this.startNode();
if (this.match(5)) {
this.setContext(_context.types.brace);
this.next();
this.expect(21);
node.argument = this.parseMaybeAssignAllowIn();
this.setContext(_context.types.j_oTag);
this.state.canStartJSXElement = true;
this.expect(8);
return this.finishNode(node, "JSXSpreadAttribute");
}
node.name = this.jsxParseNamespacedName();
node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
return this.finishNode(node, "JSXAttribute");
}
jsxParseOpeningElementAt(startLoc) {
const node = this.startNodeAt(startLoc);
if (this.eat(141)) {
return this.finishNode(node, "JSXOpeningFragment");
}
node.name = this.jsxParseElementName();
return this.jsxParseOpeningElementAfterName(node);
}
jsxParseOpeningElementAfterName(node) {
const attributes = [];
while (!this.match(56) && !this.match(141)) {
attributes.push(this.jsxParseAttribute());
}
node.attributes = attributes;
node.selfClosing = this.eat(56);
this.expect(141);
return this.finishNode(node, "JSXOpeningElement");
}
jsxParseClosingElementAt(startLoc) {
const node = this.startNodeAt(startLoc);
if (this.eat(141)) {
return this.finishNode(node, "JSXClosingFragment");
}
node.name = this.jsxParseElementName();
this.expect(141);
return this.finishNode(node, "JSXClosingElement");
}
jsxParseElementAt(startLoc) {
const node = this.startNodeAt(startLoc);
const children = [];
const openingElement = this.jsxParseOpeningElementAt(startLoc);
let closingElement = null;
if (!openingElement.selfClosing) {
contents: for (;;) {
switch (this.state.type) {
case 140:
startLoc = this.state.startLoc;
this.next();
if (this.eat(56)) {
closingElement = this.jsxParseClosingElementAt(startLoc);
break contents;
}
children.push(this.jsxParseElementAt(startLoc));
break;
case 139:
children.push(this.parseExprAtom());
break;
case 5:
{
const node = this.startNode();
this.setContext(_context.types.brace);
this.next();
if (this.match(21)) {
children.push(this.jsxParseSpreadChild(node));
} else {
children.push(this.jsxParseExpressionContainer(node, _context.types.j_expr));
}
break;
}
default:
this.unexpected();
}
}
if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
this.raise(JsxErrors.MissingClosingTagFragment, {
at: closingElement
});
} else if (!isFragment(openingElement) && isFragment(closingElement)) {
this.raise(JsxErrors.MissingClosingTagElement, {
at: closingElement,
openingTagName: getQualifiedJSXName(openingElement.name)
});
} else if (!isFragment(openingElement) && !isFragment(closingElement)) {
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
this.raise(JsxErrors.MissingClosingTagElement, {
at: closingElement,
openingTagName: getQualifiedJSXName(openingElement.name)
});
}
}
}
if (isFragment(openingElement)) {
node.openingFragment = openingElement;
node.closingFragment = closingElement;
} else {
node.openingElement = openingElement;
node.closingElement = closingElement;
}
node.children = children;
if (this.match(47)) {
throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, {
at: this.state.startLoc
});
}
return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
}
jsxParseElement() {
const startLoc = this.state.startLoc;
this.next();
return this.jsxParseElementAt(startLoc);
}
setContext(newContext) {
const {
context
} = this.state;
context[context.length - 1] = newContext;
}
parseExprAtom(refExpressionErrors) {
if (this.match(139)) {
return this.parseLiteral(this.state.value, "JSXText");
} else if (this.match(140)) {
return this.jsxParseElement();
} else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
this.replaceToken(140);
return this.jsxParseElement();
} else {
return super.parseExprAtom(refExpressionErrors);
}
}
skipSpace() {
const curContext = this.curContext();
if (!curContext.preserveSpace) super.skipSpace();
}
getTokenFromCode(code) {
const context = this.curContext();
if (context === _context.types.j_expr) {
this.jsxReadToken();
return;
}
if (context === _context.types.j_oTag || context === _context.types.j_cTag) {
if ((0, _identifier.isIdentifierStart)(code)) {
this.jsxReadWord();
return;
}
if (code === 62) {
++this.state.pos;
this.finishToken(141);
return;
}
if ((code === 34 || code === 39) && context === _context.types.j_oTag) {
this.jsxReadString(code);
return;
}
}
if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
++this.state.pos;
this.finishToken(140);
return;
}
super.getTokenFromCode(code);
}
updateContext(prevType) {
const {
context,
type
} = this.state;
if (type === 56 && prevType === 140) {
context.splice(-2, 2, _context.types.j_cTag);
this.state.canStartJSXElement = false;
} else if (type === 140) {
context.push(_context.types.j_oTag);
} else if (type === 141) {
const out = context[context.length - 1];
if (out === _context.types.j_oTag && prevType === 56 || out === _context.types.j_cTag) {
context.pop();
this.state.canStartJSXElement = context[context.length - 1] === _context.types.j_expr;
} else {
this.setContext(_context.types.j_expr);
this.state.canStartJSXElement = true;
}
} else {
this.state.canStartJSXElement = (0, _types.tokenComesBeforeExpression)(type);
}
}
};
exports.default = _default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

266
node_modules/@babel/parser/lib/plugins/jsx/xhtml.js generated vendored Normal file
View File

@ -0,0 +1,266 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const entities = {
__proto__: null,
quot: "\u0022",
amp: "&",
apos: "\u0027",
lt: "<",
gt: ">",
nbsp: "\u00A0",
iexcl: "\u00A1",
cent: "\u00A2",
pound: "\u00A3",
curren: "\u00A4",
yen: "\u00A5",
brvbar: "\u00A6",
sect: "\u00A7",
uml: "\u00A8",
copy: "\u00A9",
ordf: "\u00AA",
laquo: "\u00AB",
not: "\u00AC",
shy: "\u00AD",
reg: "\u00AE",
macr: "\u00AF",
deg: "\u00B0",
plusmn: "\u00B1",
sup2: "\u00B2",
sup3: "\u00B3",
acute: "\u00B4",
micro: "\u00B5",
para: "\u00B6",
middot: "\u00B7",
cedil: "\u00B8",
sup1: "\u00B9",
ordm: "\u00BA",
raquo: "\u00BB",
frac14: "\u00BC",
frac12: "\u00BD",
frac34: "\u00BE",
iquest: "\u00BF",
Agrave: "\u00C0",
Aacute: "\u00C1",
Acirc: "\u00C2",
Atilde: "\u00C3",
Auml: "\u00C4",
Aring: "\u00C5",
AElig: "\u00C6",
Ccedil: "\u00C7",
Egrave: "\u00C8",
Eacute: "\u00C9",
Ecirc: "\u00CA",
Euml: "\u00CB",
Igrave: "\u00CC",
Iacute: "\u00CD",
Icirc: "\u00CE",
Iuml: "\u00CF",
ETH: "\u00D0",
Ntilde: "\u00D1",
Ograve: "\u00D2",
Oacute: "\u00D3",
Ocirc: "\u00D4",
Otilde: "\u00D5",
Ouml: "\u00D6",
times: "\u00D7",
Oslash: "\u00D8",
Ugrave: "\u00D9",
Uacute: "\u00DA",
Ucirc: "\u00DB",
Uuml: "\u00DC",
Yacute: "\u00DD",
THORN: "\u00DE",
szlig: "\u00DF",
agrave: "\u00E0",
aacute: "\u00E1",
acirc: "\u00E2",
atilde: "\u00E3",
auml: "\u00E4",
aring: "\u00E5",
aelig: "\u00E6",
ccedil: "\u00E7",
egrave: "\u00E8",
eacute: "\u00E9",
ecirc: "\u00EA",
euml: "\u00EB",
igrave: "\u00EC",
iacute: "\u00ED",
icirc: "\u00EE",
iuml: "\u00EF",
eth: "\u00F0",
ntilde: "\u00F1",
ograve: "\u00F2",
oacute: "\u00F3",
ocirc: "\u00F4",
otilde: "\u00F5",
ouml: "\u00F6",
divide: "\u00F7",
oslash: "\u00F8",
ugrave: "\u00F9",
uacute: "\u00FA",
ucirc: "\u00FB",
uuml: "\u00FC",
yacute: "\u00FD",
thorn: "\u00FE",
yuml: "\u00FF",
OElig: "\u0152",
oelig: "\u0153",
Scaron: "\u0160",
scaron: "\u0161",
Yuml: "\u0178",
fnof: "\u0192",
circ: "\u02C6",
tilde: "\u02DC",
Alpha: "\u0391",
Beta: "\u0392",
Gamma: "\u0393",
Delta: "\u0394",
Epsilon: "\u0395",
Zeta: "\u0396",
Eta: "\u0397",
Theta: "\u0398",
Iota: "\u0399",
Kappa: "\u039A",
Lambda: "\u039B",
Mu: "\u039C",
Nu: "\u039D",
Xi: "\u039E",
Omicron: "\u039F",
Pi: "\u03A0",
Rho: "\u03A1",
Sigma: "\u03A3",
Tau: "\u03A4",
Upsilon: "\u03A5",
Phi: "\u03A6",
Chi: "\u03A7",
Psi: "\u03A8",
Omega: "\u03A9",
alpha: "\u03B1",
beta: "\u03B2",
gamma: "\u03B3",
delta: "\u03B4",
epsilon: "\u03B5",
zeta: "\u03B6",
eta: "\u03B7",
theta: "\u03B8",
iota: "\u03B9",
kappa: "\u03BA",
lambda: "\u03BB",
mu: "\u03BC",
nu: "\u03BD",
xi: "\u03BE",
omicron: "\u03BF",
pi: "\u03C0",
rho: "\u03C1",
sigmaf: "\u03C2",
sigma: "\u03C3",
tau: "\u03C4",
upsilon: "\u03C5",
phi: "\u03C6",
chi: "\u03C7",
psi: "\u03C8",
omega: "\u03C9",
thetasym: "\u03D1",
upsih: "\u03D2",
piv: "\u03D6",
ensp: "\u2002",
emsp: "\u2003",
thinsp: "\u2009",
zwnj: "\u200C",
zwj: "\u200D",
lrm: "\u200E",
rlm: "\u200F",
ndash: "\u2013",
mdash: "\u2014",
lsquo: "\u2018",
rsquo: "\u2019",
sbquo: "\u201A",
ldquo: "\u201C",
rdquo: "\u201D",
bdquo: "\u201E",
dagger: "\u2020",
Dagger: "\u2021",
bull: "\u2022",
hellip: "\u2026",
permil: "\u2030",
prime: "\u2032",
Prime: "\u2033",
lsaquo: "\u2039",
rsaquo: "\u203A",
oline: "\u203E",
frasl: "\u2044",
euro: "\u20AC",
image: "\u2111",
weierp: "\u2118",
real: "\u211C",
trade: "\u2122",
alefsym: "\u2135",
larr: "\u2190",
uarr: "\u2191",
rarr: "\u2192",
darr: "\u2193",
harr: "\u2194",
crarr: "\u21B5",
lArr: "\u21D0",
uArr: "\u21D1",
rArr: "\u21D2",
dArr: "\u21D3",
hArr: "\u21D4",
forall: "\u2200",
part: "\u2202",
exist: "\u2203",
empty: "\u2205",
nabla: "\u2207",
isin: "\u2208",
notin: "\u2209",
ni: "\u220B",
prod: "\u220F",
sum: "\u2211",
minus: "\u2212",
lowast: "\u2217",
radic: "\u221A",
prop: "\u221D",
infin: "\u221E",
ang: "\u2220",
and: "\u2227",
or: "\u2228",
cap: "\u2229",
cup: "\u222A",
int: "\u222B",
there4: "\u2234",
sim: "\u223C",
cong: "\u2245",
asymp: "\u2248",
ne: "\u2260",
equiv: "\u2261",
le: "\u2264",
ge: "\u2265",
sub: "\u2282",
sup: "\u2283",
nsub: "\u2284",
sube: "\u2286",
supe: "\u2287",
oplus: "\u2295",
otimes: "\u2297",
perp: "\u22A5",
sdot: "\u22C5",
lceil: "\u2308",
rceil: "\u2309",
lfloor: "\u230A",
rfloor: "\u230B",
lang: "\u2329",
rang: "\u232A",
loz: "\u25CA",
spades: "\u2660",
clubs: "\u2663",
hearts: "\u2665",
diams: "\u2666"
};
var _default = entities;
exports.default = _default;
//# sourceMappingURL=xhtml.js.map

File diff suppressed because one or more lines are too long