@vue/compiler-sfc 3.4.0-alpha.4 → 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 +129 -126
- package/dist/compiler-sfc.d.ts +6 -6
- package/dist/compiler-sfc.esm-browser.js +638 -620
- package/package.json +5 -5
|
@@ -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` );
|
|
@@ -2240,16 +2251,16 @@ const ErrorCodes = {
|
|
|
2240
2251
|
"45": "X_INVALID_EXPRESSION",
|
|
2241
2252
|
"X_KEEP_ALIVE_INVALID_CHILDREN": 46,
|
|
2242
2253
|
"46": "X_KEEP_ALIVE_INVALID_CHILDREN",
|
|
2243
|
-
"
|
|
2244
|
-
"47": "
|
|
2245
|
-
"
|
|
2246
|
-
"48": "
|
|
2247
|
-
"
|
|
2248
|
-
"49": "
|
|
2249
|
-
"
|
|
2250
|
-
"50": "
|
|
2251
|
-
"
|
|
2252
|
-
"51": "
|
|
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",
|
|
2253
2264
|
"__EXTEND_POINT__": 52,
|
|
2254
2265
|
"52": "__EXTEND_POINT__"
|
|
2255
2266
|
};
|
|
@@ -2305,12 +2316,12 @@ const errorMessages = {
|
|
|
2305
2316
|
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
2306
2317
|
[45]: `Error parsing JavaScript expression: `,
|
|
2307
2318
|
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
2308
|
-
[
|
|
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.`,
|
|
2309
2320
|
// generic errors
|
|
2310
|
-
[
|
|
2311
|
-
[
|
|
2312
|
-
[
|
|
2313
|
-
[
|
|
2321
|
+
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
2322
|
+
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
2323
|
+
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
2324
|
+
[50]: `"scopeId" option is only supported in module mode.`,
|
|
2314
2325
|
// just to fulfill types
|
|
2315
2326
|
[52]: ``
|
|
2316
2327
|
};
|
|
@@ -16804,6 +16815,471 @@ var parse_1$1 = lib.parse = parse$9;
|
|
|
16804
16815
|
var parseExpression_1 = lib.parseExpression = parseExpression;
|
|
16805
16816
|
lib.tokTypes = tokTypes;
|
|
16806
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
|
+
|
|
16807
17283
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
16808
17284
|
function isCoreComponent(tag) {
|
|
16809
17285
|
switch (tag) {
|
|
@@ -16893,9 +17369,7 @@ const isMemberExpressionNode = (path, context) => {
|
|
|
16893
17369
|
let ret = parseExpression_1(path, {
|
|
16894
17370
|
plugins: context.expressionPlugins
|
|
16895
17371
|
});
|
|
16896
|
-
|
|
16897
|
-
ret = ret.expression;
|
|
16898
|
-
}
|
|
17372
|
+
ret = unwrapTSNode(ret);
|
|
16899
17373
|
return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier";
|
|
16900
17374
|
} catch (e) {
|
|
16901
17375
|
return false;
|
|
@@ -17806,7 +18280,7 @@ function baseParse(input, options) {
|
|
|
17806
18280
|
}
|
|
17807
18281
|
|
|
17808
18282
|
function hoistStatic(root, context) {
|
|
17809
|
-
walk$
|
|
18283
|
+
walk$1(
|
|
17810
18284
|
root,
|
|
17811
18285
|
context,
|
|
17812
18286
|
// Root node is unfortunately non-hoistable due to potential parent
|
|
@@ -17818,7 +18292,7 @@ function isSingleElementRoot(root, child) {
|
|
|
17818
18292
|
const { children } = root;
|
|
17819
18293
|
return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
|
17820
18294
|
}
|
|
17821
|
-
function walk$
|
|
18295
|
+
function walk$1(node, context, doNotHoistNode = false) {
|
|
17822
18296
|
const { children } = node;
|
|
17823
18297
|
const originalCount = children.length;
|
|
17824
18298
|
let hoistedCount = 0;
|
|
@@ -17854,15 +18328,15 @@ function walk$2(node, context, doNotHoistNode = false) {
|
|
|
17854
18328
|
if (isComponent) {
|
|
17855
18329
|
context.scopes.vSlot++;
|
|
17856
18330
|
}
|
|
17857
|
-
walk$
|
|
18331
|
+
walk$1(child, context);
|
|
17858
18332
|
if (isComponent) {
|
|
17859
18333
|
context.scopes.vSlot--;
|
|
17860
18334
|
}
|
|
17861
18335
|
} else if (child.type === 11) {
|
|
17862
|
-
walk$
|
|
18336
|
+
walk$1(child, context, child.children.length === 1);
|
|
17863
18337
|
} else if (child.type === 9) {
|
|
17864
18338
|
for (let i2 = 0; i2 < child.branches.length; i2++) {
|
|
17865
|
-
walk$
|
|
18339
|
+
walk$1(
|
|
17866
18340
|
child.branches[i2],
|
|
17867
18341
|
context,
|
|
17868
18342
|
child.branches[i2].children.length === 1
|
|
@@ -18076,6 +18550,7 @@ function createTransformContext(root, {
|
|
|
18076
18550
|
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
18077
18551
|
const context = {
|
|
18078
18552
|
// options
|
|
18553
|
+
filename,
|
|
18079
18554
|
selfName: nameMatch && capitalize$1(camelize(nameMatch[1])),
|
|
18080
18555
|
prefixIdentifiers,
|
|
18081
18556
|
hoistStatic: hoistStatic2,
|
|
@@ -22456,464 +22931,6 @@ function genReturnStatement({ returns }, context) {
|
|
|
22456
22931
|
}
|
|
22457
22932
|
}
|
|
22458
22933
|
|
|
22459
|
-
// @ts-check
|
|
22460
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22461
|
-
|
|
22462
|
-
/** @typedef {{
|
|
22463
|
-
skip: () => void;
|
|
22464
|
-
remove: () => void;
|
|
22465
|
-
replace: (node: BaseNode) => void;
|
|
22466
|
-
}} WalkerContext */
|
|
22467
|
-
|
|
22468
|
-
class WalkerBase {
|
|
22469
|
-
constructor() {
|
|
22470
|
-
/** @type {boolean} */
|
|
22471
|
-
this.should_skip = false;
|
|
22472
|
-
|
|
22473
|
-
/** @type {boolean} */
|
|
22474
|
-
this.should_remove = false;
|
|
22475
|
-
|
|
22476
|
-
/** @type {BaseNode | null} */
|
|
22477
|
-
this.replacement = null;
|
|
22478
|
-
|
|
22479
|
-
/** @type {WalkerContext} */
|
|
22480
|
-
this.context = {
|
|
22481
|
-
skip: () => (this.should_skip = true),
|
|
22482
|
-
remove: () => (this.should_remove = true),
|
|
22483
|
-
replace: (node) => (this.replacement = node)
|
|
22484
|
-
};
|
|
22485
|
-
}
|
|
22486
|
-
|
|
22487
|
-
/**
|
|
22488
|
-
*
|
|
22489
|
-
* @param {any} parent
|
|
22490
|
-
* @param {string} prop
|
|
22491
|
-
* @param {number} index
|
|
22492
|
-
* @param {BaseNode} node
|
|
22493
|
-
*/
|
|
22494
|
-
replace(parent, prop, index, node) {
|
|
22495
|
-
if (parent) {
|
|
22496
|
-
if (index !== null) {
|
|
22497
|
-
parent[prop][index] = node;
|
|
22498
|
-
} else {
|
|
22499
|
-
parent[prop] = node;
|
|
22500
|
-
}
|
|
22501
|
-
}
|
|
22502
|
-
}
|
|
22503
|
-
|
|
22504
|
-
/**
|
|
22505
|
-
*
|
|
22506
|
-
* @param {any} parent
|
|
22507
|
-
* @param {string} prop
|
|
22508
|
-
* @param {number} index
|
|
22509
|
-
*/
|
|
22510
|
-
remove(parent, prop, index) {
|
|
22511
|
-
if (parent) {
|
|
22512
|
-
if (index !== null) {
|
|
22513
|
-
parent[prop].splice(index, 1);
|
|
22514
|
-
} else {
|
|
22515
|
-
delete parent[prop];
|
|
22516
|
-
}
|
|
22517
|
-
}
|
|
22518
|
-
}
|
|
22519
|
-
}
|
|
22520
|
-
|
|
22521
|
-
// @ts-check
|
|
22522
|
-
|
|
22523
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22524
|
-
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
|
22525
|
-
|
|
22526
|
-
/** @typedef {(
|
|
22527
|
-
* this: WalkerContext,
|
|
22528
|
-
* node: BaseNode,
|
|
22529
|
-
* parent: BaseNode,
|
|
22530
|
-
* key: string,
|
|
22531
|
-
* index: number
|
|
22532
|
-
* ) => void} SyncHandler */
|
|
22533
|
-
|
|
22534
|
-
class SyncWalker extends WalkerBase {
|
|
22535
|
-
/**
|
|
22536
|
-
*
|
|
22537
|
-
* @param {SyncHandler} enter
|
|
22538
|
-
* @param {SyncHandler} leave
|
|
22539
|
-
*/
|
|
22540
|
-
constructor(enter, leave) {
|
|
22541
|
-
super();
|
|
22542
|
-
|
|
22543
|
-
/** @type {SyncHandler} */
|
|
22544
|
-
this.enter = enter;
|
|
22545
|
-
|
|
22546
|
-
/** @type {SyncHandler} */
|
|
22547
|
-
this.leave = leave;
|
|
22548
|
-
}
|
|
22549
|
-
|
|
22550
|
-
/**
|
|
22551
|
-
*
|
|
22552
|
-
* @param {BaseNode} node
|
|
22553
|
-
* @param {BaseNode} parent
|
|
22554
|
-
* @param {string} [prop]
|
|
22555
|
-
* @param {number} [index]
|
|
22556
|
-
* @returns {BaseNode}
|
|
22557
|
-
*/
|
|
22558
|
-
visit(node, parent, prop, index) {
|
|
22559
|
-
if (node) {
|
|
22560
|
-
if (this.enter) {
|
|
22561
|
-
const _should_skip = this.should_skip;
|
|
22562
|
-
const _should_remove = this.should_remove;
|
|
22563
|
-
const _replacement = this.replacement;
|
|
22564
|
-
this.should_skip = false;
|
|
22565
|
-
this.should_remove = false;
|
|
22566
|
-
this.replacement = null;
|
|
22567
|
-
|
|
22568
|
-
this.enter.call(this.context, node, parent, prop, index);
|
|
22569
|
-
|
|
22570
|
-
if (this.replacement) {
|
|
22571
|
-
node = this.replacement;
|
|
22572
|
-
this.replace(parent, prop, index, node);
|
|
22573
|
-
}
|
|
22574
|
-
|
|
22575
|
-
if (this.should_remove) {
|
|
22576
|
-
this.remove(parent, prop, index);
|
|
22577
|
-
}
|
|
22578
|
-
|
|
22579
|
-
const skipped = this.should_skip;
|
|
22580
|
-
const removed = this.should_remove;
|
|
22581
|
-
|
|
22582
|
-
this.should_skip = _should_skip;
|
|
22583
|
-
this.should_remove = _should_remove;
|
|
22584
|
-
this.replacement = _replacement;
|
|
22585
|
-
|
|
22586
|
-
if (skipped) return node;
|
|
22587
|
-
if (removed) return null;
|
|
22588
|
-
}
|
|
22589
|
-
|
|
22590
|
-
for (const key in node) {
|
|
22591
|
-
const value = node[key];
|
|
22592
|
-
|
|
22593
|
-
if (typeof value !== "object") {
|
|
22594
|
-
continue;
|
|
22595
|
-
} else if (Array.isArray(value)) {
|
|
22596
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
22597
|
-
if (value[i] !== null && typeof value[i].type === 'string') {
|
|
22598
|
-
if (!this.visit(value[i], node, key, i)) {
|
|
22599
|
-
// removed
|
|
22600
|
-
i--;
|
|
22601
|
-
}
|
|
22602
|
-
}
|
|
22603
|
-
}
|
|
22604
|
-
} else if (value !== null && typeof value.type === "string") {
|
|
22605
|
-
this.visit(value, node, key, null);
|
|
22606
|
-
}
|
|
22607
|
-
}
|
|
22608
|
-
|
|
22609
|
-
if (this.leave) {
|
|
22610
|
-
const _replacement = this.replacement;
|
|
22611
|
-
const _should_remove = this.should_remove;
|
|
22612
|
-
this.replacement = null;
|
|
22613
|
-
this.should_remove = false;
|
|
22614
|
-
|
|
22615
|
-
this.leave.call(this.context, node, parent, prop, index);
|
|
22616
|
-
|
|
22617
|
-
if (this.replacement) {
|
|
22618
|
-
node = this.replacement;
|
|
22619
|
-
this.replace(parent, prop, index, node);
|
|
22620
|
-
}
|
|
22621
|
-
|
|
22622
|
-
if (this.should_remove) {
|
|
22623
|
-
this.remove(parent, prop, index);
|
|
22624
|
-
}
|
|
22625
|
-
|
|
22626
|
-
const removed = this.should_remove;
|
|
22627
|
-
|
|
22628
|
-
this.replacement = _replacement;
|
|
22629
|
-
this.should_remove = _should_remove;
|
|
22630
|
-
|
|
22631
|
-
if (removed) return null;
|
|
22632
|
-
}
|
|
22633
|
-
}
|
|
22634
|
-
|
|
22635
|
-
return node;
|
|
22636
|
-
}
|
|
22637
|
-
}
|
|
22638
|
-
|
|
22639
|
-
// @ts-check
|
|
22640
|
-
|
|
22641
|
-
/** @typedef { import('estree').BaseNode} BaseNode */
|
|
22642
|
-
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
|
22643
|
-
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
|
22644
|
-
|
|
22645
|
-
/**
|
|
22646
|
-
*
|
|
22647
|
-
* @param {BaseNode} ast
|
|
22648
|
-
* @param {{
|
|
22649
|
-
* enter?: SyncHandler
|
|
22650
|
-
* leave?: SyncHandler
|
|
22651
|
-
* }} walker
|
|
22652
|
-
* @returns {BaseNode}
|
|
22653
|
-
*/
|
|
22654
|
-
function walk$1(ast, { enter, leave }) {
|
|
22655
|
-
const instance = new SyncWalker(enter, leave);
|
|
22656
|
-
return instance.visit(ast, null);
|
|
22657
|
-
}
|
|
22658
|
-
|
|
22659
|
-
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
|
|
22660
|
-
const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
|
|
22661
|
-
walk$1(root, {
|
|
22662
|
-
enter(node, parent) {
|
|
22663
|
-
parent && parentStack.push(parent);
|
|
22664
|
-
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
|
|
22665
|
-
return this.skip();
|
|
22666
|
-
}
|
|
22667
|
-
if (node.type === "Identifier") {
|
|
22668
|
-
const isLocal = !!knownIds[node.name];
|
|
22669
|
-
const isRefed = isReferencedIdentifier(node, parent, parentStack);
|
|
22670
|
-
if (includeAll || isRefed && !isLocal) {
|
|
22671
|
-
onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
22672
|
-
}
|
|
22673
|
-
} else if (node.type === "ObjectProperty" && parent.type === "ObjectPattern") {
|
|
22674
|
-
node.inPattern = true;
|
|
22675
|
-
} else if (isFunctionType(node)) {
|
|
22676
|
-
walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
22677
|
-
} else if (node.type === "BlockStatement") {
|
|
22678
|
-
walkBlockDeclarations(
|
|
22679
|
-
node,
|
|
22680
|
-
(id) => markScopeIdentifier(node, id, knownIds)
|
|
22681
|
-
);
|
|
22682
|
-
}
|
|
22683
|
-
},
|
|
22684
|
-
leave(node, parent) {
|
|
22685
|
-
parent && parentStack.pop();
|
|
22686
|
-
if (node !== rootExp && node.scopeIds) {
|
|
22687
|
-
for (const id of node.scopeIds) {
|
|
22688
|
-
knownIds[id]--;
|
|
22689
|
-
if (knownIds[id] === 0) {
|
|
22690
|
-
delete knownIds[id];
|
|
22691
|
-
}
|
|
22692
|
-
}
|
|
22693
|
-
}
|
|
22694
|
-
}
|
|
22695
|
-
});
|
|
22696
|
-
}
|
|
22697
|
-
function isReferencedIdentifier(id, parent, parentStack) {
|
|
22698
|
-
if (!parent) {
|
|
22699
|
-
return true;
|
|
22700
|
-
}
|
|
22701
|
-
if (id.name === "arguments") {
|
|
22702
|
-
return false;
|
|
22703
|
-
}
|
|
22704
|
-
if (isReferenced(id, parent)) {
|
|
22705
|
-
return true;
|
|
22706
|
-
}
|
|
22707
|
-
switch (parent.type) {
|
|
22708
|
-
case "AssignmentExpression":
|
|
22709
|
-
case "AssignmentPattern":
|
|
22710
|
-
return true;
|
|
22711
|
-
case "ObjectPattern":
|
|
22712
|
-
case "ArrayPattern":
|
|
22713
|
-
return isInDestructureAssignment(parent, parentStack);
|
|
22714
|
-
}
|
|
22715
|
-
return false;
|
|
22716
|
-
}
|
|
22717
|
-
function isInDestructureAssignment(parent, parentStack) {
|
|
22718
|
-
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
22719
|
-
let i = parentStack.length;
|
|
22720
|
-
while (i--) {
|
|
22721
|
-
const p = parentStack[i];
|
|
22722
|
-
if (p.type === "AssignmentExpression") {
|
|
22723
|
-
return true;
|
|
22724
|
-
} else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
|
|
22725
|
-
break;
|
|
22726
|
-
}
|
|
22727
|
-
}
|
|
22728
|
-
}
|
|
22729
|
-
return false;
|
|
22730
|
-
}
|
|
22731
|
-
function walkFunctionParams(node, onIdent) {
|
|
22732
|
-
for (const p of node.params) {
|
|
22733
|
-
for (const id of extractIdentifiers$1(p)) {
|
|
22734
|
-
onIdent(id);
|
|
22735
|
-
}
|
|
22736
|
-
}
|
|
22737
|
-
}
|
|
22738
|
-
function walkBlockDeclarations(block, onIdent) {
|
|
22739
|
-
for (const stmt of block.body) {
|
|
22740
|
-
if (stmt.type === "VariableDeclaration") {
|
|
22741
|
-
if (stmt.declare)
|
|
22742
|
-
continue;
|
|
22743
|
-
for (const decl of stmt.declarations) {
|
|
22744
|
-
for (const id of extractIdentifiers$1(decl.id)) {
|
|
22745
|
-
onIdent(id);
|
|
22746
|
-
}
|
|
22747
|
-
}
|
|
22748
|
-
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
22749
|
-
if (stmt.declare || !stmt.id)
|
|
22750
|
-
continue;
|
|
22751
|
-
onIdent(stmt.id);
|
|
22752
|
-
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
22753
|
-
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
22754
|
-
if (variable && variable.type === "VariableDeclaration") {
|
|
22755
|
-
for (const decl of variable.declarations) {
|
|
22756
|
-
for (const id of extractIdentifiers$1(decl.id)) {
|
|
22757
|
-
onIdent(id);
|
|
22758
|
-
}
|
|
22759
|
-
}
|
|
22760
|
-
}
|
|
22761
|
-
}
|
|
22762
|
-
}
|
|
22763
|
-
}
|
|
22764
|
-
function extractIdentifiers$1(param, nodes = []) {
|
|
22765
|
-
switch (param.type) {
|
|
22766
|
-
case "Identifier":
|
|
22767
|
-
nodes.push(param);
|
|
22768
|
-
break;
|
|
22769
|
-
case "MemberExpression":
|
|
22770
|
-
let object = param;
|
|
22771
|
-
while (object.type === "MemberExpression") {
|
|
22772
|
-
object = object.object;
|
|
22773
|
-
}
|
|
22774
|
-
nodes.push(object);
|
|
22775
|
-
break;
|
|
22776
|
-
case "ObjectPattern":
|
|
22777
|
-
for (const prop of param.properties) {
|
|
22778
|
-
if (prop.type === "RestElement") {
|
|
22779
|
-
extractIdentifiers$1(prop.argument, nodes);
|
|
22780
|
-
} else {
|
|
22781
|
-
extractIdentifiers$1(prop.value, nodes);
|
|
22782
|
-
}
|
|
22783
|
-
}
|
|
22784
|
-
break;
|
|
22785
|
-
case "ArrayPattern":
|
|
22786
|
-
param.elements.forEach((element) => {
|
|
22787
|
-
if (element)
|
|
22788
|
-
extractIdentifiers$1(element, nodes);
|
|
22789
|
-
});
|
|
22790
|
-
break;
|
|
22791
|
-
case "RestElement":
|
|
22792
|
-
extractIdentifiers$1(param.argument, nodes);
|
|
22793
|
-
break;
|
|
22794
|
-
case "AssignmentPattern":
|
|
22795
|
-
extractIdentifiers$1(param.left, nodes);
|
|
22796
|
-
break;
|
|
22797
|
-
}
|
|
22798
|
-
return nodes;
|
|
22799
|
-
}
|
|
22800
|
-
function markScopeIdentifier(node, child, knownIds) {
|
|
22801
|
-
const { name } = child;
|
|
22802
|
-
if (node.scopeIds && node.scopeIds.has(name)) {
|
|
22803
|
-
return;
|
|
22804
|
-
}
|
|
22805
|
-
if (name in knownIds) {
|
|
22806
|
-
knownIds[name]++;
|
|
22807
|
-
} else {
|
|
22808
|
-
knownIds[name] = 1;
|
|
22809
|
-
}
|
|
22810
|
-
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
22811
|
-
}
|
|
22812
|
-
const isFunctionType = (node) => {
|
|
22813
|
-
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
22814
|
-
};
|
|
22815
|
-
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
22816
|
-
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
22817
|
-
function isReferenced(node, parent, grandparent) {
|
|
22818
|
-
switch (parent.type) {
|
|
22819
|
-
case "MemberExpression":
|
|
22820
|
-
case "OptionalMemberExpression":
|
|
22821
|
-
if (parent.property === node) {
|
|
22822
|
-
return !!parent.computed;
|
|
22823
|
-
}
|
|
22824
|
-
return parent.object === node;
|
|
22825
|
-
case "JSXMemberExpression":
|
|
22826
|
-
return parent.object === node;
|
|
22827
|
-
case "VariableDeclarator":
|
|
22828
|
-
return parent.init === node;
|
|
22829
|
-
case "ArrowFunctionExpression":
|
|
22830
|
-
return parent.body === node;
|
|
22831
|
-
case "PrivateName":
|
|
22832
|
-
return false;
|
|
22833
|
-
case "ClassMethod":
|
|
22834
|
-
case "ClassPrivateMethod":
|
|
22835
|
-
case "ObjectMethod":
|
|
22836
|
-
if (parent.key === node) {
|
|
22837
|
-
return !!parent.computed;
|
|
22838
|
-
}
|
|
22839
|
-
return false;
|
|
22840
|
-
case "ObjectProperty":
|
|
22841
|
-
if (parent.key === node) {
|
|
22842
|
-
return !!parent.computed;
|
|
22843
|
-
}
|
|
22844
|
-
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
22845
|
-
case "ClassProperty":
|
|
22846
|
-
if (parent.key === node) {
|
|
22847
|
-
return !!parent.computed;
|
|
22848
|
-
}
|
|
22849
|
-
return true;
|
|
22850
|
-
case "ClassPrivateProperty":
|
|
22851
|
-
return parent.key !== node;
|
|
22852
|
-
case "ClassDeclaration":
|
|
22853
|
-
case "ClassExpression":
|
|
22854
|
-
return parent.superClass === node;
|
|
22855
|
-
case "AssignmentExpression":
|
|
22856
|
-
return parent.right === node;
|
|
22857
|
-
case "AssignmentPattern":
|
|
22858
|
-
return parent.right === node;
|
|
22859
|
-
case "LabeledStatement":
|
|
22860
|
-
return false;
|
|
22861
|
-
case "CatchClause":
|
|
22862
|
-
return false;
|
|
22863
|
-
case "RestElement":
|
|
22864
|
-
return false;
|
|
22865
|
-
case "BreakStatement":
|
|
22866
|
-
case "ContinueStatement":
|
|
22867
|
-
return false;
|
|
22868
|
-
case "FunctionDeclaration":
|
|
22869
|
-
case "FunctionExpression":
|
|
22870
|
-
return false;
|
|
22871
|
-
case "ExportNamespaceSpecifier":
|
|
22872
|
-
case "ExportDefaultSpecifier":
|
|
22873
|
-
return false;
|
|
22874
|
-
case "ExportSpecifier":
|
|
22875
|
-
if (grandparent == null ? void 0 : grandparent.source) {
|
|
22876
|
-
return false;
|
|
22877
|
-
}
|
|
22878
|
-
return parent.local === node;
|
|
22879
|
-
case "ImportDefaultSpecifier":
|
|
22880
|
-
case "ImportNamespaceSpecifier":
|
|
22881
|
-
case "ImportSpecifier":
|
|
22882
|
-
return false;
|
|
22883
|
-
case "ImportAttribute":
|
|
22884
|
-
return false;
|
|
22885
|
-
case "JSXAttribute":
|
|
22886
|
-
return false;
|
|
22887
|
-
case "ObjectPattern":
|
|
22888
|
-
case "ArrayPattern":
|
|
22889
|
-
return false;
|
|
22890
|
-
case "MetaProperty":
|
|
22891
|
-
return false;
|
|
22892
|
-
case "ObjectTypeProperty":
|
|
22893
|
-
return parent.key !== node;
|
|
22894
|
-
case "TSEnumMember":
|
|
22895
|
-
return parent.id !== node;
|
|
22896
|
-
case "TSPropertySignature":
|
|
22897
|
-
if (parent.key === node) {
|
|
22898
|
-
return !!parent.computed;
|
|
22899
|
-
}
|
|
22900
|
-
return true;
|
|
22901
|
-
}
|
|
22902
|
-
return true;
|
|
22903
|
-
}
|
|
22904
|
-
const TS_NODE_TYPES = [
|
|
22905
|
-
"TSAsExpression",
|
|
22906
|
-
// foo as number
|
|
22907
|
-
"TSTypeAssertion",
|
|
22908
|
-
// (<number>foo)
|
|
22909
|
-
"TSNonNullExpression",
|
|
22910
|
-
// foo!
|
|
22911
|
-
"TSInstantiationExpression",
|
|
22912
|
-
// foo<string>
|
|
22913
|
-
"TSSatisfiesExpression"
|
|
22914
|
-
// foo satisfies T
|
|
22915
|
-
];
|
|
22916
|
-
|
|
22917
22934
|
const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
|
|
22918
22935
|
const constantBailRE = /\w\s*\(|\.[^\d]/;
|
|
22919
22936
|
const transformExpression = (node, context) => {
|
|
@@ -24536,7 +24553,7 @@ const transformOn$1 = (dir, node, context, augmentor) => {
|
|
|
24536
24553
|
if (arg.isStatic) {
|
|
24537
24554
|
let rawName = arg.content;
|
|
24538
24555
|
if (rawName.startsWith("vnode")) {
|
|
24539
|
-
context.onError(createCompilerError(
|
|
24556
|
+
context.onError(createCompilerError(51, arg.loc));
|
|
24540
24557
|
}
|
|
24541
24558
|
if (rawName.startsWith("vue:")) {
|
|
24542
24559
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
@@ -24923,12 +24940,15 @@ function baseCompile(source, options = {}) {
|
|
|
24923
24940
|
const isModuleMode = options.mode === "module";
|
|
24924
24941
|
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
24925
24942
|
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
24926
|
-
onError(createCompilerError(
|
|
24943
|
+
onError(createCompilerError(49));
|
|
24927
24944
|
}
|
|
24928
24945
|
if (options.scopeId && !isModuleMode) {
|
|
24929
|
-
onError(createCompilerError(
|
|
24946
|
+
onError(createCompilerError(50));
|
|
24930
24947
|
}
|
|
24931
|
-
const
|
|
24948
|
+
const resolvedOptions = extend({}, options, {
|
|
24949
|
+
prefixIdentifiers
|
|
24950
|
+
});
|
|
24951
|
+
const ast = isString$2(source) ? baseParse(source, resolvedOptions) : source;
|
|
24932
24952
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|
|
24933
24953
|
if (options.isTS) {
|
|
24934
24954
|
const { expressionPlugins } = options;
|
|
@@ -24938,8 +24958,7 @@ function baseCompile(source, options = {}) {
|
|
|
24938
24958
|
}
|
|
24939
24959
|
transform(
|
|
24940
24960
|
ast,
|
|
24941
|
-
extend({},
|
|
24942
|
-
prefixIdentifiers,
|
|
24961
|
+
extend({}, resolvedOptions, {
|
|
24943
24962
|
nodeTransforms: [
|
|
24944
24963
|
...nodeTransforms,
|
|
24945
24964
|
...options.nodeTransforms || []
|
|
@@ -24953,12 +24972,7 @@ function baseCompile(source, options = {}) {
|
|
|
24953
24972
|
)
|
|
24954
24973
|
})
|
|
24955
24974
|
);
|
|
24956
|
-
return generate(
|
|
24957
|
-
ast,
|
|
24958
|
-
extend({}, options, {
|
|
24959
|
-
prefixIdentifiers
|
|
24960
|
-
})
|
|
24961
|
-
);
|
|
24975
|
+
return generate(ast, resolvedOptions);
|
|
24962
24976
|
}
|
|
24963
24977
|
|
|
24964
24978
|
const BindingTypes = {
|
|
@@ -25002,7 +25016,7 @@ registerRuntimeHelpers({
|
|
|
25002
25016
|
const parserOptions = {
|
|
25003
25017
|
parseMode: "html",
|
|
25004
25018
|
isVoidTag,
|
|
25005
|
-
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
25019
|
+
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
|
25006
25020
|
isPreTag: (tag) => tag === "pre",
|
|
25007
25021
|
decodeEntities: void 0,
|
|
25008
25022
|
isBuiltInComponent: (tag) => {
|
|
@@ -25814,6 +25828,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
25814
25828
|
transformOn: transformOn$1,
|
|
25815
25829
|
transformStyle: transformStyle,
|
|
25816
25830
|
traverseNode: traverseNode,
|
|
25831
|
+
unwrapTSNode: unwrapTSNode,
|
|
25817
25832
|
walkBlockDeclarations: walkBlockDeclarations,
|
|
25818
25833
|
walkFunctionParams: walkFunctionParams,
|
|
25819
25834
|
walkIdentifiers: walkIdentifiers,
|
|
@@ -26086,13 +26101,6 @@ function concatStrings(strs) {
|
|
|
26086
26101
|
function isLiteralNode(node) {
|
|
26087
26102
|
return node.type.endsWith("Literal");
|
|
26088
26103
|
}
|
|
26089
|
-
function unwrapTSNode(node) {
|
|
26090
|
-
if (TS_NODE_TYPES.includes(node.type)) {
|
|
26091
|
-
return unwrapTSNode(node.expression);
|
|
26092
|
-
} else {
|
|
26093
|
-
return node;
|
|
26094
|
-
}
|
|
26095
|
-
}
|
|
26096
26104
|
function isCallOf(node, test) {
|
|
26097
26105
|
return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
|
|
26098
26106
|
}
|
|
@@ -45525,10 +45533,118 @@ class MagicString {
|
|
|
45525
45533
|
}
|
|
45526
45534
|
}
|
|
45527
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
|
+
|
|
45528
45644
|
function rewriteDefault(input, as, parserPlugins) {
|
|
45529
45645
|
const ast = parse_1$1(input, {
|
|
45530
45646
|
sourceType: "module",
|
|
45531
|
-
plugins: parserPlugins
|
|
45647
|
+
plugins: resolveParserPlugins("js", parserPlugins)
|
|
45532
45648
|
}).program.body;
|
|
45533
45649
|
const s = new MagicString(input);
|
|
45534
45650
|
rewriteDefaultAST(ast, s, as);
|
|
@@ -45680,103 +45796,6 @@ export default ${defaultVar}`;
|
|
|
45680
45796
|
}
|
|
45681
45797
|
}
|
|
45682
45798
|
|
|
45683
|
-
var _a, _b;
|
|
45684
|
-
class ScriptCompileContext {
|
|
45685
|
-
constructor(descriptor, options) {
|
|
45686
|
-
this.descriptor = descriptor;
|
|
45687
|
-
this.options = options;
|
|
45688
|
-
this.source = this.descriptor.source;
|
|
45689
|
-
this.filename = this.descriptor.filename;
|
|
45690
|
-
this.s = new MagicString(this.source);
|
|
45691
|
-
this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
|
|
45692
|
-
this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
|
|
45693
|
-
this.userImports = /* @__PURE__ */ Object.create(null);
|
|
45694
|
-
// macros presence check
|
|
45695
|
-
this.hasDefinePropsCall = false;
|
|
45696
|
-
this.hasDefineEmitCall = false;
|
|
45697
|
-
this.hasDefineExposeCall = false;
|
|
45698
|
-
this.hasDefaultExportName = false;
|
|
45699
|
-
this.hasDefaultExportRender = false;
|
|
45700
|
-
this.hasDefineOptionsCall = false;
|
|
45701
|
-
this.hasDefineSlotsCall = false;
|
|
45702
|
-
this.hasDefineModelCall = false;
|
|
45703
|
-
this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
|
|
45704
|
-
// defineModel
|
|
45705
|
-
this.modelDecls = /* @__PURE__ */ Object.create(null);
|
|
45706
|
-
// codegen
|
|
45707
|
-
this.bindingMetadata = {};
|
|
45708
|
-
this.helperImports = /* @__PURE__ */ new Set();
|
|
45709
|
-
const { script, scriptSetup } = descriptor;
|
|
45710
|
-
const scriptLang = script && script.lang;
|
|
45711
|
-
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
45712
|
-
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
45713
|
-
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
45714
|
-
const plugins = resolveParserPlugins(
|
|
45715
|
-
scriptLang || scriptSetupLang,
|
|
45716
|
-
options.babelParserPlugins
|
|
45717
|
-
);
|
|
45718
|
-
function parse(input, offset) {
|
|
45719
|
-
try {
|
|
45720
|
-
return parse_1$1(input, {
|
|
45721
|
-
plugins,
|
|
45722
|
-
sourceType: "module"
|
|
45723
|
-
}).program;
|
|
45724
|
-
} catch (e) {
|
|
45725
|
-
e.message = `[vue/compiler-sfc] ${e.message}
|
|
45726
|
-
|
|
45727
|
-
${descriptor.filename}
|
|
45728
|
-
${generateCodeFrame(
|
|
45729
|
-
descriptor.source,
|
|
45730
|
-
e.pos + offset,
|
|
45731
|
-
e.pos + offset + 1
|
|
45732
|
-
)}`;
|
|
45733
|
-
throw e;
|
|
45734
|
-
}
|
|
45735
|
-
}
|
|
45736
|
-
this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
|
|
45737
|
-
this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
|
|
45738
|
-
}
|
|
45739
|
-
helper(key) {
|
|
45740
|
-
this.helperImports.add(key);
|
|
45741
|
-
return `_${key}`;
|
|
45742
|
-
}
|
|
45743
|
-
getString(node, scriptSetup = true) {
|
|
45744
|
-
const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
|
|
45745
|
-
return block.content.slice(node.start, node.end);
|
|
45746
|
-
}
|
|
45747
|
-
error(msg, node, scope) {
|
|
45748
|
-
const offset = scope ? scope.offset : this.startOffset;
|
|
45749
|
-
throw new Error(
|
|
45750
|
-
`[@vue/compiler-sfc] ${msg}
|
|
45751
|
-
|
|
45752
|
-
${(scope || this.descriptor).filename}
|
|
45753
|
-
${generateCodeFrame(
|
|
45754
|
-
(scope || this.descriptor).source,
|
|
45755
|
-
node.start + offset,
|
|
45756
|
-
node.end + offset
|
|
45757
|
-
)}`
|
|
45758
|
-
);
|
|
45759
|
-
}
|
|
45760
|
-
}
|
|
45761
|
-
function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
45762
|
-
const plugins = [];
|
|
45763
|
-
if (lang === "jsx" || lang === "tsx") {
|
|
45764
|
-
plugins.push("jsx");
|
|
45765
|
-
} else if (userPlugins) {
|
|
45766
|
-
userPlugins = userPlugins.filter((p) => p !== "jsx");
|
|
45767
|
-
}
|
|
45768
|
-
if (lang === "ts" || lang === "tsx") {
|
|
45769
|
-
plugins.push(["typescript", { dts }]);
|
|
45770
|
-
if (!userPlugins || !userPlugins.includes("decorators")) {
|
|
45771
|
-
plugins.push("decorators-legacy");
|
|
45772
|
-
}
|
|
45773
|
-
}
|
|
45774
|
-
if (userPlugins) {
|
|
45775
|
-
plugins.push(...userPlugins);
|
|
45776
|
-
}
|
|
45777
|
-
return plugins;
|
|
45778
|
-
}
|
|
45779
|
-
|
|
45780
45799
|
var __defProp$1 = Object.defineProperty;
|
|
45781
45800
|
var __defProps$1 = Object.defineProperties;
|
|
45782
45801
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -46759,6 +46778,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
46759
46778
|
scope
|
|
46760
46779
|
);
|
|
46761
46780
|
}
|
|
46781
|
+
break;
|
|
46762
46782
|
case "TSMethodSignature":
|
|
46763
46783
|
case "TSFunctionType":
|
|
46764
46784
|
return ["Function"];
|
|
@@ -47023,17 +47043,6 @@ function processDefineModel(ctx, node, declId) {
|
|
|
47023
47043
|
if (!isCallOf(node, DEFINE_MODEL)) {
|
|
47024
47044
|
return false;
|
|
47025
47045
|
}
|
|
47026
|
-
if (!ctx.options.defineModel) {
|
|
47027
|
-
warnOnce$3(
|
|
47028
|
-
`defineModel() is an experimental feature and disabled by default.
|
|
47029
|
-
To enable it, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
|
|
47030
|
-
);
|
|
47031
|
-
return false;
|
|
47032
|
-
}
|
|
47033
|
-
warnOnce$3(
|
|
47034
|
-
`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.
|
|
47035
|
-
To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
|
|
47036
|
-
);
|
|
47037
47046
|
ctx.hasDefineModelCall = true;
|
|
47038
47047
|
const type = node.typeParameters && node.typeParameters.params[0] || void 0;
|
|
47039
47048
|
let modelName;
|
|
@@ -47300,6 +47309,15 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
47300
47309
|
defaultString
|
|
47301
47310
|
])} }`;
|
|
47302
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
|
+
}
|
|
47303
47321
|
return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
|
|
47304
47322
|
}
|
|
47305
47323
|
}
|
|
@@ -47494,7 +47512,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
47494
47512
|
}
|
|
47495
47513
|
const ast = ctx.scriptSetupAst;
|
|
47496
47514
|
walkScope(ast, true);
|
|
47497
|
-
walk$
|
|
47515
|
+
walk$2(ast, {
|
|
47498
47516
|
enter(node, parent) {
|
|
47499
47517
|
parent && parentStack.push(parent);
|
|
47500
47518
|
if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
|
|
@@ -48065,7 +48083,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
48065
48083
|
}
|
|
48066
48084
|
if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
|
|
48067
48085
|
const scope = [scriptSetupAst.body];
|
|
48068
|
-
walk$
|
|
48086
|
+
walk$2(node, {
|
|
48069
48087
|
enter(child, parent) {
|
|
48070
48088
|
if (isFunctionType(child)) {
|
|
48071
48089
|
this.skip();
|
|
@@ -48526,9 +48544,9 @@ function isStaticNode(node) {
|
|
|
48526
48544
|
return false;
|
|
48527
48545
|
}
|
|
48528
48546
|
|
|
48529
|
-
const version = "3.4.0-
|
|
48547
|
+
const version = "3.4.0-beta.1";
|
|
48530
48548
|
const parseCache = parseCache$1;
|
|
48531
|
-
const walk = walk$
|
|
48549
|
+
const walk = walk$2;
|
|
48532
48550
|
const shouldTransformRef = () => false;
|
|
48533
48551
|
|
|
48534
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 };
|