wc-compiler 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wcc.dist.cjs +443 -485
- package/package.json +1 -1
- package/src/jsx-loader.js +1 -1
package/dist/wcc.dist.cjs
CHANGED
|
@@ -6055,35 +6055,6 @@ base$1.MethodDefinition = base$1.PropertyDefinition = base$1.Property = function
|
|
|
6055
6055
|
if (node.value) { c(node.value, st, "Expression"); }
|
|
6056
6056
|
};
|
|
6057
6057
|
|
|
6058
|
-
function getDefaultExportFromCjs (x) {
|
|
6059
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6060
|
-
}
|
|
6061
|
-
|
|
6062
|
-
function getAugmentedNamespace(n) {
|
|
6063
|
-
if (n.__esModule) return n;
|
|
6064
|
-
var f = n.default;
|
|
6065
|
-
if (typeof f == "function") {
|
|
6066
|
-
var a = function a () {
|
|
6067
|
-
if (this instanceof a) {
|
|
6068
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
6069
|
-
}
|
|
6070
|
-
return f.apply(this, arguments);
|
|
6071
|
-
};
|
|
6072
|
-
a.prototype = f.prototype;
|
|
6073
|
-
} else a = {};
|
|
6074
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
6075
|
-
Object.keys(n).forEach(function (k) {
|
|
6076
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
6077
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
6078
|
-
enumerable: true,
|
|
6079
|
-
get: function () {
|
|
6080
|
-
return n[k];
|
|
6081
|
-
}
|
|
6082
|
-
});
|
|
6083
|
-
});
|
|
6084
|
-
return a;
|
|
6085
|
-
}
|
|
6086
|
-
|
|
6087
6058
|
var estraverse = {};
|
|
6088
6059
|
|
|
6089
6060
|
/*
|
|
@@ -9700,9 +9671,7 @@ function generate(node, options) {
|
|
|
9700
9671
|
getDefaultOptions().format;
|
|
9701
9672
|
updateDeeply({}, Precedence);
|
|
9702
9673
|
|
|
9703
|
-
var
|
|
9704
|
-
|
|
9705
|
-
var xhtml = {
|
|
9674
|
+
var XHTMLEntities = {
|
|
9706
9675
|
quot: '\u0022',
|
|
9707
9676
|
amp: '&',
|
|
9708
9677
|
apos: '\u0027',
|
|
@@ -9958,500 +9927,489 @@ var xhtml = {
|
|
|
9958
9927
|
diams: '\u2666'
|
|
9959
9928
|
};
|
|
9960
9929
|
|
|
9961
|
-
|
|
9930
|
+
const hexNumber = /^[\da-fA-F]+$/;
|
|
9931
|
+
const decimalNumber = /^\d+$/;
|
|
9932
|
+
|
|
9933
|
+
// The map to `acorn-jsx` tokens from `acorn` namespace objects.
|
|
9934
|
+
const acornJsxMap = new WeakMap();
|
|
9935
|
+
|
|
9936
|
+
// Get the original tokens for the given `acorn` namespace object.
|
|
9937
|
+
function getJsxTokens(acorn) {
|
|
9938
|
+
acorn = acorn.Parser.acorn || acorn;
|
|
9939
|
+
let acornJsx = acornJsxMap.get(acorn);
|
|
9940
|
+
if (!acornJsx) {
|
|
9941
|
+
const tt = acorn.tokTypes;
|
|
9942
|
+
const TokContext = acorn.TokContext;
|
|
9943
|
+
const TokenType = acorn.TokenType;
|
|
9944
|
+
const tc_oTag = new TokContext('<tag', false);
|
|
9945
|
+
const tc_cTag = new TokContext('</tag', false);
|
|
9946
|
+
const tc_expr = new TokContext('<tag>...</tag>', true, true);
|
|
9947
|
+
const tokContexts = {
|
|
9948
|
+
tc_oTag: tc_oTag,
|
|
9949
|
+
tc_cTag: tc_cTag,
|
|
9950
|
+
tc_expr: tc_expr
|
|
9951
|
+
};
|
|
9952
|
+
const tokTypes = {
|
|
9953
|
+
jsxName: new TokenType('jsxName'),
|
|
9954
|
+
jsxText: new TokenType('jsxText', {beforeExpr: true}),
|
|
9955
|
+
jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}),
|
|
9956
|
+
jsxTagEnd: new TokenType('jsxTagEnd')
|
|
9957
|
+
};
|
|
9962
9958
|
|
|
9963
|
-
|
|
9959
|
+
tokTypes.jsxTagStart.updateContext = function() {
|
|
9960
|
+
this.context.push(tc_expr); // treat as beginning of JSX expression
|
|
9961
|
+
this.context.push(tc_oTag); // start opening tag context
|
|
9962
|
+
this.exprAllowed = false;
|
|
9963
|
+
};
|
|
9964
|
+
tokTypes.jsxTagEnd.updateContext = function(prevType) {
|
|
9965
|
+
let out = this.context.pop();
|
|
9966
|
+
if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
|
|
9967
|
+
this.context.pop();
|
|
9968
|
+
this.exprAllowed = this.curContext() === tc_expr;
|
|
9969
|
+
} else {
|
|
9970
|
+
this.exprAllowed = true;
|
|
9971
|
+
}
|
|
9972
|
+
};
|
|
9964
9973
|
|
|
9965
|
-
|
|
9974
|
+
acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes };
|
|
9975
|
+
acornJsxMap.set(acorn, acornJsx);
|
|
9976
|
+
}
|
|
9966
9977
|
|
|
9967
|
-
|
|
9968
|
-
|
|
9978
|
+
return acornJsx;
|
|
9979
|
+
}
|
|
9969
9980
|
|
|
9970
|
-
|
|
9971
|
-
const acornJsxMap = new WeakMap();
|
|
9981
|
+
// Transforms JSX element name to string.
|
|
9972
9982
|
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
let acornJsx = acornJsxMap.get(acorn);
|
|
9977
|
-
if (!acornJsx) {
|
|
9978
|
-
const tt = acorn.tokTypes;
|
|
9979
|
-
const TokContext = acorn.TokContext;
|
|
9980
|
-
const TokenType = acorn.TokenType;
|
|
9981
|
-
const tc_oTag = new TokContext('<tag', false);
|
|
9982
|
-
const tc_cTag = new TokContext('</tag', false);
|
|
9983
|
-
const tc_expr = new TokContext('<tag>...</tag>', true, true);
|
|
9984
|
-
const tokContexts = {
|
|
9985
|
-
tc_oTag: tc_oTag,
|
|
9986
|
-
tc_cTag: tc_cTag,
|
|
9987
|
-
tc_expr: tc_expr
|
|
9988
|
-
};
|
|
9989
|
-
const tokTypes = {
|
|
9990
|
-
jsxName: new TokenType('jsxName'),
|
|
9991
|
-
jsxText: new TokenType('jsxText', {beforeExpr: true}),
|
|
9992
|
-
jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}),
|
|
9993
|
-
jsxTagEnd: new TokenType('jsxTagEnd')
|
|
9994
|
-
};
|
|
9983
|
+
function getQualifiedJSXName(object) {
|
|
9984
|
+
if (!object)
|
|
9985
|
+
return object;
|
|
9995
9986
|
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
this.context.push(tc_oTag); // start opening tag context
|
|
9999
|
-
this.exprAllowed = false;
|
|
10000
|
-
};
|
|
10001
|
-
tokTypes.jsxTagEnd.updateContext = function(prevType) {
|
|
10002
|
-
let out = this.context.pop();
|
|
10003
|
-
if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
|
|
10004
|
-
this.context.pop();
|
|
10005
|
-
this.exprAllowed = this.curContext() === tc_expr;
|
|
10006
|
-
} else {
|
|
10007
|
-
this.exprAllowed = true;
|
|
10008
|
-
}
|
|
10009
|
-
};
|
|
10010
|
-
|
|
10011
|
-
acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes };
|
|
10012
|
-
acornJsxMap.set(acorn, acornJsx);
|
|
10013
|
-
}
|
|
10014
|
-
|
|
10015
|
-
return acornJsx;
|
|
10016
|
-
}
|
|
10017
|
-
|
|
10018
|
-
// Transforms JSX element name to string.
|
|
10019
|
-
|
|
10020
|
-
function getQualifiedJSXName(object) {
|
|
10021
|
-
if (!object)
|
|
10022
|
-
return object;
|
|
10023
|
-
|
|
10024
|
-
if (object.type === 'JSXIdentifier')
|
|
10025
|
-
return object.name;
|
|
10026
|
-
|
|
10027
|
-
if (object.type === 'JSXNamespacedName')
|
|
10028
|
-
return object.namespace.name + ':' + object.name.name;
|
|
10029
|
-
|
|
10030
|
-
if (object.type === 'JSXMemberExpression')
|
|
10031
|
-
return getQualifiedJSXName(object.object) + '.' +
|
|
10032
|
-
getQualifiedJSXName(object.property);
|
|
10033
|
-
}
|
|
10034
|
-
|
|
10035
|
-
module.exports = function(options) {
|
|
10036
|
-
options = options || {};
|
|
10037
|
-
return function(Parser) {
|
|
10038
|
-
return plugin({
|
|
10039
|
-
allowNamespaces: options.allowNamespaces !== false,
|
|
10040
|
-
allowNamespacedObjects: !!options.allowNamespacedObjects
|
|
10041
|
-
}, Parser);
|
|
10042
|
-
};
|
|
10043
|
-
};
|
|
10044
|
-
|
|
10045
|
-
// This is `tokTypes` of the peer dep.
|
|
10046
|
-
// This can be different instances from the actual `tokTypes` this plugin uses.
|
|
10047
|
-
Object.defineProperty(module.exports, "tokTypes", {
|
|
10048
|
-
get: function get_tokTypes() {
|
|
10049
|
-
return getJsxTokens(require$$1).tokTypes;
|
|
10050
|
-
},
|
|
10051
|
-
configurable: true,
|
|
10052
|
-
enumerable: true
|
|
10053
|
-
});
|
|
10054
|
-
|
|
10055
|
-
function plugin(options, Parser) {
|
|
10056
|
-
const acorn = Parser.acorn || require$$1;
|
|
10057
|
-
const acornJsx = getJsxTokens(acorn);
|
|
10058
|
-
const tt = acorn.tokTypes;
|
|
10059
|
-
const tok = acornJsx.tokTypes;
|
|
10060
|
-
const tokContexts = acorn.tokContexts;
|
|
10061
|
-
const tc_oTag = acornJsx.tokContexts.tc_oTag;
|
|
10062
|
-
const tc_cTag = acornJsx.tokContexts.tc_cTag;
|
|
10063
|
-
const tc_expr = acornJsx.tokContexts.tc_expr;
|
|
10064
|
-
const isNewLine = acorn.isNewLine;
|
|
10065
|
-
const isIdentifierStart = acorn.isIdentifierStart;
|
|
10066
|
-
const isIdentifierChar = acorn.isIdentifierChar;
|
|
10067
|
-
|
|
10068
|
-
return class extends Parser {
|
|
10069
|
-
// Expose actual `tokTypes` and `tokContexts` to other plugins.
|
|
10070
|
-
static get acornJsx() {
|
|
10071
|
-
return acornJsx;
|
|
10072
|
-
}
|
|
9987
|
+
if (object.type === 'JSXIdentifier')
|
|
9988
|
+
return object.name;
|
|
10073
9989
|
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
let out = '', chunkStart = this.pos;
|
|
10077
|
-
for (;;) {
|
|
10078
|
-
if (this.pos >= this.input.length)
|
|
10079
|
-
this.raise(this.start, 'Unterminated JSX contents');
|
|
10080
|
-
let ch = this.input.charCodeAt(this.pos);
|
|
10081
|
-
|
|
10082
|
-
switch (ch) {
|
|
10083
|
-
case 60: // '<'
|
|
10084
|
-
case 123: // '{'
|
|
10085
|
-
if (this.pos === this.start) {
|
|
10086
|
-
if (ch === 60 && this.exprAllowed) {
|
|
10087
|
-
++this.pos;
|
|
10088
|
-
return this.finishToken(tok.jsxTagStart);
|
|
10089
|
-
}
|
|
10090
|
-
return this.getTokenFromCode(ch);
|
|
10091
|
-
}
|
|
10092
|
-
out += this.input.slice(chunkStart, this.pos);
|
|
10093
|
-
return this.finishToken(tok.jsxText, out);
|
|
10094
|
-
|
|
10095
|
-
case 38: // '&'
|
|
10096
|
-
out += this.input.slice(chunkStart, this.pos);
|
|
10097
|
-
out += this.jsx_readEntity();
|
|
10098
|
-
chunkStart = this.pos;
|
|
10099
|
-
break;
|
|
10100
|
-
|
|
10101
|
-
case 62: // '>'
|
|
10102
|
-
case 125: // '}'
|
|
10103
|
-
this.raise(
|
|
10104
|
-
this.pos,
|
|
10105
|
-
"Unexpected token `" + this.input[this.pos] + "`. Did you mean `" +
|
|
10106
|
-
(ch === 62 ? ">" : "}") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?"
|
|
10107
|
-
);
|
|
10108
|
-
|
|
10109
|
-
default:
|
|
10110
|
-
if (isNewLine(ch)) {
|
|
10111
|
-
out += this.input.slice(chunkStart, this.pos);
|
|
10112
|
-
out += this.jsx_readNewLine(true);
|
|
10113
|
-
chunkStart = this.pos;
|
|
10114
|
-
} else {
|
|
10115
|
-
++this.pos;
|
|
10116
|
-
}
|
|
10117
|
-
}
|
|
10118
|
-
}
|
|
10119
|
-
}
|
|
9990
|
+
if (object.type === 'JSXNamespacedName')
|
|
9991
|
+
return object.namespace.name + ':' + object.name.name;
|
|
10120
9992
|
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
|
|
10126
|
-
++this.pos;
|
|
10127
|
-
out = normalizeCRLF ? '\n' : '\r\n';
|
|
10128
|
-
} else {
|
|
10129
|
-
out = String.fromCharCode(ch);
|
|
10130
|
-
}
|
|
10131
|
-
if (this.options.locations) {
|
|
10132
|
-
++this.curLine;
|
|
10133
|
-
this.lineStart = this.pos;
|
|
10134
|
-
}
|
|
10135
|
-
|
|
10136
|
-
return out;
|
|
10137
|
-
}
|
|
9993
|
+
if (object.type === 'JSXMemberExpression')
|
|
9994
|
+
return getQualifiedJSXName(object.object) + '.' +
|
|
9995
|
+
getQualifiedJSXName(object.property);
|
|
9996
|
+
}
|
|
10138
9997
|
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
}
|
|
10158
|
-
out += this.input.slice(chunkStart, this.pos++);
|
|
10159
|
-
return this.finishToken(tt.string, out);
|
|
10160
|
-
}
|
|
9998
|
+
function acornJsx(options) {
|
|
9999
|
+
options = options || {};
|
|
10000
|
+
return function(Parser) {
|
|
10001
|
+
return plugin({
|
|
10002
|
+
allowNamespaces: options.allowNamespaces !== false,
|
|
10003
|
+
allowNamespacedObjects: !!options.allowNamespacedObjects
|
|
10004
|
+
}, Parser);
|
|
10005
|
+
};
|
|
10006
|
+
}
|
|
10007
|
+
// This is `tokTypes` of the peer dep.
|
|
10008
|
+
// This can be different instances from the actual `tokTypes` this plugin uses.
|
|
10009
|
+
Object.defineProperty(acornJsx, "tokTypes", {
|
|
10010
|
+
get: function get_tokTypes() {
|
|
10011
|
+
return getJsxTokens(acorn).tokTypes
|
|
10012
|
+
},
|
|
10013
|
+
configurable: true,
|
|
10014
|
+
enumerable: true
|
|
10015
|
+
});
|
|
10161
10016
|
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10017
|
+
function plugin(options, Parser) {
|
|
10018
|
+
const acorn = Parser.acorn || require("acorn");
|
|
10019
|
+
const acornJsx = getJsxTokens(acorn);
|
|
10020
|
+
const tt = acorn.tokTypes;
|
|
10021
|
+
const tok = acornJsx.tokTypes;
|
|
10022
|
+
const tokContexts = acorn.tokContexts;
|
|
10023
|
+
const tc_oTag = acornJsx.tokContexts.tc_oTag;
|
|
10024
|
+
const tc_cTag = acornJsx.tokContexts.tc_cTag;
|
|
10025
|
+
const tc_expr = acornJsx.tokContexts.tc_expr;
|
|
10026
|
+
const isNewLine = acorn.isNewLine;
|
|
10027
|
+
const isIdentifierStart = acorn.isIdentifierStart;
|
|
10028
|
+
const isIdentifierChar = acorn.isIdentifierChar;
|
|
10029
|
+
|
|
10030
|
+
return class extends Parser {
|
|
10031
|
+
// Expose actual `tokTypes` and `tokContexts` to other plugins.
|
|
10032
|
+
static get acornJsx() {
|
|
10033
|
+
return acornJsx;
|
|
10034
|
+
}
|
|
10035
|
+
|
|
10036
|
+
// Reads inline JSX contents token.
|
|
10037
|
+
jsx_readToken() {
|
|
10038
|
+
let out = '', chunkStart = this.pos;
|
|
10039
|
+
for (;;) {
|
|
10040
|
+
if (this.pos >= this.input.length)
|
|
10041
|
+
this.raise(this.start, 'Unterminated JSX contents');
|
|
10042
|
+
let ch = this.input.charCodeAt(this.pos);
|
|
10043
|
+
|
|
10044
|
+
switch (ch) {
|
|
10045
|
+
case 60: // '<'
|
|
10046
|
+
case 123: // '{'
|
|
10047
|
+
if (this.pos === this.start) {
|
|
10048
|
+
if (ch === 60 && this.exprAllowed) {
|
|
10049
|
+
++this.pos;
|
|
10050
|
+
return this.finishToken(tok.jsxTagStart);
|
|
10051
|
+
}
|
|
10052
|
+
return this.getTokenFromCode(ch);
|
|
10053
|
+
}
|
|
10054
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
10055
|
+
return this.finishToken(tok.jsxText, out);
|
|
10056
|
+
|
|
10057
|
+
case 38: // '&'
|
|
10058
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
10059
|
+
out += this.jsx_readEntity();
|
|
10060
|
+
chunkStart = this.pos;
|
|
10061
|
+
break;
|
|
10062
|
+
|
|
10063
|
+
case 62: // '>'
|
|
10064
|
+
case 125: // '}'
|
|
10065
|
+
this.raise(
|
|
10066
|
+
this.pos,
|
|
10067
|
+
"Unexpected token `" + this.input[this.pos] + "`. Did you mean `" +
|
|
10068
|
+
(ch === 62 ? ">" : "}") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?"
|
|
10069
|
+
);
|
|
10194
10070
|
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
} while (isIdentifierChar(ch) || ch === 45); // '-'
|
|
10207
|
-
return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
|
|
10208
|
-
}
|
|
10071
|
+
default:
|
|
10072
|
+
if (isNewLine(ch)) {
|
|
10073
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
10074
|
+
out += this.jsx_readNewLine(true);
|
|
10075
|
+
chunkStart = this.pos;
|
|
10076
|
+
} else {
|
|
10077
|
+
++this.pos;
|
|
10078
|
+
}
|
|
10079
|
+
}
|
|
10080
|
+
}
|
|
10081
|
+
}
|
|
10209
10082
|
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10083
|
+
jsx_readNewLine(normalizeCRLF) {
|
|
10084
|
+
let ch = this.input.charCodeAt(this.pos);
|
|
10085
|
+
let out;
|
|
10086
|
+
++this.pos;
|
|
10087
|
+
if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
|
|
10088
|
+
++this.pos;
|
|
10089
|
+
out = normalizeCRLF ? '\n' : '\r\n';
|
|
10090
|
+
} else {
|
|
10091
|
+
out = String.fromCharCode(ch);
|
|
10092
|
+
}
|
|
10093
|
+
if (this.options.locations) {
|
|
10094
|
+
++this.curLine;
|
|
10095
|
+
this.lineStart = this.pos;
|
|
10096
|
+
}
|
|
10223
10097
|
|
|
10224
|
-
|
|
10098
|
+
return out;
|
|
10099
|
+
}
|
|
10100
|
+
|
|
10101
|
+
jsx_readString(quote) {
|
|
10102
|
+
let out = '', chunkStart = ++this.pos;
|
|
10103
|
+
for (;;) {
|
|
10104
|
+
if (this.pos >= this.input.length)
|
|
10105
|
+
this.raise(this.start, 'Unterminated string constant');
|
|
10106
|
+
let ch = this.input.charCodeAt(this.pos);
|
|
10107
|
+
if (ch === quote) break;
|
|
10108
|
+
if (ch === 38) { // '&'
|
|
10109
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
10110
|
+
out += this.jsx_readEntity();
|
|
10111
|
+
chunkStart = this.pos;
|
|
10112
|
+
} else if (isNewLine(ch)) {
|
|
10113
|
+
out += this.input.slice(chunkStart, this.pos);
|
|
10114
|
+
out += this.jsx_readNewLine(false);
|
|
10115
|
+
chunkStart = this.pos;
|
|
10116
|
+
} else {
|
|
10117
|
+
++this.pos;
|
|
10118
|
+
}
|
|
10119
|
+
}
|
|
10120
|
+
out += this.input.slice(chunkStart, this.pos++);
|
|
10121
|
+
return this.finishToken(tt.string, out);
|
|
10122
|
+
}
|
|
10123
|
+
|
|
10124
|
+
jsx_readEntity() {
|
|
10125
|
+
let str = '', count = 0, entity;
|
|
10126
|
+
let ch = this.input[this.pos];
|
|
10127
|
+
if (ch !== '&')
|
|
10128
|
+
this.raise(this.pos, 'Entity must start with an ampersand');
|
|
10129
|
+
let startPos = ++this.pos;
|
|
10130
|
+
while (this.pos < this.input.length && count++ < 10) {
|
|
10131
|
+
ch = this.input[this.pos++];
|
|
10132
|
+
if (ch === ';') {
|
|
10133
|
+
if (str[0] === '#') {
|
|
10134
|
+
if (str[1] === 'x') {
|
|
10135
|
+
str = str.substr(2);
|
|
10136
|
+
if (hexNumber.test(str))
|
|
10137
|
+
entity = String.fromCharCode(parseInt(str, 16));
|
|
10138
|
+
} else {
|
|
10139
|
+
str = str.substr(1);
|
|
10140
|
+
if (decimalNumber.test(str))
|
|
10141
|
+
entity = String.fromCharCode(parseInt(str, 10));
|
|
10142
|
+
}
|
|
10143
|
+
} else {
|
|
10144
|
+
entity = XHTMLEntities[str];
|
|
10145
|
+
}
|
|
10146
|
+
break;
|
|
10147
|
+
}
|
|
10148
|
+
str += ch;
|
|
10149
|
+
}
|
|
10150
|
+
if (!entity) {
|
|
10151
|
+
this.pos = startPos;
|
|
10152
|
+
return '&';
|
|
10153
|
+
}
|
|
10154
|
+
return entity;
|
|
10155
|
+
}
|
|
10225
10156
|
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
node.name = this.jsx_parseIdentifier();
|
|
10233
|
-
return this.finishNode(node, 'JSXNamespacedName');
|
|
10234
|
-
}
|
|
10157
|
+
// Read a JSX identifier (valid tag or attribute name).
|
|
10158
|
+
//
|
|
10159
|
+
// Optimized version since JSX identifiers can't contain
|
|
10160
|
+
// escape characters and so can be read as single slice.
|
|
10161
|
+
// Also assumes that first character was already checked
|
|
10162
|
+
// by isIdentifierStart in readToken.
|
|
10235
10163
|
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
|
|
10244
|
-
this.unexpected();
|
|
10245
|
-
}
|
|
10246
|
-
while (this.eat(tt.dot)) {
|
|
10247
|
-
let newNode = this.startNodeAt(startPos, startLoc);
|
|
10248
|
-
newNode.object = node;
|
|
10249
|
-
newNode.property = this.jsx_parseIdentifier();
|
|
10250
|
-
node = this.finishNode(newNode, 'JSXMemberExpression');
|
|
10251
|
-
}
|
|
10252
|
-
return node;
|
|
10253
|
-
}
|
|
10164
|
+
jsx_readWord() {
|
|
10165
|
+
let ch, start = this.pos;
|
|
10166
|
+
do {
|
|
10167
|
+
ch = this.input.charCodeAt(++this.pos);
|
|
10168
|
+
} while (isIdentifierChar(ch) || ch === 45); // '-'
|
|
10169
|
+
return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
|
|
10170
|
+
}
|
|
10254
10171
|
|
|
10255
|
-
|
|
10172
|
+
// Parse next token as JSX identifier
|
|
10256
10173
|
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10174
|
+
jsx_parseIdentifier() {
|
|
10175
|
+
let node = this.startNode();
|
|
10176
|
+
if (this.type === tok.jsxName)
|
|
10177
|
+
node.name = this.value;
|
|
10178
|
+
else if (this.type.keyword)
|
|
10179
|
+
node.name = this.type.keyword;
|
|
10180
|
+
else
|
|
10181
|
+
this.unexpected();
|
|
10182
|
+
this.next();
|
|
10183
|
+
return this.finishNode(node, 'JSXIdentifier');
|
|
10184
|
+
}
|
|
10264
10185
|
|
|
10265
|
-
|
|
10266
|
-
case tt.string:
|
|
10267
|
-
return this.parseExprAtom();
|
|
10186
|
+
// Parse namespaced identifier.
|
|
10268
10187
|
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10188
|
+
jsx_parseNamespacedName() {
|
|
10189
|
+
let startPos = this.start, startLoc = this.startLoc;
|
|
10190
|
+
let name = this.jsx_parseIdentifier();
|
|
10191
|
+
if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
|
|
10192
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
10193
|
+
node.namespace = name;
|
|
10194
|
+
node.name = this.jsx_parseIdentifier();
|
|
10195
|
+
return this.finishNode(node, 'JSXNamespacedName');
|
|
10196
|
+
}
|
|
10273
10197
|
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
// at the beginning of the next one (right brace).
|
|
10198
|
+
// Parses element name in any form - namespaced, member
|
|
10199
|
+
// or single identifier.
|
|
10277
10200
|
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10201
|
+
jsx_parseElementName() {
|
|
10202
|
+
if (this.type === tok.jsxTagEnd) return '';
|
|
10203
|
+
let startPos = this.start, startLoc = this.startLoc;
|
|
10204
|
+
let node = this.jsx_parseNamespacedName();
|
|
10205
|
+
if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
|
|
10206
|
+
this.unexpected();
|
|
10207
|
+
}
|
|
10208
|
+
while (this.eat(tt.dot)) {
|
|
10209
|
+
let newNode = this.startNodeAt(startPos, startLoc);
|
|
10210
|
+
newNode.object = node;
|
|
10211
|
+
newNode.property = this.jsx_parseIdentifier();
|
|
10212
|
+
node = this.finishNode(newNode, 'JSXMemberExpression');
|
|
10213
|
+
}
|
|
10214
|
+
return node;
|
|
10215
|
+
}
|
|
10282
10216
|
|
|
10283
|
-
|
|
10217
|
+
// Parses any type of JSX attribute value.
|
|
10284
10218
|
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
return this.finishNode(node, 'JSXExpressionContainer');
|
|
10293
|
-
}
|
|
10219
|
+
jsx_parseAttributeValue() {
|
|
10220
|
+
switch (this.type) {
|
|
10221
|
+
case tt.braceL:
|
|
10222
|
+
let node = this.jsx_parseExpressionContainer();
|
|
10223
|
+
if (node.expression.type === 'JSXEmptyExpression')
|
|
10224
|
+
this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
|
|
10225
|
+
return node;
|
|
10294
10226
|
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
let node = this.startNode();
|
|
10299
|
-
if (this.eat(tt.braceL)) {
|
|
10300
|
-
this.expect(tt.ellipsis);
|
|
10301
|
-
node.argument = this.parseMaybeAssign();
|
|
10302
|
-
this.expect(tt.braceR);
|
|
10303
|
-
return this.finishNode(node, 'JSXSpreadAttribute');
|
|
10304
|
-
}
|
|
10305
|
-
node.name = this.jsx_parseNamespacedName();
|
|
10306
|
-
node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
|
|
10307
|
-
return this.finishNode(node, 'JSXAttribute');
|
|
10308
|
-
}
|
|
10227
|
+
case tok.jsxTagStart:
|
|
10228
|
+
case tt.string:
|
|
10229
|
+
return this.parseExprAtom();
|
|
10309
10230
|
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
node.attributes = [];
|
|
10315
|
-
let nodeName = this.jsx_parseElementName();
|
|
10316
|
-
if (nodeName) node.name = nodeName;
|
|
10317
|
-
while (this.type !== tt.slash && this.type !== tok.jsxTagEnd)
|
|
10318
|
-
node.attributes.push(this.jsx_parseAttribute());
|
|
10319
|
-
node.selfClosing = this.eat(tt.slash);
|
|
10320
|
-
this.expect(tok.jsxTagEnd);
|
|
10321
|
-
return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
|
|
10322
|
-
}
|
|
10231
|
+
default:
|
|
10232
|
+
this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
|
|
10233
|
+
}
|
|
10234
|
+
}
|
|
10323
10235
|
|
|
10324
|
-
|
|
10236
|
+
// JSXEmptyExpression is unique type since it doesn't actually parse anything,
|
|
10237
|
+
// and so it should start at the end of last read token (left brace) and finish
|
|
10238
|
+
// at the beginning of the next one (right brace).
|
|
10325
10239
|
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
this.expect(tok.jsxTagEnd);
|
|
10331
|
-
return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
|
|
10332
|
-
}
|
|
10240
|
+
jsx_parseEmptyExpression() {
|
|
10241
|
+
let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
|
|
10242
|
+
return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
|
|
10243
|
+
}
|
|
10333
10244
|
|
|
10334
|
-
|
|
10335
|
-
// (starting after '<'), attributes, contents and closing tag.
|
|
10336
|
-
|
|
10337
|
-
jsx_parseElementAt(startPos, startLoc) {
|
|
10338
|
-
let node = this.startNodeAt(startPos, startLoc);
|
|
10339
|
-
let children = [];
|
|
10340
|
-
let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
|
|
10341
|
-
let closingElement = null;
|
|
10342
|
-
|
|
10343
|
-
if (!openingElement.selfClosing) {
|
|
10344
|
-
contents: for (;;) {
|
|
10345
|
-
switch (this.type) {
|
|
10346
|
-
case tok.jsxTagStart:
|
|
10347
|
-
startPos = this.start; startLoc = this.startLoc;
|
|
10348
|
-
this.next();
|
|
10349
|
-
if (this.eat(tt.slash)) {
|
|
10350
|
-
closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
|
|
10351
|
-
break contents;
|
|
10352
|
-
}
|
|
10353
|
-
children.push(this.jsx_parseElementAt(startPos, startLoc));
|
|
10354
|
-
break;
|
|
10245
|
+
// Parses JSX expression enclosed into curly brackets.
|
|
10355
10246
|
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10247
|
+
jsx_parseExpressionContainer() {
|
|
10248
|
+
let node = this.startNode();
|
|
10249
|
+
this.next();
|
|
10250
|
+
node.expression = this.type === tt.braceR
|
|
10251
|
+
? this.jsx_parseEmptyExpression()
|
|
10252
|
+
: this.parseExpression();
|
|
10253
|
+
this.expect(tt.braceR);
|
|
10254
|
+
return this.finishNode(node, 'JSXExpressionContainer');
|
|
10255
|
+
}
|
|
10256
|
+
|
|
10257
|
+
// Parses following JSX attribute name-value pair.
|
|
10258
|
+
|
|
10259
|
+
jsx_parseAttribute() {
|
|
10260
|
+
let node = this.startNode();
|
|
10261
|
+
if (this.eat(tt.braceL)) {
|
|
10262
|
+
this.expect(tt.ellipsis);
|
|
10263
|
+
node.argument = this.parseMaybeAssign();
|
|
10264
|
+
this.expect(tt.braceR);
|
|
10265
|
+
return this.finishNode(node, 'JSXSpreadAttribute');
|
|
10266
|
+
}
|
|
10267
|
+
node.name = this.jsx_parseNamespacedName();
|
|
10268
|
+
node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
|
|
10269
|
+
return this.finishNode(node, 'JSXAttribute');
|
|
10270
|
+
}
|
|
10271
|
+
|
|
10272
|
+
// Parses JSX opening tag starting after '<'.
|
|
10273
|
+
|
|
10274
|
+
jsx_parseOpeningElementAt(startPos, startLoc) {
|
|
10275
|
+
let node = this.startNodeAt(startPos, startLoc);
|
|
10276
|
+
node.attributes = [];
|
|
10277
|
+
let nodeName = this.jsx_parseElementName();
|
|
10278
|
+
if (nodeName) node.name = nodeName;
|
|
10279
|
+
while (this.type !== tt.slash && this.type !== tok.jsxTagEnd)
|
|
10280
|
+
node.attributes.push(this.jsx_parseAttribute());
|
|
10281
|
+
node.selfClosing = this.eat(tt.slash);
|
|
10282
|
+
this.expect(tok.jsxTagEnd);
|
|
10283
|
+
return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
|
|
10284
|
+
}
|
|
10285
|
+
|
|
10286
|
+
// Parses JSX closing tag starting after '</'.
|
|
10287
|
+
|
|
10288
|
+
jsx_parseClosingElementAt(startPos, startLoc) {
|
|
10289
|
+
let node = this.startNodeAt(startPos, startLoc);
|
|
10290
|
+
let nodeName = this.jsx_parseElementName();
|
|
10291
|
+
if (nodeName) node.name = nodeName;
|
|
10292
|
+
this.expect(tok.jsxTagEnd);
|
|
10293
|
+
return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
|
|
10294
|
+
}
|
|
10295
|
+
|
|
10296
|
+
// Parses entire JSX element, including it's opening tag
|
|
10297
|
+
// (starting after '<'), attributes, contents and closing tag.
|
|
10298
|
+
|
|
10299
|
+
jsx_parseElementAt(startPos, startLoc) {
|
|
10300
|
+
let node = this.startNodeAt(startPos, startLoc);
|
|
10301
|
+
let children = [];
|
|
10302
|
+
let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
|
|
10303
|
+
let closingElement = null;
|
|
10304
|
+
|
|
10305
|
+
if (!openingElement.selfClosing) {
|
|
10306
|
+
contents: for (;;) {
|
|
10307
|
+
switch (this.type) {
|
|
10308
|
+
case tok.jsxTagStart:
|
|
10309
|
+
startPos = this.start; startLoc = this.startLoc;
|
|
10310
|
+
this.next();
|
|
10311
|
+
if (this.eat(tt.slash)) {
|
|
10312
|
+
closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
|
|
10313
|
+
break contents;
|
|
10314
|
+
}
|
|
10315
|
+
children.push(this.jsx_parseElementAt(startPos, startLoc));
|
|
10316
|
+
break;
|
|
10359
10317
|
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10318
|
+
case tok.jsxText:
|
|
10319
|
+
children.push(this.parseExprAtom());
|
|
10320
|
+
break;
|
|
10363
10321
|
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
}
|
|
10368
|
-
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
|
10369
|
-
this.raise(
|
|
10370
|
-
closingElement.start,
|
|
10371
|
-
'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
|
|
10372
|
-
}
|
|
10373
|
-
}
|
|
10374
|
-
let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
|
|
10375
|
-
|
|
10376
|
-
node['opening' + fragmentOrElement] = openingElement;
|
|
10377
|
-
node['closing' + fragmentOrElement] = closingElement;
|
|
10378
|
-
node.children = children;
|
|
10379
|
-
if (this.type === tt.relational && this.value === "<") {
|
|
10380
|
-
this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
|
|
10381
|
-
}
|
|
10382
|
-
return this.finishNode(node, 'JSX' + fragmentOrElement);
|
|
10383
|
-
}
|
|
10322
|
+
case tt.braceL:
|
|
10323
|
+
children.push(this.jsx_parseExpressionContainer());
|
|
10324
|
+
break;
|
|
10384
10325
|
|
|
10385
|
-
|
|
10326
|
+
default:
|
|
10327
|
+
this.unexpected();
|
|
10328
|
+
}
|
|
10329
|
+
}
|
|
10330
|
+
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
|
|
10331
|
+
this.raise(
|
|
10332
|
+
closingElement.start,
|
|
10333
|
+
'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
|
|
10386
10337
|
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10338
|
+
node['opening' + fragmentOrElement] = openingElement;
|
|
10339
|
+
node['closing' + fragmentOrElement] = closingElement;
|
|
10340
|
+
node.children = children;
|
|
10341
|
+
if (this.type === tt.relational && this.value === "<") {
|
|
10342
|
+
this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
|
|
10343
|
+
}
|
|
10344
|
+
return this.finishNode(node, 'JSX' + fragmentOrElement);
|
|
10345
|
+
}
|
|
10392
10346
|
|
|
10393
|
-
|
|
10347
|
+
// Parse JSX text
|
|
10394
10348
|
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10349
|
+
jsx_parseText() {
|
|
10350
|
+
let node = this.parseLiteral(this.value);
|
|
10351
|
+
node.type = "JSXText";
|
|
10352
|
+
return node;
|
|
10353
|
+
}
|
|
10400
10354
|
|
|
10401
|
-
|
|
10402
|
-
if (this.type === tok.jsxText)
|
|
10403
|
-
return this.jsx_parseText();
|
|
10404
|
-
else if (this.type === tok.jsxTagStart)
|
|
10405
|
-
return this.jsx_parseElement();
|
|
10406
|
-
else
|
|
10407
|
-
return super.parseExprAtom(refShortHandDefaultPos);
|
|
10408
|
-
}
|
|
10355
|
+
// Parses entire JSX element from current position.
|
|
10409
10356
|
|
|
10410
|
-
|
|
10411
|
-
|
|
10357
|
+
jsx_parseElement() {
|
|
10358
|
+
let startPos = this.start, startLoc = this.startLoc;
|
|
10359
|
+
this.next();
|
|
10360
|
+
return this.jsx_parseElementAt(startPos, startLoc);
|
|
10361
|
+
}
|
|
10412
10362
|
|
|
10413
|
-
|
|
10363
|
+
parseExprAtom(refShortHandDefaultPos) {
|
|
10364
|
+
if (this.type === tok.jsxText)
|
|
10365
|
+
return this.jsx_parseText();
|
|
10366
|
+
else if (this.type === tok.jsxTagStart)
|
|
10367
|
+
return this.jsx_parseElement();
|
|
10368
|
+
else
|
|
10369
|
+
return super.parseExprAtom(refShortHandDefaultPos);
|
|
10370
|
+
}
|
|
10414
10371
|
|
|
10415
|
-
|
|
10416
|
-
|
|
10372
|
+
readToken(code) {
|
|
10373
|
+
let context = this.curContext();
|
|
10417
10374
|
|
|
10418
|
-
|
|
10419
|
-
++this.pos;
|
|
10420
|
-
return this.finishToken(tok.jsxTagEnd);
|
|
10421
|
-
}
|
|
10375
|
+
if (context === tc_expr) return this.jsx_readToken();
|
|
10422
10376
|
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
}
|
|
10377
|
+
if (context === tc_oTag || context === tc_cTag) {
|
|
10378
|
+
if (isIdentifierStart(code)) return this.jsx_readWord();
|
|
10426
10379
|
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
return super.readToken(code);
|
|
10432
|
-
}
|
|
10380
|
+
if (code == 62) {
|
|
10381
|
+
++this.pos;
|
|
10382
|
+
return this.finishToken(tok.jsxTagEnd);
|
|
10383
|
+
}
|
|
10433
10384
|
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);
|
|
10438
|
-
else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);
|
|
10439
|
-
else super.updateContext(prevType);
|
|
10440
|
-
this.exprAllowed = true;
|
|
10441
|
-
} else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
|
|
10442
|
-
this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
|
|
10443
|
-
this.context.push(tc_cTag); // reconsider as closing tag context
|
|
10444
|
-
this.exprAllowed = false;
|
|
10445
|
-
} else {
|
|
10446
|
-
return super.updateContext(prevType);
|
|
10447
|
-
}
|
|
10448
|
-
}
|
|
10449
|
-
};
|
|
10450
|
-
}
|
|
10451
|
-
} (acornJsx));
|
|
10385
|
+
if ((code === 34 || code === 39) && context == tc_oTag)
|
|
10386
|
+
return this.jsx_readString(code);
|
|
10387
|
+
}
|
|
10452
10388
|
|
|
10453
|
-
|
|
10454
|
-
|
|
10389
|
+
if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
|
|
10390
|
+
++this.pos;
|
|
10391
|
+
return this.finishToken(tok.jsxTagStart);
|
|
10392
|
+
}
|
|
10393
|
+
return super.readToken(code);
|
|
10394
|
+
}
|
|
10395
|
+
|
|
10396
|
+
updateContext(prevType) {
|
|
10397
|
+
if (this.type == tt.braceL) {
|
|
10398
|
+
var curContext = this.curContext();
|
|
10399
|
+
if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);
|
|
10400
|
+
else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);
|
|
10401
|
+
else super.updateContext(prevType);
|
|
10402
|
+
this.exprAllowed = true;
|
|
10403
|
+
} else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
|
|
10404
|
+
this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
|
|
10405
|
+
this.context.push(tc_cTag); // reconsider as closing tag context
|
|
10406
|
+
this.exprAllowed = false;
|
|
10407
|
+
} else {
|
|
10408
|
+
return super.updateContext(prevType);
|
|
10409
|
+
}
|
|
10410
|
+
}
|
|
10411
|
+
};
|
|
10412
|
+
}
|
|
10455
10413
|
|
|
10456
10414
|
var unicode$3 = {};
|
|
10457
10415
|
|
|
@@ -18396,7 +18354,7 @@ function getParser(moduleURL) {
|
|
|
18396
18354
|
}
|
|
18397
18355
|
|
|
18398
18356
|
return {
|
|
18399
|
-
parser: Parser$2.extend(
|
|
18357
|
+
parser: Parser$2.extend(acornJsx()),
|
|
18400
18358
|
config: {
|
|
18401
18359
|
// https://github.com/acornjs/acorn/issues/829#issuecomment-1172586171
|
|
18402
18360
|
...base$1,
|
|
@@ -18603,7 +18561,7 @@ function parseJsx(moduleURL) {
|
|
|
18603
18561
|
const hasOwnObservedAttributes = undefined;
|
|
18604
18562
|
let inferredObservability = false;
|
|
18605
18563
|
let observedAttributes = [];
|
|
18606
|
-
let tree = Parser$2.extend(
|
|
18564
|
+
let tree = Parser$2.extend(acornJsx()).parse(moduleContents, {
|
|
18607
18565
|
ecmaVersion: 'latest',
|
|
18608
18566
|
sourceType: 'module'
|
|
18609
18567
|
});
|
|
@@ -18728,7 +18686,7 @@ function parseJsx(moduleURL) {
|
|
|
18728
18686
|
`;
|
|
18729
18687
|
/* eslint-enable indent */
|
|
18730
18688
|
|
|
18731
|
-
tree = Parser$2.extend(
|
|
18689
|
+
tree = Parser$2.extend(acornJsx()).parse(newModuleContents, {
|
|
18732
18690
|
ecmaVersion: 'latest',
|
|
18733
18691
|
sourceType: 'module'
|
|
18734
18692
|
});
|
package/package.json
CHANGED
package/src/jsx-loader.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as acorn from 'acorn';
|
|
|
4
4
|
import * as walk from 'acorn-walk';
|
|
5
5
|
import { generate } from '@projectevergreen/escodegen-esm';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
-
import jsx from 'acorn-jsx';
|
|
7
|
+
import jsx from '@projectevergreen/acorn-jsx-esm';
|
|
8
8
|
import { parse, parseFragment, serialize } from 'parse5';
|
|
9
9
|
|
|
10
10
|
const jsxRegex = /\.(jsx)$/;
|