@vue/compiler-sfc 3.4.0-alpha.3 → 3.4.0-beta.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/compiler-sfc.cjs.js +3248 -3139
- package/dist/compiler-sfc.d.ts +10 -9
- package/dist/compiler-sfc.esm-browser.js +1169 -758
- package/package.json +9 -9
|
@@ -7,8 +7,8 @@ const EMPTY_OBJ = Object.freeze({}) ;
|
|
|
7
7
|
const NOOP = () => {
|
|
8
8
|
};
|
|
9
9
|
const NO = () => false;
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
|
|
11
|
+
(key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
12
12
|
const extend = Object.assign;
|
|
13
13
|
const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
14
14
|
const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
|
|
@@ -79,7 +79,7 @@ const slotFlagsText = {
|
|
|
79
79
|
[3]: "FORWARDED"
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
|
|
82
|
+
const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
|
|
83
83
|
const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
|
|
84
84
|
|
|
85
85
|
const range = 2;
|
|
@@ -189,9 +189,11 @@ function normalizeClass(value) {
|
|
|
189
189
|
|
|
190
190
|
const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
|
|
191
191
|
const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
|
|
192
|
+
const MATH_TAGS = "math,maction,annotation,annotation-xml,menclose,merror,mfenced,mfrac,mi,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,semantics,mspace,msqrt,mstyle,msub,msup,msubsup,mtable,mtd,mtext,mtr,munder,munderover";
|
|
192
193
|
const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
193
194
|
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
194
195
|
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
196
|
+
const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
|
|
195
197
|
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
196
198
|
|
|
197
199
|
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
@@ -220,7 +222,7 @@ const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
|
|
|
220
222
|
`accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
|
|
221
223
|
);
|
|
222
224
|
const isKnownSvgAttr = /* @__PURE__ */ makeMap(
|
|
223
|
-
`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
|
|
225
|
+
`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
|
|
224
226
|
);
|
|
225
227
|
|
|
226
228
|
const escapeRE = /["'&<>]/;
|
|
@@ -271,20 +273,29 @@ const replacer = (_key, val) => {
|
|
|
271
273
|
return replacer(_key, val.value);
|
|
272
274
|
} else if (isMap(val)) {
|
|
273
275
|
return {
|
|
274
|
-
[`Map(${val.size})`]: [...val.entries()].reduce(
|
|
275
|
-
entries[
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
[`Map(${val.size})`]: [...val.entries()].reduce(
|
|
277
|
+
(entries, [key, val2], i) => {
|
|
278
|
+
entries[stringifySymbol(key, i) + " =>"] = val2;
|
|
279
|
+
return entries;
|
|
280
|
+
},
|
|
281
|
+
{}
|
|
282
|
+
)
|
|
278
283
|
};
|
|
279
284
|
} else if (isSet(val)) {
|
|
280
285
|
return {
|
|
281
|
-
[`Set(${val.size})`]: [...val.values()]
|
|
286
|
+
[`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
|
282
287
|
};
|
|
288
|
+
} else if (isSymbol$1(val)) {
|
|
289
|
+
return stringifySymbol(val);
|
|
283
290
|
} else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
|
|
284
291
|
return String(val);
|
|
285
292
|
}
|
|
286
293
|
return val;
|
|
287
294
|
};
|
|
295
|
+
const stringifySymbol = (v, i = "") => {
|
|
296
|
+
var _a;
|
|
297
|
+
return isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
|
|
298
|
+
};
|
|
288
299
|
|
|
289
300
|
const FRAGMENT = Symbol(`Fragment` );
|
|
290
301
|
const TELEPORT = Symbol(`Teleport` );
|
|
@@ -374,6 +385,90 @@ function registerRuntimeHelpers(helpers) {
|
|
|
374
385
|
});
|
|
375
386
|
}
|
|
376
387
|
|
|
388
|
+
const Namespaces = {
|
|
389
|
+
"HTML": 0,
|
|
390
|
+
"0": "HTML",
|
|
391
|
+
"SVG": 1,
|
|
392
|
+
"1": "SVG",
|
|
393
|
+
"MATH_ML": 2,
|
|
394
|
+
"2": "MATH_ML"
|
|
395
|
+
};
|
|
396
|
+
const NodeTypes = {
|
|
397
|
+
"ROOT": 0,
|
|
398
|
+
"0": "ROOT",
|
|
399
|
+
"ELEMENT": 1,
|
|
400
|
+
"1": "ELEMENT",
|
|
401
|
+
"TEXT": 2,
|
|
402
|
+
"2": "TEXT",
|
|
403
|
+
"COMMENT": 3,
|
|
404
|
+
"3": "COMMENT",
|
|
405
|
+
"SIMPLE_EXPRESSION": 4,
|
|
406
|
+
"4": "SIMPLE_EXPRESSION",
|
|
407
|
+
"INTERPOLATION": 5,
|
|
408
|
+
"5": "INTERPOLATION",
|
|
409
|
+
"ATTRIBUTE": 6,
|
|
410
|
+
"6": "ATTRIBUTE",
|
|
411
|
+
"DIRECTIVE": 7,
|
|
412
|
+
"7": "DIRECTIVE",
|
|
413
|
+
"COMPOUND_EXPRESSION": 8,
|
|
414
|
+
"8": "COMPOUND_EXPRESSION",
|
|
415
|
+
"IF": 9,
|
|
416
|
+
"9": "IF",
|
|
417
|
+
"IF_BRANCH": 10,
|
|
418
|
+
"10": "IF_BRANCH",
|
|
419
|
+
"FOR": 11,
|
|
420
|
+
"11": "FOR",
|
|
421
|
+
"TEXT_CALL": 12,
|
|
422
|
+
"12": "TEXT_CALL",
|
|
423
|
+
"VNODE_CALL": 13,
|
|
424
|
+
"13": "VNODE_CALL",
|
|
425
|
+
"JS_CALL_EXPRESSION": 14,
|
|
426
|
+
"14": "JS_CALL_EXPRESSION",
|
|
427
|
+
"JS_OBJECT_EXPRESSION": 15,
|
|
428
|
+
"15": "JS_OBJECT_EXPRESSION",
|
|
429
|
+
"JS_PROPERTY": 16,
|
|
430
|
+
"16": "JS_PROPERTY",
|
|
431
|
+
"JS_ARRAY_EXPRESSION": 17,
|
|
432
|
+
"17": "JS_ARRAY_EXPRESSION",
|
|
433
|
+
"JS_FUNCTION_EXPRESSION": 18,
|
|
434
|
+
"18": "JS_FUNCTION_EXPRESSION",
|
|
435
|
+
"JS_CONDITIONAL_EXPRESSION": 19,
|
|
436
|
+
"19": "JS_CONDITIONAL_EXPRESSION",
|
|
437
|
+
"JS_CACHE_EXPRESSION": 20,
|
|
438
|
+
"20": "JS_CACHE_EXPRESSION",
|
|
439
|
+
"JS_BLOCK_STATEMENT": 21,
|
|
440
|
+
"21": "JS_BLOCK_STATEMENT",
|
|
441
|
+
"JS_TEMPLATE_LITERAL": 22,
|
|
442
|
+
"22": "JS_TEMPLATE_LITERAL",
|
|
443
|
+
"JS_IF_STATEMENT": 23,
|
|
444
|
+
"23": "JS_IF_STATEMENT",
|
|
445
|
+
"JS_ASSIGNMENT_EXPRESSION": 24,
|
|
446
|
+
"24": "JS_ASSIGNMENT_EXPRESSION",
|
|
447
|
+
"JS_SEQUENCE_EXPRESSION": 25,
|
|
448
|
+
"25": "JS_SEQUENCE_EXPRESSION",
|
|
449
|
+
"JS_RETURN_STATEMENT": 26,
|
|
450
|
+
"26": "JS_RETURN_STATEMENT"
|
|
451
|
+
};
|
|
452
|
+
const ElementTypes = {
|
|
453
|
+
"ELEMENT": 0,
|
|
454
|
+
"0": "ELEMENT",
|
|
455
|
+
"COMPONENT": 1,
|
|
456
|
+
"1": "COMPONENT",
|
|
457
|
+
"SLOT": 2,
|
|
458
|
+
"2": "SLOT",
|
|
459
|
+
"TEMPLATE": 3,
|
|
460
|
+
"3": "TEMPLATE"
|
|
461
|
+
};
|
|
462
|
+
const ConstantTypes = {
|
|
463
|
+
"NOT_CONSTANT": 0,
|
|
464
|
+
"0": "NOT_CONSTANT",
|
|
465
|
+
"CAN_SKIP_PATCH": 1,
|
|
466
|
+
"1": "CAN_SKIP_PATCH",
|
|
467
|
+
"CAN_HOIST": 2,
|
|
468
|
+
"2": "CAN_HOIST",
|
|
469
|
+
"CAN_STRINGIFY": 3,
|
|
470
|
+
"3": "CAN_STRINGIFY"
|
|
471
|
+
};
|
|
377
472
|
const locStub = {
|
|
378
473
|
start: { line: 1, column: 1, offset: 0 },
|
|
379
474
|
end: { line: 1, column: 1, offset: 0 },
|
|
@@ -1166,7 +1261,9 @@ let Tokenizer$1 = class Tokenizer {
|
|
|
1166
1261
|
this.inRCDATA = false;
|
|
1167
1262
|
/** For disabling RCDATA tags handling */
|
|
1168
1263
|
this.inXML = false;
|
|
1169
|
-
/**
|
|
1264
|
+
/** For disabling interpolation parsing in v-pre */
|
|
1265
|
+
this.inVPre = false;
|
|
1266
|
+
/** Record newline positions for fast line / column calculation */
|
|
1170
1267
|
this.newlines = [];
|
|
1171
1268
|
this.mode = 0;
|
|
1172
1269
|
this.delimiterOpen = defaultDelimitersOpen;
|
|
@@ -1191,6 +1288,7 @@ let Tokenizer$1 = class Tokenizer {
|
|
|
1191
1288
|
this.sectionStart = 0;
|
|
1192
1289
|
this.index = 0;
|
|
1193
1290
|
this.baseState = 1;
|
|
1291
|
+
this.inRCDATA = false;
|
|
1194
1292
|
this.currentSequence = void 0;
|
|
1195
1293
|
this.newlines.length = 0;
|
|
1196
1294
|
this.delimiterOpen = defaultDelimitersOpen;
|
|
@@ -1231,7 +1329,7 @@ let Tokenizer$1 = class Tokenizer {
|
|
|
1231
1329
|
this.sectionStart = this.index;
|
|
1232
1330
|
} else if (c === 38) {
|
|
1233
1331
|
this.startEntity();
|
|
1234
|
-
} else if (c === this.delimiterOpen[0]) {
|
|
1332
|
+
} else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
|
1235
1333
|
this.state = 2;
|
|
1236
1334
|
this.delimiterIndex = 0;
|
|
1237
1335
|
this.stateInterpolationOpen(c);
|
|
@@ -1967,6 +2065,16 @@ let Tokenizer$1 = class Tokenizer {
|
|
|
1967
2065
|
}
|
|
1968
2066
|
};
|
|
1969
2067
|
|
|
2068
|
+
const CompilerDeprecationTypes = {
|
|
2069
|
+
"COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
|
|
2070
|
+
"COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
|
|
2071
|
+
"COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
|
|
2072
|
+
"COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
|
|
2073
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2074
|
+
"COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
|
|
2075
|
+
"COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
|
|
2076
|
+
"COMPILER_FILTERS": "COMPILER_FILTER"
|
|
2077
|
+
};
|
|
1970
2078
|
const deprecationData = {
|
|
1971
2079
|
["COMPILER_IS_ON_ELEMENT"]: {
|
|
1972
2080
|
message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
|
|
@@ -2048,6 +2156,114 @@ function createCompilerError(code, loc, messages, additionalMessage) {
|
|
|
2048
2156
|
error.loc = loc;
|
|
2049
2157
|
return error;
|
|
2050
2158
|
}
|
|
2159
|
+
const ErrorCodes = {
|
|
2160
|
+
"ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
|
|
2161
|
+
"0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
|
|
2162
|
+
"CDATA_IN_HTML_CONTENT": 1,
|
|
2163
|
+
"1": "CDATA_IN_HTML_CONTENT",
|
|
2164
|
+
"DUPLICATE_ATTRIBUTE": 2,
|
|
2165
|
+
"2": "DUPLICATE_ATTRIBUTE",
|
|
2166
|
+
"END_TAG_WITH_ATTRIBUTES": 3,
|
|
2167
|
+
"3": "END_TAG_WITH_ATTRIBUTES",
|
|
2168
|
+
"END_TAG_WITH_TRAILING_SOLIDUS": 4,
|
|
2169
|
+
"4": "END_TAG_WITH_TRAILING_SOLIDUS",
|
|
2170
|
+
"EOF_BEFORE_TAG_NAME": 5,
|
|
2171
|
+
"5": "EOF_BEFORE_TAG_NAME",
|
|
2172
|
+
"EOF_IN_CDATA": 6,
|
|
2173
|
+
"6": "EOF_IN_CDATA",
|
|
2174
|
+
"EOF_IN_COMMENT": 7,
|
|
2175
|
+
"7": "EOF_IN_COMMENT",
|
|
2176
|
+
"EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
|
|
2177
|
+
"8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
|
|
2178
|
+
"EOF_IN_TAG": 9,
|
|
2179
|
+
"9": "EOF_IN_TAG",
|
|
2180
|
+
"INCORRECTLY_CLOSED_COMMENT": 10,
|
|
2181
|
+
"10": "INCORRECTLY_CLOSED_COMMENT",
|
|
2182
|
+
"INCORRECTLY_OPENED_COMMENT": 11,
|
|
2183
|
+
"11": "INCORRECTLY_OPENED_COMMENT",
|
|
2184
|
+
"INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
|
|
2185
|
+
"12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
|
|
2186
|
+
"MISSING_ATTRIBUTE_VALUE": 13,
|
|
2187
|
+
"13": "MISSING_ATTRIBUTE_VALUE",
|
|
2188
|
+
"MISSING_END_TAG_NAME": 14,
|
|
2189
|
+
"14": "MISSING_END_TAG_NAME",
|
|
2190
|
+
"MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
|
|
2191
|
+
"15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
|
|
2192
|
+
"NESTED_COMMENT": 16,
|
|
2193
|
+
"16": "NESTED_COMMENT",
|
|
2194
|
+
"UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
|
|
2195
|
+
"17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
|
|
2196
|
+
"UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
|
|
2197
|
+
"18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
|
|
2198
|
+
"UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
|
|
2199
|
+
"19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
|
|
2200
|
+
"UNEXPECTED_NULL_CHARACTER": 20,
|
|
2201
|
+
"20": "UNEXPECTED_NULL_CHARACTER",
|
|
2202
|
+
"UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
|
|
2203
|
+
"21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
|
|
2204
|
+
"UNEXPECTED_SOLIDUS_IN_TAG": 22,
|
|
2205
|
+
"22": "UNEXPECTED_SOLIDUS_IN_TAG",
|
|
2206
|
+
"X_INVALID_END_TAG": 23,
|
|
2207
|
+
"23": "X_INVALID_END_TAG",
|
|
2208
|
+
"X_MISSING_END_TAG": 24,
|
|
2209
|
+
"24": "X_MISSING_END_TAG",
|
|
2210
|
+
"X_MISSING_INTERPOLATION_END": 25,
|
|
2211
|
+
"25": "X_MISSING_INTERPOLATION_END",
|
|
2212
|
+
"X_MISSING_DIRECTIVE_NAME": 26,
|
|
2213
|
+
"26": "X_MISSING_DIRECTIVE_NAME",
|
|
2214
|
+
"X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
|
|
2215
|
+
"27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
|
|
2216
|
+
"X_V_IF_NO_EXPRESSION": 28,
|
|
2217
|
+
"28": "X_V_IF_NO_EXPRESSION",
|
|
2218
|
+
"X_V_IF_SAME_KEY": 29,
|
|
2219
|
+
"29": "X_V_IF_SAME_KEY",
|
|
2220
|
+
"X_V_ELSE_NO_ADJACENT_IF": 30,
|
|
2221
|
+
"30": "X_V_ELSE_NO_ADJACENT_IF",
|
|
2222
|
+
"X_V_FOR_NO_EXPRESSION": 31,
|
|
2223
|
+
"31": "X_V_FOR_NO_EXPRESSION",
|
|
2224
|
+
"X_V_FOR_MALFORMED_EXPRESSION": 32,
|
|
2225
|
+
"32": "X_V_FOR_MALFORMED_EXPRESSION",
|
|
2226
|
+
"X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
|
|
2227
|
+
"33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
|
|
2228
|
+
"X_V_BIND_NO_EXPRESSION": 34,
|
|
2229
|
+
"34": "X_V_BIND_NO_EXPRESSION",
|
|
2230
|
+
"X_V_ON_NO_EXPRESSION": 35,
|
|
2231
|
+
"35": "X_V_ON_NO_EXPRESSION",
|
|
2232
|
+
"X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
|
|
2233
|
+
"36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
|
|
2234
|
+
"X_V_SLOT_MIXED_SLOT_USAGE": 37,
|
|
2235
|
+
"37": "X_V_SLOT_MIXED_SLOT_USAGE",
|
|
2236
|
+
"X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
|
|
2237
|
+
"38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
|
|
2238
|
+
"X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
|
|
2239
|
+
"39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
|
|
2240
|
+
"X_V_SLOT_MISPLACED": 40,
|
|
2241
|
+
"40": "X_V_SLOT_MISPLACED",
|
|
2242
|
+
"X_V_MODEL_NO_EXPRESSION": 41,
|
|
2243
|
+
"41": "X_V_MODEL_NO_EXPRESSION",
|
|
2244
|
+
"X_V_MODEL_MALFORMED_EXPRESSION": 42,
|
|
2245
|
+
"42": "X_V_MODEL_MALFORMED_EXPRESSION",
|
|
2246
|
+
"X_V_MODEL_ON_SCOPE_VARIABLE": 43,
|
|
2247
|
+
"43": "X_V_MODEL_ON_SCOPE_VARIABLE",
|
|
2248
|
+
"X_V_MODEL_ON_PROPS": 44,
|
|
2249
|
+
"44": "X_V_MODEL_ON_PROPS",
|
|
2250
|
+
"X_INVALID_EXPRESSION": 45,
|
|
2251
|
+
"45": "X_INVALID_EXPRESSION",
|
|
2252
|
+
"X_KEEP_ALIVE_INVALID_CHILDREN": 46,
|
|
2253
|
+
"46": "X_KEEP_ALIVE_INVALID_CHILDREN",
|
|
2254
|
+
"X_PREFIX_ID_NOT_SUPPORTED": 47,
|
|
2255
|
+
"47": "X_PREFIX_ID_NOT_SUPPORTED",
|
|
2256
|
+
"X_MODULE_MODE_NOT_SUPPORTED": 48,
|
|
2257
|
+
"48": "X_MODULE_MODE_NOT_SUPPORTED",
|
|
2258
|
+
"X_CACHE_HANDLER_NOT_SUPPORTED": 49,
|
|
2259
|
+
"49": "X_CACHE_HANDLER_NOT_SUPPORTED",
|
|
2260
|
+
"X_SCOPE_ID_NOT_SUPPORTED": 50,
|
|
2261
|
+
"50": "X_SCOPE_ID_NOT_SUPPORTED",
|
|
2262
|
+
"X_VNODE_HOOKS": 51,
|
|
2263
|
+
"51": "X_VNODE_HOOKS",
|
|
2264
|
+
"__EXTEND_POINT__": 52,
|
|
2265
|
+
"52": "__EXTEND_POINT__"
|
|
2266
|
+
};
|
|
2051
2267
|
const errorMessages = {
|
|
2052
2268
|
// parse errors
|
|
2053
2269
|
[0]: "Illegal comment.",
|
|
@@ -2100,16 +2316,14 @@ const errorMessages = {
|
|
|
2100
2316
|
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
2101
2317
|
[45]: `Error parsing JavaScript expression: `,
|
|
2102
2318
|
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
2319
|
+
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
2103
2320
|
// generic errors
|
|
2104
2321
|
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
2105
2322
|
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
2106
2323
|
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
2107
2324
|
[50]: `"scopeId" option is only supported in module mode.`,
|
|
2108
|
-
// deprecations
|
|
2109
|
-
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
2110
|
-
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
2111
2325
|
// just to fulfill types
|
|
2112
|
-
[
|
|
2326
|
+
[52]: ``
|
|
2113
2327
|
};
|
|
2114
2328
|
|
|
2115
2329
|
function getDefaultExportFromCjs (x) {
|
|
@@ -16601,6 +16815,471 @@ var parse_1$1 = lib.parse = parse$9;
|
|
|
16601
16815
|
var parseExpression_1 = lib.parseExpression = parseExpression;
|
|
16602
16816
|
lib.tokTypes = tokTypes;
|
|
16603
16817
|
|
|
16818
|
+
// @ts-check
|
|
16819
|
+
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
16820
|
+
|
|
16821
|
+
/** @typedef {{
|
|
16822
|
+
skip: () => void;
|
|
16823
|
+
remove: () => void;
|
|
16824
|
+
replace: (node: BaseNode) => void;
|
|
16825
|
+
}} WalkerContext */
|
|
16826
|
+
|
|
16827
|
+
class WalkerBase {
|
|
16828
|
+
constructor() {
|
|
16829
|
+
/** @type {boolean} */
|
|
16830
|
+
this.should_skip = false;
|
|
16831
|
+
|
|
16832
|
+
/** @type {boolean} */
|
|
16833
|
+
this.should_remove = false;
|
|
16834
|
+
|
|
16835
|
+
/** @type {BaseNode | null} */
|
|
16836
|
+
this.replacement = null;
|
|
16837
|
+
|
|
16838
|
+
/** @type {WalkerContext} */
|
|
16839
|
+
this.context = {
|
|
16840
|
+
skip: () => (this.should_skip = true),
|
|
16841
|
+
remove: () => (this.should_remove = true),
|
|
16842
|
+
replace: (node) => (this.replacement = node)
|
|
16843
|
+
};
|
|
16844
|
+
}
|
|
16845
|
+
|
|
16846
|
+
/**
|
|
16847
|
+
*
|
|
16848
|
+
* @param {any} parent
|
|
16849
|
+
* @param {string} prop
|
|
16850
|
+
* @param {number} index
|
|
16851
|
+
* @param {BaseNode} node
|
|
16852
|
+
*/
|
|
16853
|
+
replace(parent, prop, index, node) {
|
|
16854
|
+
if (parent) {
|
|
16855
|
+
if (index !== null) {
|
|
16856
|
+
parent[prop][index] = node;
|
|
16857
|
+
} else {
|
|
16858
|
+
parent[prop] = node;
|
|
16859
|
+
}
|
|
16860
|
+
}
|
|
16861
|
+
}
|
|
16862
|
+
|
|
16863
|
+
/**
|
|
16864
|
+
*
|
|
16865
|
+
* @param {any} parent
|
|
16866
|
+
* @param {string} prop
|
|
16867
|
+
* @param {number} index
|
|
16868
|
+
*/
|
|
16869
|
+
remove(parent, prop, index) {
|
|
16870
|
+
if (parent) {
|
|
16871
|
+
if (index !== null) {
|
|
16872
|
+
parent[prop].splice(index, 1);
|
|
16873
|
+
} else {
|
|
16874
|
+
delete parent[prop];
|
|
16875
|
+
}
|
|
16876
|
+
}
|
|
16877
|
+
}
|
|
16878
|
+
}
|
|
16879
|
+
|
|
16880
|
+
// @ts-check
|
|
16881
|
+
|
|
16882
|
+
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
16883
|
+
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
|
16884
|
+
|
|
16885
|
+
/** @typedef {(
|
|
16886
|
+
* this: WalkerContext,
|
|
16887
|
+
* node: BaseNode,
|
|
16888
|
+
* parent: BaseNode,
|
|
16889
|
+
* key: string,
|
|
16890
|
+
* index: number
|
|
16891
|
+
* ) => void} SyncHandler */
|
|
16892
|
+
|
|
16893
|
+
class SyncWalker extends WalkerBase {
|
|
16894
|
+
/**
|
|
16895
|
+
*
|
|
16896
|
+
* @param {SyncHandler} enter
|
|
16897
|
+
* @param {SyncHandler} leave
|
|
16898
|
+
*/
|
|
16899
|
+
constructor(enter, leave) {
|
|
16900
|
+
super();
|
|
16901
|
+
|
|
16902
|
+
/** @type {SyncHandler} */
|
|
16903
|
+
this.enter = enter;
|
|
16904
|
+
|
|
16905
|
+
/** @type {SyncHandler} */
|
|
16906
|
+
this.leave = leave;
|
|
16907
|
+
}
|
|
16908
|
+
|
|
16909
|
+
/**
|
|
16910
|
+
*
|
|
16911
|
+
* @param {BaseNode} node
|
|
16912
|
+
* @param {BaseNode} parent
|
|
16913
|
+
* @param {string} [prop]
|
|
16914
|
+
* @param {number} [index]
|
|
16915
|
+
* @returns {BaseNode}
|
|
16916
|
+
*/
|
|
16917
|
+
visit(node, parent, prop, index) {
|
|
16918
|
+
if (node) {
|
|
16919
|
+
if (this.enter) {
|
|
16920
|
+
const _should_skip = this.should_skip;
|
|
16921
|
+
const _should_remove = this.should_remove;
|
|
16922
|
+
const _replacement = this.replacement;
|
|
16923
|
+
this.should_skip = false;
|
|
16924
|
+
this.should_remove = false;
|
|
16925
|
+
this.replacement = null;
|
|
16926
|
+
|
|
16927
|
+
this.enter.call(this.context, node, parent, prop, index);
|
|
16928
|
+
|
|
16929
|
+
if (this.replacement) {
|
|
16930
|
+
node = this.replacement;
|
|
16931
|
+
this.replace(parent, prop, index, node);
|
|
16932
|
+
}
|
|
16933
|
+
|
|
16934
|
+
if (this.should_remove) {
|
|
16935
|
+
this.remove(parent, prop, index);
|
|
16936
|
+
}
|
|
16937
|
+
|
|
16938
|
+
const skipped = this.should_skip;
|
|
16939
|
+
const removed = this.should_remove;
|
|
16940
|
+
|
|
16941
|
+
this.should_skip = _should_skip;
|
|
16942
|
+
this.should_remove = _should_remove;
|
|
16943
|
+
this.replacement = _replacement;
|
|
16944
|
+
|
|
16945
|
+
if (skipped) return node;
|
|
16946
|
+
if (removed) return null;
|
|
16947
|
+
}
|
|
16948
|
+
|
|
16949
|
+
for (const key in node) {
|
|
16950
|
+
const value = node[key];
|
|
16951
|
+
|
|
16952
|
+
if (typeof value !== "object") {
|
|
16953
|
+
continue;
|
|
16954
|
+
} else if (Array.isArray(value)) {
|
|
16955
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
16956
|
+
if (value[i] !== null && typeof value[i].type === 'string') {
|
|
16957
|
+
if (!this.visit(value[i], node, key, i)) {
|
|
16958
|
+
// removed
|
|
16959
|
+
i--;
|
|
16960
|
+
}
|
|
16961
|
+
}
|
|
16962
|
+
}
|
|
16963
|
+
} else if (value !== null && typeof value.type === "string") {
|
|
16964
|
+
this.visit(value, node, key, null);
|
|
16965
|
+
}
|
|
16966
|
+
}
|
|
16967
|
+
|
|
16968
|
+
if (this.leave) {
|
|
16969
|
+
const _replacement = this.replacement;
|
|
16970
|
+
const _should_remove = this.should_remove;
|
|
16971
|
+
this.replacement = null;
|
|
16972
|
+
this.should_remove = false;
|
|
16973
|
+
|
|
16974
|
+
this.leave.call(this.context, node, parent, prop, index);
|
|
16975
|
+
|
|
16976
|
+
if (this.replacement) {
|
|
16977
|
+
node = this.replacement;
|
|
16978
|
+
this.replace(parent, prop, index, node);
|
|
16979
|
+
}
|
|
16980
|
+
|
|
16981
|
+
if (this.should_remove) {
|
|
16982
|
+
this.remove(parent, prop, index);
|
|
16983
|
+
}
|
|
16984
|
+
|
|
16985
|
+
const removed = this.should_remove;
|
|
16986
|
+
|
|
16987
|
+
this.replacement = _replacement;
|
|
16988
|
+
this.should_remove = _should_remove;
|
|
16989
|
+
|
|
16990
|
+
if (removed) return null;
|
|
16991
|
+
}
|
|
16992
|
+
}
|
|
16993
|
+
|
|
16994
|
+
return node;
|
|
16995
|
+
}
|
|
16996
|
+
}
|
|
16997
|
+
|
|
16998
|
+
// @ts-check
|
|
16999
|
+
|
|
17000
|
+
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
17001
|
+
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
|
17002
|
+
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
|
17003
|
+
|
|
17004
|
+
/**
|
|
17005
|
+
*
|
|
17006
|
+
* @param {BaseNode} ast
|
|
17007
|
+
* @param {{
|
|
17008
|
+
* enter?: SyncHandler
|
|
17009
|
+
* leave?: SyncHandler
|
|
17010
|
+
* }} walker
|
|
17011
|
+
* @returns {BaseNode}
|
|
17012
|
+
*/
|
|
17013
|
+
function walk$2(ast, { enter, leave }) {
|
|
17014
|
+
const instance = new SyncWalker(enter, leave);
|
|
17015
|
+
return instance.visit(ast, null);
|
|
17016
|
+
}
|
|
17017
|
+
|
|
17018
|
+
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
|
|
17019
|
+
const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
|
|
17020
|
+
walk$2(root, {
|
|
17021
|
+
enter(node, parent) {
|
|
17022
|
+
parent && parentStack.push(parent);
|
|
17023
|
+
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
|
|
17024
|
+
return this.skip();
|
|
17025
|
+
}
|
|
17026
|
+
if (node.type === "Identifier") {
|
|
17027
|
+
const isLocal = !!knownIds[node.name];
|
|
17028
|
+
const isRefed = isReferencedIdentifier(node, parent, parentStack);
|
|
17029
|
+
if (includeAll || isRefed && !isLocal) {
|
|
17030
|
+
onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
17031
|
+
}
|
|
17032
|
+
} else if (node.type === "ObjectProperty" && parent.type === "ObjectPattern") {
|
|
17033
|
+
node.inPattern = true;
|
|
17034
|
+
} else if (isFunctionType(node)) {
|
|
17035
|
+
walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
17036
|
+
} else if (node.type === "BlockStatement") {
|
|
17037
|
+
walkBlockDeclarations(
|
|
17038
|
+
node,
|
|
17039
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
17040
|
+
);
|
|
17041
|
+
}
|
|
17042
|
+
},
|
|
17043
|
+
leave(node, parent) {
|
|
17044
|
+
parent && parentStack.pop();
|
|
17045
|
+
if (node !== rootExp && node.scopeIds) {
|
|
17046
|
+
for (const id of node.scopeIds) {
|
|
17047
|
+
knownIds[id]--;
|
|
17048
|
+
if (knownIds[id] === 0) {
|
|
17049
|
+
delete knownIds[id];
|
|
17050
|
+
}
|
|
17051
|
+
}
|
|
17052
|
+
}
|
|
17053
|
+
}
|
|
17054
|
+
});
|
|
17055
|
+
}
|
|
17056
|
+
function isReferencedIdentifier(id, parent, parentStack) {
|
|
17057
|
+
if (!parent) {
|
|
17058
|
+
return true;
|
|
17059
|
+
}
|
|
17060
|
+
if (id.name === "arguments") {
|
|
17061
|
+
return false;
|
|
17062
|
+
}
|
|
17063
|
+
if (isReferenced(id, parent)) {
|
|
17064
|
+
return true;
|
|
17065
|
+
}
|
|
17066
|
+
switch (parent.type) {
|
|
17067
|
+
case "AssignmentExpression":
|
|
17068
|
+
case "AssignmentPattern":
|
|
17069
|
+
return true;
|
|
17070
|
+
case "ObjectPattern":
|
|
17071
|
+
case "ArrayPattern":
|
|
17072
|
+
return isInDestructureAssignment(parent, parentStack);
|
|
17073
|
+
}
|
|
17074
|
+
return false;
|
|
17075
|
+
}
|
|
17076
|
+
function isInDestructureAssignment(parent, parentStack) {
|
|
17077
|
+
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
17078
|
+
let i = parentStack.length;
|
|
17079
|
+
while (i--) {
|
|
17080
|
+
const p = parentStack[i];
|
|
17081
|
+
if (p.type === "AssignmentExpression") {
|
|
17082
|
+
return true;
|
|
17083
|
+
} else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
|
|
17084
|
+
break;
|
|
17085
|
+
}
|
|
17086
|
+
}
|
|
17087
|
+
}
|
|
17088
|
+
return false;
|
|
17089
|
+
}
|
|
17090
|
+
function walkFunctionParams(node, onIdent) {
|
|
17091
|
+
for (const p of node.params) {
|
|
17092
|
+
for (const id of extractIdentifiers$1(p)) {
|
|
17093
|
+
onIdent(id);
|
|
17094
|
+
}
|
|
17095
|
+
}
|
|
17096
|
+
}
|
|
17097
|
+
function walkBlockDeclarations(block, onIdent) {
|
|
17098
|
+
for (const stmt of block.body) {
|
|
17099
|
+
if (stmt.type === "VariableDeclaration") {
|
|
17100
|
+
if (stmt.declare)
|
|
17101
|
+
continue;
|
|
17102
|
+
for (const decl of stmt.declarations) {
|
|
17103
|
+
for (const id of extractIdentifiers$1(decl.id)) {
|
|
17104
|
+
onIdent(id);
|
|
17105
|
+
}
|
|
17106
|
+
}
|
|
17107
|
+
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
17108
|
+
if (stmt.declare || !stmt.id)
|
|
17109
|
+
continue;
|
|
17110
|
+
onIdent(stmt.id);
|
|
17111
|
+
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
17112
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
17113
|
+
if (variable && variable.type === "VariableDeclaration") {
|
|
17114
|
+
for (const decl of variable.declarations) {
|
|
17115
|
+
for (const id of extractIdentifiers$1(decl.id)) {
|
|
17116
|
+
onIdent(id);
|
|
17117
|
+
}
|
|
17118
|
+
}
|
|
17119
|
+
}
|
|
17120
|
+
}
|
|
17121
|
+
}
|
|
17122
|
+
}
|
|
17123
|
+
function extractIdentifiers$1(param, nodes = []) {
|
|
17124
|
+
switch (param.type) {
|
|
17125
|
+
case "Identifier":
|
|
17126
|
+
nodes.push(param);
|
|
17127
|
+
break;
|
|
17128
|
+
case "MemberExpression":
|
|
17129
|
+
let object = param;
|
|
17130
|
+
while (object.type === "MemberExpression") {
|
|
17131
|
+
object = object.object;
|
|
17132
|
+
}
|
|
17133
|
+
nodes.push(object);
|
|
17134
|
+
break;
|
|
17135
|
+
case "ObjectPattern":
|
|
17136
|
+
for (const prop of param.properties) {
|
|
17137
|
+
if (prop.type === "RestElement") {
|
|
17138
|
+
extractIdentifiers$1(prop.argument, nodes);
|
|
17139
|
+
} else {
|
|
17140
|
+
extractIdentifiers$1(prop.value, nodes);
|
|
17141
|
+
}
|
|
17142
|
+
}
|
|
17143
|
+
break;
|
|
17144
|
+
case "ArrayPattern":
|
|
17145
|
+
param.elements.forEach((element) => {
|
|
17146
|
+
if (element)
|
|
17147
|
+
extractIdentifiers$1(element, nodes);
|
|
17148
|
+
});
|
|
17149
|
+
break;
|
|
17150
|
+
case "RestElement":
|
|
17151
|
+
extractIdentifiers$1(param.argument, nodes);
|
|
17152
|
+
break;
|
|
17153
|
+
case "AssignmentPattern":
|
|
17154
|
+
extractIdentifiers$1(param.left, nodes);
|
|
17155
|
+
break;
|
|
17156
|
+
}
|
|
17157
|
+
return nodes;
|
|
17158
|
+
}
|
|
17159
|
+
function markScopeIdentifier(node, child, knownIds) {
|
|
17160
|
+
const { name } = child;
|
|
17161
|
+
if (node.scopeIds && node.scopeIds.has(name)) {
|
|
17162
|
+
return;
|
|
17163
|
+
}
|
|
17164
|
+
if (name in knownIds) {
|
|
17165
|
+
knownIds[name]++;
|
|
17166
|
+
} else {
|
|
17167
|
+
knownIds[name] = 1;
|
|
17168
|
+
}
|
|
17169
|
+
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
17170
|
+
}
|
|
17171
|
+
const isFunctionType = (node) => {
|
|
17172
|
+
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
17173
|
+
};
|
|
17174
|
+
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
17175
|
+
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
17176
|
+
function isReferenced(node, parent, grandparent) {
|
|
17177
|
+
switch (parent.type) {
|
|
17178
|
+
case "MemberExpression":
|
|
17179
|
+
case "OptionalMemberExpression":
|
|
17180
|
+
if (parent.property === node) {
|
|
17181
|
+
return !!parent.computed;
|
|
17182
|
+
}
|
|
17183
|
+
return parent.object === node;
|
|
17184
|
+
case "JSXMemberExpression":
|
|
17185
|
+
return parent.object === node;
|
|
17186
|
+
case "VariableDeclarator":
|
|
17187
|
+
return parent.init === node;
|
|
17188
|
+
case "ArrowFunctionExpression":
|
|
17189
|
+
return parent.body === node;
|
|
17190
|
+
case "PrivateName":
|
|
17191
|
+
return false;
|
|
17192
|
+
case "ClassMethod":
|
|
17193
|
+
case "ClassPrivateMethod":
|
|
17194
|
+
case "ObjectMethod":
|
|
17195
|
+
if (parent.key === node) {
|
|
17196
|
+
return !!parent.computed;
|
|
17197
|
+
}
|
|
17198
|
+
return false;
|
|
17199
|
+
case "ObjectProperty":
|
|
17200
|
+
if (parent.key === node) {
|
|
17201
|
+
return !!parent.computed;
|
|
17202
|
+
}
|
|
17203
|
+
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
17204
|
+
case "ClassProperty":
|
|
17205
|
+
if (parent.key === node) {
|
|
17206
|
+
return !!parent.computed;
|
|
17207
|
+
}
|
|
17208
|
+
return true;
|
|
17209
|
+
case "ClassPrivateProperty":
|
|
17210
|
+
return parent.key !== node;
|
|
17211
|
+
case "ClassDeclaration":
|
|
17212
|
+
case "ClassExpression":
|
|
17213
|
+
return parent.superClass === node;
|
|
17214
|
+
case "AssignmentExpression":
|
|
17215
|
+
return parent.right === node;
|
|
17216
|
+
case "AssignmentPattern":
|
|
17217
|
+
return parent.right === node;
|
|
17218
|
+
case "LabeledStatement":
|
|
17219
|
+
return false;
|
|
17220
|
+
case "CatchClause":
|
|
17221
|
+
return false;
|
|
17222
|
+
case "RestElement":
|
|
17223
|
+
return false;
|
|
17224
|
+
case "BreakStatement":
|
|
17225
|
+
case "ContinueStatement":
|
|
17226
|
+
return false;
|
|
17227
|
+
case "FunctionDeclaration":
|
|
17228
|
+
case "FunctionExpression":
|
|
17229
|
+
return false;
|
|
17230
|
+
case "ExportNamespaceSpecifier":
|
|
17231
|
+
case "ExportDefaultSpecifier":
|
|
17232
|
+
return false;
|
|
17233
|
+
case "ExportSpecifier":
|
|
17234
|
+
if (grandparent == null ? void 0 : grandparent.source) {
|
|
17235
|
+
return false;
|
|
17236
|
+
}
|
|
17237
|
+
return parent.local === node;
|
|
17238
|
+
case "ImportDefaultSpecifier":
|
|
17239
|
+
case "ImportNamespaceSpecifier":
|
|
17240
|
+
case "ImportSpecifier":
|
|
17241
|
+
return false;
|
|
17242
|
+
case "ImportAttribute":
|
|
17243
|
+
return false;
|
|
17244
|
+
case "JSXAttribute":
|
|
17245
|
+
return false;
|
|
17246
|
+
case "ObjectPattern":
|
|
17247
|
+
case "ArrayPattern":
|
|
17248
|
+
return false;
|
|
17249
|
+
case "MetaProperty":
|
|
17250
|
+
return false;
|
|
17251
|
+
case "ObjectTypeProperty":
|
|
17252
|
+
return parent.key !== node;
|
|
17253
|
+
case "TSEnumMember":
|
|
17254
|
+
return parent.id !== node;
|
|
17255
|
+
case "TSPropertySignature":
|
|
17256
|
+
if (parent.key === node) {
|
|
17257
|
+
return !!parent.computed;
|
|
17258
|
+
}
|
|
17259
|
+
return true;
|
|
17260
|
+
}
|
|
17261
|
+
return true;
|
|
17262
|
+
}
|
|
17263
|
+
const TS_NODE_TYPES = [
|
|
17264
|
+
"TSAsExpression",
|
|
17265
|
+
// foo as number
|
|
17266
|
+
"TSTypeAssertion",
|
|
17267
|
+
// (<number>foo)
|
|
17268
|
+
"TSNonNullExpression",
|
|
17269
|
+
// foo!
|
|
17270
|
+
"TSInstantiationExpression",
|
|
17271
|
+
// foo<string>
|
|
17272
|
+
"TSSatisfiesExpression"
|
|
17273
|
+
// foo satisfies T
|
|
17274
|
+
];
|
|
17275
|
+
function unwrapTSNode(node) {
|
|
17276
|
+
if (TS_NODE_TYPES.includes(node.type)) {
|
|
17277
|
+
return unwrapTSNode(node.expression);
|
|
17278
|
+
} else {
|
|
17279
|
+
return node;
|
|
17280
|
+
}
|
|
17281
|
+
}
|
|
17282
|
+
|
|
16604
17283
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
16605
17284
|
function isCoreComponent(tag) {
|
|
16606
17285
|
switch (tag) {
|
|
@@ -16690,9 +17369,7 @@ const isMemberExpressionNode = (path, context) => {
|
|
|
16690
17369
|
let ret = parseExpression_1(path, {
|
|
16691
17370
|
plugins: context.expressionPlugins
|
|
16692
17371
|
});
|
|
16693
|
-
|
|
16694
|
-
ret = ret.expression;
|
|
16695
|
-
}
|
|
17372
|
+
ret = unwrapTSNode(ret);
|
|
16696
17373
|
return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier";
|
|
16697
17374
|
} catch (e) {
|
|
16698
17375
|
return false;
|
|
@@ -16918,7 +17595,8 @@ const defaultParserOptions = {
|
|
|
16918
17595
|
isCustomElement: NO,
|
|
16919
17596
|
onError: defaultOnError,
|
|
16920
17597
|
onWarn: defaultOnWarn,
|
|
16921
|
-
comments: true
|
|
17598
|
+
comments: true,
|
|
17599
|
+
prefixIdentifiers: false
|
|
16922
17600
|
};
|
|
16923
17601
|
let currentOptions = defaultParserOptions;
|
|
16924
17602
|
let currentRoot = null;
|
|
@@ -16960,7 +17638,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
|
|
|
16960
17638
|
}
|
|
16961
17639
|
addNode({
|
|
16962
17640
|
type: 5,
|
|
16963
|
-
content:
|
|
17641
|
+
content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
|
16964
17642
|
loc: getLoc(start, end)
|
|
16965
17643
|
});
|
|
16966
17644
|
},
|
|
@@ -17053,7 +17731,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
|
|
|
17053
17731
|
loc: getLoc(start)
|
|
17054
17732
|
};
|
|
17055
17733
|
if (name === "pre") {
|
|
17056
|
-
inVPre = true;
|
|
17734
|
+
inVPre = tokenizer$2.inVPre = true;
|
|
17057
17735
|
currentVPreBoundary = currentOpenTag;
|
|
17058
17736
|
const props = currentOpenTag.props;
|
|
17059
17737
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -17073,7 +17751,7 @@ const tokenizer$2 = new Tokenizer$1(stack, {
|
|
|
17073
17751
|
setLocEnd(currentProp.nameLoc, end);
|
|
17074
17752
|
} else {
|
|
17075
17753
|
const isStatic = arg[0] !== `[`;
|
|
17076
|
-
currentProp.arg =
|
|
17754
|
+
currentProp.arg = createExp(
|
|
17077
17755
|
isStatic ? arg : arg.slice(1, -1),
|
|
17078
17756
|
isStatic,
|
|
17079
17757
|
getLoc(start, end),
|
|
@@ -17140,10 +17818,22 @@ const tokenizer$2 = new Tokenizer$1(stack, {
|
|
|
17140
17818
|
tokenizer$2.enterRCDATA(toCharCodes(`</template`), 0);
|
|
17141
17819
|
}
|
|
17142
17820
|
} else {
|
|
17143
|
-
|
|
17821
|
+
let expParseMode = 0 /* Normal */;
|
|
17822
|
+
{
|
|
17823
|
+
if (currentProp.name === "for") {
|
|
17824
|
+
expParseMode = 3 /* Skip */;
|
|
17825
|
+
} else if (currentProp.name === "slot") {
|
|
17826
|
+
expParseMode = 1 /* Params */;
|
|
17827
|
+
} else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
|
|
17828
|
+
expParseMode = 2 /* Statements */;
|
|
17829
|
+
}
|
|
17830
|
+
}
|
|
17831
|
+
currentProp.exp = createExp(
|
|
17144
17832
|
currentAttrValue,
|
|
17145
17833
|
false,
|
|
17146
|
-
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
17834
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex),
|
|
17835
|
+
0,
|
|
17836
|
+
expParseMode
|
|
17147
17837
|
);
|
|
17148
17838
|
if (currentProp.name === "for") {
|
|
17149
17839
|
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
@@ -17236,10 +17926,16 @@ function parseForExpression(input) {
|
|
|
17236
17926
|
if (!inMatch)
|
|
17237
17927
|
return;
|
|
17238
17928
|
const [, LHS, RHS] = inMatch;
|
|
17239
|
-
const createAliasExpression = (content, offset) => {
|
|
17929
|
+
const createAliasExpression = (content, offset, asParam = false) => {
|
|
17240
17930
|
const start = loc.start.offset + offset;
|
|
17241
17931
|
const end = start + content.length;
|
|
17242
|
-
return
|
|
17932
|
+
return createExp(
|
|
17933
|
+
content,
|
|
17934
|
+
false,
|
|
17935
|
+
getLoc(start, end),
|
|
17936
|
+
0,
|
|
17937
|
+
asParam ? 1 /* Params */ : 0 /* Normal */
|
|
17938
|
+
);
|
|
17243
17939
|
};
|
|
17244
17940
|
const result = {
|
|
17245
17941
|
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
@@ -17257,7 +17953,7 @@ function parseForExpression(input) {
|
|
|
17257
17953
|
let keyOffset;
|
|
17258
17954
|
if (keyContent) {
|
|
17259
17955
|
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
17260
|
-
result.key = createAliasExpression(keyContent, keyOffset);
|
|
17956
|
+
result.key = createAliasExpression(keyContent, keyOffset, true);
|
|
17261
17957
|
}
|
|
17262
17958
|
if (iteratorMatch[2]) {
|
|
17263
17959
|
const indexContent = iteratorMatch[2].trim();
|
|
@@ -17267,13 +17963,14 @@ function parseForExpression(input) {
|
|
|
17267
17963
|
exp.indexOf(
|
|
17268
17964
|
indexContent,
|
|
17269
17965
|
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
17270
|
-
)
|
|
17966
|
+
),
|
|
17967
|
+
true
|
|
17271
17968
|
);
|
|
17272
17969
|
}
|
|
17273
17970
|
}
|
|
17274
17971
|
}
|
|
17275
17972
|
if (valueContent) {
|
|
17276
|
-
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
17973
|
+
result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
|
17277
17974
|
}
|
|
17278
17975
|
return result;
|
|
17279
17976
|
}
|
|
@@ -17344,7 +18041,7 @@ function onCloseTag(el, end, isImplied = false) {
|
|
|
17344
18041
|
inPre--;
|
|
17345
18042
|
}
|
|
17346
18043
|
if (currentVPreBoundary === el) {
|
|
17347
|
-
inVPre = false;
|
|
18044
|
+
inVPre = tokenizer$2.inVPre = false;
|
|
17348
18045
|
currentVPreBoundary = null;
|
|
17349
18046
|
}
|
|
17350
18047
|
if (tokenizer$2.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
@@ -17508,8 +18205,36 @@ function dirToAttr(dir) {
|
|
|
17508
18205
|
}
|
|
17509
18206
|
return attr;
|
|
17510
18207
|
}
|
|
17511
|
-
function
|
|
17512
|
-
|
|
18208
|
+
function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
|
|
18209
|
+
const exp = createSimpleExpression(content, isStatic, loc, constType);
|
|
18210
|
+
if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
|
|
18211
|
+
if (isSimpleIdentifier(content)) {
|
|
18212
|
+
exp.ast = null;
|
|
18213
|
+
return exp;
|
|
18214
|
+
}
|
|
18215
|
+
try {
|
|
18216
|
+
const plugins = currentOptions.expressionPlugins;
|
|
18217
|
+
const options = {
|
|
18218
|
+
plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
|
|
18219
|
+
};
|
|
18220
|
+
if (parseMode === 2 /* Statements */) {
|
|
18221
|
+
exp.ast = parse_1$1(` ${content} `, options).program;
|
|
18222
|
+
} else if (parseMode === 1 /* Params */) {
|
|
18223
|
+
exp.ast = parseExpression_1(`(${content})=>{}`, options);
|
|
18224
|
+
} else {
|
|
18225
|
+
exp.ast = parseExpression_1(`(${content})`, options);
|
|
18226
|
+
}
|
|
18227
|
+
} catch (e) {
|
|
18228
|
+
exp.ast = false;
|
|
18229
|
+
emitError(45, loc.start.offset, e.message);
|
|
18230
|
+
}
|
|
18231
|
+
}
|
|
18232
|
+
return exp;
|
|
18233
|
+
}
|
|
18234
|
+
function emitError(code, index, message) {
|
|
18235
|
+
currentOptions.onError(
|
|
18236
|
+
createCompilerError(code, getLoc(index, index), void 0, message)
|
|
18237
|
+
);
|
|
17513
18238
|
}
|
|
17514
18239
|
function reset() {
|
|
17515
18240
|
tokenizer$2.reset();
|
|
@@ -17540,6 +18265,7 @@ function baseParse(input, options) {
|
|
|
17540
18265
|
}
|
|
17541
18266
|
}
|
|
17542
18267
|
tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
18268
|
+
tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
|
17543
18269
|
const delimiters = options == null ? void 0 : options.delimiters;
|
|
17544
18270
|
if (delimiters) {
|
|
17545
18271
|
tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
|
|
@@ -17554,7 +18280,7 @@ function baseParse(input, options) {
|
|
|
17554
18280
|
}
|
|
17555
18281
|
|
|
17556
18282
|
function hoistStatic(root, context) {
|
|
17557
|
-
walk$
|
|
18283
|
+
walk$1(
|
|
17558
18284
|
root,
|
|
17559
18285
|
context,
|
|
17560
18286
|
// Root node is unfortunately non-hoistable due to potential parent
|
|
@@ -17566,7 +18292,7 @@ function isSingleElementRoot(root, child) {
|
|
|
17566
18292
|
const { children } = root;
|
|
17567
18293
|
return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
|
17568
18294
|
}
|
|
17569
|
-
function walk$
|
|
18295
|
+
function walk$1(node, context, doNotHoistNode = false) {
|
|
17570
18296
|
const { children } = node;
|
|
17571
18297
|
const originalCount = children.length;
|
|
17572
18298
|
let hoistedCount = 0;
|
|
@@ -17602,15 +18328,15 @@ function walk$2(node, context, doNotHoistNode = false) {
|
|
|
17602
18328
|
if (isComponent) {
|
|
17603
18329
|
context.scopes.vSlot++;
|
|
17604
18330
|
}
|
|
17605
|
-
walk$
|
|
18331
|
+
walk$1(child, context);
|
|
17606
18332
|
if (isComponent) {
|
|
17607
18333
|
context.scopes.vSlot--;
|
|
17608
18334
|
}
|
|
17609
18335
|
} else if (child.type === 11) {
|
|
17610
|
-
walk$
|
|
18336
|
+
walk$1(child, context, child.children.length === 1);
|
|
17611
18337
|
} else if (child.type === 9) {
|
|
17612
18338
|
for (let i2 = 0; i2 < child.branches.length; i2++) {
|
|
17613
|
-
walk$
|
|
18339
|
+
walk$1(
|
|
17614
18340
|
child.branches[i2],
|
|
17615
18341
|
context,
|
|
17616
18342
|
child.branches[i2].children.length === 1
|
|
@@ -17824,6 +18550,7 @@ function createTransformContext(root, {
|
|
|
17824
18550
|
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
17825
18551
|
const context = {
|
|
17826
18552
|
// options
|
|
18553
|
+
filename,
|
|
17827
18554
|
selfName: nameMatch && capitalize$1(camelize(nameMatch[1])),
|
|
17828
18555
|
prefixIdentifiers,
|
|
17829
18556
|
hoistStatic: hoistStatic2,
|
|
@@ -22204,464 +22931,6 @@ function genReturnStatement({ returns }, context) {
|
|
|
22204
22931
|
}
|
|
22205
22932
|
}
|
|
22206
22933
|
|
|
22207
|
-
// @ts-check
|
|
22208
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22209
|
-
|
|
22210
|
-
/** @typedef {{
|
|
22211
|
-
skip: () => void;
|
|
22212
|
-
remove: () => void;
|
|
22213
|
-
replace: (node: BaseNode) => void;
|
|
22214
|
-
}} WalkerContext */
|
|
22215
|
-
|
|
22216
|
-
class WalkerBase {
|
|
22217
|
-
constructor() {
|
|
22218
|
-
/** @type {boolean} */
|
|
22219
|
-
this.should_skip = false;
|
|
22220
|
-
|
|
22221
|
-
/** @type {boolean} */
|
|
22222
|
-
this.should_remove = false;
|
|
22223
|
-
|
|
22224
|
-
/** @type {BaseNode | null} */
|
|
22225
|
-
this.replacement = null;
|
|
22226
|
-
|
|
22227
|
-
/** @type {WalkerContext} */
|
|
22228
|
-
this.context = {
|
|
22229
|
-
skip: () => (this.should_skip = true),
|
|
22230
|
-
remove: () => (this.should_remove = true),
|
|
22231
|
-
replace: (node) => (this.replacement = node)
|
|
22232
|
-
};
|
|
22233
|
-
}
|
|
22234
|
-
|
|
22235
|
-
/**
|
|
22236
|
-
*
|
|
22237
|
-
* @param {any} parent
|
|
22238
|
-
* @param {string} prop
|
|
22239
|
-
* @param {number} index
|
|
22240
|
-
* @param {BaseNode} node
|
|
22241
|
-
*/
|
|
22242
|
-
replace(parent, prop, index, node) {
|
|
22243
|
-
if (parent) {
|
|
22244
|
-
if (index !== null) {
|
|
22245
|
-
parent[prop][index] = node;
|
|
22246
|
-
} else {
|
|
22247
|
-
parent[prop] = node;
|
|
22248
|
-
}
|
|
22249
|
-
}
|
|
22250
|
-
}
|
|
22251
|
-
|
|
22252
|
-
/**
|
|
22253
|
-
*
|
|
22254
|
-
* @param {any} parent
|
|
22255
|
-
* @param {string} prop
|
|
22256
|
-
* @param {number} index
|
|
22257
|
-
*/
|
|
22258
|
-
remove(parent, prop, index) {
|
|
22259
|
-
if (parent) {
|
|
22260
|
-
if (index !== null) {
|
|
22261
|
-
parent[prop].splice(index, 1);
|
|
22262
|
-
} else {
|
|
22263
|
-
delete parent[prop];
|
|
22264
|
-
}
|
|
22265
|
-
}
|
|
22266
|
-
}
|
|
22267
|
-
}
|
|
22268
|
-
|
|
22269
|
-
// @ts-check
|
|
22270
|
-
|
|
22271
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22272
|
-
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
|
22273
|
-
|
|
22274
|
-
/** @typedef {(
|
|
22275
|
-
* this: WalkerContext,
|
|
22276
|
-
* node: BaseNode,
|
|
22277
|
-
* parent: BaseNode,
|
|
22278
|
-
* key: string,
|
|
22279
|
-
* index: number
|
|
22280
|
-
* ) => void} SyncHandler */
|
|
22281
|
-
|
|
22282
|
-
class SyncWalker extends WalkerBase {
|
|
22283
|
-
/**
|
|
22284
|
-
*
|
|
22285
|
-
* @param {SyncHandler} enter
|
|
22286
|
-
* @param {SyncHandler} leave
|
|
22287
|
-
*/
|
|
22288
|
-
constructor(enter, leave) {
|
|
22289
|
-
super();
|
|
22290
|
-
|
|
22291
|
-
/** @type {SyncHandler} */
|
|
22292
|
-
this.enter = enter;
|
|
22293
|
-
|
|
22294
|
-
/** @type {SyncHandler} */
|
|
22295
|
-
this.leave = leave;
|
|
22296
|
-
}
|
|
22297
|
-
|
|
22298
|
-
/**
|
|
22299
|
-
*
|
|
22300
|
-
* @param {BaseNode} node
|
|
22301
|
-
* @param {BaseNode} parent
|
|
22302
|
-
* @param {string} [prop]
|
|
22303
|
-
* @param {number} [index]
|
|
22304
|
-
* @returns {BaseNode}
|
|
22305
|
-
*/
|
|
22306
|
-
visit(node, parent, prop, index) {
|
|
22307
|
-
if (node) {
|
|
22308
|
-
if (this.enter) {
|
|
22309
|
-
const _should_skip = this.should_skip;
|
|
22310
|
-
const _should_remove = this.should_remove;
|
|
22311
|
-
const _replacement = this.replacement;
|
|
22312
|
-
this.should_skip = false;
|
|
22313
|
-
this.should_remove = false;
|
|
22314
|
-
this.replacement = null;
|
|
22315
|
-
|
|
22316
|
-
this.enter.call(this.context, node, parent, prop, index);
|
|
22317
|
-
|
|
22318
|
-
if (this.replacement) {
|
|
22319
|
-
node = this.replacement;
|
|
22320
|
-
this.replace(parent, prop, index, node);
|
|
22321
|
-
}
|
|
22322
|
-
|
|
22323
|
-
if (this.should_remove) {
|
|
22324
|
-
this.remove(parent, prop, index);
|
|
22325
|
-
}
|
|
22326
|
-
|
|
22327
|
-
const skipped = this.should_skip;
|
|
22328
|
-
const removed = this.should_remove;
|
|
22329
|
-
|
|
22330
|
-
this.should_skip = _should_skip;
|
|
22331
|
-
this.should_remove = _should_remove;
|
|
22332
|
-
this.replacement = _replacement;
|
|
22333
|
-
|
|
22334
|
-
if (skipped) return node;
|
|
22335
|
-
if (removed) return null;
|
|
22336
|
-
}
|
|
22337
|
-
|
|
22338
|
-
for (const key in node) {
|
|
22339
|
-
const value = node[key];
|
|
22340
|
-
|
|
22341
|
-
if (typeof value !== "object") {
|
|
22342
|
-
continue;
|
|
22343
|
-
} else if (Array.isArray(value)) {
|
|
22344
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
22345
|
-
if (value[i] !== null && typeof value[i].type === 'string') {
|
|
22346
|
-
if (!this.visit(value[i], node, key, i)) {
|
|
22347
|
-
// removed
|
|
22348
|
-
i--;
|
|
22349
|
-
}
|
|
22350
|
-
}
|
|
22351
|
-
}
|
|
22352
|
-
} else if (value !== null && typeof value.type === "string") {
|
|
22353
|
-
this.visit(value, node, key, null);
|
|
22354
|
-
}
|
|
22355
|
-
}
|
|
22356
|
-
|
|
22357
|
-
if (this.leave) {
|
|
22358
|
-
const _replacement = this.replacement;
|
|
22359
|
-
const _should_remove = this.should_remove;
|
|
22360
|
-
this.replacement = null;
|
|
22361
|
-
this.should_remove = false;
|
|
22362
|
-
|
|
22363
|
-
this.leave.call(this.context, node, parent, prop, index);
|
|
22364
|
-
|
|
22365
|
-
if (this.replacement) {
|
|
22366
|
-
node = this.replacement;
|
|
22367
|
-
this.replace(parent, prop, index, node);
|
|
22368
|
-
}
|
|
22369
|
-
|
|
22370
|
-
if (this.should_remove) {
|
|
22371
|
-
this.remove(parent, prop, index);
|
|
22372
|
-
}
|
|
22373
|
-
|
|
22374
|
-
const removed = this.should_remove;
|
|
22375
|
-
|
|
22376
|
-
this.replacement = _replacement;
|
|
22377
|
-
this.should_remove = _should_remove;
|
|
22378
|
-
|
|
22379
|
-
if (removed) return null;
|
|
22380
|
-
}
|
|
22381
|
-
}
|
|
22382
|
-
|
|
22383
|
-
return node;
|
|
22384
|
-
}
|
|
22385
|
-
}
|
|
22386
|
-
|
|
22387
|
-
// @ts-check
|
|
22388
|
-
|
|
22389
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22390
|
-
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
|
22391
|
-
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
|
22392
|
-
|
|
22393
|
-
/**
|
|
22394
|
-
*
|
|
22395
|
-
* @param {BaseNode} ast
|
|
22396
|
-
* @param {{
|
|
22397
|
-
* enter?: SyncHandler
|
|
22398
|
-
* leave?: SyncHandler
|
|
22399
|
-
* }} walker
|
|
22400
|
-
* @returns {BaseNode}
|
|
22401
|
-
*/
|
|
22402
|
-
function walk$1(ast, { enter, leave }) {
|
|
22403
|
-
const instance = new SyncWalker(enter, leave);
|
|
22404
|
-
return instance.visit(ast, null);
|
|
22405
|
-
}
|
|
22406
|
-
|
|
22407
|
-
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
|
|
22408
|
-
const rootExp = root.type === "Program" && root.body[0].type === "ExpressionStatement" && root.body[0].expression;
|
|
22409
|
-
walk$1(root, {
|
|
22410
|
-
enter(node, parent) {
|
|
22411
|
-
parent && parentStack.push(parent);
|
|
22412
|
-
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
|
|
22413
|
-
return this.skip();
|
|
22414
|
-
}
|
|
22415
|
-
if (node.type === "Identifier") {
|
|
22416
|
-
const isLocal = !!knownIds[node.name];
|
|
22417
|
-
const isRefed = isReferencedIdentifier(node, parent, parentStack);
|
|
22418
|
-
if (includeAll || isRefed && !isLocal) {
|
|
22419
|
-
onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
22420
|
-
}
|
|
22421
|
-
} else if (node.type === "ObjectProperty" && parent.type === "ObjectPattern") {
|
|
22422
|
-
node.inPattern = true;
|
|
22423
|
-
} else if (isFunctionType(node)) {
|
|
22424
|
-
walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
22425
|
-
} else if (node.type === "BlockStatement") {
|
|
22426
|
-
walkBlockDeclarations(
|
|
22427
|
-
node,
|
|
22428
|
-
(id) => markScopeIdentifier(node, id, knownIds)
|
|
22429
|
-
);
|
|
22430
|
-
}
|
|
22431
|
-
},
|
|
22432
|
-
leave(node, parent) {
|
|
22433
|
-
parent && parentStack.pop();
|
|
22434
|
-
if (node !== rootExp && node.scopeIds) {
|
|
22435
|
-
for (const id of node.scopeIds) {
|
|
22436
|
-
knownIds[id]--;
|
|
22437
|
-
if (knownIds[id] === 0) {
|
|
22438
|
-
delete knownIds[id];
|
|
22439
|
-
}
|
|
22440
|
-
}
|
|
22441
|
-
}
|
|
22442
|
-
}
|
|
22443
|
-
});
|
|
22444
|
-
}
|
|
22445
|
-
function isReferencedIdentifier(id, parent, parentStack) {
|
|
22446
|
-
if (!parent) {
|
|
22447
|
-
return true;
|
|
22448
|
-
}
|
|
22449
|
-
if (id.name === "arguments") {
|
|
22450
|
-
return false;
|
|
22451
|
-
}
|
|
22452
|
-
if (isReferenced(id, parent)) {
|
|
22453
|
-
return true;
|
|
22454
|
-
}
|
|
22455
|
-
switch (parent.type) {
|
|
22456
|
-
case "AssignmentExpression":
|
|
22457
|
-
case "AssignmentPattern":
|
|
22458
|
-
return true;
|
|
22459
|
-
case "ObjectPattern":
|
|
22460
|
-
case "ArrayPattern":
|
|
22461
|
-
return isInDestructureAssignment(parent, parentStack);
|
|
22462
|
-
}
|
|
22463
|
-
return false;
|
|
22464
|
-
}
|
|
22465
|
-
function isInDestructureAssignment(parent, parentStack) {
|
|
22466
|
-
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
22467
|
-
let i = parentStack.length;
|
|
22468
|
-
while (i--) {
|
|
22469
|
-
const p = parentStack[i];
|
|
22470
|
-
if (p.type === "AssignmentExpression") {
|
|
22471
|
-
return true;
|
|
22472
|
-
} else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
|
|
22473
|
-
break;
|
|
22474
|
-
}
|
|
22475
|
-
}
|
|
22476
|
-
}
|
|
22477
|
-
return false;
|
|
22478
|
-
}
|
|
22479
|
-
function walkFunctionParams(node, onIdent) {
|
|
22480
|
-
for (const p of node.params) {
|
|
22481
|
-
for (const id of extractIdentifiers(p)) {
|
|
22482
|
-
onIdent(id);
|
|
22483
|
-
}
|
|
22484
|
-
}
|
|
22485
|
-
}
|
|
22486
|
-
function walkBlockDeclarations(block, onIdent) {
|
|
22487
|
-
for (const stmt of block.body) {
|
|
22488
|
-
if (stmt.type === "VariableDeclaration") {
|
|
22489
|
-
if (stmt.declare)
|
|
22490
|
-
continue;
|
|
22491
|
-
for (const decl of stmt.declarations) {
|
|
22492
|
-
for (const id of extractIdentifiers(decl.id)) {
|
|
22493
|
-
onIdent(id);
|
|
22494
|
-
}
|
|
22495
|
-
}
|
|
22496
|
-
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
22497
|
-
if (stmt.declare || !stmt.id)
|
|
22498
|
-
continue;
|
|
22499
|
-
onIdent(stmt.id);
|
|
22500
|
-
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
22501
|
-
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
22502
|
-
if (variable && variable.type === "VariableDeclaration") {
|
|
22503
|
-
for (const decl of variable.declarations) {
|
|
22504
|
-
for (const id of extractIdentifiers(decl.id)) {
|
|
22505
|
-
onIdent(id);
|
|
22506
|
-
}
|
|
22507
|
-
}
|
|
22508
|
-
}
|
|
22509
|
-
}
|
|
22510
|
-
}
|
|
22511
|
-
}
|
|
22512
|
-
function extractIdentifiers(param, nodes = []) {
|
|
22513
|
-
switch (param.type) {
|
|
22514
|
-
case "Identifier":
|
|
22515
|
-
nodes.push(param);
|
|
22516
|
-
break;
|
|
22517
|
-
case "MemberExpression":
|
|
22518
|
-
let object = param;
|
|
22519
|
-
while (object.type === "MemberExpression") {
|
|
22520
|
-
object = object.object;
|
|
22521
|
-
}
|
|
22522
|
-
nodes.push(object);
|
|
22523
|
-
break;
|
|
22524
|
-
case "ObjectPattern":
|
|
22525
|
-
for (const prop of param.properties) {
|
|
22526
|
-
if (prop.type === "RestElement") {
|
|
22527
|
-
extractIdentifiers(prop.argument, nodes);
|
|
22528
|
-
} else {
|
|
22529
|
-
extractIdentifiers(prop.value, nodes);
|
|
22530
|
-
}
|
|
22531
|
-
}
|
|
22532
|
-
break;
|
|
22533
|
-
case "ArrayPattern":
|
|
22534
|
-
param.elements.forEach((element) => {
|
|
22535
|
-
if (element)
|
|
22536
|
-
extractIdentifiers(element, nodes);
|
|
22537
|
-
});
|
|
22538
|
-
break;
|
|
22539
|
-
case "RestElement":
|
|
22540
|
-
extractIdentifiers(param.argument, nodes);
|
|
22541
|
-
break;
|
|
22542
|
-
case "AssignmentPattern":
|
|
22543
|
-
extractIdentifiers(param.left, nodes);
|
|
22544
|
-
break;
|
|
22545
|
-
}
|
|
22546
|
-
return nodes;
|
|
22547
|
-
}
|
|
22548
|
-
function markScopeIdentifier(node, child, knownIds) {
|
|
22549
|
-
const { name } = child;
|
|
22550
|
-
if (node.scopeIds && node.scopeIds.has(name)) {
|
|
22551
|
-
return;
|
|
22552
|
-
}
|
|
22553
|
-
if (name in knownIds) {
|
|
22554
|
-
knownIds[name]++;
|
|
22555
|
-
} else {
|
|
22556
|
-
knownIds[name] = 1;
|
|
22557
|
-
}
|
|
22558
|
-
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
22559
|
-
}
|
|
22560
|
-
const isFunctionType = (node) => {
|
|
22561
|
-
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
22562
|
-
};
|
|
22563
|
-
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
22564
|
-
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
22565
|
-
function isReferenced(node, parent, grandparent) {
|
|
22566
|
-
switch (parent.type) {
|
|
22567
|
-
case "MemberExpression":
|
|
22568
|
-
case "OptionalMemberExpression":
|
|
22569
|
-
if (parent.property === node) {
|
|
22570
|
-
return !!parent.computed;
|
|
22571
|
-
}
|
|
22572
|
-
return parent.object === node;
|
|
22573
|
-
case "JSXMemberExpression":
|
|
22574
|
-
return parent.object === node;
|
|
22575
|
-
case "VariableDeclarator":
|
|
22576
|
-
return parent.init === node;
|
|
22577
|
-
case "ArrowFunctionExpression":
|
|
22578
|
-
return parent.body === node;
|
|
22579
|
-
case "PrivateName":
|
|
22580
|
-
return false;
|
|
22581
|
-
case "ClassMethod":
|
|
22582
|
-
case "ClassPrivateMethod":
|
|
22583
|
-
case "ObjectMethod":
|
|
22584
|
-
if (parent.key === node) {
|
|
22585
|
-
return !!parent.computed;
|
|
22586
|
-
}
|
|
22587
|
-
return false;
|
|
22588
|
-
case "ObjectProperty":
|
|
22589
|
-
if (parent.key === node) {
|
|
22590
|
-
return !!parent.computed;
|
|
22591
|
-
}
|
|
22592
|
-
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
22593
|
-
case "ClassProperty":
|
|
22594
|
-
if (parent.key === node) {
|
|
22595
|
-
return !!parent.computed;
|
|
22596
|
-
}
|
|
22597
|
-
return true;
|
|
22598
|
-
case "ClassPrivateProperty":
|
|
22599
|
-
return parent.key !== node;
|
|
22600
|
-
case "ClassDeclaration":
|
|
22601
|
-
case "ClassExpression":
|
|
22602
|
-
return parent.superClass === node;
|
|
22603
|
-
case "AssignmentExpression":
|
|
22604
|
-
return parent.right === node;
|
|
22605
|
-
case "AssignmentPattern":
|
|
22606
|
-
return parent.right === node;
|
|
22607
|
-
case "LabeledStatement":
|
|
22608
|
-
return false;
|
|
22609
|
-
case "CatchClause":
|
|
22610
|
-
return false;
|
|
22611
|
-
case "RestElement":
|
|
22612
|
-
return false;
|
|
22613
|
-
case "BreakStatement":
|
|
22614
|
-
case "ContinueStatement":
|
|
22615
|
-
return false;
|
|
22616
|
-
case "FunctionDeclaration":
|
|
22617
|
-
case "FunctionExpression":
|
|
22618
|
-
return false;
|
|
22619
|
-
case "ExportNamespaceSpecifier":
|
|
22620
|
-
case "ExportDefaultSpecifier":
|
|
22621
|
-
return false;
|
|
22622
|
-
case "ExportSpecifier":
|
|
22623
|
-
if (grandparent == null ? void 0 : grandparent.source) {
|
|
22624
|
-
return false;
|
|
22625
|
-
}
|
|
22626
|
-
return parent.local === node;
|
|
22627
|
-
case "ImportDefaultSpecifier":
|
|
22628
|
-
case "ImportNamespaceSpecifier":
|
|
22629
|
-
case "ImportSpecifier":
|
|
22630
|
-
return false;
|
|
22631
|
-
case "ImportAttribute":
|
|
22632
|
-
return false;
|
|
22633
|
-
case "JSXAttribute":
|
|
22634
|
-
return false;
|
|
22635
|
-
case "ObjectPattern":
|
|
22636
|
-
case "ArrayPattern":
|
|
22637
|
-
return false;
|
|
22638
|
-
case "MetaProperty":
|
|
22639
|
-
return false;
|
|
22640
|
-
case "ObjectTypeProperty":
|
|
22641
|
-
return parent.key !== node;
|
|
22642
|
-
case "TSEnumMember":
|
|
22643
|
-
return parent.id !== node;
|
|
22644
|
-
case "TSPropertySignature":
|
|
22645
|
-
if (parent.key === node) {
|
|
22646
|
-
return !!parent.computed;
|
|
22647
|
-
}
|
|
22648
|
-
return true;
|
|
22649
|
-
}
|
|
22650
|
-
return true;
|
|
22651
|
-
}
|
|
22652
|
-
const TS_NODE_TYPES = [
|
|
22653
|
-
"TSAsExpression",
|
|
22654
|
-
// foo as number
|
|
22655
|
-
"TSTypeAssertion",
|
|
22656
|
-
// (<number>foo)
|
|
22657
|
-
"TSNonNullExpression",
|
|
22658
|
-
// foo!
|
|
22659
|
-
"TSInstantiationExpression",
|
|
22660
|
-
// foo<string>
|
|
22661
|
-
"TSSatisfiesExpression"
|
|
22662
|
-
// foo satisfies T
|
|
22663
|
-
];
|
|
22664
|
-
|
|
22665
22934
|
const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
|
|
22666
22935
|
const constantBailRE = /\w\s*\(|\.[^\d]/;
|
|
22667
22936
|
const transformExpression = (node, context) => {
|
|
@@ -22754,7 +23023,11 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
22754
23023
|
};
|
|
22755
23024
|
const rawExp = node.content;
|
|
22756
23025
|
const bailConstant = constantBailRE.test(rawExp);
|
|
22757
|
-
|
|
23026
|
+
let ast = node.ast;
|
|
23027
|
+
if (ast === false) {
|
|
23028
|
+
return node;
|
|
23029
|
+
}
|
|
23030
|
+
if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
|
|
22758
23031
|
const isScopeVarReference = context.identifiers[rawExp];
|
|
22759
23032
|
const isAllowedGlobal = isGloballyAllowed(rawExp);
|
|
22760
23033
|
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
@@ -22772,22 +23045,23 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
22772
23045
|
}
|
|
22773
23046
|
return node;
|
|
22774
23047
|
}
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
23048
|
+
if (!ast) {
|
|
23049
|
+
const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
|
|
23050
|
+
try {
|
|
23051
|
+
ast = parse_1$1(source, {
|
|
23052
|
+
plugins: context.expressionPlugins
|
|
23053
|
+
}).program;
|
|
23054
|
+
} catch (e) {
|
|
23055
|
+
context.onError(
|
|
23056
|
+
createCompilerError(
|
|
23057
|
+
45,
|
|
23058
|
+
node.loc,
|
|
23059
|
+
void 0,
|
|
23060
|
+
e.message
|
|
23061
|
+
)
|
|
23062
|
+
);
|
|
23063
|
+
return node;
|
|
23064
|
+
}
|
|
22791
23065
|
}
|
|
22792
23066
|
const ids = [];
|
|
22793
23067
|
const parentStack = [];
|
|
@@ -22827,15 +23101,15 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
22827
23101
|
if (leadingText.length || id.prefix) {
|
|
22828
23102
|
children.push(leadingText + (id.prefix || ``));
|
|
22829
23103
|
}
|
|
22830
|
-
const
|
|
23104
|
+
const source = rawExp.slice(start, end);
|
|
22831
23105
|
children.push(
|
|
22832
23106
|
createSimpleExpression(
|
|
22833
23107
|
id.name,
|
|
22834
23108
|
false,
|
|
22835
23109
|
{
|
|
22836
|
-
start: advancePositionWithClone(node.loc.start,
|
|
22837
|
-
end: advancePositionWithClone(node.loc.start,
|
|
22838
|
-
source
|
|
23110
|
+
start: advancePositionWithClone(node.loc.start, source, start),
|
|
23111
|
+
end: advancePositionWithClone(node.loc.start, source, end),
|
|
23112
|
+
source
|
|
22839
23113
|
},
|
|
22840
23114
|
id.isConstant ? 3 : 0
|
|
22841
23115
|
)
|
|
@@ -22847,6 +23121,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
22847
23121
|
let ret;
|
|
22848
23122
|
if (children.length) {
|
|
22849
23123
|
ret = createCompoundExpression(children, node.loc);
|
|
23124
|
+
ret.ast = ast;
|
|
22850
23125
|
} else {
|
|
22851
23126
|
ret = node;
|
|
22852
23127
|
ret.constType = bailConstant ? 0 : 3;
|
|
@@ -23800,6 +24075,10 @@ function resolveSetupReference(name, context) {
|
|
|
23800
24075
|
`${context.helperString(UNREF)}(${fromMaybeRef})`
|
|
23801
24076
|
) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
23802
24077
|
}
|
|
24078
|
+
const fromProps = checkType("props");
|
|
24079
|
+
if (fromProps) {
|
|
24080
|
+
return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
|
|
24081
|
+
}
|
|
23803
24082
|
}
|
|
23804
24083
|
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
23805
24084
|
const { tag, loc: elementLoc, children } = node;
|
|
@@ -23840,6 +24119,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
23840
24119
|
if (isEventHandler && isReservedProp(name)) {
|
|
23841
24120
|
hasVnodeHook = true;
|
|
23842
24121
|
}
|
|
24122
|
+
if (isEventHandler && value.type === 14) {
|
|
24123
|
+
value = value.arguments[0];
|
|
24124
|
+
}
|
|
23843
24125
|
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
|
23844
24126
|
return;
|
|
23845
24127
|
}
|
|
@@ -24271,9 +24553,7 @@ const transformOn$1 = (dir, node, context, augmentor) => {
|
|
|
24271
24553
|
if (arg.isStatic) {
|
|
24272
24554
|
let rawName = arg.content;
|
|
24273
24555
|
if (rawName.startsWith("vnode")) {
|
|
24274
|
-
context.
|
|
24275
|
-
createCompilerError(51, arg.loc)
|
|
24276
|
-
);
|
|
24556
|
+
context.onError(createCompilerError(51, arg.loc));
|
|
24277
24557
|
}
|
|
24278
24558
|
if (rawName.startsWith("vue:")) {
|
|
24279
24559
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
@@ -24665,7 +24945,10 @@ function baseCompile(source, options = {}) {
|
|
|
24665
24945
|
if (options.scopeId && !isModuleMode) {
|
|
24666
24946
|
onError(createCompilerError(50));
|
|
24667
24947
|
}
|
|
24668
|
-
const
|
|
24948
|
+
const resolvedOptions = extend({}, options, {
|
|
24949
|
+
prefixIdentifiers
|
|
24950
|
+
});
|
|
24951
|
+
const ast = isString$2(source) ? baseParse(source, resolvedOptions) : source;
|
|
24669
24952
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|
|
24670
24953
|
if (options.isTS) {
|
|
24671
24954
|
const { expressionPlugins } = options;
|
|
@@ -24675,8 +24958,7 @@ function baseCompile(source, options = {}) {
|
|
|
24675
24958
|
}
|
|
24676
24959
|
transform(
|
|
24677
24960
|
ast,
|
|
24678
|
-
extend({},
|
|
24679
|
-
prefixIdentifiers,
|
|
24961
|
+
extend({}, resolvedOptions, {
|
|
24680
24962
|
nodeTransforms: [
|
|
24681
24963
|
...nodeTransforms,
|
|
24682
24964
|
...options.nodeTransforms || []
|
|
@@ -24690,14 +24972,22 @@ function baseCompile(source, options = {}) {
|
|
|
24690
24972
|
)
|
|
24691
24973
|
})
|
|
24692
24974
|
);
|
|
24693
|
-
return generate(
|
|
24694
|
-
ast,
|
|
24695
|
-
extend({}, options, {
|
|
24696
|
-
prefixIdentifiers
|
|
24697
|
-
})
|
|
24698
|
-
);
|
|
24975
|
+
return generate(ast, resolvedOptions);
|
|
24699
24976
|
}
|
|
24700
24977
|
|
|
24978
|
+
const BindingTypes = {
|
|
24979
|
+
"DATA": "data",
|
|
24980
|
+
"PROPS": "props",
|
|
24981
|
+
"PROPS_ALIASED": "props-aliased",
|
|
24982
|
+
"SETUP_LET": "setup-let",
|
|
24983
|
+
"SETUP_CONST": "setup-const",
|
|
24984
|
+
"SETUP_REACTIVE_CONST": "setup-reactive-const",
|
|
24985
|
+
"SETUP_MAYBE_REF": "setup-maybe-ref",
|
|
24986
|
+
"SETUP_REF": "setup-ref",
|
|
24987
|
+
"OPTIONS": "options",
|
|
24988
|
+
"LITERAL_CONST": "literal-const"
|
|
24989
|
+
};
|
|
24990
|
+
|
|
24701
24991
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
24702
24992
|
|
|
24703
24993
|
const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
|
@@ -24726,7 +25016,7 @@ registerRuntimeHelpers({
|
|
|
24726
25016
|
const parserOptions = {
|
|
24727
25017
|
parseMode: "html",
|
|
24728
25018
|
isVoidTag,
|
|
24729
|
-
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
25019
|
+
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
|
24730
25020
|
isPreTag: (tag) => tag === "pre",
|
|
24731
25021
|
decodeEntities: void 0,
|
|
24732
25022
|
isBuiltInComponent: (tag) => {
|
|
@@ -24802,6 +25092,32 @@ function createDOMCompilerError(code, loc) {
|
|
|
24802
25092
|
DOMErrorMessages
|
|
24803
25093
|
);
|
|
24804
25094
|
}
|
|
25095
|
+
const DOMErrorCodes = {
|
|
25096
|
+
"X_V_HTML_NO_EXPRESSION": 53,
|
|
25097
|
+
"53": "X_V_HTML_NO_EXPRESSION",
|
|
25098
|
+
"X_V_HTML_WITH_CHILDREN": 54,
|
|
25099
|
+
"54": "X_V_HTML_WITH_CHILDREN",
|
|
25100
|
+
"X_V_TEXT_NO_EXPRESSION": 55,
|
|
25101
|
+
"55": "X_V_TEXT_NO_EXPRESSION",
|
|
25102
|
+
"X_V_TEXT_WITH_CHILDREN": 56,
|
|
25103
|
+
"56": "X_V_TEXT_WITH_CHILDREN",
|
|
25104
|
+
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
|
|
25105
|
+
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
|
|
25106
|
+
"X_V_MODEL_ARG_ON_ELEMENT": 58,
|
|
25107
|
+
"58": "X_V_MODEL_ARG_ON_ELEMENT",
|
|
25108
|
+
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
|
|
25109
|
+
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
|
25110
|
+
"X_V_MODEL_UNNECESSARY_VALUE": 60,
|
|
25111
|
+
"60": "X_V_MODEL_UNNECESSARY_VALUE",
|
|
25112
|
+
"X_V_SHOW_NO_EXPRESSION": 61,
|
|
25113
|
+
"61": "X_V_SHOW_NO_EXPRESSION",
|
|
25114
|
+
"X_TRANSITION_INVALID_CHILDREN": 62,
|
|
25115
|
+
"62": "X_TRANSITION_INVALID_CHILDREN",
|
|
25116
|
+
"X_IGNORED_SIDE_EFFECT_TAG": 63,
|
|
25117
|
+
"63": "X_IGNORED_SIDE_EFFECT_TAG",
|
|
25118
|
+
"__EXTEND_POINT__": 64,
|
|
25119
|
+
"64": "__EXTEND_POINT__"
|
|
25120
|
+
};
|
|
24805
25121
|
const DOMErrorMessages = {
|
|
24806
25122
|
[53]: `v-html is missing expression.`,
|
|
24807
25123
|
[54]: `v-html will override element children.`,
|
|
@@ -25364,6 +25680,7 @@ function parse$8(template, options = {}) {
|
|
|
25364
25680
|
var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
25365
25681
|
__proto__: null,
|
|
25366
25682
|
BASE_TRANSITION: BASE_TRANSITION,
|
|
25683
|
+
BindingTypes: BindingTypes,
|
|
25367
25684
|
CAMELIZE: CAMELIZE,
|
|
25368
25685
|
CAPITALIZE: CAPITALIZE,
|
|
25369
25686
|
CREATE_BLOCK: CREATE_BLOCK,
|
|
@@ -25374,9 +25691,14 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
25374
25691
|
CREATE_STATIC: CREATE_STATIC,
|
|
25375
25692
|
CREATE_TEXT: CREATE_TEXT,
|
|
25376
25693
|
CREATE_VNODE: CREATE_VNODE,
|
|
25694
|
+
CompilerDeprecationTypes: CompilerDeprecationTypes,
|
|
25695
|
+
ConstantTypes: ConstantTypes,
|
|
25377
25696
|
DOMDirectiveTransforms: DOMDirectiveTransforms,
|
|
25697
|
+
DOMErrorCodes: DOMErrorCodes,
|
|
25378
25698
|
DOMErrorMessages: DOMErrorMessages,
|
|
25379
25699
|
DOMNodeTransforms: DOMNodeTransforms,
|
|
25700
|
+
ElementTypes: ElementTypes,
|
|
25701
|
+
ErrorCodes: ErrorCodes,
|
|
25380
25702
|
FRAGMENT: FRAGMENT,
|
|
25381
25703
|
GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
|
|
25382
25704
|
IS_MEMO_SAME: IS_MEMO_SAME,
|
|
@@ -25386,6 +25708,8 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
25386
25708
|
NORMALIZE_CLASS: NORMALIZE_CLASS,
|
|
25387
25709
|
NORMALIZE_PROPS: NORMALIZE_PROPS,
|
|
25388
25710
|
NORMALIZE_STYLE: NORMALIZE_STYLE,
|
|
25711
|
+
Namespaces: Namespaces,
|
|
25712
|
+
NodeTypes: NodeTypes,
|
|
25389
25713
|
OPEN_BLOCK: OPEN_BLOCK,
|
|
25390
25714
|
POP_SCOPE_ID: POP_SCOPE_ID,
|
|
25391
25715
|
PUSH_SCOPE_ID: PUSH_SCOPE_ID,
|
|
@@ -25451,7 +25775,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
25451
25775
|
createTransformContext: createTransformContext,
|
|
25452
25776
|
createVNodeCall: createVNodeCall,
|
|
25453
25777
|
errorMessages: errorMessages,
|
|
25454
|
-
extractIdentifiers: extractIdentifiers,
|
|
25778
|
+
extractIdentifiers: extractIdentifiers$1,
|
|
25455
25779
|
findDir: findDir,
|
|
25456
25780
|
findProp: findProp,
|
|
25457
25781
|
forAliasRE: forAliasRE,
|
|
@@ -25504,6 +25828,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
25504
25828
|
transformOn: transformOn$1,
|
|
25505
25829
|
transformStyle: transformStyle,
|
|
25506
25830
|
traverseNode: traverseNode,
|
|
25831
|
+
unwrapTSNode: unwrapTSNode,
|
|
25507
25832
|
walkBlockDeclarations: walkBlockDeclarations,
|
|
25508
25833
|
walkFunctionParams: walkFunctionParams,
|
|
25509
25834
|
walkIdentifiers: walkIdentifiers,
|
|
@@ -25776,13 +26101,6 @@ function concatStrings(strs) {
|
|
|
25776
26101
|
function isLiteralNode(node) {
|
|
25777
26102
|
return node.type.endsWith("Literal");
|
|
25778
26103
|
}
|
|
25779
|
-
function unwrapTSNode(node) {
|
|
25780
|
-
if (TS_NODE_TYPES.includes(node.type)) {
|
|
25781
|
-
return unwrapTSNode(node.expression);
|
|
25782
|
-
} else {
|
|
25783
|
-
return node;
|
|
25784
|
-
}
|
|
25785
|
-
}
|
|
25786
26104
|
function isCallOf(node, test) {
|
|
25787
26105
|
return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
|
|
25788
26106
|
}
|
|
@@ -25810,8 +26128,11 @@ function getEscapedPropName(key) {
|
|
|
25810
26128
|
return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
|
|
25811
26129
|
}
|
|
25812
26130
|
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
25813
|
-
function getEscapedCssVarName(key) {
|
|
25814
|
-
return key.replace(
|
|
26131
|
+
function getEscapedCssVarName(key, doubleEscape) {
|
|
26132
|
+
return key.replace(
|
|
26133
|
+
cssVarNameEscapeSymbolsRE,
|
|
26134
|
+
(s) => doubleEscape ? `\\\\${s}` : `\\${s}`
|
|
26135
|
+
);
|
|
25815
26136
|
}
|
|
25816
26137
|
|
|
25817
26138
|
function pad$1 (hash, len) {
|
|
@@ -25888,15 +26209,15 @@ const CSS_VARS_HELPER = `useCssVars`;
|
|
|
25888
26209
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
25889
26210
|
return `{
|
|
25890
26211
|
${vars.map(
|
|
25891
|
-
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
|
|
26212
|
+
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
|
|
25892
26213
|
).join(",\n ")}
|
|
25893
26214
|
}`;
|
|
25894
26215
|
}
|
|
25895
|
-
function genVarName(id, raw, isProd) {
|
|
26216
|
+
function genVarName(id, raw, isProd, isSSR = false) {
|
|
25896
26217
|
if (isProd) {
|
|
25897
26218
|
return hash(id + raw);
|
|
25898
26219
|
} else {
|
|
25899
|
-
return `${id}-${getEscapedCssVarName(raw)}`;
|
|
26220
|
+
return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
|
|
25900
26221
|
}
|
|
25901
26222
|
}
|
|
25902
26223
|
function normalizeExpression(exp) {
|
|
@@ -26250,11 +26571,7 @@ function createCache(max = 500) {
|
|
|
26250
26571
|
}
|
|
26251
26572
|
|
|
26252
26573
|
function isImportUsed(local, sfc) {
|
|
26253
|
-
return
|
|
26254
|
-
// #4274 escape $ since it's a special char in regex
|
|
26255
|
-
// (and is the only regex special char that is valid in identifiers)
|
|
26256
|
-
`[^\\w$_]${local.replace(/\$/g, "\\$")}[^\\w$_]`
|
|
26257
|
-
).test(resolveTemplateUsageCheckString(sfc));
|
|
26574
|
+
return resolveTemplateUsageCheckString(sfc).has(local);
|
|
26258
26575
|
}
|
|
26259
26576
|
const templateUsageCheckCache = createCache();
|
|
26260
26577
|
function resolveTemplateUsageCheckString(sfc) {
|
|
@@ -26263,80 +26580,51 @@ function resolveTemplateUsageCheckString(sfc) {
|
|
|
26263
26580
|
if (cached) {
|
|
26264
26581
|
return cached;
|
|
26265
26582
|
}
|
|
26266
|
-
|
|
26583
|
+
const ids = /* @__PURE__ */ new Set();
|
|
26267
26584
|
ast.children.forEach(walk);
|
|
26268
26585
|
function walk(node) {
|
|
26269
26586
|
var _a;
|
|
26270
26587
|
switch (node.type) {
|
|
26271
26588
|
case 1:
|
|
26272
26589
|
if (!parserOptions.isNativeTag(node.tag) && !parserOptions.isBuiltInComponent(node.tag)) {
|
|
26273
|
-
|
|
26590
|
+
ids.add(camelize(node.tag));
|
|
26591
|
+
ids.add(capitalize$1(camelize(node.tag)));
|
|
26274
26592
|
}
|
|
26275
26593
|
for (let i = 0; i < node.props.length; i++) {
|
|
26276
26594
|
const prop = node.props[i];
|
|
26277
26595
|
if (prop.type === 7) {
|
|
26278
26596
|
if (!isBuiltInDirective(prop.name)) {
|
|
26279
|
-
|
|
26597
|
+
ids.add(`v${capitalize$1(camelize(prop.name))}`);
|
|
26280
26598
|
}
|
|
26281
26599
|
if (prop.arg && !prop.arg.isStatic) {
|
|
26282
|
-
|
|
26283
|
-
prop.arg.content
|
|
26284
|
-
)}`;
|
|
26600
|
+
extractIdentifiers(ids, prop.arg);
|
|
26285
26601
|
}
|
|
26286
|
-
if (prop.
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
)}`;
|
|
26602
|
+
if (prop.name === "for") {
|
|
26603
|
+
extractIdentifiers(ids, prop.forParseResult.source);
|
|
26604
|
+
} else if (prop.exp) {
|
|
26605
|
+
extractIdentifiers(ids, prop.exp);
|
|
26291
26606
|
}
|
|
26292
26607
|
}
|
|
26293
26608
|
if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
|
|
26294
|
-
|
|
26609
|
+
ids.add(prop.value.content);
|
|
26295
26610
|
}
|
|
26296
26611
|
}
|
|
26297
26612
|
node.children.forEach(walk);
|
|
26298
26613
|
break;
|
|
26299
26614
|
case 5:
|
|
26300
|
-
|
|
26615
|
+
extractIdentifiers(ids, node.content);
|
|
26301
26616
|
break;
|
|
26302
26617
|
}
|
|
26303
26618
|
}
|
|
26304
|
-
|
|
26305
|
-
|
|
26306
|
-
return code;
|
|
26307
|
-
}
|
|
26308
|
-
function processExp(exp, dir) {
|
|
26309
|
-
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
|
26310
|
-
if (dir === "slot") {
|
|
26311
|
-
exp = `(${exp})=>{}`;
|
|
26312
|
-
} else if (dir === "on") {
|
|
26313
|
-
exp = `()=>{return ${exp}}`;
|
|
26314
|
-
} else if (dir === "for") {
|
|
26315
|
-
const inMatch = exp.match(forAliasRE);
|
|
26316
|
-
if (inMatch) {
|
|
26317
|
-
let [, LHS, RHS] = inMatch;
|
|
26318
|
-
LHS = LHS.trim().replace(/^\(|\)$/g, "");
|
|
26319
|
-
return processExp(`(${LHS})=>{}`) + processExp(RHS);
|
|
26320
|
-
}
|
|
26321
|
-
}
|
|
26322
|
-
let ret = "";
|
|
26323
|
-
const ast = parseExpression_1(exp, { plugins: ["typescript"] });
|
|
26324
|
-
walkIdentifiers(ast, (node) => {
|
|
26325
|
-
ret += `,` + node.name;
|
|
26326
|
-
});
|
|
26327
|
-
return ret;
|
|
26328
|
-
}
|
|
26329
|
-
return stripStrings(exp);
|
|
26330
|
-
}
|
|
26331
|
-
function stripStrings(exp) {
|
|
26332
|
-
return exp.replace(/'[^']*'|"[^"]*"/g, "").replace(/`[^`]+`/g, stripTemplateString);
|
|
26619
|
+
templateUsageCheckCache.set(content, ids);
|
|
26620
|
+
return ids;
|
|
26333
26621
|
}
|
|
26334
|
-
function
|
|
26335
|
-
|
|
26336
|
-
|
|
26337
|
-
|
|
26622
|
+
function extractIdentifiers(ids, node) {
|
|
26623
|
+
if (node.ast) {
|
|
26624
|
+
walkIdentifiers(node.ast, (n) => ids.add(n.name));
|
|
26625
|
+
} else if (node.ast === null) {
|
|
26626
|
+
ids.add(node.content);
|
|
26338
26627
|
}
|
|
26339
|
-
return "";
|
|
26340
26628
|
}
|
|
26341
26629
|
|
|
26342
26630
|
const DEFAULT_FILENAME = "anonymous.vue";
|
|
@@ -26347,7 +26635,8 @@ function parse$7(source, {
|
|
|
26347
26635
|
sourceRoot = "",
|
|
26348
26636
|
pad = false,
|
|
26349
26637
|
ignoreEmpty = true,
|
|
26350
|
-
compiler = CompilerDOM
|
|
26638
|
+
compiler = CompilerDOM,
|
|
26639
|
+
parseExpressions = true
|
|
26351
26640
|
} = {}) {
|
|
26352
26641
|
const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
|
|
26353
26642
|
const cache = parseCache$1.get(sourceKey);
|
|
@@ -26369,6 +26658,7 @@ function parse$7(source, {
|
|
|
26369
26658
|
const errors = [];
|
|
26370
26659
|
const ast = compiler.parse(source, {
|
|
26371
26660
|
parseMode: "sfc",
|
|
26661
|
+
prefixIdentifiers: parseExpressions,
|
|
26372
26662
|
onError: (e) => {
|
|
26373
26663
|
errors.push(e);
|
|
26374
26664
|
}
|
|
@@ -26458,22 +26748,29 @@ function parse$7(source, {
|
|
|
26458
26748
|
descriptor.script = null;
|
|
26459
26749
|
}
|
|
26460
26750
|
}
|
|
26751
|
+
let templateColumnOffset = 0;
|
|
26752
|
+
if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
|
|
26753
|
+
[descriptor.template.content, templateColumnOffset] = dedent(
|
|
26754
|
+
descriptor.template.content
|
|
26755
|
+
);
|
|
26756
|
+
}
|
|
26461
26757
|
if (sourceMap) {
|
|
26462
|
-
const genMap = (block) => {
|
|
26758
|
+
const genMap = (block, columnOffset = 0) => {
|
|
26463
26759
|
if (block && !block.src) {
|
|
26464
26760
|
block.map = generateSourceMap(
|
|
26465
26761
|
filename,
|
|
26466
26762
|
source,
|
|
26467
26763
|
block.content,
|
|
26468
26764
|
sourceRoot,
|
|
26469
|
-
!pad || block.type === "template" ? block.loc.start.line - 1 : 0
|
|
26765
|
+
!pad || block.type === "template" ? block.loc.start.line - 1 : 0,
|
|
26766
|
+
columnOffset
|
|
26470
26767
|
);
|
|
26471
26768
|
}
|
|
26472
26769
|
};
|
|
26473
|
-
genMap(descriptor.template);
|
|
26770
|
+
genMap(descriptor.template, templateColumnOffset);
|
|
26474
26771
|
genMap(descriptor.script);
|
|
26475
|
-
descriptor.styles.forEach(genMap);
|
|
26476
|
-
descriptor.customBlocks.forEach(genMap);
|
|
26772
|
+
descriptor.styles.forEach((s) => genMap(s));
|
|
26773
|
+
descriptor.customBlocks.forEach((s) => genMap(s));
|
|
26477
26774
|
}
|
|
26478
26775
|
descriptor.cssVars = parseCssVars(descriptor);
|
|
26479
26776
|
const slottedRE = /(?:::v-|:)slotted\(/;
|
|
@@ -26531,7 +26828,7 @@ function createBlock(node, source, pad) {
|
|
|
26531
26828
|
const splitRE = /\r?\n/g;
|
|
26532
26829
|
const emptyRE = /^(?:\/\/)?\s*$/;
|
|
26533
26830
|
const replaceRE = /./g;
|
|
26534
|
-
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
|
|
26831
|
+
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
|
|
26535
26832
|
const map = new SourceMapGenerator$6({
|
|
26536
26833
|
file: filename.replace(/\\/g, "/"),
|
|
26537
26834
|
sourceRoot: sourceRoot.replace(/\\/g, "/")
|
|
@@ -26546,7 +26843,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
|
|
|
26546
26843
|
if (!/\s/.test(line[i])) {
|
|
26547
26844
|
map._mappings.add({
|
|
26548
26845
|
originalLine,
|
|
26549
|
-
originalColumn: i,
|
|
26846
|
+
originalColumn: i + columnOffset,
|
|
26550
26847
|
generatedLine,
|
|
26551
26848
|
generatedColumn: i,
|
|
26552
26849
|
source: filename,
|
|
@@ -26597,6 +26894,26 @@ function hmrShouldReload(prevImports, next) {
|
|
|
26597
26894
|
}
|
|
26598
26895
|
return false;
|
|
26599
26896
|
}
|
|
26897
|
+
function dedent(s) {
|
|
26898
|
+
const lines = s.split("\n");
|
|
26899
|
+
const minIndent = lines.reduce(function(minIndent2, line) {
|
|
26900
|
+
var _a, _b;
|
|
26901
|
+
if (line.trim() === "") {
|
|
26902
|
+
return minIndent2;
|
|
26903
|
+
}
|
|
26904
|
+
const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
|
|
26905
|
+
return Math.min(indent, minIndent2);
|
|
26906
|
+
}, Infinity);
|
|
26907
|
+
if (minIndent === 0) {
|
|
26908
|
+
return [s, minIndent];
|
|
26909
|
+
}
|
|
26910
|
+
return [
|
|
26911
|
+
lines.map(function(line) {
|
|
26912
|
+
return line.slice(minIndent);
|
|
26913
|
+
}).join("\n"),
|
|
26914
|
+
minIndent
|
|
26915
|
+
];
|
|
26916
|
+
}
|
|
26600
26917
|
|
|
26601
26918
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
26602
26919
|
|
|
@@ -32144,7 +32461,7 @@ var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
|
|
|
32144
32461
|
|
|
32145
32462
|
var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
|
|
32146
32463
|
|
|
32147
|
-
var require$$
|
|
32464
|
+
var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
|
|
32148
32465
|
|
|
32149
32466
|
var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
|
|
32150
32467
|
|
|
@@ -33714,7 +34031,7 @@ var nonSecure = { nanoid: nanoid$1, customAlphabet };
|
|
|
33714
34031
|
|
|
33715
34032
|
let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
|
|
33716
34033
|
let { existsSync, readFileSync } = require$$0$2;
|
|
33717
|
-
let { dirname: dirname$1, join } = require$$
|
|
34034
|
+
let { dirname: dirname$1, join } = require$$1;
|
|
33718
34035
|
|
|
33719
34036
|
function fromBase64(str) {
|
|
33720
34037
|
if (Buffer$1) {
|
|
@@ -33855,7 +34172,7 @@ PreviousMap$2.default = PreviousMap$2;
|
|
|
33855
34172
|
|
|
33856
34173
|
let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
|
|
33857
34174
|
let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
|
|
33858
|
-
let { isAbsolute, resolve: resolve$1 } = require$$
|
|
34175
|
+
let { isAbsolute, resolve: resolve$1 } = require$$1;
|
|
33859
34176
|
let { nanoid } = nonSecure;
|
|
33860
34177
|
|
|
33861
34178
|
let terminalHighlight = terminalHighlight_1;
|
|
@@ -34101,7 +34418,7 @@ if (terminalHighlight && terminalHighlight.registerInput) {
|
|
|
34101
34418
|
}
|
|
34102
34419
|
|
|
34103
34420
|
let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
|
|
34104
|
-
let { dirname, relative, resolve, sep } = require$$
|
|
34421
|
+
let { dirname, relative, resolve, sep } = require$$1;
|
|
34105
34422
|
let { pathToFileURL } = require$$2;
|
|
34106
34423
|
|
|
34107
34424
|
let Input$3 = input;
|
|
@@ -36536,7 +36853,7 @@ let Root$2 = root$2;
|
|
|
36536
36853
|
|
|
36537
36854
|
let Processor$1 = class Processor {
|
|
36538
36855
|
constructor(plugins = []) {
|
|
36539
|
-
this.version = '8.4.
|
|
36856
|
+
this.version = '8.4.32';
|
|
36540
36857
|
this.plugins = this.normalize(plugins);
|
|
36541
36858
|
}
|
|
36542
36859
|
|
|
@@ -40328,14 +40645,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
|
|
|
40328
40645
|
return false;
|
|
40329
40646
|
}
|
|
40330
40647
|
}
|
|
40331
|
-
if (n.type !== "pseudo" && n.type !== "combinator") {
|
|
40648
|
+
if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
|
|
40332
40649
|
node = n;
|
|
40333
40650
|
}
|
|
40334
|
-
|
|
40335
|
-
|
|
40651
|
+
});
|
|
40652
|
+
if (node) {
|
|
40653
|
+
const { type, value } = node;
|
|
40654
|
+
if (type === "pseudo" && (value === ":is" || value === ":where")) {
|
|
40655
|
+
node.nodes.forEach(
|
|
40656
|
+
(value2) => rewriteSelector(id, value2, selectorRoot, slotted)
|
|
40657
|
+
);
|
|
40336
40658
|
shouldInject = false;
|
|
40337
40659
|
}
|
|
40338
|
-
}
|
|
40660
|
+
}
|
|
40339
40661
|
if (node) {
|
|
40340
40662
|
node.spaces.after = "";
|
|
40341
40663
|
} else {
|
|
@@ -45211,10 +45533,118 @@ class MagicString {
|
|
|
45211
45533
|
}
|
|
45212
45534
|
}
|
|
45213
45535
|
|
|
45536
|
+
var _a, _b;
|
|
45537
|
+
class ScriptCompileContext {
|
|
45538
|
+
constructor(descriptor, options) {
|
|
45539
|
+
this.descriptor = descriptor;
|
|
45540
|
+
this.options = options;
|
|
45541
|
+
this.isCE = false;
|
|
45542
|
+
this.source = this.descriptor.source;
|
|
45543
|
+
this.filename = this.descriptor.filename;
|
|
45544
|
+
this.s = new MagicString(this.source);
|
|
45545
|
+
this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
|
|
45546
|
+
this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
|
|
45547
|
+
this.userImports = /* @__PURE__ */ Object.create(null);
|
|
45548
|
+
// macros presence check
|
|
45549
|
+
this.hasDefinePropsCall = false;
|
|
45550
|
+
this.hasDefineEmitCall = false;
|
|
45551
|
+
this.hasDefineExposeCall = false;
|
|
45552
|
+
this.hasDefaultExportName = false;
|
|
45553
|
+
this.hasDefaultExportRender = false;
|
|
45554
|
+
this.hasDefineOptionsCall = false;
|
|
45555
|
+
this.hasDefineSlotsCall = false;
|
|
45556
|
+
this.hasDefineModelCall = false;
|
|
45557
|
+
this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
|
|
45558
|
+
// defineModel
|
|
45559
|
+
this.modelDecls = /* @__PURE__ */ Object.create(null);
|
|
45560
|
+
// codegen
|
|
45561
|
+
this.bindingMetadata = {};
|
|
45562
|
+
this.helperImports = /* @__PURE__ */ new Set();
|
|
45563
|
+
const { script, scriptSetup } = descriptor;
|
|
45564
|
+
const scriptLang = script && script.lang;
|
|
45565
|
+
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
45566
|
+
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
45567
|
+
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
45568
|
+
const customElement = options.customElement;
|
|
45569
|
+
const filename = this.descriptor.filename;
|
|
45570
|
+
if (customElement) {
|
|
45571
|
+
this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
|
|
45572
|
+
}
|
|
45573
|
+
const plugins = resolveParserPlugins(
|
|
45574
|
+
scriptLang || scriptSetupLang,
|
|
45575
|
+
options.babelParserPlugins
|
|
45576
|
+
);
|
|
45577
|
+
function parse(input, offset) {
|
|
45578
|
+
try {
|
|
45579
|
+
return parse_1$1(input, {
|
|
45580
|
+
plugins,
|
|
45581
|
+
sourceType: "module"
|
|
45582
|
+
}).program;
|
|
45583
|
+
} catch (e) {
|
|
45584
|
+
e.message = `[vue/compiler-sfc] ${e.message}
|
|
45585
|
+
|
|
45586
|
+
${descriptor.filename}
|
|
45587
|
+
${generateCodeFrame(
|
|
45588
|
+
descriptor.source,
|
|
45589
|
+
e.pos + offset,
|
|
45590
|
+
e.pos + offset + 1
|
|
45591
|
+
)}`;
|
|
45592
|
+
throw e;
|
|
45593
|
+
}
|
|
45594
|
+
}
|
|
45595
|
+
this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
|
|
45596
|
+
this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
|
|
45597
|
+
}
|
|
45598
|
+
helper(key) {
|
|
45599
|
+
this.helperImports.add(key);
|
|
45600
|
+
return `_${key}`;
|
|
45601
|
+
}
|
|
45602
|
+
getString(node, scriptSetup = true) {
|
|
45603
|
+
const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
|
|
45604
|
+
return block.content.slice(node.start, node.end);
|
|
45605
|
+
}
|
|
45606
|
+
error(msg, node, scope) {
|
|
45607
|
+
const offset = scope ? scope.offset : this.startOffset;
|
|
45608
|
+
throw new Error(
|
|
45609
|
+
`[@vue/compiler-sfc] ${msg}
|
|
45610
|
+
|
|
45611
|
+
${(scope || this.descriptor).filename}
|
|
45612
|
+
${generateCodeFrame(
|
|
45613
|
+
(scope || this.descriptor).source,
|
|
45614
|
+
node.start + offset,
|
|
45615
|
+
node.end + offset
|
|
45616
|
+
)}`
|
|
45617
|
+
);
|
|
45618
|
+
}
|
|
45619
|
+
}
|
|
45620
|
+
function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
45621
|
+
const plugins = [];
|
|
45622
|
+
if (!userPlugins || !userPlugins.some(
|
|
45623
|
+
(p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
|
|
45624
|
+
)) {
|
|
45625
|
+
plugins.push("importAttributes");
|
|
45626
|
+
}
|
|
45627
|
+
if (lang === "jsx" || lang === "tsx") {
|
|
45628
|
+
plugins.push("jsx");
|
|
45629
|
+
} else if (userPlugins) {
|
|
45630
|
+
userPlugins = userPlugins.filter((p) => p !== "jsx");
|
|
45631
|
+
}
|
|
45632
|
+
if (lang === "ts" || lang === "tsx") {
|
|
45633
|
+
plugins.push(["typescript", { dts }], "explicitResourceManagement");
|
|
45634
|
+
if (!userPlugins || !userPlugins.includes("decorators")) {
|
|
45635
|
+
plugins.push("decorators-legacy");
|
|
45636
|
+
}
|
|
45637
|
+
}
|
|
45638
|
+
if (userPlugins) {
|
|
45639
|
+
plugins.push(...userPlugins);
|
|
45640
|
+
}
|
|
45641
|
+
return plugins;
|
|
45642
|
+
}
|
|
45643
|
+
|
|
45214
45644
|
function rewriteDefault(input, as, parserPlugins) {
|
|
45215
45645
|
const ast = parse_1$1(input, {
|
|
45216
45646
|
sourceType: "module",
|
|
45217
|
-
plugins: parserPlugins
|
|
45647
|
+
plugins: resolveParserPlugins("js", parserPlugins)
|
|
45218
45648
|
}).program.body;
|
|
45219
45649
|
const s = new MagicString(input);
|
|
45220
45650
|
rewriteDefaultAST(ast, s, as);
|
|
@@ -45366,103 +45796,6 @@ export default ${defaultVar}`;
|
|
|
45366
45796
|
}
|
|
45367
45797
|
}
|
|
45368
45798
|
|
|
45369
|
-
var _a, _b;
|
|
45370
|
-
class ScriptCompileContext {
|
|
45371
|
-
constructor(descriptor, options) {
|
|
45372
|
-
this.descriptor = descriptor;
|
|
45373
|
-
this.options = options;
|
|
45374
|
-
this.source = this.descriptor.source;
|
|
45375
|
-
this.filename = this.descriptor.filename;
|
|
45376
|
-
this.s = new MagicString(this.source);
|
|
45377
|
-
this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
|
|
45378
|
-
this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
|
|
45379
|
-
this.userImports = /* @__PURE__ */ Object.create(null);
|
|
45380
|
-
// macros presence check
|
|
45381
|
-
this.hasDefinePropsCall = false;
|
|
45382
|
-
this.hasDefineEmitCall = false;
|
|
45383
|
-
this.hasDefineExposeCall = false;
|
|
45384
|
-
this.hasDefaultExportName = false;
|
|
45385
|
-
this.hasDefaultExportRender = false;
|
|
45386
|
-
this.hasDefineOptionsCall = false;
|
|
45387
|
-
this.hasDefineSlotsCall = false;
|
|
45388
|
-
this.hasDefineModelCall = false;
|
|
45389
|
-
this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
|
|
45390
|
-
// defineModel
|
|
45391
|
-
this.modelDecls = /* @__PURE__ */ Object.create(null);
|
|
45392
|
-
// codegen
|
|
45393
|
-
this.bindingMetadata = {};
|
|
45394
|
-
this.helperImports = /* @__PURE__ */ new Set();
|
|
45395
|
-
const { script, scriptSetup } = descriptor;
|
|
45396
|
-
const scriptLang = script && script.lang;
|
|
45397
|
-
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
45398
|
-
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
45399
|
-
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
45400
|
-
const plugins = resolveParserPlugins(
|
|
45401
|
-
scriptLang || scriptSetupLang,
|
|
45402
|
-
options.babelParserPlugins
|
|
45403
|
-
);
|
|
45404
|
-
function parse(input, offset) {
|
|
45405
|
-
try {
|
|
45406
|
-
return parse_1$1(input, {
|
|
45407
|
-
plugins,
|
|
45408
|
-
sourceType: "module"
|
|
45409
|
-
}).program;
|
|
45410
|
-
} catch (e) {
|
|
45411
|
-
e.message = `[vue/compiler-sfc] ${e.message}
|
|
45412
|
-
|
|
45413
|
-
${descriptor.filename}
|
|
45414
|
-
${generateCodeFrame(
|
|
45415
|
-
descriptor.source,
|
|
45416
|
-
e.pos + offset,
|
|
45417
|
-
e.pos + offset + 1
|
|
45418
|
-
)}`;
|
|
45419
|
-
throw e;
|
|
45420
|
-
}
|
|
45421
|
-
}
|
|
45422
|
-
this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
|
|
45423
|
-
this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
|
|
45424
|
-
}
|
|
45425
|
-
helper(key) {
|
|
45426
|
-
this.helperImports.add(key);
|
|
45427
|
-
return `_${key}`;
|
|
45428
|
-
}
|
|
45429
|
-
getString(node, scriptSetup = true) {
|
|
45430
|
-
const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
|
|
45431
|
-
return block.content.slice(node.start, node.end);
|
|
45432
|
-
}
|
|
45433
|
-
error(msg, node, scope) {
|
|
45434
|
-
const offset = scope ? scope.offset : this.startOffset;
|
|
45435
|
-
throw new Error(
|
|
45436
|
-
`[@vue/compiler-sfc] ${msg}
|
|
45437
|
-
|
|
45438
|
-
${(scope || this.descriptor).filename}
|
|
45439
|
-
${generateCodeFrame(
|
|
45440
|
-
(scope || this.descriptor).source,
|
|
45441
|
-
node.start + offset,
|
|
45442
|
-
node.end + offset
|
|
45443
|
-
)}`
|
|
45444
|
-
);
|
|
45445
|
-
}
|
|
45446
|
-
}
|
|
45447
|
-
function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
45448
|
-
const plugins = [];
|
|
45449
|
-
if (lang === "jsx" || lang === "tsx") {
|
|
45450
|
-
plugins.push("jsx");
|
|
45451
|
-
} else if (userPlugins) {
|
|
45452
|
-
userPlugins = userPlugins.filter((p) => p !== "jsx");
|
|
45453
|
-
}
|
|
45454
|
-
if (lang === "ts" || lang === "tsx") {
|
|
45455
|
-
plugins.push(["typescript", { dts }]);
|
|
45456
|
-
if (!userPlugins || !userPlugins.includes("decorators")) {
|
|
45457
|
-
plugins.push("decorators-legacy");
|
|
45458
|
-
}
|
|
45459
|
-
}
|
|
45460
|
-
if (userPlugins) {
|
|
45461
|
-
plugins.push(...userPlugins);
|
|
45462
|
-
}
|
|
45463
|
-
return plugins;
|
|
45464
|
-
}
|
|
45465
|
-
|
|
45466
45799
|
var __defProp$1 = Object.defineProperty;
|
|
45467
45800
|
var __defProps$1 = Object.defineProperties;
|
|
45468
45801
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -45495,33 +45828,39 @@ class TypeScope {
|
|
|
45495
45828
|
this.exportedDeclares = /* @__PURE__ */ Object.create(null);
|
|
45496
45829
|
}
|
|
45497
45830
|
}
|
|
45498
|
-
function resolveTypeElements(ctx, node, scope) {
|
|
45831
|
+
function resolveTypeElements(ctx, node, scope, typeParameters) {
|
|
45499
45832
|
if (node._resolvedElements) {
|
|
45500
45833
|
return node._resolvedElements;
|
|
45501
45834
|
}
|
|
45502
45835
|
return node._resolvedElements = innerResolveTypeElements(
|
|
45503
45836
|
ctx,
|
|
45504
45837
|
node,
|
|
45505
|
-
node._ownerScope || scope || ctxToScope(ctx)
|
|
45838
|
+
node._ownerScope || scope || ctxToScope(ctx),
|
|
45839
|
+
typeParameters
|
|
45506
45840
|
);
|
|
45507
45841
|
}
|
|
45508
|
-
function innerResolveTypeElements(ctx, node, scope) {
|
|
45842
|
+
function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
45509
45843
|
var _a, _b;
|
|
45510
45844
|
switch (node.type) {
|
|
45511
45845
|
case "TSTypeLiteral":
|
|
45512
|
-
return typeElementsToMap(ctx, node.members, scope);
|
|
45846
|
+
return typeElementsToMap(ctx, node.members, scope, typeParameters);
|
|
45513
45847
|
case "TSInterfaceDeclaration":
|
|
45514
|
-
return resolveInterfaceMembers(ctx, node, scope);
|
|
45848
|
+
return resolveInterfaceMembers(ctx, node, scope, typeParameters);
|
|
45515
45849
|
case "TSTypeAliasDeclaration":
|
|
45516
45850
|
case "TSParenthesizedType":
|
|
45517
|
-
return resolveTypeElements(
|
|
45851
|
+
return resolveTypeElements(
|
|
45852
|
+
ctx,
|
|
45853
|
+
node.typeAnnotation,
|
|
45854
|
+
scope,
|
|
45855
|
+
typeParameters
|
|
45856
|
+
);
|
|
45518
45857
|
case "TSFunctionType": {
|
|
45519
45858
|
return { props: {}, calls: [node] };
|
|
45520
45859
|
}
|
|
45521
45860
|
case "TSUnionType":
|
|
45522
45861
|
case "TSIntersectionType":
|
|
45523
45862
|
return mergeElements(
|
|
45524
|
-
node.types.map((t) => resolveTypeElements(ctx, t, scope)),
|
|
45863
|
+
node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
|
|
45525
45864
|
node.type
|
|
45526
45865
|
);
|
|
45527
45866
|
case "TSMappedType":
|
|
@@ -45538,20 +45877,53 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
45538
45877
|
const typeName = getReferenceName(node);
|
|
45539
45878
|
if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
|
|
45540
45879
|
return resolveExtractPropTypes(
|
|
45541
|
-
resolveTypeElements(
|
|
45880
|
+
resolveTypeElements(
|
|
45881
|
+
ctx,
|
|
45882
|
+
node.typeParameters.params[0],
|
|
45883
|
+
scope,
|
|
45884
|
+
typeParameters
|
|
45885
|
+
),
|
|
45542
45886
|
scope
|
|
45543
45887
|
);
|
|
45544
45888
|
}
|
|
45545
45889
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
45546
45890
|
if (resolved) {
|
|
45547
|
-
|
|
45891
|
+
const typeParams = /* @__PURE__ */ Object.create(null);
|
|
45892
|
+
if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
|
|
45893
|
+
resolved.typeParameters.params.forEach((p, i) => {
|
|
45894
|
+
let param = typeParameters && typeParameters[p.name];
|
|
45895
|
+
if (!param)
|
|
45896
|
+
param = node.typeParameters.params[i];
|
|
45897
|
+
typeParams[p.name] = param;
|
|
45898
|
+
});
|
|
45899
|
+
}
|
|
45900
|
+
return resolveTypeElements(
|
|
45901
|
+
ctx,
|
|
45902
|
+
resolved,
|
|
45903
|
+
resolved._ownerScope,
|
|
45904
|
+
typeParams
|
|
45905
|
+
);
|
|
45548
45906
|
} else {
|
|
45549
45907
|
if (typeof typeName === "string") {
|
|
45908
|
+
if (typeParameters && typeParameters[typeName]) {
|
|
45909
|
+
return resolveTypeElements(
|
|
45910
|
+
ctx,
|
|
45911
|
+
typeParameters[typeName],
|
|
45912
|
+
scope,
|
|
45913
|
+
typeParameters
|
|
45914
|
+
);
|
|
45915
|
+
}
|
|
45550
45916
|
if (
|
|
45551
45917
|
// @ts-ignore
|
|
45552
45918
|
SupportedBuiltinsSet.has(typeName)
|
|
45553
45919
|
) {
|
|
45554
|
-
return resolveBuiltin(
|
|
45920
|
+
return resolveBuiltin(
|
|
45921
|
+
ctx,
|
|
45922
|
+
node,
|
|
45923
|
+
typeName,
|
|
45924
|
+
scope,
|
|
45925
|
+
typeParameters
|
|
45926
|
+
);
|
|
45555
45927
|
} else if (typeName === "ReturnType" && node.typeParameters) {
|
|
45556
45928
|
const ret = resolveReturnType(
|
|
45557
45929
|
ctx,
|
|
@@ -45600,10 +45972,14 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
45600
45972
|
}
|
|
45601
45973
|
return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
|
|
45602
45974
|
}
|
|
45603
|
-
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
|
|
45975
|
+
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
|
|
45604
45976
|
const res = { props: {} };
|
|
45605
45977
|
for (const e of elements) {
|
|
45606
45978
|
if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
|
|
45979
|
+
if (typeParameters) {
|
|
45980
|
+
scope = createChildScope(scope);
|
|
45981
|
+
Object.assign(scope.types, typeParameters);
|
|
45982
|
+
}
|
|
45607
45983
|
e._ownerScope = scope;
|
|
45608
45984
|
const name = getId(e.key);
|
|
45609
45985
|
if (name && !e.computed) {
|
|
@@ -45666,8 +46042,13 @@ function createProperty(key, typeAnnotation, scope, optional) {
|
|
|
45666
46042
|
_ownerScope: scope
|
|
45667
46043
|
};
|
|
45668
46044
|
}
|
|
45669
|
-
function resolveInterfaceMembers(ctx, node, scope) {
|
|
45670
|
-
const base = typeElementsToMap(
|
|
46045
|
+
function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
|
|
46046
|
+
const base = typeElementsToMap(
|
|
46047
|
+
ctx,
|
|
46048
|
+
node.body.body,
|
|
46049
|
+
node._ownerScope,
|
|
46050
|
+
typeParameters
|
|
46051
|
+
);
|
|
45671
46052
|
if (node.extends) {
|
|
45672
46053
|
for (const ext of node.extends) {
|
|
45673
46054
|
if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
@@ -45841,8 +46222,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
|
|
|
45841
46222
|
"Pick",
|
|
45842
46223
|
"Omit"
|
|
45843
46224
|
]);
|
|
45844
|
-
function resolveBuiltin(ctx, node, name, scope) {
|
|
45845
|
-
const t = resolveTypeElements(
|
|
46225
|
+
function resolveBuiltin(ctx, node, name, scope, typeParameters) {
|
|
46226
|
+
const t = resolveTypeElements(
|
|
46227
|
+
ctx,
|
|
46228
|
+
node.typeParameters.params[0],
|
|
46229
|
+
scope,
|
|
46230
|
+
typeParameters
|
|
46231
|
+
);
|
|
45846
46232
|
switch (name) {
|
|
45847
46233
|
case "Partial": {
|
|
45848
46234
|
const res2 = { props: {}, calls: t.calls };
|
|
@@ -45970,7 +46356,21 @@ function resolveGlobalScope(ctx) {
|
|
|
45970
46356
|
let ts;
|
|
45971
46357
|
let loadTS;
|
|
45972
46358
|
function registerTS(_loadTS) {
|
|
45973
|
-
loadTS =
|
|
46359
|
+
loadTS = () => {
|
|
46360
|
+
try {
|
|
46361
|
+
return _loadTS();
|
|
46362
|
+
} catch (err) {
|
|
46363
|
+
if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
|
|
46364
|
+
throw new Error(
|
|
46365
|
+
'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
|
|
46366
|
+
);
|
|
46367
|
+
} else {
|
|
46368
|
+
throw new Error(
|
|
46369
|
+
"Failed to load TypeScript for resolving imported types."
|
|
46370
|
+
);
|
|
46371
|
+
}
|
|
46372
|
+
}
|
|
46373
|
+
};
|
|
45974
46374
|
}
|
|
45975
46375
|
function resolveFS(ctx) {
|
|
45976
46376
|
if (ctx.fs) {
|
|
@@ -46004,7 +46404,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
|
|
|
46004
46404
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
46005
46405
|
}
|
|
46006
46406
|
function importSourceToScope(ctx, node, scope, source) {
|
|
46007
|
-
|
|
46407
|
+
let fs;
|
|
46408
|
+
try {
|
|
46409
|
+
fs = resolveFS(ctx);
|
|
46410
|
+
} catch (err) {
|
|
46411
|
+
return ctx.error(err.message, node, scope);
|
|
46412
|
+
}
|
|
46008
46413
|
if (!fs) {
|
|
46009
46414
|
return ctx.error(
|
|
46010
46415
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
@@ -46129,14 +46534,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
46129
46534
|
if (node._resolvedChildScope) {
|
|
46130
46535
|
return node._resolvedChildScope;
|
|
46131
46536
|
}
|
|
46132
|
-
const scope =
|
|
46133
|
-
parentScope.filename,
|
|
46134
|
-
parentScope.source,
|
|
46135
|
-
parentScope.offset,
|
|
46136
|
-
Object.create(parentScope.imports),
|
|
46137
|
-
Object.create(parentScope.types),
|
|
46138
|
-
Object.create(parentScope.declares)
|
|
46139
|
-
);
|
|
46537
|
+
const scope = createChildScope(parentScope);
|
|
46140
46538
|
if (node.body.type === "TSModuleDeclaration") {
|
|
46141
46539
|
const decl = node.body;
|
|
46142
46540
|
decl._ownerScope = scope;
|
|
@@ -46147,6 +46545,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
46147
46545
|
}
|
|
46148
46546
|
return node._resolvedChildScope = scope;
|
|
46149
46547
|
}
|
|
46548
|
+
function createChildScope(parentScope) {
|
|
46549
|
+
return new TypeScope(
|
|
46550
|
+
parentScope.filename,
|
|
46551
|
+
parentScope.source,
|
|
46552
|
+
parentScope.offset,
|
|
46553
|
+
Object.create(parentScope.imports),
|
|
46554
|
+
Object.create(parentScope.types),
|
|
46555
|
+
Object.create(parentScope.declares)
|
|
46556
|
+
);
|
|
46557
|
+
}
|
|
46150
46558
|
const importExportRE = /^Import|^Export/;
|
|
46151
46559
|
function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
46152
46560
|
const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
|
|
@@ -46268,7 +46676,7 @@ function recordType(node, types, declares, overwriteId) {
|
|
|
46268
46676
|
types[overwriteId || getId(node.id)] = node;
|
|
46269
46677
|
break;
|
|
46270
46678
|
case "TSTypeAliasDeclaration":
|
|
46271
|
-
types[node.id.name] = node.typeAnnotation;
|
|
46679
|
+
types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
|
|
46272
46680
|
break;
|
|
46273
46681
|
case "TSDeclareFunction":
|
|
46274
46682
|
if (node.id)
|
|
@@ -46370,6 +46778,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
46370
46778
|
scope
|
|
46371
46779
|
);
|
|
46372
46780
|
}
|
|
46781
|
+
break;
|
|
46373
46782
|
case "TSMethodSignature":
|
|
46374
46783
|
case "TSFunctionType":
|
|
46375
46784
|
return ["Function"];
|
|
@@ -46634,17 +47043,6 @@ function processDefineModel(ctx, node, declId) {
|
|
|
46634
47043
|
if (!isCallOf(node, DEFINE_MODEL)) {
|
|
46635
47044
|
return false;
|
|
46636
47045
|
}
|
|
46637
|
-
if (!ctx.options.defineModel) {
|
|
46638
|
-
warnOnce$3(
|
|
46639
|
-
`defineModel() is an experimental feature and disabled by default.
|
|
46640
|
-
To enable it, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
|
|
46641
|
-
);
|
|
46642
|
-
return false;
|
|
46643
|
-
}
|
|
46644
|
-
warnOnce$3(
|
|
46645
|
-
`This project is using defineModel(), which is an experimental feature. It may receive breaking changes or be removed in the future, so use at your own risk.
|
|
46646
|
-
To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
|
|
46647
|
-
);
|
|
46648
47046
|
ctx.hasDefineModelCall = true;
|
|
46649
47047
|
const type = node.typeParameters && node.typeParameters.params[0] || void 0;
|
|
46650
47048
|
let modelName;
|
|
@@ -46808,7 +47206,7 @@ function genRuntimeProps(ctx) {
|
|
|
46808
47206
|
);
|
|
46809
47207
|
}
|
|
46810
47208
|
if (defaults.length) {
|
|
46811
|
-
propsDecls =
|
|
47209
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
46812
47210
|
`mergeDefaults`
|
|
46813
47211
|
)}(${propsDecls}, {
|
|
46814
47212
|
${defaults.join(",\n ")}
|
|
@@ -46820,7 +47218,9 @@ function genRuntimeProps(ctx) {
|
|
|
46820
47218
|
}
|
|
46821
47219
|
const modelsDecls = genModelProps(ctx);
|
|
46822
47220
|
if (propsDecls && modelsDecls) {
|
|
46823
|
-
return
|
|
47221
|
+
return `/*#__PURE__*/${ctx.helper(
|
|
47222
|
+
"mergeModels"
|
|
47223
|
+
)}(${propsDecls}, ${modelsDecls})`;
|
|
46824
47224
|
} else {
|
|
46825
47225
|
return modelsDecls || propsDecls;
|
|
46826
47226
|
}
|
|
@@ -46842,9 +47242,9 @@ function extractRuntimeProps(ctx) {
|
|
|
46842
47242
|
${propStrings.join(",\n ")}
|
|
46843
47243
|
}`;
|
|
46844
47244
|
if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
|
|
46845
|
-
propsDecls =
|
|
46846
|
-
|
|
46847
|
-
)})`;
|
|
47245
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
47246
|
+
"mergeDefaults"
|
|
47247
|
+
)}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
|
|
46848
47248
|
}
|
|
46849
47249
|
return propsDecls;
|
|
46850
47250
|
}
|
|
@@ -46909,6 +47309,15 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
46909
47309
|
defaultString
|
|
46910
47310
|
])} }`;
|
|
46911
47311
|
} else {
|
|
47312
|
+
if (ctx.isCE) {
|
|
47313
|
+
if (defaultString) {
|
|
47314
|
+
return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
|
|
47315
|
+
type
|
|
47316
|
+
)} }`}`;
|
|
47317
|
+
} else {
|
|
47318
|
+
return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
|
|
47319
|
+
}
|
|
47320
|
+
}
|
|
46912
47321
|
return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
|
|
46913
47322
|
}
|
|
46914
47323
|
}
|
|
@@ -47062,7 +47471,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
47062
47471
|
}
|
|
47063
47472
|
for (const decl of stmt.declarations) {
|
|
47064
47473
|
const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
|
|
47065
|
-
for (const id of extractIdentifiers(decl.id)) {
|
|
47474
|
+
for (const id of extractIdentifiers$1(decl.id)) {
|
|
47066
47475
|
if (isDefineProps) {
|
|
47067
47476
|
excludedIds.add(id);
|
|
47068
47477
|
} else {
|
|
@@ -47103,7 +47512,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
47103
47512
|
}
|
|
47104
47513
|
const ast = ctx.scriptSetupAst;
|
|
47105
47514
|
walkScope(ast, true);
|
|
47106
|
-
walk$
|
|
47515
|
+
walk$2(ast, {
|
|
47107
47516
|
enter(node, parent) {
|
|
47108
47517
|
parent && parentStack.push(parent);
|
|
47109
47518
|
if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
|
|
@@ -47181,7 +47590,9 @@ function genRuntimeEmits(ctx) {
|
|
|
47181
47590
|
}
|
|
47182
47591
|
if (ctx.hasDefineModelCall) {
|
|
47183
47592
|
let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
|
|
47184
|
-
emitsDecl = emitsDecl ?
|
|
47593
|
+
emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
|
|
47594
|
+
"mergeModels"
|
|
47595
|
+
)}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
|
|
47185
47596
|
}
|
|
47186
47597
|
return emitsDecl;
|
|
47187
47598
|
}
|
|
@@ -47672,7 +48083,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
47672
48083
|
}
|
|
47673
48084
|
if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
|
|
47674
48085
|
const scope = [scriptSetupAst.body];
|
|
47675
|
-
walk$
|
|
48086
|
+
walk$2(node, {
|
|
47676
48087
|
enter(child, parent) {
|
|
47677
48088
|
if (isFunctionType(child)) {
|
|
47678
48089
|
this.skip();
|
|
@@ -48133,9 +48544,9 @@ function isStaticNode(node) {
|
|
|
48133
48544
|
return false;
|
|
48134
48545
|
}
|
|
48135
48546
|
|
|
48136
|
-
const version = "3.4.0-
|
|
48547
|
+
const version = "3.4.0-beta.1";
|
|
48137
48548
|
const parseCache = parseCache$1;
|
|
48138
|
-
const walk = walk$
|
|
48549
|
+
const walk = walk$2;
|
|
48139
48550
|
const shouldTransformRef = () => false;
|
|
48140
48551
|
|
|
48141
|
-
export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };
|
|
48552
|
+
export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };
|