prettier 3.9.4 → 3.9.5
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/THIRD-PARTY-NOTICES.md +33 -27
- package/index.cjs +1 -1
- package/index.mjs +2 -3
- package/internal/experimental-cli.mjs +1 -1
- package/package.json +1 -1
- package/plugins/angular.js +1 -1
- package/plugins/angular.mjs +1 -1
- package/plugins/estree.js +32 -32
- package/plugins/estree.mjs +32 -32
- package/plugins/flow.js +5 -5
- package/plugins/flow.mjs +5 -5
- package/plugins/html.js +8 -8
- package/plugins/html.mjs +8 -8
- package/plugins/markdown.js +56 -56
- package/plugins/markdown.mjs +56 -56
- package/plugins/meriyah.js +4 -4
- package/plugins/meriyah.mjs +4 -4
- package/plugins/postcss.js +33 -33
- package/plugins/postcss.mjs +31 -31
- package/standalone.js +2 -2
- package/standalone.mjs +2 -2
package/standalone.js
CHANGED
|
@@ -9,7 +9,7 @@ Expected it to be ${n}.`}var wt=class extends Error{name="InvalidDocError";const
|
|
|
9
9
|
`,u):d;E&&(a.write(E),i.length>0&&(o+=Re(E)));break}case U:for(let E=d.length-1;E>=0;E--)i.push({indent:f,mode:F,doc:d[E]});break;case V:a.markPosition();break;case I:i.push({indent:Zr(f,e),mode:F,doc:d.contents});break;case R:i.push({indent:Qr(f,d.n,e),mode:F,doc:d.contents});break;case v:o-=a.trim();break;case x:{let E=(function(){if(F===Q&&!D)return{indent:f,mode:d.break?K:Q,doc:d.contents};D=!1;let h=n-o,_=s.length>0,P={indent:f,mode:Q,doc:d.contents};if(!d.break&&tt(P,i,h,_,r))return P;if(!d.expandedStates)return{indent:f,mode:K,doc:d.contents};if(!d.break)for(let A=1;A<d.expandedStates.length-1;A++){let B={indent:f,mode:Q,doc:d.expandedStates[A]};if(tt(B,i,h,_,r))return B}return{indent:f,mode:K,doc:y(0,d.expandedStates,-1)}})();i.push(E),d.id&&(r[d.id]=E.mode);break}case S:{let E=n-o,C=d[Lt]??0,{parts:h}=d,_=h.length-C;if(_===0)break;let P=h[C+0],A=h[C+1],B={indent:f,mode:Q,doc:P},J={indent:f,mode:K,doc:P},$e=tt(B,[],E,s.length>0,r,!0);if(_===1){$e?i.push(B):i.push(J);break}let pr={indent:f,mode:Q,doc:A},_t={indent:f,mode:K,doc:A};if(_===2){$e?i.push(pr,B):i.push(_t,J);break}let bu=h[C+2],ku={indent:f,mode:F,doc:{...d,[Lt]:C+2}},Iu=tt({indent:f,mode:Q,doc:[P,A,bu]},[],E,s.length>0,r,!0);i.push(ku),Iu?i.push(pr,B):$e?i.push(_t,B):i.push(_t,J);break}case T:case L:{let E=d.groupId?r[d.groupId]:F;if(E===K){let C=d.type===T?d.breakContents:d.negate?d.contents:oe(d.contents);C&&i.push({indent:f,mode:F,doc:C})}if(E===Q){let C=d.type===T?d.flatContents:d.negate?oe(d.contents):d.contents;C&&i.push({indent:f,mode:F,doc:C})}break}case M:s.push({indent:f,mode:F,doc:d.contents});break;case Y:s.length>0&&i.push({indent:f,mode:F,doc:ke});break;case g:switch(F){case Q:if(!d.hard){d.soft||(a.write(" "),o+=1);break}D=!0;case K:if(s.length>0){i.push({indent:f,mode:F,doc:d},...s.reverse()),s.length=0;break}d.literal?(a.write(u),o=0,f.root&&(f.root.value&&a.write(f.root.value),o=f.root.length)):(a.trim(),a.write(u+f.value),o=f.length);break}break;case b:i.push({indent:f,mode:F,doc:d.contents});break;case N:break;default:throw new Z(d)}i.length===0&&s.length>0&&(i.push(...s.reverse()),s.length=0)}let{text:c,positions:p}=a.finish();if(p.length!==2)return{formatted:c};let[l,m]=p;return{formatted:c,cursorNodeStart:l,cursorNodeText:c.slice(l,m)}}function mo(t,e,r=0){let n=0;for(let u=r;u<t.length;++u)t[u]===" "?n=n+e-n%e:n++;return n}var he=mo;var Mt=class{constructor(e){this.stack=[e]}get key(){let{stack:e,siblings:r}=this;return y(0,e,r===null?-2:-4)??null}get index(){return this.siblings===null?null:y(0,this.stack,-2)}get node(){return y(0,this.stack,-1)}get parent(){return this.getNode(1)}get grandparent(){return this.getNode(2)}get isInArray(){return this.siblings!==null}get siblings(){let{stack:e}=this,r=y(0,e,-3);return Array.isArray(r)?r:null}get next(){let{siblings:e}=this;return e===null?null:e[this.index+1]}get previous(){let{siblings:e}=this;return e===null?null:e[this.index-1]}get isFirst(){return this.index===0}get isLast(){let{siblings:e,index:r}=this;return e!==null&&r===e.length-1}get isRoot(){return this.stack.length===1}get root(){return this.stack[0]}get ancestors(){return[...this.#e()]}getName(){let{stack:e}=this,{length:r}=e;return r>1?y(0,e,-2):null}getValue(){return y(0,this.stack,-1)}getNode(e=0){let r=this.#t(e);return r===-1?null:this.stack[r]}getParentNode(e=0){return this.getNode(e+1)}#t(e){let{stack:r}=this;for(let n=r.length-1;n>=0;n-=2)if(!Array.isArray(r[n])&&--e<0)return n;return-1}call(e,...r){let{stack:n}=this,{length:u}=n,o=y(0,n,-1);for(let i of r)o=o?.[i],n.push(i,o);try{return e(this)}finally{n.length=u}}callParent(e,r=0){let n=this.#t(r+1),u=this.stack.splice(n+1);try{return e(this)}finally{this.stack.push(...u)}}each(e,...r){let{stack:n}=this,{length:u}=n,o=y(0,n,-1);for(let i of r)o=o[i],n.push(i,o);try{for(let i=0;i<o.length;++i)n.push(i,o[i]),e(this,i,o),n.length-=2}finally{n.length=u}}map(e,...r){let n=[];return this.each((u,o,i)=>{n[o]=e(u,o,i)},...r),n}match(...e){let r=this.stack.length-1,n=null,u=this.stack[r--];for(let o of e){if(u===void 0)return!1;let i=null;if(typeof n=="number"&&(i=n,n=this.stack[r--],u=this.stack[r--]),o&&!o(u,n,i))return!1;n=this.stack[r--],u=this.stack[r--]}return!0}findAncestor(e){for(let r of this.#e())if(e(r))return r}hasAncestor(e){for(let r of this.#e())if(e(r))return!0;return!1}*#e(){let{stack:e}=this;for(let r=e.length-3;r>=0;r-=2){let n=e[r];Array.isArray(n)||(yield n)}}},tn=Mt;function Fo(t){return Array.isArray(t)&&t.length>0}var rt=Fo;function Eo(t){return t!==null&&typeof t=="object"}var ge=Eo;function _e(t){return(e,r,n)=>{if(r===!1)return!1;let u=!!n?.backwards,{length:o}=e,i=r;for(;i>=0&&i<o;){let D=e.charAt(i);if(t instanceof RegExp){if(!t.test(D))return i}else if(!t.includes(D))return i;u?i--:i++}return i===-1||i===o?i:!1}}var rn=_e(/\s/),j=_e(" "),nt=_e(",; "),ut=_e(/[^\n\r]/);var nn=t=>t===`
|
|
10
10
|
`||t==="\r"||t==="\u2028"||t==="\u2029";function Co(t,e,r){if(e===!1)return!1;let n=!!r?.backwards,u=t.charAt(e);if(n){if(t.charAt(e-1)==="\r"&&u===`
|
|
11
11
|
`)return e-2;if(nn(u))return e-1}else{if(u==="\r"&&t.charAt(e+1)===`
|
|
12
|
-
`)return e+2;if(nn(u))return e+1}return e}var $=Co;function ho(t,e,r={}){let n=j(t,r.backwards?e-1:e,r),u=$(t,n,r);return n!==u}var H=ho;function*ye(t,e){let{getVisitorKeys:r,filter:n=()=>!0}=e,u=o=>ge(o)&&n(o);for(let o of r(t)){let i=t[o];if(Array.isArray(i))for(let D of i)u(D)&&(yield D);else u(i)&&(yield i)}}function*un(t,e){let r=[t];for(let n=0;n<r.length;n++){let u=r[n];for(let o of ye(u,e))yield o,r.push(o)}}function on(t,e){return ye(t,e).next().done}function go(t,e,r){let{filter:n}=r;if(!n)return[];let u,o=(r.getChildren?.(t,r)??[...ye(t,{getVisitorKeys:r.getVisitorKeys})]).flatMap(s=>(u??(u=[t,...e]),n(s,u)?[s]:sn(s,u,r))),{locStart:i,locEnd:D}=r;return o.sort((s,a)=>i(s)-i(a)||D(s)-D(a)),o}function sn(t,e,r){return Fe(r.cache,t,n=>go(n,e,r))}var ot=sn;function _o(t){let e=t.type||t.kind||"(unknown type)",r=String(t.name||t.id&&(typeof t.id=="object"?t.id.name:t.id)||t.key&&(typeof t.key=="object"?t.key.name:t.key)||t.value&&(typeof t.value=="object"?"":String(t.value))||t.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),e+(r?" "+r:"")}function Yt(t,e){(t.comments??(t.comments=[])).push(e),e.printed=!1,e.nodeDescription=_o(t)}function ce(t,e){e.leading=!0,e.trailing=!1,Yt(t,e)}function re(t,e,r){e.leading=!1,e.trailing=!1,r&&(e.marker=r),Yt(t,e)}function fe(t,e){e.leading=!1,e.trailing=!0,Yt(t,e)}var Vt=new WeakMap;function an(t,e,r,n,u=[]){let{locStart:o,locEnd:i}=r,D=o(e),s=i(e),a=ot(t,u,{cache:Vt,locStart:o,locEnd:i,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes}),c,p,l=0,m=a.length;for(;l<m;){let f=l+m>>1,F=a[f],d=o(F),E=i(F);if(d<=D&&s<=E)return an(F,e,r,F,[F,...u]);if(E<=D){c=F,l=f+1;continue}if(s<=d){p=F,m=f;continue}throw new Error("Comment location overlaps with node location")}if(n?.type==="TemplateLiteral"){let{quasis:f}=n,F=Ut(f,e,r);c&&Ut(f,c,r)!==F&&(c=null),p&&Ut(f,p,r)!==F&&(p=null)}return{enclosingNode:n,precedingNode:c,followingNode:p}}var jt=()=>!1;function cn(t,e){let{comments:r}=t;if(delete t.comments,!rt(r)||!e.printer.canAttachComment)return;let n=[],{printer:{features:{experimental_avoidAstMutation:u},handleComments:o={}},originalText:i}=e,{ownLine:D=jt,endOfLine:s=jt,remaining:a=jt}=o,c=r.map((l,m)=>({...an(t,l,e),comment:l,text:i,options:e,ast:t,isLastComment:r.length-1===m,placement:void 0})),p=!u;for(let[l,m]of c.entries()){let{comment:f,precedingNode:F,enclosingNode:d,followingNode:E,text:C,options:h,ast:_,isLastComment:P}=m,A=yo(C,h,c,l)?"ownLine":Ao(C,h,c,l)?"endOfLine":"remaining",B;if(u?(m.placement=A,B=[m]):B=[f,C,h,_,P],p&&(f.
|
|
12
|
+
`)return e+2;if(nn(u))return e+1}return e}var $=Co;function ho(t,e,r={}){let n=j(t,r.backwards?e-1:e,r),u=$(t,n,r);return n!==u}var H=ho;function*ye(t,e){let{getVisitorKeys:r,filter:n=()=>!0}=e,u=o=>ge(o)&&n(o);for(let o of r(t)){let i=t[o];if(Array.isArray(i))for(let D of i)u(D)&&(yield D);else u(i)&&(yield i)}}function*un(t,e){let r=[t];for(let n=0;n<r.length;n++){let u=r[n];for(let o of ye(u,e))yield o,r.push(o)}}function on(t,e){return ye(t,e).next().done}function go(t,e,r){let{filter:n}=r;if(!n)return[];let u,o=(r.getChildren?.(t,r)??[...ye(t,{getVisitorKeys:r.getVisitorKeys})]).flatMap(s=>(u??(u=[t,...e]),n(s,u)?[s]:sn(s,u,r))),{locStart:i,locEnd:D}=r;return o.sort((s,a)=>i(s)-i(a)||D(s)-D(a)),o}function sn(t,e,r){return Fe(r.cache,t,n=>go(n,e,r))}var ot=sn;function _o(t){let e=t.type||t.kind||"(unknown type)",r=String(t.name||t.id&&(typeof t.id=="object"?t.id.name:t.id)||t.key&&(typeof t.key=="object"?t.key.name:t.key)||t.value&&(typeof t.value=="object"?"":String(t.value))||t.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),e+(r?" "+r:"")}function Yt(t,e){(t.comments??(t.comments=[])).push(e),e.printed=!1,e.nodeDescription=_o(t)}function ce(t,e){e.leading=!0,e.trailing=!1,Yt(t,e)}function re(t,e,r){e.leading=!1,e.trailing=!1,r&&(e.marker=r),Yt(t,e)}function fe(t,e){e.leading=!1,e.trailing=!0,Yt(t,e)}var Vt=new WeakMap;function an(t,e,r,n,u=[]){let{locStart:o,locEnd:i}=r,D=o(e),s=i(e),a=ot(t,u,{cache:Vt,locStart:o,locEnd:i,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes}),c,p,l=0,m=a.length;for(;l<m;){let f=l+m>>1,F=a[f],d=o(F),E=i(F);if(d<=D&&s<=E)return an(F,e,r,F,[F,...u]);if(E<=D){c=F,l=f+1;continue}if(s<=d){p=F,m=f;continue}throw new Error("Comment location overlaps with node location")}if(n?.type==="TemplateLiteral"){let{quasis:f}=n,F=Ut(f,e,r);c&&Ut(f,c,r)!==F&&(c=null),p&&Ut(f,p,r)!==F&&(p=null)}return{enclosingNode:n,precedingNode:c,followingNode:p}}var jt=()=>!1;function cn(t,e){let{comments:r}=t;if(delete t.comments,!rt(r)||!e.printer.canAttachComment)return;let n=[],{printer:{features:{experimental_avoidAstMutation:u},handleComments:o={}},originalText:i}=e,{ownLine:D=jt,endOfLine:s=jt,remaining:a=jt}=o,c=r.map((l,m)=>({...an(t,l,e),comment:l,text:i,options:e,ast:t,isLastComment:r.length-1===m,placement:void 0})),p=!u;for(let[l,m]of c.entries()){let{comment:f,precedingNode:F,enclosingNode:d,followingNode:E,text:C,options:h,ast:_,isLastComment:P}=m,A=yo(C,h,c,l)?"ownLine":Ao(C,h,c,l)?"endOfLine":"remaining",B;if(u?(m.placement=A,B=[m]):B=[f,C,h,_,P],p&&(f.enclosingNode=d,f.precedingNode=F,f.followingNode=E),f.placement=A,A==="ownLine")D(...B)||(E?ce(E,f):F?fe(F,f):d?re(d,f):re(_,f));else if(A==="endOfLine")s(...B)||(F?fe(F,f):E?ce(E,f):d?re(d,f):re(_,f));else if(!a(...B))if(F&&E){let J=n.length;J>0&&n[J-1].followingNode!==E&&Dn(n,h),n.push(m)}else F?fe(F,f):E?ce(E,f):d?re(d,f):re(_,f)}if(Dn(n,e),p)for(let l of r)delete l.precedingNode,delete l.enclosingNode,delete l.followingNode}var fn=t=>!/[\S\n\u2028\u2029]/.test(t);function yo(t,e,r,n){let{comment:u,precedingNode:o}=r[n],{locStart:i,locEnd:D}=e,s=i(u);if(o)for(let a=n-1;a>=0;a--){let{comment:c,precedingNode:p}=r[a];if(p!==o||!fn(t.slice(D(c),s)))break;s=i(c)}return H(t,s,{backwards:!0})}function Ao(t,e,r,n){let{comment:u,followingNode:o}=r[n],{locStart:i,locEnd:D}=e,s=D(u);if(o)for(let a=n+1;a<r.length;a++){let{comment:c,followingNode:p}=r[a];if(p!==o||!fn(t.slice(s,i(c))))break;s=D(c)}return H(t,s)}function Dn(t,e){let r=t.length;if(r===0)return;let{precedingNode:n,followingNode:u}=t[0],o=e.locStart(u),i;for(i=r;i>0;--i){let{comment:D,precedingNode:s,followingNode:a}=t[i-1];k(s,n),k(a,u);let c=e.originalText.slice(e.locEnd(D),o);if(e.printer.isGap?.(c,e)??/^[\s(]*$/.test(c))o=e.locStart(D);else break}for(let[D,{comment:s}]of t.entries())D<i?fe(n,s):ce(u,s);for(let D of[n,u])D.comments&&D.comments.length>1&&D.comments.sort((s,a)=>e.locStart(s)-e.locStart(a));t.length=0}function Ut(t,e,r){let n=r.locStart(e)-1;for(let u=1;u<t.length;++u)if(n<r.locStart(t[u]))return u-1;return 0}function xo(t,e){let r=e-1;r=j(t,r,{backwards:!0}),r=$(t,r,{backwards:!0}),r=j(t,r,{backwards:!0});let n=$(t,r,{backwards:!0});return r!==n}var ve=xo;var ln=()=>!0;function pn(t,e){let r=t.node;return r.printed=!0,e.printer.printComment(t,e)}function Bo(t,e){let r=t.node,n=[pn(t,e)],{printer:u,originalText:o,locStart:i,locEnd:D}=e;if(u.isBlockComment?.(r)){let c=" ";H(o,D(r))&&(H(o,i(r),{backwards:!0})?c=W:c=Ze),n.push(c)}else n.push(W);let a=$(o,j(o,D(r)));return a!==!1&&H(o,a)&&n.push(W),n}function To(t,e,r){let n=t.node,u=pn(t,e),{printer:o,originalText:i,locStart:D}=e,s=o.isBlockComment?.(n);if(r?.hasLineSuffix&&!r?.isBlock||H(i,D(n),{backwards:!0})){let a=ve(i,D(n));return{doc:Ie([W,a?W:"",u]),isBlock:s,hasLineSuffix:!0}}return!s||r?.hasLineSuffix?{doc:[Ie([" ",u]),ae],isBlock:s,hasLineSuffix:!0}:{doc:[" ",u],isBlock:s,hasLineSuffix:!1}}function No(t,e,r){let n=e[Symbol.for("printedComments")],u=r?.filter??ln,o=new Set(t.node?.comments?.filter(i=>!n?.has(i)&&i.leading&&u(i)));return o.size===0?"":t.map(({node:i})=>o.has(i)?Bo(t,e):"","comments").filter(Boolean)}function wo(t,e,r){let n=t.node?.comments,u=new Set(n?.filter(c=>c.trailing)),o=e[Symbol.for("printedComments")],i=r?.filter??ln,D=new Set(n?.filter(c=>u.has(c)&&!o?.has(c)&&i(c)));if(D.size===0)return"";let s=[],a;return t.each(({node:c})=>{u.has(c)&&(a=To(t,e,a),D.has(c)&&s.push(a.doc))},"comments"),s}function mn(t,e,r,n){let u=No(t,r,n),o=wo(t,r,n);return u||o?Ee(e,i=>[u,i,o]):e}function dn(t){let{[ue]:e,[Symbol.for("printedComments")]:r}=t;for(let n of e){if(!n.printed&&!r.has(n))throw new Error('Comment "'+n.value.trim()+'" was not printed. Please report this error!');delete n.printed}}var Fn=()=>k;var Le=class extends Error{name="ConfigError"},Me=class extends Error{name="UndefinedParserError"};var Oo=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),le=Oo;var En={checkIgnorePragma:{category:"Special",type:"boolean",default:!1,description:"Check whether the file's first docblock comment contains '@noprettier' or '@noformat' to determine if it should be formatted.",cliCategory:"Other"},cursorOffset:{category:"Special",type:"int",default:-1,range:{start:-1,end:1/0,step:1},description:"Print (to stderr) where a cursor at the given position would move to after formatting.",cliCategory:"Editor"},endOfLine:{category:"Global",type:"choice",default:"lf",description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:`Maintain existing
|
|
13
13
|
(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:t=>typeof t=="string"||typeof t=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"},{value:"mjml",description:"MJML"}]},plugins:{type:"path",array:!0,default:[{value:[]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:t=>typeof t=="string"||typeof t=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:80,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive).
|
|
14
14
|
The range will extend forwards to the end of the selected statement.`,cliCategory:"Editor"},rangeStart:{category:"Special",type:"int",default:0,range:{start:0,end:1/0,step:1},description:`Format code starting at a given character offset.
|
|
15
15
|
The range will extend backwards to the start of the first line containing the selected statement.`,cliCategory:"Editor"},requirePragma:{category:"Special",type:"boolean",default:!1,description:"Require either '@prettier' or '@format' to be present in the file's first docblock comment in order for it to be formatted.",cliCategory:"Other"},tabWidth:{type:"int",category:"Global",default:2,description:"Number of spaces per indentation level.",range:{start:0,end:1/0,step:1}},useTabs:{category:"Global",type:"boolean",default:!1,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{category:"Global",type:"choice",default:"auto",description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};function it({plugins:t=[],showDeprecated:e=!1}={}){let r=t.flatMap(u=>u.languages??[]),n=[];for(let u of So(Object.assign({},...t.map(({options:o})=>o),En)))!e&&u.deprecated||(Array.isArray(u.choices)&&(e||(u.choices=u.choices.filter(o=>!o.deprecated)),u.name==="parser"&&(u.choices=[...u.choices,...Po(u.choices,r,t)])),u.pluginDefaults=Object.fromEntries(t.filter(o=>o.defaultOptions?.[u.name]!==void 0).map(o=>[o.name,o.defaultOptions[u.name]])),n.push(u));return{languages:r,options:n}}function*Po(t,e,r){let n=new Set(t.map(u=>u.value));for(let u of e)if(u.parsers){for(let o of u.parsers)if(!n.has(o)){n.add(o);let i=r.find(s=>s.parsers&&le(s.parsers,o)),D=u.name;i?.name&&(D+=` (plugin: ${i.name})`),yield{value:o,description:D}}}}function So(t){let e=[];for(let[r,n]of Object.entries(t)){let u={name:r,...n};Array.isArray(u.default)&&(u.default=y(0,u.default,-1).value),e.push(u)}return e}var bo=Array.prototype.toReversed??function(){return[...this].reverse()},ko=X("toReversed",function(){if(Array.isArray(this))return bo}),Cn=ko;function Io(){let t=globalThis,e=t.process?.platform;if(typeof e=="string")return e.startsWith("win");let r=t.Deno?.build?.os;return typeof r=="string"?r==="windows":t.navigator?.platform?.startsWith("Win")??!1}var Ro=Io();function hn(t){if(t=t instanceof URL?t:new URL(t),t.protocol!=="file:")throw new TypeError(`URL must be a file URL: received "${t.protocol}"`);return t}function vo(t){return t=hn(t),decodeURIComponent(t.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Lo(t){t=hn(t);let e=decodeURIComponent(t.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return t.hostname!==""&&(e=`\\\\${t.hostname}${e}`),e}function Wt(t){return Ro?Lo(t):vo(t)}var gn=t=>String(t).split(/[/\\]/).pop(),_n=t=>String(t).startsWith("file:");function yn(t,e){if(!e)return;let r=gn(e).toLowerCase();return t.find(({filenames:n})=>n?.some(u=>u.toLowerCase()===r))??t.find(({extensions:n})=>n?.some(u=>r.endsWith(u)))}function Mo(t,e){if(e)return t.find(({name:r})=>r.toLowerCase()===e)??t.find(({aliases:r})=>r?.includes(e))??t.find(({extensions:r})=>r?.includes(`.${e}`))}var Yo=void 0;function An(t,e){if(e){if(_n(e))try{e=Wt(e)}catch{return}if(typeof e=="string")return t.find(({isSupported:r})=>r?.({filepath:e}))}}function jo(t,e){let r=Cn(0,t.plugins).flatMap(u=>u.languages??[]);return(Mo(r,e.language)??yn(r,e.physicalFile)??yn(r,e.file)??An(r,e.physicalFile)??An(r,e.file)??Yo?.(r,e.physicalFile))?.parsers[0]}var st=jo;var ie={key:t=>/^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(t)?t:JSON.stringify(t),value(t){if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(r=>ie.value(r)).join(", ")}]`;let e=Object.keys(t);return e.length===0?"{}":`{ ${e.map(r=>`${ie.key(r)}: ${ie.value(t[r])}`).join(", ")} }`},pair:({key:t,value:e})=>ie.value({[t]:e})};var xn=new Proxy(String,{get:()=>xn}),z=xn;var Bn=(t,e,{descriptor:r})=>{let n=[`${z.yellow(typeof t=="string"?r.key(t):r.pair(t))} is deprecated`];return e&&n.push(`we now treat it as ${z.blue(typeof e=="string"?r.key(e):r.pair(e))}`),n.join("; ")+"."};var Dt=Symbol.for("vnopts.VALUE_NOT_EXIST"),Ae=Symbol.for("vnopts.VALUE_UNCHANGED");var Tn=" ".repeat(2),wn=(t,e,r)=>{let{text:n,list:u}=r.normalizeExpectedResult(r.schemas[t].expected(r)),o=[];return n&&o.push(Nn(t,e,n,r.descriptor)),u&&o.push([Nn(t,e,u.title,r.descriptor)].concat(u.values.map(i=>On(i,r.loggerPrintWidth))).join(`
|
|
@@ -24,6 +24,6 @@ ${f}`),u.reset(f)}function eu(t,e,r={}){return Zn(t,e,r)}async function ci(t,e){
|
|
|
24
24
|
`&&(l+=Nt(m.slice(0,l),`
|
|
25
25
|
`)),m=ne(0,m,`
|
|
26
26
|
`,f)}return{formatted:m,cursorOffset:l,comments:c.comments}}function Dr(t,e,r){return typeof e!="number"||Number.isNaN(e)||e<0||e>t.length?r:e}function fu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=e;return r=Dr(t,r,-1),n=Dr(t,n,0),u=Dr(t,u,t.length),{...e,cursorOffset:r,rangeStart:n,rangeEnd:u}}function du(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o}=fu(t,e),i=t.charAt(0)===pu;if(i&&(t=t.slice(1),r--,n--,u--),o==="auto"&&(o=hr(t)),t.includes("\r")){let D=s=>Nt(t.slice(0,Math.max(s,0)),`\r
|
|
27
|
-
`);r-=D(r),n-=D(n),u-=D(u),t=gr(t)}return{hasBOM:i,text:t,options:fu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function lu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function Ai(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function ar(t,e){let{hasBOM:r,text:n,options:u}=du(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await lu(n,u)||u.checkIgnorePragma&&await Ai(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await yi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await lu(n,u)&&(n=u.printer.insertPragma(n)),o=await mu(n,u)),r&&(o.formatted=pu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function Fu(t,e,r){let{text:n,options:u}=du(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await or(o.ast,u)),r.massage&&(o.ast=uu(o.ast,u))),o}async function Eu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Cu(t,e){let r=Vr(t),{formatted:n}=await ar(r,{...e,parser:"__js_expression"});return n}async function hu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...ir(r,e)}),Ve(r,e)}async function gu(t,e){return Ce(t,await se(e))}var cr={};At(cr,{builders:()=>Bi,printer:()=>Ti,utils:()=>Ni});var Bi={join:be,line:Ze,softline:Yr,hardline:W,literalline:Je,group:Ot,conditionalGroup:Rr,fill:Ir,lineSuffix:Ie,lineSuffixBoundary:jr,cursor:ee,breakParent:ae,ifBreak:vr,trim:Ur,indent:oe,indentIfBreak:Lr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:br,dedent:kr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Pt,label:Mr,concat:t=>t},Ti={printDocToString:Ce},Ni={willBreak:Br,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Nr,stripTrailingHardline:He,replaceEndOfLine:wr,canBreak:Or};var _u="3.9.
|
|
27
|
+
`);r-=D(r),n-=D(n),u-=D(u),t=gr(t)}return{hasBOM:i,text:t,options:fu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function lu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function Ai(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function ar(t,e){let{hasBOM:r,text:n,options:u}=du(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await lu(n,u)||u.checkIgnorePragma&&await Ai(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await yi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await lu(n,u)&&(n=u.printer.insertPragma(n)),o=await mu(n,u)),r&&(o.formatted=pu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function Fu(t,e,r){let{text:n,options:u}=du(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await or(o.ast,u)),r.massage&&(o.ast=uu(o.ast,u))),o}async function Eu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Cu(t,e){let r=Vr(t),{formatted:n}=await ar(r,{...e,parser:"__js_expression"});return n}async function hu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...ir(r,e)}),Ve(r,e)}async function gu(t,e){return Ce(t,await se(e))}var cr={};At(cr,{builders:()=>Bi,printer:()=>Ti,utils:()=>Ni});var Bi={join:be,line:Ze,softline:Yr,hardline:W,literalline:Je,group:Ot,conditionalGroup:Rr,fill:Ir,lineSuffix:Ie,lineSuffixBoundary:jr,cursor:ee,breakParent:ae,ifBreak:vr,trim:Ur,indent:oe,indentIfBreak:Lr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:br,dedent:kr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Pt,label:Mr,concat:t=>t},Ti={printDocToString:Ce},Ni={willBreak:Br,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Nr,stripTrailingHardline:He,replaceEndOfLine:wr,canBreak:Or};var _u="3.9.5";var lr={};At(lr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>yu,getMaxContinuousCount:()=>Au,getNextNonSpaceNonCommentCharacter:()=>xu,getNextNonSpaceNonCommentCharacterIndex:()=>ji,getPreferredQuote:()=>Nu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>wu,hasSpaces:()=>Ou,isNextLineEmpty:()=>zi,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Vi,makeString:()=>$i,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>rn});function wi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=wi;function Oi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Oi;function Pi(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Pi;function Si(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Si;function bi(t,e){let r=t.lastIndexOf(`
|
|
28
28
|
`);return r===-1?0:he(t.slice(r+1).match(/^[\t ]*/)[0],e)}var yu=bi;function fr(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function ki(t,e){let r=t.matchAll(new RegExp(`(?:${fr(e)})+`,"g"));return r.reduce||(r=[...r]),r.reduce((n,[u])=>Math.max(n,u.length),0)/e.length}var Au=ki;function Ii(t,e){let r=We(t,e);return r===!1?"":t.charAt(r)}var xu=Ii;var Bu=Object.freeze({character:"'",codePoint:39}),Tu=Object.freeze({character:'"',codePoint:34}),Ri=Object.freeze({preferred:Bu,alternate:Tu}),vi=Object.freeze({preferred:Tu,alternate:Bu});function Nu(t,e){let{preferred:r,alternate:n}=e===!0||e==="'"?Ri:vi,{length:u}=t,o=0,i=0;for(let D=0;D<u;D++){let s=t.charCodeAt(D);s===r.codePoint?o++:s===n.codePoint&&i++}return(o>i?n:r).character}function Li(t,e,r){for(let n=e;n<r;++n)if(t.charAt(n)===`
|
|
29
29
|
`)return!0;return!1}var wu=Li;function Mi(t,e,r={}){return j(t,r.backwards?e-1:e,r)!==e}var Ou=Mi;function Yi(t,e,r){return We(t,r(e))}function ji(t,e){return arguments.length===2||typeof e=="number"?We(t,e):Yi(...arguments)}function Ui(t,e,r){return ve(t,r(e))}function Vi(t,e){return arguments.length===2||typeof e=="number"?ve(t,e):Ui(...arguments)}function Wi(t,e,r){return gt(t,r(e))}function $i(t,e,r){let n=e==='"'?"'":'"',o=ne(0,t,/\\(.)|(["'])/gs,(i,D,s)=>D===n?D:s===e?"\\"+s:s||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(D)?D:"\\"+D));return e+o+e}function zi(t,e){return arguments.length===2||typeof e=="number"?gt(t,e):Wi(...arguments)}function de(t,e=1){return async(...r)=>{let n=r[e]??{},u=n.plugins??[];return r[e]={...n,plugins:Array.isArray(u)?u:Object.values(u)},await t(...r)}}var Pu=de(ar);async function Su(t,e){let{formatted:r}=await Pu(t,{...e,cursorOffset:-1});return r}async function Gi(t,e){return await Su(t,e)===t}var Ki=de(it,0),Hi={parse:de(Fu),formatAST:de(Eu),formatDoc:de(Cu),printToDoc:de(hu),printDocToString:de(gu)};return Yu(Ji);});
|
package/standalone.mjs
CHANGED
|
@@ -9,7 +9,7 @@ Expected it to be ${n}.`}var Nt=class extends Error{name="InvalidDocError";const
|
|
|
9
9
|
`,u):d;E&&(a.write(E),i.length>0&&(o+=Re(E)));break}case U:for(let E=d.length-1;E>=0;E--)i.push({indent:f,mode:F,doc:d[E]});break;case V:a.markPosition();break;case I:i.push({indent:Qr(f,e),mode:F,doc:d.contents});break;case R:i.push({indent:Xr(f,d.n,e),mode:F,doc:d.contents});break;case v:o-=a.trim();break;case x:{let E=(function(){if(F===Q&&!D)return{indent:f,mode:d.break?K:Q,doc:d.contents};D=!1;let h=n-o,_=s.length>0,P={indent:f,mode:Q,doc:d.contents};if(!d.break&&tt(P,i,h,_,r))return P;if(!d.expandedStates)return{indent:f,mode:K,doc:d.contents};if(!d.break)for(let A=1;A<d.expandedStates.length-1;A++){let B={indent:f,mode:Q,doc:d.expandedStates[A]};if(tt(B,i,h,_,r))return B}return{indent:f,mode:K,doc:y(0,d.expandedStates,-1)}})();i.push(E),d.id&&(r[d.id]=E.mode);break}case S:{let E=n-o,C=d[vt]??0,{parts:h}=d,_=h.length-C;if(_===0)break;let P=h[C+0],A=h[C+1],B={indent:f,mode:Q,doc:P},J={indent:f,mode:K,doc:P},$e=tt(B,[],E,s.length>0,r,!0);if(_===1){$e?i.push(B):i.push(J);break}let lr={indent:f,mode:Q,doc:A},_t={indent:f,mode:K,doc:A};if(_===2){$e?i.push(lr,B):i.push(_t,J);break}let bu=h[C+2],ku={indent:f,mode:F,doc:{...d,[vt]:C+2}},Iu=tt({indent:f,mode:Q,doc:[P,A,bu]},[],E,s.length>0,r,!0);i.push(ku),Iu?i.push(lr,B):$e?i.push(_t,B):i.push(_t,J);break}case T:case L:{let E=d.groupId?r[d.groupId]:F;if(E===K){let C=d.type===T?d.breakContents:d.negate?d.contents:oe(d.contents);C&&i.push({indent:f,mode:F,doc:C})}if(E===Q){let C=d.type===T?d.flatContents:d.negate?oe(d.contents):d.contents;C&&i.push({indent:f,mode:F,doc:C})}break}case M:s.push({indent:f,mode:F,doc:d.contents});break;case Y:s.length>0&&i.push({indent:f,mode:F,doc:ke});break;case g:switch(F){case Q:if(!d.hard){d.soft||(a.write(" "),o+=1);break}D=!0;case K:if(s.length>0){i.push({indent:f,mode:F,doc:d},...s.reverse()),s.length=0;break}d.literal?(a.write(u),o=0,f.root&&(f.root.value&&a.write(f.root.value),o=f.root.length)):(a.trim(),a.write(u+f.value),o=f.length);break}break;case b:i.push({indent:f,mode:F,doc:d.contents});break;case N:break;default:throw new Z(d)}i.length===0&&s.length>0&&(i.push(...s.reverse()),s.length=0)}let{text:c,positions:p}=a.finish();if(p.length!==2)return{formatted:c};let[l,m]=p;return{formatted:c,cursorNodeStart:l,cursorNodeText:c.slice(l,m)}}function co(t,e,r=0){let n=0;for(let u=r;u<t.length;++u)t[u]===" "?n=n+e-n%e:n++;return n}var he=co;var Lt=class{constructor(e){this.stack=[e]}get key(){let{stack:e,siblings:r}=this;return y(0,e,r===null?-2:-4)??null}get index(){return this.siblings===null?null:y(0,this.stack,-2)}get node(){return y(0,this.stack,-1)}get parent(){return this.getNode(1)}get grandparent(){return this.getNode(2)}get isInArray(){return this.siblings!==null}get siblings(){let{stack:e}=this,r=y(0,e,-3);return Array.isArray(r)?r:null}get next(){let{siblings:e}=this;return e===null?null:e[this.index+1]}get previous(){let{siblings:e}=this;return e===null?null:e[this.index-1]}get isFirst(){return this.index===0}get isLast(){let{siblings:e,index:r}=this;return e!==null&&r===e.length-1}get isRoot(){return this.stack.length===1}get root(){return this.stack[0]}get ancestors(){return[...this.#e()]}getName(){let{stack:e}=this,{length:r}=e;return r>1?y(0,e,-2):null}getValue(){return y(0,this.stack,-1)}getNode(e=0){let r=this.#t(e);return r===-1?null:this.stack[r]}getParentNode(e=0){return this.getNode(e+1)}#t(e){let{stack:r}=this;for(let n=r.length-1;n>=0;n-=2)if(!Array.isArray(r[n])&&--e<0)return n;return-1}call(e,...r){let{stack:n}=this,{length:u}=n,o=y(0,n,-1);for(let i of r)o=o?.[i],n.push(i,o);try{return e(this)}finally{n.length=u}}callParent(e,r=0){let n=this.#t(r+1),u=this.stack.splice(n+1);try{return e(this)}finally{this.stack.push(...u)}}each(e,...r){let{stack:n}=this,{length:u}=n,o=y(0,n,-1);for(let i of r)o=o[i],n.push(i,o);try{for(let i=0;i<o.length;++i)n.push(i,o[i]),e(this,i,o),n.length-=2}finally{n.length=u}}map(e,...r){let n=[];return this.each((u,o,i)=>{n[o]=e(u,o,i)},...r),n}match(...e){let r=this.stack.length-1,n=null,u=this.stack[r--];for(let o of e){if(u===void 0)return!1;let i=null;if(typeof n=="number"&&(i=n,n=this.stack[r--],u=this.stack[r--]),o&&!o(u,n,i))return!1;n=this.stack[r--],u=this.stack[r--]}return!0}findAncestor(e){for(let r of this.#e())if(e(r))return r}hasAncestor(e){for(let r of this.#e())if(e(r))return!0;return!1}*#e(){let{stack:e}=this;for(let r=e.length-3;r>=0;r-=2){let n=e[r];Array.isArray(n)||(yield n)}}},en=Lt;function fo(t){return Array.isArray(t)&&t.length>0}var rt=fo;function lo(t){return t!==null&&typeof t=="object"}var ge=lo;function _e(t){return(e,r,n)=>{if(r===!1)return!1;let u=!!n?.backwards,{length:o}=e,i=r;for(;i>=0&&i<o;){let D=e.charAt(i);if(t instanceof RegExp){if(!t.test(D))return i}else if(!t.includes(D))return i;u?i--:i++}return i===-1||i===o?i:!1}}var tn=_e(/\s/),j=_e(" "),nt=_e(",; "),ut=_e(/[^\n\r]/);var rn=t=>t===`
|
|
10
10
|
`||t==="\r"||t==="\u2028"||t==="\u2029";function po(t,e,r){if(e===!1)return!1;let n=!!r?.backwards,u=t.charAt(e);if(n){if(t.charAt(e-1)==="\r"&&u===`
|
|
11
11
|
`)return e-2;if(rn(u))return e-1}else{if(u==="\r"&&t.charAt(e+1)===`
|
|
12
|
-
`)return e+2;if(rn(u))return e+1}return e}var $=po;function mo(t,e,r={}){let n=j(t,r.backwards?e-1:e,r),u=$(t,n,r);return n!==u}var H=mo;function*ye(t,e){let{getVisitorKeys:r,filter:n=()=>!0}=e,u=o=>ge(o)&&n(o);for(let o of r(t)){let i=t[o];if(Array.isArray(i))for(let D of i)u(D)&&(yield D);else u(i)&&(yield i)}}function*nn(t,e){let r=[t];for(let n=0;n<r.length;n++){let u=r[n];for(let o of ye(u,e))yield o,r.push(o)}}function un(t,e){return ye(t,e).next().done}function Fo(t,e,r){let{filter:n}=r;if(!n)return[];let u,o=(r.getChildren?.(t,r)??[...ye(t,{getVisitorKeys:r.getVisitorKeys})]).flatMap(s=>(u??(u=[t,...e]),n(s,u)?[s]:on(s,u,r))),{locStart:i,locEnd:D}=r;return o.sort((s,a)=>i(s)-i(a)||D(s)-D(a)),o}function on(t,e,r){return Fe(r.cache,t,n=>Fo(n,e,r))}var ot=on;function Eo(t){let e=t.type||t.kind||"(unknown type)",r=String(t.name||t.id&&(typeof t.id=="object"?t.id.name:t.id)||t.key&&(typeof t.key=="object"?t.key.name:t.key)||t.value&&(typeof t.value=="object"?"":String(t.value))||t.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),e+(r?" "+r:"")}function Mt(t,e){(t.comments??(t.comments=[])).push(e),e.printed=!1,e.nodeDescription=Eo(t)}function ce(t,e){e.leading=!0,e.trailing=!1,Mt(t,e)}function re(t,e,r){e.leading=!1,e.trailing=!1,r&&(e.marker=r),Mt(t,e)}function fe(t,e){e.leading=!1,e.trailing=!0,Mt(t,e)}var Ut=new WeakMap;function Dn(t,e,r,n,u=[]){let{locStart:o,locEnd:i}=r,D=o(e),s=i(e),a=ot(t,u,{cache:Ut,locStart:o,locEnd:i,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes}),c,p,l=0,m=a.length;for(;l<m;){let f=l+m>>1,F=a[f],d=o(F),E=i(F);if(d<=D&&s<=E)return Dn(F,e,r,F,[F,...u]);if(E<=D){c=F,l=f+1;continue}if(s<=d){p=F,m=f;continue}throw new Error("Comment location overlaps with node location")}if(n?.type==="TemplateLiteral"){let{quasis:f}=n,F=jt(f,e,r);c&&jt(f,c,r)!==F&&(c=null),p&&jt(f,p,r)!==F&&(p=null)}return{enclosingNode:n,precedingNode:c,followingNode:p}}var Yt=()=>!1;function an(t,e){let{comments:r}=t;if(delete t.comments,!rt(r)||!e.printer.canAttachComment)return;let n=[],{printer:{features:{experimental_avoidAstMutation:u},handleComments:o={}},originalText:i}=e,{ownLine:D=Yt,endOfLine:s=Yt,remaining:a=Yt}=o,c=r.map((l,m)=>({...Dn(t,l,e),comment:l,text:i,options:e,ast:t,isLastComment:r.length-1===m,placement:void 0})),p=!u;for(let[l,m]of c.entries()){let{comment:f,precedingNode:F,enclosingNode:d,followingNode:E,text:C,options:h,ast:_,isLastComment:P}=m,A=Co(C,h,c,l)?"ownLine":ho(C,h,c,l)?"endOfLine":"remaining",B;if(u?(m.placement=A,B=[m]):B=[f,C,h,_,P],p&&(f.
|
|
12
|
+
`)return e+2;if(rn(u))return e+1}return e}var $=po;function mo(t,e,r={}){let n=j(t,r.backwards?e-1:e,r),u=$(t,n,r);return n!==u}var H=mo;function*ye(t,e){let{getVisitorKeys:r,filter:n=()=>!0}=e,u=o=>ge(o)&&n(o);for(let o of r(t)){let i=t[o];if(Array.isArray(i))for(let D of i)u(D)&&(yield D);else u(i)&&(yield i)}}function*nn(t,e){let r=[t];for(let n=0;n<r.length;n++){let u=r[n];for(let o of ye(u,e))yield o,r.push(o)}}function un(t,e){return ye(t,e).next().done}function Fo(t,e,r){let{filter:n}=r;if(!n)return[];let u,o=(r.getChildren?.(t,r)??[...ye(t,{getVisitorKeys:r.getVisitorKeys})]).flatMap(s=>(u??(u=[t,...e]),n(s,u)?[s]:on(s,u,r))),{locStart:i,locEnd:D}=r;return o.sort((s,a)=>i(s)-i(a)||D(s)-D(a)),o}function on(t,e,r){return Fe(r.cache,t,n=>Fo(n,e,r))}var ot=on;function Eo(t){let e=t.type||t.kind||"(unknown type)",r=String(t.name||t.id&&(typeof t.id=="object"?t.id.name:t.id)||t.key&&(typeof t.key=="object"?t.key.name:t.key)||t.value&&(typeof t.value=="object"?"":String(t.value))||t.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),e+(r?" "+r:"")}function Mt(t,e){(t.comments??(t.comments=[])).push(e),e.printed=!1,e.nodeDescription=Eo(t)}function ce(t,e){e.leading=!0,e.trailing=!1,Mt(t,e)}function re(t,e,r){e.leading=!1,e.trailing=!1,r&&(e.marker=r),Mt(t,e)}function fe(t,e){e.leading=!1,e.trailing=!0,Mt(t,e)}var Ut=new WeakMap;function Dn(t,e,r,n,u=[]){let{locStart:o,locEnd:i}=r,D=o(e),s=i(e),a=ot(t,u,{cache:Ut,locStart:o,locEnd:i,getVisitorKeys:r.getVisitorKeys,filter:r.printer.canAttachComment,getChildren:r.printer.getCommentChildNodes}),c,p,l=0,m=a.length;for(;l<m;){let f=l+m>>1,F=a[f],d=o(F),E=i(F);if(d<=D&&s<=E)return Dn(F,e,r,F,[F,...u]);if(E<=D){c=F,l=f+1;continue}if(s<=d){p=F,m=f;continue}throw new Error("Comment location overlaps with node location")}if(n?.type==="TemplateLiteral"){let{quasis:f}=n,F=jt(f,e,r);c&&jt(f,c,r)!==F&&(c=null),p&&jt(f,p,r)!==F&&(p=null)}return{enclosingNode:n,precedingNode:c,followingNode:p}}var Yt=()=>!1;function an(t,e){let{comments:r}=t;if(delete t.comments,!rt(r)||!e.printer.canAttachComment)return;let n=[],{printer:{features:{experimental_avoidAstMutation:u},handleComments:o={}},originalText:i}=e,{ownLine:D=Yt,endOfLine:s=Yt,remaining:a=Yt}=o,c=r.map((l,m)=>({...Dn(t,l,e),comment:l,text:i,options:e,ast:t,isLastComment:r.length-1===m,placement:void 0})),p=!u;for(let[l,m]of c.entries()){let{comment:f,precedingNode:F,enclosingNode:d,followingNode:E,text:C,options:h,ast:_,isLastComment:P}=m,A=Co(C,h,c,l)?"ownLine":ho(C,h,c,l)?"endOfLine":"remaining",B;if(u?(m.placement=A,B=[m]):B=[f,C,h,_,P],p&&(f.enclosingNode=d,f.precedingNode=F,f.followingNode=E),f.placement=A,A==="ownLine")D(...B)||(E?ce(E,f):F?fe(F,f):d?re(d,f):re(_,f));else if(A==="endOfLine")s(...B)||(F?fe(F,f):E?ce(E,f):d?re(d,f):re(_,f));else if(!a(...B))if(F&&E){let J=n.length;J>0&&n[J-1].followingNode!==E&&sn(n,h),n.push(m)}else F?fe(F,f):E?ce(E,f):d?re(d,f):re(_,f)}if(sn(n,e),p)for(let l of r)delete l.precedingNode,delete l.enclosingNode,delete l.followingNode}var cn=t=>!/[\S\n\u2028\u2029]/.test(t);function Co(t,e,r,n){let{comment:u,precedingNode:o}=r[n],{locStart:i,locEnd:D}=e,s=i(u);if(o)for(let a=n-1;a>=0;a--){let{comment:c,precedingNode:p}=r[a];if(p!==o||!cn(t.slice(D(c),s)))break;s=i(c)}return H(t,s,{backwards:!0})}function ho(t,e,r,n){let{comment:u,followingNode:o}=r[n],{locStart:i,locEnd:D}=e,s=D(u);if(o)for(let a=n+1;a<r.length;a++){let{comment:c,followingNode:p}=r[a];if(p!==o||!cn(t.slice(s,i(c))))break;s=D(c)}return H(t,s)}function sn(t,e){let r=t.length;if(r===0)return;let{precedingNode:n,followingNode:u}=t[0],o=e.locStart(u),i;for(i=r;i>0;--i){let{comment:D,precedingNode:s,followingNode:a}=t[i-1];k(s,n),k(a,u);let c=e.originalText.slice(e.locEnd(D),o);if(e.printer.isGap?.(c,e)??/^[\s(]*$/.test(c))o=e.locStart(D);else break}for(let[D,{comment:s}]of t.entries())D<i?fe(n,s):ce(u,s);for(let D of[n,u])D.comments&&D.comments.length>1&&D.comments.sort((s,a)=>e.locStart(s)-e.locStart(a));t.length=0}function jt(t,e,r){let n=r.locStart(e)-1;for(let u=1;u<t.length;++u)if(n<r.locStart(t[u]))return u-1;return 0}function go(t,e){let r=e-1;r=j(t,r,{backwards:!0}),r=$(t,r,{backwards:!0}),r=j(t,r,{backwards:!0});let n=$(t,r,{backwards:!0});return r!==n}var ve=go;var fn=()=>!0;function ln(t,e){let r=t.node;return r.printed=!0,e.printer.printComment(t,e)}function _o(t,e){let r=t.node,n=[ln(t,e)],{printer:u,originalText:o,locStart:i,locEnd:D}=e;if(u.isBlockComment?.(r)){let c=" ";H(o,D(r))&&(H(o,i(r),{backwards:!0})?c=W:c=Ze),n.push(c)}else n.push(W);let a=$(o,j(o,D(r)));return a!==!1&&H(o,a)&&n.push(W),n}function yo(t,e,r){let n=t.node,u=ln(t,e),{printer:o,originalText:i,locStart:D}=e,s=o.isBlockComment?.(n);if(r?.hasLineSuffix&&!r?.isBlock||H(i,D(n),{backwards:!0})){let a=ve(i,D(n));return{doc:Ie([W,a?W:"",u]),isBlock:s,hasLineSuffix:!0}}return!s||r?.hasLineSuffix?{doc:[Ie([" ",u]),ae],isBlock:s,hasLineSuffix:!0}:{doc:[" ",u],isBlock:s,hasLineSuffix:!1}}function Ao(t,e,r){let n=e[Symbol.for("printedComments")],u=r?.filter??fn,o=new Set(t.node?.comments?.filter(i=>!n?.has(i)&&i.leading&&u(i)));return o.size===0?"":t.map(({node:i})=>o.has(i)?_o(t,e):"","comments").filter(Boolean)}function xo(t,e,r){let n=t.node?.comments,u=new Set(n?.filter(c=>c.trailing)),o=e[Symbol.for("printedComments")],i=r?.filter??fn,D=new Set(n?.filter(c=>u.has(c)&&!o?.has(c)&&i(c)));if(D.size===0)return"";let s=[],a;return t.each(({node:c})=>{u.has(c)&&(a=yo(t,e,a),D.has(c)&&s.push(a.doc))},"comments"),s}function pn(t,e,r,n){let u=Ao(t,r,n),o=xo(t,r,n);return u||o?Ee(e,i=>[u,i,o]):e}function mn(t){let{[ue]:e,[Symbol.for("printedComments")]:r}=t;for(let n of e){if(!n.printed&&!r.has(n))throw new Error('Comment "'+n.value.trim()+'" was not printed. Please report this error!');delete n.printed}}var dn=()=>k;var Le=class extends Error{name="ConfigError"},Me=class extends Error{name="UndefinedParserError"};var Bo=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),le=Bo;var Fn={checkIgnorePragma:{category:"Special",type:"boolean",default:!1,description:"Check whether the file's first docblock comment contains '@noprettier' or '@noformat' to determine if it should be formatted.",cliCategory:"Other"},cursorOffset:{category:"Special",type:"int",default:-1,range:{start:-1,end:1/0,step:1},description:"Print (to stderr) where a cursor at the given position would move to after formatting.",cliCategory:"Editor"},endOfLine:{category:"Global",type:"choice",default:"lf",description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:`Maintain existing
|
|
13
13
|
(mixed values within one file are normalised by looking at what's used after the first line)`}]},filepath:{category:"Special",type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:"Other",cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{category:"Special",type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:"Other"},parser:{category:"Global",type:"choice",default:void 0,description:"Which parser to use.",exception:t=>typeof t=="string"||typeof t=="function",choices:[{value:"flow",description:"Flow"},{value:"babel",description:"JavaScript"},{value:"babel-flow",description:"Flow"},{value:"babel-ts",description:"TypeScript"},{value:"typescript",description:"TypeScript"},{value:"acorn",description:"JavaScript"},{value:"espree",description:"JavaScript"},{value:"meriyah",description:"JavaScript"},{value:"css",description:"CSS"},{value:"less",description:"Less"},{value:"scss",description:"SCSS"},{value:"json",description:"JSON"},{value:"json5",description:"JSON5"},{value:"jsonc",description:"JSON with Comments"},{value:"json-stringify",description:"JSON.stringify"},{value:"graphql",description:"GraphQL"},{value:"markdown",description:"Markdown"},{value:"mdx",description:"MDX"},{value:"vue",description:"Vue"},{value:"yaml",description:"YAML"},{value:"glimmer",description:"Ember / Handlebars"},{value:"html",description:"HTML"},{value:"angular",description:"Angular"},{value:"lwc",description:"Lightning Web Components"},{value:"mjml",description:"MJML"}]},plugins:{type:"path",array:!0,default:[{value:[]}],category:"Global",description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:t=>typeof t=="string"||typeof t=="object",cliName:"plugin",cliCategory:"Config"},printWidth:{category:"Global",type:"int",default:80,description:"The line length where Prettier will try wrap.",range:{start:0,end:1/0,step:1}},rangeEnd:{category:"Special",type:"int",default:1/0,range:{start:0,end:1/0,step:1},description:`Format code ending at a given character offset (exclusive).
|
|
14
14
|
The range will extend forwards to the end of the selected statement.`,cliCategory:"Editor"},rangeStart:{category:"Special",type:"int",default:0,range:{start:0,end:1/0,step:1},description:`Format code starting at a given character offset.
|
|
15
15
|
The range will extend backwards to the start of the first line containing the selected statement.`,cliCategory:"Editor"},requirePragma:{category:"Special",type:"boolean",default:!1,description:"Require either '@prettier' or '@format' to be present in the file's first docblock comment in order for it to be formatted.",cliCategory:"Other"},tabWidth:{type:"int",category:"Global",default:2,description:"Number of spaces per indentation level.",range:{start:0,end:1/0,step:1}},useTabs:{category:"Global",type:"boolean",default:!1,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{category:"Global",type:"choice",default:"auto",description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};function it({plugins:t=[],showDeprecated:e=!1}={}){let r=t.flatMap(u=>u.languages??[]),n=[];for(let u of No(Object.assign({},...t.map(({options:o})=>o),Fn)))!e&&u.deprecated||(Array.isArray(u.choices)&&(e||(u.choices=u.choices.filter(o=>!o.deprecated)),u.name==="parser"&&(u.choices=[...u.choices,...To(u.choices,r,t)])),u.pluginDefaults=Object.fromEntries(t.filter(o=>o.defaultOptions?.[u.name]!==void 0).map(o=>[o.name,o.defaultOptions[u.name]])),n.push(u));return{languages:r,options:n}}function*To(t,e,r){let n=new Set(t.map(u=>u.value));for(let u of e)if(u.parsers){for(let o of u.parsers)if(!n.has(o)){n.add(o);let i=r.find(s=>s.parsers&&le(s.parsers,o)),D=u.name;i?.name&&(D+=` (plugin: ${i.name})`),yield{value:o,description:D}}}}function No(t){let e=[];for(let[r,n]of Object.entries(t)){let u={name:r,...n};Array.isArray(u.default)&&(u.default=y(0,u.default,-1).value),e.push(u)}return e}var wo=Array.prototype.toReversed??function(){return[...this].reverse()},Oo=X("toReversed",function(){if(Array.isArray(this))return wo}),En=Oo;function Po(){let t=globalThis,e=t.process?.platform;if(typeof e=="string")return e.startsWith("win");let r=t.Deno?.build?.os;return typeof r=="string"?r==="windows":t.navigator?.platform?.startsWith("Win")??!1}var So=Po();function Cn(t){if(t=t instanceof URL?t:new URL(t),t.protocol!=="file:")throw new TypeError(`URL must be a file URL: received "${t.protocol}"`);return t}function bo(t){return t=Cn(t),decodeURIComponent(t.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function ko(t){t=Cn(t);let e=decodeURIComponent(t.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return t.hostname!==""&&(e=`\\\\${t.hostname}${e}`),e}function Vt(t){return So?ko(t):bo(t)}var hn=t=>String(t).split(/[/\\]/).pop(),gn=t=>String(t).startsWith("file:");function _n(t,e){if(!e)return;let r=hn(e).toLowerCase();return t.find(({filenames:n})=>n?.some(u=>u.toLowerCase()===r))??t.find(({extensions:n})=>n?.some(u=>r.endsWith(u)))}function Io(t,e){if(e)return t.find(({name:r})=>r.toLowerCase()===e)??t.find(({aliases:r})=>r?.includes(e))??t.find(({extensions:r})=>r?.includes(`.${e}`))}var Ro=void 0;function yn(t,e){if(e){if(gn(e))try{e=Vt(e)}catch{return}if(typeof e=="string")return t.find(({isSupported:r})=>r?.({filepath:e}))}}function vo(t,e){let r=En(0,t.plugins).flatMap(u=>u.languages??[]);return(Io(r,e.language)??_n(r,e.physicalFile)??_n(r,e.file)??yn(r,e.physicalFile)??yn(r,e.file)??Ro?.(r,e.physicalFile))?.parsers[0]}var st=vo;var ie={key:t=>/^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(t)?t:JSON.stringify(t),value(t){if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(r=>ie.value(r)).join(", ")}]`;let e=Object.keys(t);return e.length===0?"{}":`{ ${e.map(r=>`${ie.key(r)}: ${ie.value(t[r])}`).join(", ")} }`},pair:({key:t,value:e})=>ie.value({[t]:e})};var An=new Proxy(String,{get:()=>An}),z=An;var xn=(t,e,{descriptor:r})=>{let n=[`${z.yellow(typeof t=="string"?r.key(t):r.pair(t))} is deprecated`];return e&&n.push(`we now treat it as ${z.blue(typeof e=="string"?r.key(e):r.pair(e))}`),n.join("; ")+"."};var Dt=Symbol.for("vnopts.VALUE_NOT_EXIST"),Ae=Symbol.for("vnopts.VALUE_UNCHANGED");var Bn=" ".repeat(2),Nn=(t,e,r)=>{let{text:n,list:u}=r.normalizeExpectedResult(r.schemas[t].expected(r)),o=[];return n&&o.push(Tn(t,e,n,r.descriptor)),u&&o.push([Tn(t,e,u.title,r.descriptor)].concat(u.values.map(i=>wn(i,r.loggerPrintWidth))).join(`
|
|
@@ -24,6 +24,6 @@ ${f}`),u.reset(f)}function Zn(t,e,r={}){return Qn(t,e,r)}async function ii(t,e){
|
|
|
24
24
|
`&&(l+=Tt(m.slice(0,l),`
|
|
25
25
|
`)),m=ne(0,m,`
|
|
26
26
|
`,f)}return{formatted:m,cursorOffset:l,comments:c.comments}}function sr(t,e,r){return typeof e!="number"||Number.isNaN(e)||e<0||e>t.length?r:e}function cu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=e;return r=sr(t,r,-1),n=sr(t,n,0),u=sr(t,u,t.length),{...e,cursorOffset:r,rangeStart:n,rangeEnd:u}}function mu(t,e){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o}=cu(t,e),i=t.charAt(0)===lu;if(i&&(t=t.slice(1),r--,n--,u--),o==="auto"&&(o=Cr(t)),t.includes("\r")){let D=s=>Tt(t.slice(0,Math.max(s,0)),`\r
|
|
27
|
-
`);r-=D(r),n-=D(n),u-=D(u),t=hr(t)}return{hasBOM:i,text:t,options:cu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function fu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function hi(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function Dr(t,e){let{hasBOM:r,text:n,options:u}=mu(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await fu(n,u)||u.checkIgnorePragma&&await hi(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await Ci(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await fu(n,u)&&(n=u.printer.insertPragma(n)),o=await pu(n,u)),r&&(o.formatted=lu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function du(t,e,r){let{text:n,options:u}=mu(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await ur(o.ast,u)),r.massage&&(o.ast=nu(o.ast,u))),o}async function Fu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Eu(t,e){let r=Ur(t),{formatted:n}=await Dr(r,{...e,parser:"__js_expression"});return n}async function Cu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...or(r,e)}),Ve(r,e)}async function hu(t,e){return Ce(t,await se(e))}var ar={};yt(ar,{builders:()=>_i,printer:()=>yi,utils:()=>Ai});var _i={join:be,line:Ze,softline:Mr,hardline:W,literalline:Je,group:wt,conditionalGroup:Ir,fill:kr,lineSuffix:Ie,lineSuffixBoundary:Yr,cursor:ee,breakParent:ae,ifBreak:Rr,trim:jr,indent:oe,indentIfBreak:vr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:Sr,dedent:br,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Ot,label:Lr,concat:t=>t},yi={printDocToString:Ce},Ai={willBreak:xr,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Tr,stripTrailingHardline:He,replaceEndOfLine:Nr,canBreak:wr};var gu="3.9.
|
|
27
|
+
`);r-=D(r),n-=D(n),u-=D(u),t=hr(t)}return{hasBOM:i,text:t,options:cu(t,{...e,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:o})}}async function fu(t,e){let r=await Ue(e);return!r.hasPragma||r.hasPragma(t)}async function hi(t,e){return(await Ue(e)).hasIgnorePragma?.(t)}async function Dr(t,e){let{hasBOM:r,text:n,options:u}=mu(t,await se(e));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await fu(n,u)||u.checkIgnorePragma&&await hi(n,u))return{formatted:t,cursorOffset:e.cursorOffset,comments:[]};let o;return u.rangeStart>0||u.rangeEnd<n.length?o=await Ci(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await fu(n,u)&&(n=u.printer.insertPragma(n)),o=await pu(n,u)),r&&(o.formatted=lu+o.formatted,o.cursorOffset>=0&&o.cursorOffset++),o}async function du(t,e,r){let{text:n,options:u}=mu(t,await se(e)),o=await me(n,u);return r&&(r.preprocessForPrint&&(o.ast=await ur(o.ast,u)),r.massage&&(o.ast=nu(o.ast,u))),o}async function Fu(t,e){e=await se(e);let r=await Ve(t,e);return Ce(r,e)}async function Eu(t,e){let r=Ur(t),{formatted:n}=await Dr(r,{...e,parser:"__js_expression"});return n}async function Cu(t,e){e=await se(e);let{ast:r}=await me(t,e);return e.cursorOffset>=0&&(e={...e,...or(r,e)}),Ve(r,e)}async function hu(t,e){return Ce(t,await se(e))}var ar={};yt(ar,{builders:()=>_i,printer:()=>yi,utils:()=>Ai});var _i={join:be,line:Ze,softline:Mr,hardline:W,literalline:Je,group:wt,conditionalGroup:Ir,fill:kr,lineSuffix:Ie,lineSuffixBoundary:Yr,cursor:ee,breakParent:ae,ifBreak:Rr,trim:jr,indent:oe,indentIfBreak:vr,align:De,addAlignmentToDoc:Qe,markAsRoot:Xe,dedentToRoot:Sr,dedent:br,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Ot,label:Lr,concat:t=>t},yi={printDocToString:Ce},Ai={willBreak:xr,traverseDoc:Oe,findInDoc:Ke,mapDoc:Se,removeLines:Tr,stripTrailingHardline:He,replaceEndOfLine:Nr,canBreak:wr};var gu="3.9.5";var fr={};yt(fr,{addDanglingComment:()=>re,addLeadingComment:()=>ce,addTrailingComment:()=>fe,getAlignmentSize:()=>he,getIndentSize:()=>_u,getMaxContinuousCount:()=>yu,getNextNonSpaceNonCommentCharacter:()=>Au,getNextNonSpaceNonCommentCharacterIndex:()=>vi,getPreferredQuote:()=>Tu,getStringWidth:()=>Re,hasNewline:()=>H,hasNewlineInRange:()=>Nu,hasSpaces:()=>wu,isNextLineEmpty:()=>Ui,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>Mi,makeString:()=>ji,skip:()=>_e,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>$,skipSpaces:()=>j,skipToLineEnd:()=>nt,skipTrailingComment:()=>Te,skipWhitespace:()=>tn});function xi(t,e){if(e===!1)return!1;if(t.charAt(e)==="/"&&t.charAt(e+1)==="*"){for(let r=e+2;r<t.length;++r)if(t.charAt(r)==="*"&&t.charAt(r+1)==="/")return r+2}return e}var Be=xi;function Bi(t,e){return e===!1?!1:t.charAt(e)==="/"&&t.charAt(e+1)==="/"?ut(t,e):e}var Te=Bi;function Ti(t,e){let r=null,n=e;for(;n!==r;)r=n,n=j(t,n),n=Be(t,n),n=Te(t,n),n=$(t,n);return n}var We=Ti;function Ni(t,e){let r=null,n=e;for(;n!==r;)r=n,n=nt(t,n),n=Be(t,n),n=j(t,n);return n=Te(t,n),n=$(t,n),n!==!1&&H(t,n)}var gt=Ni;function wi(t,e){let r=t.lastIndexOf(`
|
|
28
28
|
`);return r===-1?0:he(t.slice(r+1).match(/^[\t ]*/)[0],e)}var _u=wi;function cr(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Oi(t,e){let r=t.matchAll(new RegExp(`(?:${cr(e)})+`,"g"));return r.reduce||(r=[...r]),r.reduce((n,[u])=>Math.max(n,u.length),0)/e.length}var yu=Oi;function Pi(t,e){let r=We(t,e);return r===!1?"":t.charAt(r)}var Au=Pi;var xu=Object.freeze({character:"'",codePoint:39}),Bu=Object.freeze({character:'"',codePoint:34}),Si=Object.freeze({preferred:xu,alternate:Bu}),bi=Object.freeze({preferred:Bu,alternate:xu});function Tu(t,e){let{preferred:r,alternate:n}=e===!0||e==="'"?Si:bi,{length:u}=t,o=0,i=0;for(let D=0;D<u;D++){let s=t.charCodeAt(D);s===r.codePoint?o++:s===n.codePoint&&i++}return(o>i?n:r).character}function ki(t,e,r){for(let n=e;n<r;++n)if(t.charAt(n)===`
|
|
29
29
|
`)return!0;return!1}var Nu=ki;function Ii(t,e,r={}){return j(t,r.backwards?e-1:e,r)!==e}var wu=Ii;function Ri(t,e,r){return We(t,r(e))}function vi(t,e){return arguments.length===2||typeof e=="number"?We(t,e):Ri(...arguments)}function Li(t,e,r){return ve(t,r(e))}function Mi(t,e){return arguments.length===2||typeof e=="number"?ve(t,e):Li(...arguments)}function Yi(t,e,r){return gt(t,r(e))}function ji(t,e,r){let n=e==='"'?"'":'"',o=ne(0,t,/\\(.)|(["'])/gs,(i,D,s)=>D===n?D:s===e?"\\"+s:s||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(D)?D:"\\"+D));return e+o+e}function Ui(t,e){return arguments.length===2||typeof e=="number"?gt(t,e):Yi(...arguments)}function de(t,e=1){return async(...r)=>{let n=r[e]??{},u=n.plugins??[];return r[e]={...n,plugins:Array.isArray(u)?u:Object.values(u)},await t(...r)}}var Ou=de(Dr);async function Pu(t,e){let{formatted:r}=await Ou(t,{...e,cursorOffset:-1});return r}async function Vi(t,e){return await Pu(t,e)===t}var Wi=de(it,0),$i={parse:de(du),formatAST:de(Fu),formatDoc:de(Eu),printToDoc:de(Cu),printDocToString:de(hu)};export{$i as __debug,Vi as check,Su as default,ar as doc,Pu as format,Ou as formatWithCursor,Wi as getSupportInfo,fr as util,gu as version};
|