@vue/compiler-sfc 3.5.42 → 3.5.44
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/compiler-sfc.cjs.js +155 -20
- package/dist/compiler-sfc.esm-browser.js +431 -98
- package/package.json +10 -10
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.5.
|
|
2
|
+
* @vue/compiler-sfc v3.5.44
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -157,7 +157,7 @@ function parseCssVars(sfc) {
|
|
|
157
157
|
const vars = [];
|
|
158
158
|
sfc.styles.forEach((style) => {
|
|
159
159
|
let match;
|
|
160
|
-
const content = style.content
|
|
160
|
+
const content = stripComments$2(style.content);
|
|
161
161
|
while (match = vBindRE.exec(content)) {
|
|
162
162
|
const start = match.index + match[0].length;
|
|
163
163
|
const end = lexBinding(content, start);
|
|
@@ -171,6 +171,80 @@ function parseCssVars(sfc) {
|
|
|
171
171
|
});
|
|
172
172
|
return vars;
|
|
173
173
|
}
|
|
174
|
+
const cssSpecialRE = /[/"'\\(]/g;
|
|
175
|
+
function stripComments$2(content) {
|
|
176
|
+
const len = content.length;
|
|
177
|
+
let out = "";
|
|
178
|
+
let last = 0;
|
|
179
|
+
let i = 0;
|
|
180
|
+
cssSpecialRE.lastIndex = 0;
|
|
181
|
+
while (cssSpecialRE.test(content)) {
|
|
182
|
+
i = cssSpecialRE.lastIndex - 1;
|
|
183
|
+
const c = content.charCodeAt(i);
|
|
184
|
+
if (c === 47) {
|
|
185
|
+
const next = content.charCodeAt(i + 1);
|
|
186
|
+
if (next === 42 /* Asterisk */) {
|
|
187
|
+
out += content.slice(last, i);
|
|
188
|
+
const end = content.indexOf("*/", i + 2);
|
|
189
|
+
i = last = end === -1 ? len : end + 2;
|
|
190
|
+
} else if (next === 47) {
|
|
191
|
+
out += content.slice(last, i);
|
|
192
|
+
i += 2;
|
|
193
|
+
while (i < len && !isNewline(content.charCodeAt(i))) i++;
|
|
194
|
+
last = i;
|
|
195
|
+
} else {
|
|
196
|
+
i++;
|
|
197
|
+
}
|
|
198
|
+
} else if (c === 34 || c === 39) {
|
|
199
|
+
i = skipString(content, i + 1, c);
|
|
200
|
+
} else if (c === 92 /* Backslash */) {
|
|
201
|
+
i += 2;
|
|
202
|
+
} else if (isUrlFunction(content, i)) {
|
|
203
|
+
i = skipUrl(content, i + 1);
|
|
204
|
+
} else {
|
|
205
|
+
i++;
|
|
206
|
+
}
|
|
207
|
+
cssSpecialRE.lastIndex = i;
|
|
208
|
+
}
|
|
209
|
+
return last === 0 ? content : out + content.slice(last);
|
|
210
|
+
}
|
|
211
|
+
function skipString(s, i, quote) {
|
|
212
|
+
while (i < s.length) {
|
|
213
|
+
const c = s.charCodeAt(i);
|
|
214
|
+
if (c === quote) return i + 1;
|
|
215
|
+
if (isNewline(c)) return i;
|
|
216
|
+
if (c === 92 /* Backslash */) {
|
|
217
|
+
i += s.charCodeAt(i + 1) === 13 && s.charCodeAt(i + 2) === 10 ? 3 : 2;
|
|
218
|
+
} else {
|
|
219
|
+
i++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return i;
|
|
223
|
+
}
|
|
224
|
+
function isUrlFunction(s, i) {
|
|
225
|
+
const prev = s.charCodeAt(i - 4);
|
|
226
|
+
return (s.charCodeAt(i - 3) | 32) === 117 /* LowerU */ && (s.charCodeAt(i - 2) | 32) === 114 /* LowerR */ && (s.charCodeAt(i - 1) | 32) === 108 /* LowerL */ && prev !== 92 /* Backslash */ && !isIdentChar(prev);
|
|
227
|
+
}
|
|
228
|
+
function skipUrl(s, i) {
|
|
229
|
+
while (isWhitespace(s.charCodeAt(i))) i++;
|
|
230
|
+
const c = s.charCodeAt(i);
|
|
231
|
+
if (c === 34 || c === 39) return i;
|
|
232
|
+
while (i < s.length) {
|
|
233
|
+
const c2 = s.charCodeAt(i);
|
|
234
|
+
if (c2 === 41 /* RightParen */) return i + 1;
|
|
235
|
+
i += c2 === 92 /* Backslash */ ? 2 : 1;
|
|
236
|
+
}
|
|
237
|
+
return i;
|
|
238
|
+
}
|
|
239
|
+
function isIdentChar(c) {
|
|
240
|
+
return c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 45 || c === 95 /* Underscore */ || c >= 128;
|
|
241
|
+
}
|
|
242
|
+
function isNewline(c) {
|
|
243
|
+
return c === 10 || c === 13;
|
|
244
|
+
}
|
|
245
|
+
function isWhitespace(c) {
|
|
246
|
+
return c === 32 || c === 9 || c === 12 || isNewline(c);
|
|
247
|
+
}
|
|
174
248
|
function lexBinding(content, start) {
|
|
175
249
|
let state = 0 /* inParens */;
|
|
176
250
|
let parenDepth = 0;
|
|
@@ -250,12 +324,7 @@ function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
|
|
|
250
324
|
return `
|
|
251
325
|
import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
|
|
252
326
|
const __injectCSSVars__ = () => {
|
|
253
|
-
${genCssVarsCode(
|
|
254
|
-
cssVars,
|
|
255
|
-
bindings,
|
|
256
|
-
id,
|
|
257
|
-
isProd
|
|
258
|
-
)}}
|
|
327
|
+
${genCssVarsCode(cssVars, bindings, id, isProd)}}
|
|
259
328
|
const __setup__ = ${defaultVar}.setup
|
|
260
329
|
${defaultVar}.setup = __setup__
|
|
261
330
|
? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
|
|
@@ -7093,8 +7162,9 @@ function requireParser$2 () {
|
|
|
7093
7162
|
return indexes;
|
|
7094
7163
|
}
|
|
7095
7164
|
function uniqs() {
|
|
7096
|
-
|
|
7097
|
-
|
|
7165
|
+
// A Set keeps the first-occurrence order the previous filter/indexOf pass
|
|
7166
|
+
// produced, without its quadratic cost on long index lists.
|
|
7167
|
+
return Array.from(new Set(Array.prototype.concat.apply([], arguments)));
|
|
7098
7168
|
}
|
|
7099
7169
|
var Parser = /** @class */ (function () {
|
|
7100
7170
|
function Parser(rule, options) {
|
|
@@ -7139,6 +7209,11 @@ function requireParser$2 () {
|
|
|
7139
7209
|
attr.push(this.currToken);
|
|
7140
7210
|
this.position++;
|
|
7141
7211
|
}
|
|
7212
|
+
if (!this.currToken) {
|
|
7213
|
+
// Ran off the end of the token stream: the attribute was never closed.
|
|
7214
|
+
// Point at the opening bracket, which is where the author needs to look.
|
|
7215
|
+
return this.expected("closing square bracket", startingToken[tokenize_1.FIELDS.START_POS]);
|
|
7216
|
+
}
|
|
7142
7217
|
if (this.currToken[tokenize_1.FIELDS.TYPE] !== tokens.closeSquare) {
|
|
7143
7218
|
return this.expected("closing square bracket", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
7144
7219
|
}
|
|
@@ -7199,7 +7274,7 @@ function requireParser$2 () {
|
|
|
7199
7274
|
}
|
|
7200
7275
|
if (commentBefore) {
|
|
7201
7276
|
(0, util_1.ensureObject)(node, "raws", "spaces", "attribute");
|
|
7202
|
-
node.raws.spaces.attribute.before =
|
|
7277
|
+
node.raws.spaces.attribute.before = commentBefore;
|
|
7203
7278
|
commentBefore = "";
|
|
7204
7279
|
}
|
|
7205
7280
|
node.namespace = (node.namespace || "") + content;
|
|
@@ -7623,7 +7698,21 @@ function requireParser$2 () {
|
|
|
7623
7698
|
return this.error("Unexpected '|'.", this.currToken[tokenize_1.FIELDS.START_POS]);
|
|
7624
7699
|
};
|
|
7625
7700
|
Parser.prototype.namespace = function () {
|
|
7626
|
-
var
|
|
7701
|
+
var prev = this.prevToken;
|
|
7702
|
+
// Only treat the previous token as a namespace prefix when it can actually
|
|
7703
|
+
// be one (a type/word or the universal `*`). A comment, comma, combinator
|
|
7704
|
+
// or whitespace before `|` means an empty namespace, not a prefix.
|
|
7705
|
+
var before = prev &&
|
|
7706
|
+
(prev[tokenize_1.FIELDS.TYPE] === tokens.word ||
|
|
7707
|
+
prev[tokenize_1.FIELDS.TYPE] === tokens.asterisk ||
|
|
7708
|
+
prev[tokenize_1.FIELDS.TYPE] === tokens.ampersand)
|
|
7709
|
+
? this.content(prev)
|
|
7710
|
+
: true;
|
|
7711
|
+
if (!this.nextToken) {
|
|
7712
|
+
// A trailing `|` with nothing after it. `unexpectedPipe` reports against
|
|
7713
|
+
// `currToken`, which is the pipe itself and always present here.
|
|
7714
|
+
return this.unexpectedPipe();
|
|
7715
|
+
}
|
|
7627
7716
|
if (this.nextToken[tokenize_1.FIELDS.TYPE] === tokens.word) {
|
|
7628
7717
|
this.position++;
|
|
7629
7718
|
return this.word(before);
|
|
@@ -7653,6 +7742,7 @@ function requireParser$2 () {
|
|
|
7653
7742
|
Parser.prototype.parentheses = function () {
|
|
7654
7743
|
var last = this.current.last;
|
|
7655
7744
|
var unbalanced = 1;
|
|
7745
|
+
var openingToken = this.currToken;
|
|
7656
7746
|
this.position++;
|
|
7657
7747
|
if (last && last.type === types.PSEUDO) {
|
|
7658
7748
|
var selector = new selector_1.default({
|
|
@@ -7722,7 +7812,9 @@ function requireParser$2 () {
|
|
|
7722
7812
|
}
|
|
7723
7813
|
}
|
|
7724
7814
|
if (unbalanced) {
|
|
7725
|
-
|
|
7815
|
+
// `currToken` is undefined when the token stream ran out before the
|
|
7816
|
+
// parenthesis was closed; fall back to the opening one.
|
|
7817
|
+
return this.expected("closing parenthesis", (this.currToken || openingToken)[tokenize_1.FIELDS.START_POS]);
|
|
7726
7818
|
}
|
|
7727
7819
|
};
|
|
7728
7820
|
Parser.prototype.pseudo = function () {
|
|
@@ -7827,8 +7919,14 @@ function requireParser$2 () {
|
|
|
7827
7919
|
// Eliminate Sass interpolations from the list of id indexes
|
|
7828
7920
|
var interpolations = indexesOf(word, "#{");
|
|
7829
7921
|
if (interpolations.length) {
|
|
7830
|
-
|
|
7922
|
+
var interpolationIndexes_1 = new Set(interpolations);
|
|
7923
|
+
hasId = hasId.filter(function (hashIndex) { return !interpolationIndexes_1.has(hashIndex); });
|
|
7831
7924
|
}
|
|
7925
|
+
// Membership tests are built once. Scanning the arrays per index would make
|
|
7926
|
+
// a flat selector such as `.a.a.a...` quadratic in its number of class/id
|
|
7927
|
+
// indexes, which is enough to pin a CPU core on attacker-supplied input.
|
|
7928
|
+
var classIndexes = new Set(hasClass);
|
|
7929
|
+
var idIndexes = new Set(hasId);
|
|
7832
7930
|
var indices = (0, sortAscending_1.default)(uniqs(__spreadArray(__spreadArray([0], __read(hasClass), false), __read(hasId), false)));
|
|
7833
7931
|
indices.forEach(function (ind, i) {
|
|
7834
7932
|
var index = indices[i + 1] || word.length;
|
|
@@ -7840,7 +7938,7 @@ function requireParser$2 () {
|
|
|
7840
7938
|
var current = _this.currToken;
|
|
7841
7939
|
var sourceIndex = current[tokenize_1.FIELDS.START_POS] + indices[i];
|
|
7842
7940
|
var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
|
|
7843
|
-
if (
|
|
7941
|
+
if (classIndexes.has(ind)) {
|
|
7844
7942
|
var classNameOpts = {
|
|
7845
7943
|
value: value.slice(1),
|
|
7846
7944
|
source: source,
|
|
@@ -7848,7 +7946,7 @@ function requireParser$2 () {
|
|
|
7848
7946
|
};
|
|
7849
7947
|
node = new className_1.default(unescapeProp(classNameOpts, "value"));
|
|
7850
7948
|
}
|
|
7851
|
-
else if (
|
|
7949
|
+
else if (idIndexes.has(ind)) {
|
|
7852
7950
|
var idOpts = {
|
|
7853
7951
|
value: value.slice(1),
|
|
7854
7952
|
source: source,
|
|
@@ -23666,6 +23764,7 @@ function resolveExt(filename, fs) {
|
|
|
23666
23764
|
}
|
|
23667
23765
|
const tsConfigCache = createCache();
|
|
23668
23766
|
const tsConfigRefMap = /* @__PURE__ */ new Map();
|
|
23767
|
+
const extendedConfigCache = /* @__PURE__ */ new Map();
|
|
23669
23768
|
function resolveWithTS(containingFile, source, ts2, fs) {
|
|
23670
23769
|
var _a, _b;
|
|
23671
23770
|
const configPath = ts2.findConfigFile(containingFile, fs.fileExists);
|
|
@@ -23739,7 +23838,10 @@ function loadTSConfig(configPath, ts2, fs, visited = /* @__PURE__ */ new Set())
|
|
|
23739
23838
|
parseConfigHost,
|
|
23740
23839
|
path$1.dirname(configPath),
|
|
23741
23840
|
void 0,
|
|
23742
|
-
configPath
|
|
23841
|
+
configPath,
|
|
23842
|
+
void 0,
|
|
23843
|
+
void 0,
|
|
23844
|
+
extendedConfigCache
|
|
23743
23845
|
);
|
|
23744
23846
|
const res = [config];
|
|
23745
23847
|
visited.add(configPath);
|
|
@@ -23762,6 +23864,10 @@ function invalidateTypeCache(filename) {
|
|
|
23762
23864
|
fileToScopeCache.delete(filename);
|
|
23763
23865
|
fileToGlobalScopeCache.delete(filename);
|
|
23764
23866
|
tsConfigCache.delete(filename);
|
|
23867
|
+
if (filename.endsWith(".json")) {
|
|
23868
|
+
extendedConfigCache.clear();
|
|
23869
|
+
tsConfigCache.clear();
|
|
23870
|
+
}
|
|
23765
23871
|
const affectedConfig = tsConfigRefMap.get(filename);
|
|
23766
23872
|
if (affectedConfig) tsConfigCache.delete(affectedConfig);
|
|
23767
23873
|
}
|
|
@@ -25003,11 +25109,18 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
25003
25109
|
const excludedIds = /* @__PURE__ */ new WeakSet();
|
|
25004
25110
|
const parentStack = [];
|
|
25005
25111
|
const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
|
|
25112
|
+
const modelOptionNodes = /* @__PURE__ */ new Set();
|
|
25113
|
+
let currentModelOption = null;
|
|
25006
25114
|
for (const key in ctx.propsDestructuredBindings) {
|
|
25007
25115
|
const { local } = ctx.propsDestructuredBindings[key];
|
|
25008
25116
|
rootScope[local] = true;
|
|
25009
25117
|
propsLocalToPublicMap[local] = key;
|
|
25010
25118
|
}
|
|
25119
|
+
for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
|
|
25120
|
+
for (const node of runtimeOptionNodes) {
|
|
25121
|
+
modelOptionNodes.add(node);
|
|
25122
|
+
}
|
|
25123
|
+
}
|
|
25011
25124
|
function pushScope(isFunctionScope = false) {
|
|
25012
25125
|
const scope = currentScope = Object.create(currentScope);
|
|
25013
25126
|
scopeStack.push(scope);
|
|
@@ -25079,6 +25192,18 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
25079
25192
|
});
|
|
25080
25193
|
}
|
|
25081
25194
|
function rewriteId(id, parent, parentStack2) {
|
|
25195
|
+
if (currentModelOption) {
|
|
25196
|
+
const isDefault = (currentModelOption.type === "ObjectProperty" || currentModelOption.type === "ObjectMethod") && resolveObjectKey(
|
|
25197
|
+
currentModelOption.key,
|
|
25198
|
+
currentModelOption.computed
|
|
25199
|
+
) === "default";
|
|
25200
|
+
ctx.error(
|
|
25201
|
+
`\`${DEFINE_MODEL}()\` prop options cannot reference destructured props because they are hoisted outside of the setup() function.` + (isDefault ? ` Use the props argument of the default factory instead, e.g. default: props => props${shared.genPropsAccessExp(
|
|
25202
|
+
propsLocalToPublicMap[id.name]
|
|
25203
|
+
).slice(`__props`.length)}` : ``),
|
|
25204
|
+
id
|
|
25205
|
+
);
|
|
25206
|
+
}
|
|
25082
25207
|
if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
|
|
25083
25208
|
ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
|
|
25084
25209
|
}
|
|
@@ -25117,6 +25242,9 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
25117
25242
|
if (parent && parent.type.startsWith("TS") && !CompilerDOM.TS_NODE_TYPES.includes(parent.type)) {
|
|
25118
25243
|
return this.skip();
|
|
25119
25244
|
}
|
|
25245
|
+
if (modelOptionNodes.has(node)) {
|
|
25246
|
+
currentModelOption = node;
|
|
25247
|
+
}
|
|
25120
25248
|
checkUsage(node, "watch", vueImportAliases.watch);
|
|
25121
25249
|
checkUsage(node, "toRef", vueImportAliases.toRef);
|
|
25122
25250
|
if (CompilerDOM.isFunctionType(node)) {
|
|
@@ -25162,6 +25290,9 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
25162
25290
|
},
|
|
25163
25291
|
leave(node, parent) {
|
|
25164
25292
|
parent && parentStack.pop();
|
|
25293
|
+
if (node === currentModelOption) {
|
|
25294
|
+
currentModelOption = null;
|
|
25295
|
+
}
|
|
25165
25296
|
if (CompilerDOM.isFunctionType(node)) {
|
|
25166
25297
|
popScope(true);
|
|
25167
25298
|
} else if (node.type === "BlockStatement" && !CompilerDOM.isFunctionType(parent)) {
|
|
@@ -25714,6 +25845,8 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
25714
25845
|
}
|
|
25715
25846
|
if (child.type === "BlockStatement") {
|
|
25716
25847
|
scope.push(child.body);
|
|
25848
|
+
} else if (child.type === "SwitchCase") {
|
|
25849
|
+
scope.push(child.consequent);
|
|
25717
25850
|
}
|
|
25718
25851
|
if (child.type === "AwaitExpression") {
|
|
25719
25852
|
hasAwait = true;
|
|
@@ -25729,8 +25862,10 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
25729
25862
|
);
|
|
25730
25863
|
}
|
|
25731
25864
|
},
|
|
25732
|
-
|
|
25733
|
-
if (node2.type === "BlockStatement"
|
|
25865
|
+
leave(node2) {
|
|
25866
|
+
if (node2.type === "BlockStatement" || node2.type === "SwitchCase") {
|
|
25867
|
+
scope.pop();
|
|
25868
|
+
}
|
|
25734
25869
|
}
|
|
25735
25870
|
});
|
|
25736
25871
|
}
|
|
@@ -26261,7 +26396,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
26261
26396
|
return generator.toJSON();
|
|
26262
26397
|
}
|
|
26263
26398
|
|
|
26264
|
-
const version = "3.5.
|
|
26399
|
+
const version = "3.5.44";
|
|
26265
26400
|
const parseCache = parseCache$1;
|
|
26266
26401
|
const errorMessages = {
|
|
26267
26402
|
...CompilerDOM.errorMessages,
|