@vue/compiler-sfc 3.2.36 → 3.2.37
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 +67 -11
- package/dist/compiler-sfc.esm-browser.js +71 -11
- package/package.json +6 -6
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -109,8 +109,6 @@ function sum (o) {
|
|
|
109
109
|
var hashSum = sum;
|
|
110
110
|
|
|
111
111
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
112
|
-
// match v-bind() with max 2-levels of nested parens.
|
|
113
|
-
const cssVarRE = /v-bind\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
|
|
114
112
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
115
113
|
return `{\n ${vars
|
|
116
114
|
.map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
|
|
@@ -132,31 +130,89 @@ function normalizeExpression(exp) {
|
|
|
132
130
|
}
|
|
133
131
|
return exp;
|
|
134
132
|
}
|
|
133
|
+
const vBindRE = /v-bind\s*\(/g;
|
|
135
134
|
function parseCssVars(sfc) {
|
|
136
135
|
const vars = [];
|
|
137
136
|
sfc.styles.forEach(style => {
|
|
138
137
|
let match;
|
|
139
138
|
// ignore v-bind() in comments /* ... */
|
|
140
139
|
const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
|
|
141
|
-
while ((match =
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
while ((match = vBindRE.exec(content))) {
|
|
141
|
+
const start = match.index + match[0].length;
|
|
142
|
+
const end = lexBinding(content, start);
|
|
143
|
+
if (end !== null) {
|
|
144
|
+
const variable = normalizeExpression(content.slice(start, end));
|
|
145
|
+
if (!vars.includes(variable)) {
|
|
146
|
+
vars.push(variable);
|
|
147
|
+
}
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
150
|
});
|
|
148
151
|
return vars;
|
|
149
152
|
}
|
|
153
|
+
function lexBinding(content, start) {
|
|
154
|
+
let state = 0 /* inParens */;
|
|
155
|
+
let parenDepth = 0;
|
|
156
|
+
for (let i = start; i < content.length; i++) {
|
|
157
|
+
const char = content.charAt(i);
|
|
158
|
+
switch (state) {
|
|
159
|
+
case 0 /* inParens */:
|
|
160
|
+
if (char === `'`) {
|
|
161
|
+
state = 1 /* inSingleQuoteString */;
|
|
162
|
+
}
|
|
163
|
+
else if (char === `"`) {
|
|
164
|
+
state = 2 /* inDoubleQuoteString */;
|
|
165
|
+
}
|
|
166
|
+
else if (char === `(`) {
|
|
167
|
+
parenDepth++;
|
|
168
|
+
}
|
|
169
|
+
else if (char === `)`) {
|
|
170
|
+
if (parenDepth > 0) {
|
|
171
|
+
parenDepth--;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return i;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case 1 /* inSingleQuoteString */:
|
|
179
|
+
if (char === `'`) {
|
|
180
|
+
state = 0 /* inParens */;
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case 2 /* inDoubleQuoteString */:
|
|
184
|
+
if (char === `"`) {
|
|
185
|
+
state = 0 /* inParens */;
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
150
192
|
const cssVarsPlugin = opts => {
|
|
151
193
|
const { id, isProd } = opts;
|
|
152
194
|
return {
|
|
153
195
|
postcssPlugin: 'vue-sfc-vars',
|
|
154
196
|
Declaration(decl) {
|
|
155
197
|
// rewrite CSS variables
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
198
|
+
const value = decl.value;
|
|
199
|
+
if (vBindRE.test(value)) {
|
|
200
|
+
vBindRE.lastIndex = 0;
|
|
201
|
+
let transformed = '';
|
|
202
|
+
let lastIndex = 0;
|
|
203
|
+
let match;
|
|
204
|
+
while ((match = vBindRE.exec(value))) {
|
|
205
|
+
const start = match.index + match[0].length;
|
|
206
|
+
const end = lexBinding(value, start);
|
|
207
|
+
if (end !== null) {
|
|
208
|
+
const variable = normalizeExpression(value.slice(start, end));
|
|
209
|
+
transformed +=
|
|
210
|
+
value.slice(lastIndex, match.index) +
|
|
211
|
+
`var(--${genVarName(id, variable, isProd)})`;
|
|
212
|
+
lastIndex = end + 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
decl.value = transformed + value.slice(lastIndex);
|
|
160
216
|
}
|
|
161
217
|
}
|
|
162
218
|
};
|
|
@@ -4365,7 +4421,7 @@ function compileScript(sfc, options) {
|
|
|
4365
4421
|
if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
|
|
4366
4422
|
const match = filename.match(/([^/\\]+)\.\w+$/);
|
|
4367
4423
|
if (match) {
|
|
4368
|
-
runtimeOptions += `\n
|
|
4424
|
+
runtimeOptions += `\n __name: '${match[1]}',`;
|
|
4369
4425
|
}
|
|
4370
4426
|
}
|
|
4371
4427
|
if (hasInlinedSsrRenderFn) {
|
|
@@ -27716,8 +27716,6 @@ function sum (o) {
|
|
|
27716
27716
|
var hashSum = sum;
|
|
27717
27717
|
|
|
27718
27718
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
27719
|
-
// match v-bind() with max 2-levels of nested parens.
|
|
27720
|
-
const cssVarRE = /v-bind\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
|
|
27721
27719
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
27722
27720
|
return `{\n ${vars
|
|
27723
27721
|
.map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
|
|
@@ -27739,31 +27737,89 @@ function normalizeExpression(exp) {
|
|
|
27739
27737
|
}
|
|
27740
27738
|
return exp;
|
|
27741
27739
|
}
|
|
27740
|
+
const vBindRE = /v-bind\s*\(/g;
|
|
27742
27741
|
function parseCssVars(sfc) {
|
|
27743
27742
|
const vars = [];
|
|
27744
27743
|
sfc.styles.forEach(style => {
|
|
27745
27744
|
let match;
|
|
27746
27745
|
// ignore v-bind() in comments /* ... */
|
|
27747
27746
|
const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
|
|
27748
|
-
while ((match =
|
|
27749
|
-
const
|
|
27750
|
-
|
|
27751
|
-
|
|
27747
|
+
while ((match = vBindRE.exec(content))) {
|
|
27748
|
+
const start = match.index + match[0].length;
|
|
27749
|
+
const end = lexBinding(content, start);
|
|
27750
|
+
if (end !== null) {
|
|
27751
|
+
const variable = normalizeExpression(content.slice(start, end));
|
|
27752
|
+
if (!vars.includes(variable)) {
|
|
27753
|
+
vars.push(variable);
|
|
27754
|
+
}
|
|
27752
27755
|
}
|
|
27753
27756
|
}
|
|
27754
27757
|
});
|
|
27755
27758
|
return vars;
|
|
27756
27759
|
}
|
|
27760
|
+
function lexBinding(content, start) {
|
|
27761
|
+
let state = 0 /* inParens */;
|
|
27762
|
+
let parenDepth = 0;
|
|
27763
|
+
for (let i = start; i < content.length; i++) {
|
|
27764
|
+
const char = content.charAt(i);
|
|
27765
|
+
switch (state) {
|
|
27766
|
+
case 0 /* inParens */:
|
|
27767
|
+
if (char === `'`) {
|
|
27768
|
+
state = 1 /* inSingleQuoteString */;
|
|
27769
|
+
}
|
|
27770
|
+
else if (char === `"`) {
|
|
27771
|
+
state = 2 /* inDoubleQuoteString */;
|
|
27772
|
+
}
|
|
27773
|
+
else if (char === `(`) {
|
|
27774
|
+
parenDepth++;
|
|
27775
|
+
}
|
|
27776
|
+
else if (char === `)`) {
|
|
27777
|
+
if (parenDepth > 0) {
|
|
27778
|
+
parenDepth--;
|
|
27779
|
+
}
|
|
27780
|
+
else {
|
|
27781
|
+
return i;
|
|
27782
|
+
}
|
|
27783
|
+
}
|
|
27784
|
+
break;
|
|
27785
|
+
case 1 /* inSingleQuoteString */:
|
|
27786
|
+
if (char === `'`) {
|
|
27787
|
+
state = 0 /* inParens */;
|
|
27788
|
+
}
|
|
27789
|
+
break;
|
|
27790
|
+
case 2 /* inDoubleQuoteString */:
|
|
27791
|
+
if (char === `"`) {
|
|
27792
|
+
state = 0 /* inParens */;
|
|
27793
|
+
}
|
|
27794
|
+
break;
|
|
27795
|
+
}
|
|
27796
|
+
}
|
|
27797
|
+
return null;
|
|
27798
|
+
}
|
|
27757
27799
|
const cssVarsPlugin = opts => {
|
|
27758
27800
|
const { id, isProd } = opts;
|
|
27759
27801
|
return {
|
|
27760
27802
|
postcssPlugin: 'vue-sfc-vars',
|
|
27761
27803
|
Declaration(decl) {
|
|
27762
27804
|
// rewrite CSS variables
|
|
27763
|
-
|
|
27764
|
-
|
|
27765
|
-
|
|
27766
|
-
|
|
27805
|
+
const value = decl.value;
|
|
27806
|
+
if (vBindRE.test(value)) {
|
|
27807
|
+
vBindRE.lastIndex = 0;
|
|
27808
|
+
let transformed = '';
|
|
27809
|
+
let lastIndex = 0;
|
|
27810
|
+
let match;
|
|
27811
|
+
while ((match = vBindRE.exec(value))) {
|
|
27812
|
+
const start = match.index + match[0].length;
|
|
27813
|
+
const end = lexBinding(value, start);
|
|
27814
|
+
if (end !== null) {
|
|
27815
|
+
const variable = normalizeExpression(value.slice(start, end));
|
|
27816
|
+
transformed +=
|
|
27817
|
+
value.slice(lastIndex, match.index) +
|
|
27818
|
+
`var(--${genVarName(id, variable, isProd)})`;
|
|
27819
|
+
lastIndex = end + 1;
|
|
27820
|
+
}
|
|
27821
|
+
}
|
|
27822
|
+
decl.value = transformed + value.slice(lastIndex);
|
|
27767
27823
|
}
|
|
27768
27824
|
}
|
|
27769
27825
|
};
|
|
@@ -33484,6 +33540,10 @@ const ssrTransformSlotOutlet = (node, context) => {
|
|
|
33484
33540
|
resolveComponentType(parent, context, true) === TRANSITION &&
|
|
33485
33541
|
parent.children.filter(c => c.type === 1 /* ELEMENT */).length === 1) {
|
|
33486
33542
|
method = SSR_RENDER_SLOT_INNER;
|
|
33543
|
+
if (!(context.scopeId && context.slotted !== false)) {
|
|
33544
|
+
args.push('null');
|
|
33545
|
+
}
|
|
33546
|
+
args.push('true');
|
|
33487
33547
|
}
|
|
33488
33548
|
node.ssrCodegenNode = createCallExpression(context.helper(method), args);
|
|
33489
33549
|
}
|
|
@@ -36378,7 +36438,7 @@ function compileScript(sfc, options) {
|
|
|
36378
36438
|
if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
|
|
36379
36439
|
const match = filename.match(/([^/\\]+)\.\w+$/);
|
|
36380
36440
|
if (match) {
|
|
36381
|
-
runtimeOptions += `\n
|
|
36441
|
+
runtimeOptions += `\n __name: '${match[1]}',`;
|
|
36382
36442
|
}
|
|
36383
36443
|
}
|
|
36384
36444
|
if (hasInlinedSsrRenderFn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.37",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "^7.16.4",
|
|
36
|
-
"@vue/compiler-core": "3.2.
|
|
37
|
-
"@vue/compiler-dom": "3.2.
|
|
38
|
-
"@vue/compiler-ssr": "3.2.
|
|
39
|
-
"@vue/reactivity-transform": "3.2.
|
|
40
|
-
"@vue/shared": "3.2.
|
|
36
|
+
"@vue/compiler-core": "3.2.37",
|
|
37
|
+
"@vue/compiler-dom": "3.2.37",
|
|
38
|
+
"@vue/compiler-ssr": "3.2.37",
|
|
39
|
+
"@vue/reactivity-transform": "3.2.37",
|
|
40
|
+
"@vue/shared": "3.2.37",
|
|
41
41
|
"estree-walker": "^2.0.2",
|
|
42
42
|
"magic-string": "^0.25.7",
|
|
43
43
|
"source-map": "^0.6.1",
|