prettier 3.5.1 → 3.5.3
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/README.md +1 -1
- package/THIRD-PARTY-NOTICES.md +8 -8
- package/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.mjs +4 -4
- package/package.json +1 -17
- package/plugins/estree.js +25 -25
- package/plugins/estree.mjs +25 -25
- package/plugins/html.js +1 -1
- package/plugins/html.mjs +1 -1
- package/plugins/postcss.js +6 -6
- package/plugins/postcss.mjs +6 -6
- package/plugins/typescript.js +1 -1
- package/plugins/typescript.mjs +1 -1
- package/standalone.d.ts +1 -1
- package/standalone.js +2 -2
- package/standalone.mjs +2 -2
package/standalone.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function formatWithCursor(
|
|
|
17
17
|
): Promise<CursorResult>;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/
|
|
20
|
+
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.
|
|
21
21
|
*/
|
|
22
22
|
export function format(source: string, options?: Options): Promise<string>;
|
|
23
23
|
|
package/standalone.js
CHANGED
|
@@ -29,11 +29,11 @@ in order for it to be formatted.`,cliCategory:"Other"},tabWidth:{type:"int",cate
|
|
|
29
29
|
`)),An(i,r.loggerPrintWidth)};function Cn(e,t,r,n){return[`Invalid ${ce.default.red(n.key(e))} value.`,`Expected ${ce.default.blue(r)},`,`but received ${t===at?ce.default.gray("nothing"):ce.default.red(n.value(t))}.`].join(" ")}function yn({text:e,list:t},r){let n=[];return e&&n.push(`- ${ce.default.blue(e)}`),t&&n.push([`- ${ce.default.blue(t.title)}:`].concat(t.values.map(u=>yn(u,r-En.length).replace(/^|\n/g,`$&${En}`))).join(`
|
|
30
30
|
`)),An(n,r)}function An(e,t){if(e.length===1)return e[0];let[r,n]=e,[u,i]=e.map(o=>o.split(`
|
|
31
31
|
`,1)[0].length);return u>t&&u>i?n:r}var Kt=Ve(st(),1);var zt=[],vn=[];function Gt(e,t){if(e===t)return 0;let r=e;e.length>t.length&&(e=t,t=r);let n=e.length,u=t.length;for(;n>0&&e.charCodeAt(~-n)===t.charCodeAt(~-u);)n--,u--;let i=0;for(;i<n&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(n-=i,u-=i,n===0)return u;let o,s,a,D,l=0,p=0;for(;l<n;)vn[l]=e.charCodeAt(i+l),zt[l]=++l;for(;p<u;)for(o=t.charCodeAt(i+p),a=p++,s=p,l=0;l<n;l++)D=o===vn[l]?a:a+1,a=zt[l],s=zt[l]=a>s?D>s?s+1:D:D>a?a+1:D;return s}var Dt=(e,t,{descriptor:r,logger:n,schemas:u})=>{let i=[`Ignored unknown option ${Kt.default.yellow(r.pair({key:e,value:t}))}.`],o=Object.keys(u).sort().find(s=>Gt(e,s)<3);o&&i.push(`Did you mean ${Kt.default.blue(r.key(o))}?`),n.warn(i.join(" "))};var Fi=["default","expected","validate","deprecated","forward","redirect","overlap","preprocess","postprocess"];function mi(e,t){let r=new e(t),n=Object.create(r);for(let u of Fi)u in t&&(n[u]=hi(t[u],r,x.prototype[u].length));return n}var x=class{static create(t){return mi(this,t)}constructor(t){this.name=t.name}default(t){}expected(t){return"nothing"}validate(t,r){return!1}deprecated(t,r){return!1}forward(t,r){}redirect(t,r){}overlap(t,r,n){return t}preprocess(t,r){return t}postprocess(t,r){return ve}};function hi(e,t,r){return typeof e=="function"?(...n)=>e(...n.slice(0,r-1),t,...n.slice(r-1)):()=>e}var lt=class extends x{constructor(t){super(t),this._sourceName=t.sourceName}expected(t){return t.schemas[this._sourceName].expected(t)}validate(t,r){return r.schemas[this._sourceName].validate(t,r)}redirect(t,r){return this._sourceName}};var ct=class extends x{expected(){return"anything"}validate(){return!0}};var ft=class extends x{constructor({valueSchema:t,name:r=t.name,...n}){super({...n,name:r}),this._valueSchema=t}expected(t){let{text:r,list:n}=t.normalizeExpectedResult(this._valueSchema.expected(t));return{text:r&&`an array of ${r}`,list:n&&{title:"an array of the following values",values:[{list:n}]}}}validate(t,r){if(!Array.isArray(t))return!1;let n=[];for(let u of t){let i=r.normalizeValidateResult(this._valueSchema.validate(u,r),u);i!==!0&&n.push(i.value)}return n.length===0?!0:{value:n}}deprecated(t,r){let n=[];for(let u of t){let i=r.normalizeDeprecatedResult(this._valueSchema.deprecated(u,r),u);i!==!1&&n.push(...i.map(({value:o})=>({value:[o]})))}return n}forward(t,r){let n=[];for(let u of t){let i=r.normalizeForwardResult(this._valueSchema.forward(u,r),u);n.push(...i.map(Bn))}return n}redirect(t,r){let n=[],u=[];for(let i of t){let o=r.normalizeRedirectResult(this._valueSchema.redirect(i,r),i);"remain"in o&&n.push(o.remain),u.push(...o.redirect.map(Bn))}return n.length===0?{redirect:u}:{redirect:u,remain:n}}overlap(t,r){return t.concat(r)}};function Bn({from:e,to:t}){return{from:[e],to:t}}var dt=class extends x{expected(){return"true or false"}validate(t){return typeof t=="boolean"}};function _n(e,t){let r=Object.create(null);for(let n of e){let u=n[t];if(r[u])throw new Error(`Duplicate ${t} ${JSON.stringify(u)}`);r[u]=n}return r}function xn(e,t){let r=new Map;for(let n of e){let u=n[t];if(r.has(u))throw new Error(`Duplicate ${t} ${JSON.stringify(u)}`);r.set(u,n)}return r}function bn(){let e=Object.create(null);return t=>{let r=JSON.stringify(t);return e[r]?!0:(e[r]=!0,!1)}}function Nn(e,t){let r=[],n=[];for(let u of e)t(u)?r.push(u):n.push(u);return[r,n]}function On(e){return e===Math.floor(e)}function Sn(e,t){if(e===t)return 0;let r=typeof e,n=typeof t,u=["undefined","object","boolean","number","string"];return r!==n?u.indexOf(r)-u.indexOf(n):r!=="string"?Number(e)-Number(t):e.localeCompare(t)}function Tn(e){return(...t)=>{let r=e(...t);return typeof r=="string"?new Error(r):r}}function Jt(e){return e===void 0?{}:e}function qt(e){if(typeof e=="string")return{text:e};let{text:t,list:r}=e;return Ei((t||r)!==void 0,"Unexpected `expected` result, there should be at least one field."),r?{text:t,list:{title:r.title,values:r.values.map(qt)}}:{text:t}}function Xt(e,t){return e===!0?!0:e===!1?{value:t}:e}function Qt(e,t,r=!1){return e===!1?!1:e===!0?r?!0:[{value:t}]:"value"in e?[e]:e.length===0?!1:e}function wn(e,t){return typeof e=="string"||"key"in e?{from:t,to:e}:"from"in e?{from:e.from,to:e.to}:{from:t,to:e.to}}function pt(e,t){return e===void 0?[]:Array.isArray(e)?e.map(r=>wn(r,t)):[wn(e,t)]}function Zt(e,t){let r=pt(typeof e=="object"&&"redirect"in e?e.redirect:e,t);return r.length===0?{remain:t,redirect:r}:typeof e=="object"&&"remain"in e?{remain:e.remain,redirect:r}:{redirect:r}}function Ei(e,t){if(!e)throw new Error(t)}var Ft=class extends x{constructor(t){super(t),this._choices=xn(t.choices.map(r=>r&&typeof r=="object"?r:{value:r}),"value")}expected({descriptor:t}){let r=Array.from(this._choices.keys()).map(o=>this._choices.get(o)).filter(({hidden:o})=>!o).map(o=>o.value).sort(Sn).map(t.value),n=r.slice(0,-2),u=r.slice(-2);return{text:n.concat(u.join(" or ")).join(", "),list:{title:"one of the following values",values:r}}}validate(t){return this._choices.has(t)}deprecated(t){let r=this._choices.get(t);return r&&r.deprecated?{value:t}:!1}forward(t){let r=this._choices.get(t);return r?r.forward:void 0}redirect(t){let r=this._choices.get(t);return r?r.redirect:void 0}};var mt=class extends x{expected(){return"a number"}validate(t,r){return typeof t=="number"}};var ht=class extends mt{expected(){return"an integer"}validate(t,r){return r.normalizeValidateResult(super.validate(t,r),t)===!0&&On(t)}};var je=class extends x{expected(){return"a string"}validate(t){return typeof t=="string"}};var kn=oe,Ln=Dt,Pn=gn,In=hn;var Et=class{constructor(t,r){let{logger:n=console,loggerPrintWidth:u=80,descriptor:i=kn,unknown:o=Ln,invalid:s=Pn,deprecated:a=In,missing:D=()=>!1,required:l=()=>!1,preprocess:p=d=>d,postprocess:f=()=>ve}=r||{};this._utils={descriptor:i,logger:n||{warn:()=>{}},loggerPrintWidth:u,schemas:_n(t,"name"),normalizeDefaultResult:Jt,normalizeExpectedResult:qt,normalizeDeprecatedResult:Qt,normalizeForwardResult:pt,normalizeRedirectResult:Zt,normalizeValidateResult:Xt},this._unknownHandler=o,this._invalidHandler=Tn(s),this._deprecatedHandler=a,this._identifyMissing=(d,c)=>!(d in c)||D(d,c),this._identifyRequired=l,this._preprocess=p,this._postprocess=f,this.cleanHistory()}cleanHistory(){this._hasDeprecationWarned=bn()}normalize(t){let r={},u=[this._preprocess(t,this._utils)],i=()=>{for(;u.length!==0;){let o=u.shift(),s=this._applyNormalization(o,r);u.push(...s)}};i();for(let o of Object.keys(this._utils.schemas)){let s=this._utils.schemas[o];if(!(o in r)){let a=Jt(s.default(this._utils));"value"in a&&u.push({[o]:a.value})}}i();for(let o of Object.keys(this._utils.schemas)){if(!(o in r))continue;let s=this._utils.schemas[o],a=r[o],D=s.postprocess(a,this._utils);D!==ve&&(this._applyValidation(D,o,s),r[o]=D)}return this._applyPostprocess(r),this._applyRequiredCheck(r),r}_applyNormalization(t,r){let n=[],{knownKeys:u,unknownKeys:i}=this._partitionOptionKeys(t);for(let o of u){let s=this._utils.schemas[o],a=s.preprocess(t[o],this._utils);this._applyValidation(a,o,s);let D=({from:d,to:c})=>{n.push(typeof c=="string"?{[c]:d}:{[c.key]:c.value})},l=({value:d,redirectTo:c})=>{let F=Qt(s.deprecated(d,this._utils),a,!0);if(F!==!1)if(F===!0)this._hasDeprecationWarned(o)||this._utils.logger.warn(this._deprecatedHandler(o,c,this._utils));else for(let{value:m}of F){let h={key:o,value:m};if(!this._hasDeprecationWarned(h)){let C=typeof c=="string"?{key:c,value:m}:c;this._utils.logger.warn(this._deprecatedHandler(h,C,this._utils))}}};pt(s.forward(a,this._utils),a).forEach(D);let f=Zt(s.redirect(a,this._utils),a);if(f.redirect.forEach(D),"remain"in f){let d=f.remain;r[o]=o in r?s.overlap(r[o],d,this._utils):d,l({value:d})}for(let{from:d,to:c}of f.redirect)l({value:d,redirectTo:c})}for(let o of i){let s=t[o];this._applyUnknownHandler(o,s,r,(a,D)=>{n.push({[a]:D})})}return n}_applyRequiredCheck(t){for(let r of Object.keys(this._utils.schemas))if(this._identifyMissing(r,t)&&this._identifyRequired(r))throw this._invalidHandler(r,at,this._utils)}_partitionOptionKeys(t){let[r,n]=Nn(Object.keys(t).filter(u=>!this._identifyMissing(u,t)),u=>u in this._utils.schemas);return{knownKeys:r,unknownKeys:n}}_applyValidation(t,r,n){let u=Xt(n.validate(t,this._utils),t);if(u!==!0)throw this._invalidHandler(r,u.value,this._utils)}_applyUnknownHandler(t,r,n,u){let i=this._unknownHandler(t,r,this._utils);if(i)for(let o of Object.keys(i)){if(this._identifyMissing(o,i))continue;let s=i[o];o in this._utils.schemas?u(o,s):n[o]=s}}_applyPostprocess(t){let r=this._postprocess(t,this._utils);if(r!==ve){if(r.delete)for(let n of r.delete)delete t[n];if(r.override){let{knownKeys:n,unknownKeys:u}=this._partitionOptionKeys(r.override);for(let i of n){let o=r.override[i];this._applyValidation(o,i,this._utils.schemas[i]),t[i]=o}for(let i of u){let o=r.override[i];this._applyUnknownHandler(i,o,t,(s,a)=>{let D=this._utils.schemas[s];this._applyValidation(a,s,D),t[s]=a})}}}}};var er;function gi(e,t,{logger:r=!1,isCLI:n=!1,passThrough:u=!1,FlagSchema:i,descriptor:o}={}){if(n){if(!i)throw new Error("'FlagSchema' option is required.");if(!o)throw new Error("'descriptor' option is required.")}else o=oe;let s=u?Array.isArray(u)?(f,d)=>u.includes(f)?{[f]:d}:void 0:(f,d)=>({[f]:d}):(f,d,c)=>{let{_:F,...m}=c.schemas;return Dt(f,d,{...c,schemas:m})},a=yi(t,{isCLI:n,FlagSchema:i}),D=new Et(a,{logger:r,unknown:s,descriptor:o}),l=r!==!1;l&&er&&(D._hasDeprecationWarned=er);let p=D.normalize(e);return l&&(er=D._hasDeprecationWarned),p}function yi(e,{isCLI:t,FlagSchema:r}){let n=[];t&&n.push(ct.create({name:"_"}));for(let u of e)n.push(Ai(u,{isCLI:t,optionInfos:e,FlagSchema:r})),u.alias&&t&&n.push(lt.create({name:u.alias,sourceName:u.name}));return n}function Ai(e,{isCLI:t,optionInfos:r,FlagSchema:n}){let{name:u}=e,i={name:u},o,s={};switch(e.type){case"int":o=ht,t&&(i.preprocess=Number);break;case"string":o=je;break;case"choice":o=Ft,i.choices=e.choices.map(a=>a!=null&&a.redirect?{...a,redirect:{to:{key:e.name,value:a.redirect}}}:a);break;case"boolean":o=dt;break;case"flag":o=n,i.flags=r.flatMap(a=>[a.alias,a.description&&a.name,a.oppositeDescription&&`no-${a.name}`].filter(Boolean));break;case"path":o=je;break;default:throw new Error(`Unexpected type ${e.type}`)}if(e.exception?i.validate=(a,D,l)=>e.exception(a)||D.validate(a,l):i.validate=(a,D,l)=>a===void 0||D.validate(a,l),e.redirect&&(s.redirect=a=>a?{to:typeof e.redirect=="string"?e.redirect:{key:e.redirect.option,value:e.redirect.value}}:void 0),e.deprecated&&(s.deprecated=!0),t&&!e.array){let a=i.preprocess||(D=>D);i.preprocess=(D,l,p)=>l.preprocess(a(Array.isArray(D)?A(!1,D,-1):D),p)}return e.array?ft.create({...t?{preprocess:a=>Array.isArray(a)?a:[a]}:{},...s,valueSchema:o.create(i)}):o.create({...i,...s})}var Rn=gi;var vi=(e,t,r)=>{if(!(e&&t==null)){if(t.findLast)return t.findLast(r);for(let n=t.length-1;n>=0;n--){let u=t[n];if(r(u,n,t))return u}}},tr=vi;function rr(e,t){if(!t)throw new Error("parserName is required.");let r=tr(!1,e,u=>u.parsers&&Object.prototype.hasOwnProperty.call(u.parsers,t));if(r)return r;let n=`Couldn't resolve parser "${t}".`;throw n+=" Plugins must be explicitly added to the standalone bundle.",new Re(n)}function Yn(e,t){if(!t)throw new Error("astFormat is required.");let r=tr(!1,e,u=>u.printers&&Object.prototype.hasOwnProperty.call(u.printers,t));if(r)return r;let n=`Couldn't find plugin for AST format "${t}".`;throw n+=" Plugins must be explicitly added to the standalone bundle.",new Re(n)}function Ct({plugins:e,parser:t}){let r=rr(e,t);return nr(r,t)}function nr(e,t){let r=e.parsers[t];return typeof r=="function"?r():r}function jn(e,t){let r=e.printers[t];return typeof r=="function"?r():r}var Hn={astFormat:"estree",printer:{},originalText:void 0,locStart:null,locEnd:null};async function Bi(e,t={}){var p;let r={...e};if(!r.parser)if(r.filepath){if(r.parser=pn(r,{physicalFile:r.filepath}),!r.parser)throw new Ye(`No parser could be inferred for file "${r.filepath}".`)}else throw new Ye("No parser and no file path given, couldn't infer a parser.");let n=ot({plugins:e.plugins,showDeprecated:!0}).options,u={...Hn,...Object.fromEntries(n.filter(f=>f.default!==void 0).map(f=>[f.name,f.default]))},i=rr(r.plugins,r.parser),o=await nr(i,r.parser);r.astFormat=o.astFormat,r.locEnd=o.locEnd,r.locStart=o.locStart;let s=(p=i.printers)!=null&&p[o.astFormat]?i:Yn(r.plugins,o.astFormat),a=await jn(s,o.astFormat);r.printer=a;let D=s.defaultOptions?Object.fromEntries(Object.entries(s.defaultOptions).filter(([,f])=>f!==void 0)):{},l={...u,...D};for(let[f,d]of Object.entries(l))(r[f]===null||r[f]===void 0)&&(r[f]=d);return r.parser==="json"&&(r.trailingComma="none"),Rn(r,n,{passThrough:Object.keys(Hn),...t})}var se=Bi;var Mn=Ve($n(),1);async function bi(e,t){let r=await Ct(t),n=r.preprocess?r.preprocess(e,t):e;t.originalText=n;let u;try{u=await r.parse(n,t,t)}catch(i){Ni(i,e)}return{text:n,ast:u}}function Ni(e,t){let{loc:r}=e;if(r){let n=(0,Mn.codeFrameColumns)(t,r,{highlightCode:!0});throw e.message+=`
|
|
32
|
-
`+n,e.codeFrame=n,e}throw e}var fe=bi;async function Vn(e,t,r,n,u){let{embeddedLanguageFormatting:i,printer:{embed:o,hasPrettierIgnore:s=()=>!1,getVisitorKeys:a}}=r;if(!o||i!=="auto")return;if(o.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/
|
|
32
|
+
`+n,e.codeFrame=n,e}throw e}var fe=bi;async function Vn(e,t,r,n,u){let{embeddedLanguageFormatting:i,printer:{embed:o,hasPrettierIgnore:s=()=>!1,getVisitorKeys:a}}=r;if(!o||i!=="auto")return;if(o.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let D=q(o.getVisitorKeys??a),l=[];d();let p=e.stack;for(let{print:c,node:F,pathStack:m}of l)try{e.stack=m;let h=await c(f,t,e,r);h&&u.set(F,h)}catch(h){if(globalThis.PRETTIER_DEBUG)throw h}e.stack=p;function f(c,F){return Oi(c,F,r,n)}function d(){let{node:c}=e;if(c===null||typeof c!="object"||s(e))return;for(let m of D(c))Array.isArray(c[m])?e.each(d,m):e.call(d,m);let F=o(e,r);if(F){if(typeof F=="function"){l.push({print:F,node:c,pathStack:[...e.stack]});return}u.set(c,F)}}}async function Oi(e,t,r,n){let u=await se({...r,...t,parentParser:r.parser,originalText:e},{passThrough:!0}),{ast:i}=await fe(e,u),o=await n(i,u);return Xe(o)}function Si(e,t){let{originalText:r,[Symbol.for("comments")]:n,locStart:u,locEnd:i,[Symbol.for("printedComments")]:o}=t,{node:s}=e,a=u(s),D=i(s);for(let l of n)u(l)>=a&&i(l)<=D&&o.add(l);return r.slice(a,D)}var Un=Si;async function He(e,t){({ast:e}=await ir(e,t));let r=new Map,n=new qr(e),u=cn(t),i=new Map;await Vn(n,s,t,He,i);let o=await zn(n,t,s,void 0,i);if(ln(t),t.nodeAfterCursor&&!t.nodeBeforeCursor)return[Z,o];if(t.nodeBeforeCursor&&!t.nodeAfterCursor)return[o,Z];return o;function s(D,l){return D===void 0||D===n?a(l):Array.isArray(D)?n.call(()=>a(l),...D):n.call(()=>a(l),D)}function a(D){u(n);let l=n.node;if(l==null)return"";let p=l&&typeof l=="object"&&D===void 0;if(p&&r.has(l))return r.get(l);let f=zn(n,t,s,D,i);return p&&r.set(l,f),f}}function zn(e,t,r,n,u){var a;let{node:i}=e,{printer:o}=t,s;switch((a=o.hasPrettierIgnore)!=null&&a.call(o,e)?s=Un(e,t):u.has(i)?s=u.get(i):s=o.print(e,t,r,n),i){case t.cursorNode:s=me(s,D=>[Z,D,Z]);break;case t.nodeBeforeCursor:s=me(s,D=>[D,Z]);break;case t.nodeAfterCursor:s=me(s,D=>[Z,D]);break}return o.printComment&&(!o.willPrintOwnComments||!o.willPrintOwnComments(e,t))&&(s=Dn(e,s,t)),s}async function ir(e,t){let r=e.comments??[];t[Symbol.for("comments")]=r,t[Symbol.for("tokens")]=e.tokens??[],t[Symbol.for("printedComments")]=new Set,on(e,t);let{printer:{preprocess:n}}=t;return e=n?await n(e,t):e,{ast:e,comments:r}}function Ti(e,t){let{cursorOffset:r,locStart:n,locEnd:u}=t,i=q(t.printer.getVisitorKeys),o=d=>n(d)<=r&&u(d)>=r,s=e,a=[e];for(let d of Zr(e,{getVisitorKeys:i,filter:o}))a.push(d),s=d;if(en(s,{getVisitorKeys:i}))return{cursorNode:s};let D,l,p=-1,f=Number.POSITIVE_INFINITY;for(;a.length>0&&(D===void 0||l===void 0);){s=a.pop();let d=D!==void 0,c=l!==void 0;for(let F of ye(s,{getVisitorKeys:i})){if(!d){let m=u(F);m<=r&&m>p&&(D=F,p=m)}if(!c){let m=n(F);m>=r&&m<f&&(l=F,f=m)}}}return{nodeBeforeCursor:D,nodeAfterCursor:l}}var Gn=Ti;function ki(e,t){let{printer:{massageAstNode:r,getVisitorKeys:n}}=t;if(!r)return e;let u=q(n),i=r.ignoredProperties??new Set;return o(e);function o(s,a){if(!(s!==null&&typeof s=="object"))return s;if(Array.isArray(s))return s.map(f=>o(f,a)).filter(Boolean);let D={},l=new Set(u(s));for(let f in s)!Object.prototype.hasOwnProperty.call(s,f)||i.has(f)||(l.has(f)?D[f]=o(s[f],s):D[f]=s[f]);let p=r(s,D,a);if(p!==null)return p??D}}var Kn=ki;var Li=(e,t,r)=>{if(!(e&&t==null)){if(t.findLastIndex)return t.findLastIndex(r);for(let n=t.length-1;n>=0;n--){let u=t[n];if(r(u,n,t))return n}return-1}},Jn=Li;var Pi=({parser:e})=>e==="json"||e==="json5"||e==="jsonc"||e==="json-stringify";function Ii(e,t){let r=[e.node,...e.parentNodes],n=new Set([t.node,...t.parentNodes]);return r.find(u=>Qn.has(u.type)&&n.has(u))}function qn(e){let t=Jn(!1,e,r=>r.type!=="Program"&&r.type!=="File");return t===-1?e:e.slice(0,t+1)}function Ri(e,t,{locStart:r,locEnd:n}){let u=e.node,i=t.node;if(u===i)return{startNode:u,endNode:i};let o=r(e.node);for(let a of qn(t.parentNodes))if(r(a)>=o)i=a;else break;let s=n(t.node);for(let a of qn(e.parentNodes)){if(n(a)<=s)u=a;else break;if(u===i)break}return{startNode:u,endNode:i}}function or(e,t,r,n,u=[],i){let{locStart:o,locEnd:s}=r,a=o(e),D=s(e);if(!(t>D||t<a||i==="rangeEnd"&&t===a||i==="rangeStart"&&t===D)){for(let l of it(e,r)){let p=or(l,t,r,n,[e,...u],i);if(p)return p}if(!n||n(e,u[0]))return{node:e,parentNodes:u}}}function Yi(e,t){return t!=="DeclareExportDeclaration"&&e!=="TypeParameterDeclaration"&&(e==="Directive"||e==="TypeAlias"||e==="TSExportAssignment"||e.startsWith("Declare")||e.startsWith("TSDeclare")||e.endsWith("Statement")||e.endsWith("Declaration"))}var Qn=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),ji=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function Xn(e,t,r){if(!t)return!1;switch(e.parser){case"flow":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"__babel_estree":return Yi(t.type,r==null?void 0:r.type);case"json":case"json5":case"jsonc":case"json-stringify":return Qn.has(t.type);case"graphql":return ji.has(t.kind);case"vue":return t.tag!=="root"}return!1}function Zn(e,t,r){let{rangeStart:n,rangeEnd:u,locStart:i,locEnd:o}=t;Pe.ok(u>n);let s=e.slice(n,u).search(/\S/u),a=s===-1;if(!a)for(n+=s;u>n&&!/\S/u.test(e[u-1]);--u);let D=or(r,n,t,(d,c)=>Xn(t,d,c),[],"rangeStart"),l=a?D:or(r,u,t,d=>Xn(t,d),[],"rangeEnd");if(!D||!l)return{rangeStart:0,rangeEnd:0};let p,f;if(Pi(t)){let d=Ii(D,l);p=d,f=d}else({startNode:p,endNode:f}=Ri(D,l,t));return{rangeStart:Math.min(i(p),i(f)),rangeEnd:Math.max(o(p),o(f))}}var nu="\uFEFF",eu=Symbol("cursor");async function uu(e,t,r=0){if(!e||e.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await fe(e,t);t.cursorOffset>=0&&(t={...t,...Gn(n,t)});let i=await He(n,t,r);r>0&&(i=et([K,i],r,t.tabWidth));let o=Ce(i,t);if(r>0){let a=o.formatted.trim();o.cursorNodeStart!==void 0&&(o.cursorNodeStart-=o.formatted.indexOf(a),o.cursorNodeStart<0&&(o.cursorNodeStart=0,o.cursorNodeText=o.cursorNodeText.trimStart()),o.cursorNodeStart+o.cursorNodeText.length>a.length&&(o.cursorNodeText=o.cursorNodeText.trimEnd())),o.formatted=a+be(t.endOfLine)}let s=t[Symbol.for("comments")];if(t.cursorOffset>=0){let a,D,l,p;if((t.cursorNode||t.nodeBeforeCursor||t.nodeAfterCursor)&&o.cursorNodeText)if(l=o.cursorNodeStart,p=o.cursorNodeText,t.cursorNode)a=t.locStart(t.cursorNode),D=u.slice(a,t.locEnd(t.cursorNode));else{if(!t.nodeBeforeCursor&&!t.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");a=t.nodeBeforeCursor?t.locEnd(t.nodeBeforeCursor):0;let h=t.nodeAfterCursor?t.locStart(t.nodeAfterCursor):u.length;D=u.slice(a,h)}else a=0,D=u,l=0,p=o.formatted;let f=t.cursorOffset-a;if(D===p)return{formatted:o.formatted,cursorOffset:l+f,comments:s};let d=D.split("");d.splice(f,0,eu);let c=p.split(""),F=yr(d,c),m=l;for(let h of F)if(h.removed){if(h.value.includes(eu))break}else m+=h.count;return{formatted:o.formatted,cursorOffset:m,comments:s}}return{formatted:o.formatted,cursorOffset:-1,comments:s}}async function Hi(e,t){let{ast:r,text:n}=await fe(e,t),{rangeStart:u,rangeEnd:i}=Zn(n,t,r),o=n.slice(u,i),s=Math.min(u,n.lastIndexOf(`
|
|
33
33
|
`,u)+1),a=n.slice(s,u).match(/^\s*/u)[0],D=ge(a,t.tabWidth),l=await uu(o,{...t,rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:t.cursorOffset>u&&t.cursorOffset<=i?t.cursorOffset-u:-1,endOfLine:"lf"},D),p=l.formatted.trimEnd(),{cursorOffset:f}=t;f>i?f+=p.length-o.length:l.cursorOffset>=0&&(f=l.cursorOffset+u);let d=n.slice(0,u)+p+n.slice(i);if(t.endOfLine!=="lf"){let c=be(t.endOfLine);f>=0&&c===`\r
|
|
34
34
|
`&&(f+=Nt(d.slice(0,f),`
|
|
35
35
|
`)),d=ne(!1,d,`
|
|
36
36
|
`,c)}return{formatted:d,cursorOffset:f,comments:l.comments}}function sr(e,t,r){return typeof t!="number"||Number.isNaN(t)||t<0||t>e.length?r:t}function tu(e,t){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=t;return r=sr(e,r,-1),n=sr(e,n,0),u=sr(e,u,e.length),{...t,cursorOffset:r,rangeStart:n,rangeEnd:u}}function iu(e,t){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i}=tu(e,t),o=e.charAt(0)===nu;if(o&&(e=e.slice(1),r--,n--,u--),i==="auto"&&(i=Ar(e)),e.includes("\r")){let s=a=>Nt(e.slice(0,Math.max(a,0)),`\r
|
|
37
|
-
`);r-=s(r),n-=s(n),u-=s(u),e=vr(e)}return{hasBOM:o,text:e,options:tu(e,{...t,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i})}}async function ru(e,t){let r=await Ct(t);return!r.hasPragma||r.hasPragma(e)}async function ar(e,t){let{hasBOM:r,text:n,options:u}=iu(e,await se(t));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await ru(n,u))return{formatted:e,cursorOffset:t.cursorOffset,comments:[]};let i;return u.rangeStart>0||u.rangeEnd<n.length?i=await Hi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await ru(n,u)&&(n=u.printer.insertPragma(n)),i=await uu(n,u)),r&&(i.formatted=nu+i.formatted,i.cursorOffset>=0&&i.cursorOffset++),i}async function ou(e,t,r){let{text:n,options:u}=iu(e,await se(t)),i=await fe(n,u);return r&&(r.preprocessForPrint&&(i.ast=await ir(i.ast,u)),r.massage&&(i.ast=Kn(i.ast,u))),i}async function su(e,t){t=await se(t);let r=await He(e,t);return Ce(r,t)}async function au(e,t){let r=Vr(e),{formatted:n}=await ar(r,{...t,parser:"__js_expression"});return n}async function Du(e,t){t=await se(t);let{ast:r}=await fe(e,t);return He(r,t)}async function lu(e,t){return Ce(e,await se(t))}var Dr={};vt(Dr,{builders:()=>$i,printer:()=>Mi,utils:()=>Vi});var $i={join:Se,line:Ze,softline:$r,hardline:K,literalline:Qe,group:kt,conditionalGroup:Ir,fill:Rr,lineSuffix:Te,lineSuffixBoundary:Hr,cursor:Z,breakParent:he,ifBreak:Yr,trim:Wr,indent:le,indentIfBreak:jr,align:De,addAlignmentToDoc:et,markAsRoot:Lr,dedentToRoot:kr,dedent:Pr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Lt,label:Mr,concat:e=>e},Mi={printDocToString:Ce},Vi={willBreak:xr,traverseDoc:Fe,findInDoc:qe,mapDoc:Oe,removeLines:Nr,stripTrailingHardline:Xe,replaceEndOfLine:Or,canBreak:Sr};var cu="3.5.
|
|
37
|
+
`);r-=s(r),n-=s(n),u-=s(u),e=vr(e)}return{hasBOM:o,text:e,options:tu(e,{...t,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i})}}async function ru(e,t){let r=await Ct(t);return!r.hasPragma||r.hasPragma(e)}async function ar(e,t){let{hasBOM:r,text:n,options:u}=iu(e,await se(t));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await ru(n,u))return{formatted:e,cursorOffset:t.cursorOffset,comments:[]};let i;return u.rangeStart>0||u.rangeEnd<n.length?i=await Hi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await ru(n,u)&&(n=u.printer.insertPragma(n)),i=await uu(n,u)),r&&(i.formatted=nu+i.formatted,i.cursorOffset>=0&&i.cursorOffset++),i}async function ou(e,t,r){let{text:n,options:u}=iu(e,await se(t)),i=await fe(n,u);return r&&(r.preprocessForPrint&&(i.ast=await ir(i.ast,u)),r.massage&&(i.ast=Kn(i.ast,u))),i}async function su(e,t){t=await se(t);let r=await He(e,t);return Ce(r,t)}async function au(e,t){let r=Vr(e),{formatted:n}=await ar(r,{...t,parser:"__js_expression"});return n}async function Du(e,t){t=await se(t);let{ast:r}=await fe(e,t);return He(r,t)}async function lu(e,t){return Ce(e,await se(t))}var Dr={};vt(Dr,{builders:()=>$i,printer:()=>Mi,utils:()=>Vi});var $i={join:Se,line:Ze,softline:$r,hardline:K,literalline:Qe,group:kt,conditionalGroup:Ir,fill:Rr,lineSuffix:Te,lineSuffixBoundary:Hr,cursor:Z,breakParent:he,ifBreak:Yr,trim:Wr,indent:le,indentIfBreak:jr,align:De,addAlignmentToDoc:et,markAsRoot:Lr,dedentToRoot:kr,dedent:Pr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Lt,label:Mr,concat:e=>e},Mi={printDocToString:Ce},Vi={willBreak:xr,traverseDoc:Fe,findInDoc:qe,mapDoc:Oe,removeLines:Nr,stripTrailingHardline:Xe,replaceEndOfLine:Or,canBreak:Sr};var cu="3.5.3";var cr={};vt(cr,{addDanglingComment:()=>re,addLeadingComment:()=>ue,addTrailingComment:()=>ie,getAlignmentSize:()=>ge,getIndentSize:()=>fu,getMaxContinuousCount:()=>du,getNextNonSpaceNonCommentCharacter:()=>pu,getNextNonSpaceNonCommentCharacterIndex:()=>no,getPreferredQuote:()=>mu,getStringWidth:()=>Le,hasNewline:()=>V,hasNewlineInRange:()=>hu,hasSpaces:()=>Eu,isNextLineEmpty:()=>so,isNextLineEmptyAfterIndex:()=>gt,isPreviousLineEmpty:()=>io,makeString:()=>Cu,skip:()=>Ae,skipEverythingButNewLine:()=>ut,skipInlineComment:()=>Be,skipNewline:()=>W,skipSpaces:()=>S,skipToLineEnd:()=>nt,skipTrailingComment:()=>we,skipWhitespace:()=>tn});function Ui(e,t){if(t===!1)return!1;if(e.charAt(t)==="/"&&e.charAt(t+1)==="*"){for(let r=t+2;r<e.length;++r)if(e.charAt(r)==="*"&&e.charAt(r+1)==="/")return r+2}return t}var Be=Ui;function zi(e,t){return t===!1?!1:e.charAt(t)==="/"&&e.charAt(t+1)==="/"?ut(e,t):t}var we=zi;function Gi(e,t){let r=null,n=t;for(;n!==r;)r=n,n=S(e,n),n=Be(e,n),n=we(e,n),n=W(e,n);return n}var We=Gi;function Ki(e,t){let r=null,n=t;for(;n!==r;)r=n,n=nt(e,n),n=Be(e,n),n=S(e,n);return n=we(e,n),n=W(e,n),n!==!1&&V(e,n)}var gt=Ki;function Ji(e,t){let r=e.lastIndexOf(`
|
|
38
38
|
`);return r===-1?0:ge(e.slice(r+1).match(/^[\t ]*/u)[0],t)}var fu=Ji;function lr(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function qi(e,t){let r=e.match(new RegExp(`(${lr(t)})+`,"gu"));return r===null?0:r.reduce((n,u)=>Math.max(n,u.length/t.length),0)}var du=qi;function Xi(e,t){let r=We(e,t);return r===!1?"":e.charAt(r)}var pu=Xi;var yt="'",Fu='"';function Qi(e,t){let r=t===!0||t===yt?yt:Fu,n=r===yt?Fu:yt,u=0,i=0;for(let o of e)o===r?u++:o===n&&i++;return u>i?n:r}var mu=Qi;function Zi(e,t,r){for(let n=t;n<r;++n)if(e.charAt(n)===`
|
|
39
39
|
`)return!0;return!1}var hu=Zi;function eo(e,t,r={}){return S(e,r.backwards?t-1:t,r)!==t}var Eu=eo;function to(e,t,r){let n=t==='"'?"'":'"',i=ne(!1,e,/\\(.)|(["'])/gsu,(o,s,a)=>s===n?s:a===t?"\\"+a:a||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/u.test(s)?s:"\\"+s));return t+i+t}var Cu=to;function ro(e,t,r){return We(e,r(t))}function no(e,t){return arguments.length===2||typeof t=="number"?We(e,t):ro(...arguments)}function uo(e,t,r){return Ie(e,r(t))}function io(e,t){return arguments.length===2||typeof t=="number"?Ie(e,t):uo(...arguments)}function oo(e,t,r){return gt(e,r(t))}function so(e,t){return arguments.length===2||typeof t=="number"?gt(e,t):oo(...arguments)}function de(e,t=1){return async(...r)=>{let n=r[t]??{},u=n.plugins??[];return r[t]={...n,plugins:Array.isArray(u)?u:Object.values(u)},e(...r)}}var gu=de(ar);async function yu(e,t){let{formatted:r}=await gu(e,{...t,cursorOffset:-1});return r}async function ao(e,t){return await yu(e,t)===e}var Do=de(ot,0),lo={parse:de(ou),formatAST:de(su),formatDoc:de(au),printToDoc:de(Du),printDocToString:de(lu)};return xu(co);});
|
package/standalone.mjs
CHANGED
|
@@ -29,11 +29,11 @@ in order for it to be formatted.`,cliCategory:"Other"},tabWidth:{type:"int",cate
|
|
|
29
29
|
`)),An(i,r.loggerPrintWidth)};function Cn(e,t,r,n){return[`Invalid ${ce.default.red(n.key(e))} value.`,`Expected ${ce.default.blue(r)},`,`but received ${t===st?ce.default.gray("nothing"):ce.default.red(n.value(t))}.`].join(" ")}function yn({text:e,list:t},r){let n=[];return e&&n.push(`- ${ce.default.blue(e)}`),t&&n.push([`- ${ce.default.blue(t.title)}:`].concat(t.values.map(u=>yn(u,r-En.length).replace(/^|\n/g,`$&${En}`))).join(`
|
|
30
30
|
`)),An(n,r)}function An(e,t){if(e.length===1)return e[0];let[r,n]=e,[u,i]=e.map(o=>o.split(`
|
|
31
31
|
`,1)[0].length);return u>t&&u>i?n:r}var Kt=Me(ot(),1);var zt=[],vn=[];function Gt(e,t){if(e===t)return 0;let r=e;e.length>t.length&&(e=t,t=r);let n=e.length,u=t.length;for(;n>0&&e.charCodeAt(~-n)===t.charCodeAt(~-u);)n--,u--;let i=0;for(;i<n&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(n-=i,u-=i,n===0)return u;let o,s,a,D,l=0,p=0;for(;l<n;)vn[l]=e.charCodeAt(i+l),zt[l]=++l;for(;p<u;)for(o=t.charCodeAt(i+p),a=p++,s=p,l=0;l<n;l++)D=o===vn[l]?a:a+1,a=zt[l],s=zt[l]=a>s?D>s?s+1:D:D>a?a+1:D;return s}var at=(e,t,{descriptor:r,logger:n,schemas:u})=>{let i=[`Ignored unknown option ${Kt.default.yellow(r.pair({key:e,value:t}))}.`],o=Object.keys(u).sort().find(s=>Gt(e,s)<3);o&&i.push(`Did you mean ${Kt.default.blue(r.key(o))}?`),n.warn(i.join(" "))};var Fi=["default","expected","validate","deprecated","forward","redirect","overlap","preprocess","postprocess"];function mi(e,t){let r=new e(t),n=Object.create(r);for(let u of Fi)u in t&&(n[u]=hi(t[u],r,x.prototype[u].length));return n}var x=class{static create(t){return mi(this,t)}constructor(t){this.name=t.name}default(t){}expected(t){return"nothing"}validate(t,r){return!1}deprecated(t,r){return!1}forward(t,r){}redirect(t,r){}overlap(t,r,n){return t}preprocess(t,r){return t}postprocess(t,r){return ve}};function hi(e,t,r){return typeof e=="function"?(...n)=>e(...n.slice(0,r-1),t,...n.slice(r-1)):()=>e}var Dt=class extends x{constructor(t){super(t),this._sourceName=t.sourceName}expected(t){return t.schemas[this._sourceName].expected(t)}validate(t,r){return r.schemas[this._sourceName].validate(t,r)}redirect(t,r){return this._sourceName}};var lt=class extends x{expected(){return"anything"}validate(){return!0}};var ct=class extends x{constructor({valueSchema:t,name:r=t.name,...n}){super({...n,name:r}),this._valueSchema=t}expected(t){let{text:r,list:n}=t.normalizeExpectedResult(this._valueSchema.expected(t));return{text:r&&`an array of ${r}`,list:n&&{title:"an array of the following values",values:[{list:n}]}}}validate(t,r){if(!Array.isArray(t))return!1;let n=[];for(let u of t){let i=r.normalizeValidateResult(this._valueSchema.validate(u,r),u);i!==!0&&n.push(i.value)}return n.length===0?!0:{value:n}}deprecated(t,r){let n=[];for(let u of t){let i=r.normalizeDeprecatedResult(this._valueSchema.deprecated(u,r),u);i!==!1&&n.push(...i.map(({value:o})=>({value:[o]})))}return n}forward(t,r){let n=[];for(let u of t){let i=r.normalizeForwardResult(this._valueSchema.forward(u,r),u);n.push(...i.map(Bn))}return n}redirect(t,r){let n=[],u=[];for(let i of t){let o=r.normalizeRedirectResult(this._valueSchema.redirect(i,r),i);"remain"in o&&n.push(o.remain),u.push(...o.redirect.map(Bn))}return n.length===0?{redirect:u}:{redirect:u,remain:n}}overlap(t,r){return t.concat(r)}};function Bn({from:e,to:t}){return{from:[e],to:t}}var ft=class extends x{expected(){return"true or false"}validate(t){return typeof t=="boolean"}};function _n(e,t){let r=Object.create(null);for(let n of e){let u=n[t];if(r[u])throw new Error(`Duplicate ${t} ${JSON.stringify(u)}`);r[u]=n}return r}function xn(e,t){let r=new Map;for(let n of e){let u=n[t];if(r.has(u))throw new Error(`Duplicate ${t} ${JSON.stringify(u)}`);r.set(u,n)}return r}function bn(){let e=Object.create(null);return t=>{let r=JSON.stringify(t);return e[r]?!0:(e[r]=!0,!1)}}function Nn(e,t){let r=[],n=[];for(let u of e)t(u)?r.push(u):n.push(u);return[r,n]}function On(e){return e===Math.floor(e)}function Sn(e,t){if(e===t)return 0;let r=typeof e,n=typeof t,u=["undefined","object","boolean","number","string"];return r!==n?u.indexOf(r)-u.indexOf(n):r!=="string"?Number(e)-Number(t):e.localeCompare(t)}function Tn(e){return(...t)=>{let r=e(...t);return typeof r=="string"?new Error(r):r}}function Jt(e){return e===void 0?{}:e}function qt(e){if(typeof e=="string")return{text:e};let{text:t,list:r}=e;return Ei((t||r)!==void 0,"Unexpected `expected` result, there should be at least one field."),r?{text:t,list:{title:r.title,values:r.values.map(qt)}}:{text:t}}function Xt(e,t){return e===!0?!0:e===!1?{value:t}:e}function Qt(e,t,r=!1){return e===!1?!1:e===!0?r?!0:[{value:t}]:"value"in e?[e]:e.length===0?!1:e}function wn(e,t){return typeof e=="string"||"key"in e?{from:t,to:e}:"from"in e?{from:e.from,to:e.to}:{from:t,to:e.to}}function dt(e,t){return e===void 0?[]:Array.isArray(e)?e.map(r=>wn(r,t)):[wn(e,t)]}function Zt(e,t){let r=dt(typeof e=="object"&&"redirect"in e?e.redirect:e,t);return r.length===0?{remain:t,redirect:r}:typeof e=="object"&&"remain"in e?{remain:e.remain,redirect:r}:{redirect:r}}function Ei(e,t){if(!e)throw new Error(t)}var pt=class extends x{constructor(t){super(t),this._choices=xn(t.choices.map(r=>r&&typeof r=="object"?r:{value:r}),"value")}expected({descriptor:t}){let r=Array.from(this._choices.keys()).map(o=>this._choices.get(o)).filter(({hidden:o})=>!o).map(o=>o.value).sort(Sn).map(t.value),n=r.slice(0,-2),u=r.slice(-2);return{text:n.concat(u.join(" or ")).join(", "),list:{title:"one of the following values",values:r}}}validate(t){return this._choices.has(t)}deprecated(t){let r=this._choices.get(t);return r&&r.deprecated?{value:t}:!1}forward(t){let r=this._choices.get(t);return r?r.forward:void 0}redirect(t){let r=this._choices.get(t);return r?r.redirect:void 0}};var Ft=class extends x{expected(){return"a number"}validate(t,r){return typeof t=="number"}};var mt=class extends Ft{expected(){return"an integer"}validate(t,r){return r.normalizeValidateResult(super.validate(t,r),t)===!0&&On(t)}};var je=class extends x{expected(){return"a string"}validate(t){return typeof t=="string"}};var kn=oe,Ln=at,Pn=gn,In=hn;var ht=class{constructor(t,r){let{logger:n=console,loggerPrintWidth:u=80,descriptor:i=kn,unknown:o=Ln,invalid:s=Pn,deprecated:a=In,missing:D=()=>!1,required:l=()=>!1,preprocess:p=d=>d,postprocess:f=()=>ve}=r||{};this._utils={descriptor:i,logger:n||{warn:()=>{}},loggerPrintWidth:u,schemas:_n(t,"name"),normalizeDefaultResult:Jt,normalizeExpectedResult:qt,normalizeDeprecatedResult:Qt,normalizeForwardResult:dt,normalizeRedirectResult:Zt,normalizeValidateResult:Xt},this._unknownHandler=o,this._invalidHandler=Tn(s),this._deprecatedHandler=a,this._identifyMissing=(d,c)=>!(d in c)||D(d,c),this._identifyRequired=l,this._preprocess=p,this._postprocess=f,this.cleanHistory()}cleanHistory(){this._hasDeprecationWarned=bn()}normalize(t){let r={},u=[this._preprocess(t,this._utils)],i=()=>{for(;u.length!==0;){let o=u.shift(),s=this._applyNormalization(o,r);u.push(...s)}};i();for(let o of Object.keys(this._utils.schemas)){let s=this._utils.schemas[o];if(!(o in r)){let a=Jt(s.default(this._utils));"value"in a&&u.push({[o]:a.value})}}i();for(let o of Object.keys(this._utils.schemas)){if(!(o in r))continue;let s=this._utils.schemas[o],a=r[o],D=s.postprocess(a,this._utils);D!==ve&&(this._applyValidation(D,o,s),r[o]=D)}return this._applyPostprocess(r),this._applyRequiredCheck(r),r}_applyNormalization(t,r){let n=[],{knownKeys:u,unknownKeys:i}=this._partitionOptionKeys(t);for(let o of u){let s=this._utils.schemas[o],a=s.preprocess(t[o],this._utils);this._applyValidation(a,o,s);let D=({from:d,to:c})=>{n.push(typeof c=="string"?{[c]:d}:{[c.key]:c.value})},l=({value:d,redirectTo:c})=>{let F=Qt(s.deprecated(d,this._utils),a,!0);if(F!==!1)if(F===!0)this._hasDeprecationWarned(o)||this._utils.logger.warn(this._deprecatedHandler(o,c,this._utils));else for(let{value:m}of F){let h={key:o,value:m};if(!this._hasDeprecationWarned(h)){let C=typeof c=="string"?{key:c,value:m}:c;this._utils.logger.warn(this._deprecatedHandler(h,C,this._utils))}}};dt(s.forward(a,this._utils),a).forEach(D);let f=Zt(s.redirect(a,this._utils),a);if(f.redirect.forEach(D),"remain"in f){let d=f.remain;r[o]=o in r?s.overlap(r[o],d,this._utils):d,l({value:d})}for(let{from:d,to:c}of f.redirect)l({value:d,redirectTo:c})}for(let o of i){let s=t[o];this._applyUnknownHandler(o,s,r,(a,D)=>{n.push({[a]:D})})}return n}_applyRequiredCheck(t){for(let r of Object.keys(this._utils.schemas))if(this._identifyMissing(r,t)&&this._identifyRequired(r))throw this._invalidHandler(r,st,this._utils)}_partitionOptionKeys(t){let[r,n]=Nn(Object.keys(t).filter(u=>!this._identifyMissing(u,t)),u=>u in this._utils.schemas);return{knownKeys:r,unknownKeys:n}}_applyValidation(t,r,n){let u=Xt(n.validate(t,this._utils),t);if(u!==!0)throw this._invalidHandler(r,u.value,this._utils)}_applyUnknownHandler(t,r,n,u){let i=this._unknownHandler(t,r,this._utils);if(i)for(let o of Object.keys(i)){if(this._identifyMissing(o,i))continue;let s=i[o];o in this._utils.schemas?u(o,s):n[o]=s}}_applyPostprocess(t){let r=this._postprocess(t,this._utils);if(r!==ve){if(r.delete)for(let n of r.delete)delete t[n];if(r.override){let{knownKeys:n,unknownKeys:u}=this._partitionOptionKeys(r.override);for(let i of n){let o=r.override[i];this._applyValidation(o,i,this._utils.schemas[i]),t[i]=o}for(let i of u){let o=r.override[i];this._applyUnknownHandler(i,o,t,(s,a)=>{let D=this._utils.schemas[s];this._applyValidation(a,s,D),t[s]=a})}}}}};var er;function gi(e,t,{logger:r=!1,isCLI:n=!1,passThrough:u=!1,FlagSchema:i,descriptor:o}={}){if(n){if(!i)throw new Error("'FlagSchema' option is required.");if(!o)throw new Error("'descriptor' option is required.")}else o=oe;let s=u?Array.isArray(u)?(f,d)=>u.includes(f)?{[f]:d}:void 0:(f,d)=>({[f]:d}):(f,d,c)=>{let{_:F,...m}=c.schemas;return at(f,d,{...c,schemas:m})},a=yi(t,{isCLI:n,FlagSchema:i}),D=new ht(a,{logger:r,unknown:s,descriptor:o}),l=r!==!1;l&&er&&(D._hasDeprecationWarned=er);let p=D.normalize(e);return l&&(er=D._hasDeprecationWarned),p}function yi(e,{isCLI:t,FlagSchema:r}){let n=[];t&&n.push(lt.create({name:"_"}));for(let u of e)n.push(Ai(u,{isCLI:t,optionInfos:e,FlagSchema:r})),u.alias&&t&&n.push(Dt.create({name:u.alias,sourceName:u.name}));return n}function Ai(e,{isCLI:t,optionInfos:r,FlagSchema:n}){let{name:u}=e,i={name:u},o,s={};switch(e.type){case"int":o=mt,t&&(i.preprocess=Number);break;case"string":o=je;break;case"choice":o=pt,i.choices=e.choices.map(a=>a!=null&&a.redirect?{...a,redirect:{to:{key:e.name,value:a.redirect}}}:a);break;case"boolean":o=ft;break;case"flag":o=n,i.flags=r.flatMap(a=>[a.alias,a.description&&a.name,a.oppositeDescription&&`no-${a.name}`].filter(Boolean));break;case"path":o=je;break;default:throw new Error(`Unexpected type ${e.type}`)}if(e.exception?i.validate=(a,D,l)=>e.exception(a)||D.validate(a,l):i.validate=(a,D,l)=>a===void 0||D.validate(a,l),e.redirect&&(s.redirect=a=>a?{to:typeof e.redirect=="string"?e.redirect:{key:e.redirect.option,value:e.redirect.value}}:void 0),e.deprecated&&(s.deprecated=!0),t&&!e.array){let a=i.preprocess||(D=>D);i.preprocess=(D,l,p)=>l.preprocess(a(Array.isArray(D)?A(!1,D,-1):D),p)}return e.array?ct.create({...t?{preprocess:a=>Array.isArray(a)?a:[a]}:{},...s,valueSchema:o.create(i)}):o.create({...i,...s})}var Rn=gi;var vi=(e,t,r)=>{if(!(e&&t==null)){if(t.findLast)return t.findLast(r);for(let n=t.length-1;n>=0;n--){let u=t[n];if(r(u,n,t))return u}}},tr=vi;function rr(e,t){if(!t)throw new Error("parserName is required.");let r=tr(!1,e,u=>u.parsers&&Object.prototype.hasOwnProperty.call(u.parsers,t));if(r)return r;let n=`Couldn't resolve parser "${t}".`;throw n+=" Plugins must be explicitly added to the standalone bundle.",new Re(n)}function Yn(e,t){if(!t)throw new Error("astFormat is required.");let r=tr(!1,e,u=>u.printers&&Object.prototype.hasOwnProperty.call(u.printers,t));if(r)return r;let n=`Couldn't find plugin for AST format "${t}".`;throw n+=" Plugins must be explicitly added to the standalone bundle.",new Re(n)}function Et({plugins:e,parser:t}){let r=rr(e,t);return nr(r,t)}function nr(e,t){let r=e.parsers[t];return typeof r=="function"?r():r}function jn(e,t){let r=e.printers[t];return typeof r=="function"?r():r}var Hn={astFormat:"estree",printer:{},originalText:void 0,locStart:null,locEnd:null};async function Bi(e,t={}){var p;let r={...e};if(!r.parser)if(r.filepath){if(r.parser=pn(r,{physicalFile:r.filepath}),!r.parser)throw new Ye(`No parser could be inferred for file "${r.filepath}".`)}else throw new Ye("No parser and no file path given, couldn't infer a parser.");let n=it({plugins:e.plugins,showDeprecated:!0}).options,u={...Hn,...Object.fromEntries(n.filter(f=>f.default!==void 0).map(f=>[f.name,f.default]))},i=rr(r.plugins,r.parser),o=await nr(i,r.parser);r.astFormat=o.astFormat,r.locEnd=o.locEnd,r.locStart=o.locStart;let s=(p=i.printers)!=null&&p[o.astFormat]?i:Yn(r.plugins,o.astFormat),a=await jn(s,o.astFormat);r.printer=a;let D=s.defaultOptions?Object.fromEntries(Object.entries(s.defaultOptions).filter(([,f])=>f!==void 0)):{},l={...u,...D};for(let[f,d]of Object.entries(l))(r[f]===null||r[f]===void 0)&&(r[f]=d);return r.parser==="json"&&(r.trailingComma="none"),Rn(r,n,{passThrough:Object.keys(Hn),...t})}var se=Bi;var Mn=Me($n(),1);async function bi(e,t){let r=await Et(t),n=r.preprocess?r.preprocess(e,t):e;t.originalText=n;let u;try{u=await r.parse(n,t,t)}catch(i){Ni(i,e)}return{text:n,ast:u}}function Ni(e,t){let{loc:r}=e;if(r){let n=(0,Mn.codeFrameColumns)(t,r,{highlightCode:!0});throw e.message+=`
|
|
32
|
-
`+n,e.codeFrame=n,e}throw e}var fe=bi;async function Vn(e,t,r,n,u){let{embeddedLanguageFormatting:i,printer:{embed:o,hasPrettierIgnore:s=()=>!1,getVisitorKeys:a}}=r;if(!o||i!=="auto")return;if(o.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/
|
|
32
|
+
`+n,e.codeFrame=n,e}throw e}var fe=bi;async function Vn(e,t,r,n,u){let{embeddedLanguageFormatting:i,printer:{embed:o,hasPrettierIgnore:s=()=>!1,getVisitorKeys:a}}=r;if(!o||i!=="auto")return;if(o.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let D=q(o.getVisitorKeys??a),l=[];d();let p=e.stack;for(let{print:c,node:F,pathStack:m}of l)try{e.stack=m;let h=await c(f,t,e,r);h&&u.set(F,h)}catch(h){if(globalThis.PRETTIER_DEBUG)throw h}e.stack=p;function f(c,F){return Oi(c,F,r,n)}function d(){let{node:c}=e;if(c===null||typeof c!="object"||s(e))return;for(let m of D(c))Array.isArray(c[m])?e.each(d,m):e.call(d,m);let F=o(e,r);if(F){if(typeof F=="function"){l.push({print:F,node:c,pathStack:[...e.stack]});return}u.set(c,F)}}}async function Oi(e,t,r,n){let u=await se({...r,...t,parentParser:r.parser,originalText:e},{passThrough:!0}),{ast:i}=await fe(e,u),o=await n(i,u);return qe(o)}function Si(e,t){let{originalText:r,[Symbol.for("comments")]:n,locStart:u,locEnd:i,[Symbol.for("printedComments")]:o}=t,{node:s}=e,a=u(s),D=i(s);for(let l of n)u(l)>=a&&i(l)<=D&&o.add(l);return r.slice(a,D)}var Un=Si;async function He(e,t){({ast:e}=await ir(e,t));let r=new Map,n=new qr(e),u=cn(t),i=new Map;await Vn(n,s,t,He,i);let o=await zn(n,t,s,void 0,i);if(ln(t),t.nodeAfterCursor&&!t.nodeBeforeCursor)return[Z,o];if(t.nodeBeforeCursor&&!t.nodeAfterCursor)return[o,Z];return o;function s(D,l){return D===void 0||D===n?a(l):Array.isArray(D)?n.call(()=>a(l),...D):n.call(()=>a(l),D)}function a(D){u(n);let l=n.node;if(l==null)return"";let p=l&&typeof l=="object"&&D===void 0;if(p&&r.has(l))return r.get(l);let f=zn(n,t,s,D,i);return p&&r.set(l,f),f}}function zn(e,t,r,n,u){var a;let{node:i}=e,{printer:o}=t,s;switch((a=o.hasPrettierIgnore)!=null&&a.call(o,e)?s=Un(e,t):u.has(i)?s=u.get(i):s=o.print(e,t,r,n),i){case t.cursorNode:s=me(s,D=>[Z,D,Z]);break;case t.nodeBeforeCursor:s=me(s,D=>[D,Z]);break;case t.nodeAfterCursor:s=me(s,D=>[Z,D]);break}return o.printComment&&(!o.willPrintOwnComments||!o.willPrintOwnComments(e,t))&&(s=Dn(e,s,t)),s}async function ir(e,t){let r=e.comments??[];t[Symbol.for("comments")]=r,t[Symbol.for("tokens")]=e.tokens??[],t[Symbol.for("printedComments")]=new Set,on(e,t);let{printer:{preprocess:n}}=t;return e=n?await n(e,t):e,{ast:e,comments:r}}function Ti(e,t){let{cursorOffset:r,locStart:n,locEnd:u}=t,i=q(t.printer.getVisitorKeys),o=d=>n(d)<=r&&u(d)>=r,s=e,a=[e];for(let d of Zr(e,{getVisitorKeys:i,filter:o}))a.push(d),s=d;if(en(s,{getVisitorKeys:i}))return{cursorNode:s};let D,l,p=-1,f=Number.POSITIVE_INFINITY;for(;a.length>0&&(D===void 0||l===void 0);){s=a.pop();let d=D!==void 0,c=l!==void 0;for(let F of ye(s,{getVisitorKeys:i})){if(!d){let m=u(F);m<=r&&m>p&&(D=F,p=m)}if(!c){let m=n(F);m>=r&&m<f&&(l=F,f=m)}}}return{nodeBeforeCursor:D,nodeAfterCursor:l}}var Gn=Ti;function ki(e,t){let{printer:{massageAstNode:r,getVisitorKeys:n}}=t;if(!r)return e;let u=q(n),i=r.ignoredProperties??new Set;return o(e);function o(s,a){if(!(s!==null&&typeof s=="object"))return s;if(Array.isArray(s))return s.map(f=>o(f,a)).filter(Boolean);let D={},l=new Set(u(s));for(let f in s)!Object.prototype.hasOwnProperty.call(s,f)||i.has(f)||(l.has(f)?D[f]=o(s[f],s):D[f]=s[f]);let p=r(s,D,a);if(p!==null)return p??D}}var Kn=ki;var Li=(e,t,r)=>{if(!(e&&t==null)){if(t.findLastIndex)return t.findLastIndex(r);for(let n=t.length-1;n>=0;n--){let u=t[n];if(r(u,n,t))return n}return-1}},Jn=Li;var Pi=({parser:e})=>e==="json"||e==="json5"||e==="jsonc"||e==="json-stringify";function Ii(e,t){let r=[e.node,...e.parentNodes],n=new Set([t.node,...t.parentNodes]);return r.find(u=>Qn.has(u.type)&&n.has(u))}function qn(e){let t=Jn(!1,e,r=>r.type!=="Program"&&r.type!=="File");return t===-1?e:e.slice(0,t+1)}function Ri(e,t,{locStart:r,locEnd:n}){let u=e.node,i=t.node;if(u===i)return{startNode:u,endNode:i};let o=r(e.node);for(let a of qn(t.parentNodes))if(r(a)>=o)i=a;else break;let s=n(t.node);for(let a of qn(e.parentNodes)){if(n(a)<=s)u=a;else break;if(u===i)break}return{startNode:u,endNode:i}}function or(e,t,r,n,u=[],i){let{locStart:o,locEnd:s}=r,a=o(e),D=s(e);if(!(t>D||t<a||i==="rangeEnd"&&t===a||i==="rangeStart"&&t===D)){for(let l of ut(e,r)){let p=or(l,t,r,n,[e,...u],i);if(p)return p}if(!n||n(e,u[0]))return{node:e,parentNodes:u}}}function Yi(e,t){return t!=="DeclareExportDeclaration"&&e!=="TypeParameterDeclaration"&&(e==="Directive"||e==="TypeAlias"||e==="TSExportAssignment"||e.startsWith("Declare")||e.startsWith("TSDeclare")||e.endsWith("Statement")||e.endsWith("Declaration"))}var Qn=new Set(["JsonRoot","ObjectExpression","ArrayExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","UnaryExpression","TemplateLiteral"]),ji=new Set(["OperationDefinition","FragmentDefinition","VariableDefinition","TypeExtensionDefinition","ObjectTypeDefinition","FieldDefinition","DirectiveDefinition","EnumTypeDefinition","EnumValueDefinition","InputValueDefinition","InputObjectTypeDefinition","SchemaDefinition","OperationTypeDefinition","InterfaceTypeDefinition","UnionTypeDefinition","ScalarTypeDefinition"]);function Xn(e,t,r){if(!t)return!1;switch(e.parser){case"flow":case"babel":case"babel-flow":case"babel-ts":case"typescript":case"acorn":case"espree":case"meriyah":case"__babel_estree":return Yi(t.type,r==null?void 0:r.type);case"json":case"json5":case"jsonc":case"json-stringify":return Qn.has(t.type);case"graphql":return ji.has(t.kind);case"vue":return t.tag!=="root"}return!1}function Zn(e,t,r){let{rangeStart:n,rangeEnd:u,locStart:i,locEnd:o}=t;Pe.ok(u>n);let s=e.slice(n,u).search(/\S/u),a=s===-1;if(!a)for(n+=s;u>n&&!/\S/u.test(e[u-1]);--u);let D=or(r,n,t,(d,c)=>Xn(t,d,c),[],"rangeStart"),l=a?D:or(r,u,t,d=>Xn(t,d),[],"rangeEnd");if(!D||!l)return{rangeStart:0,rangeEnd:0};let p,f;if(Pi(t)){let d=Ii(D,l);p=d,f=d}else({startNode:p,endNode:f}=Ri(D,l,t));return{rangeStart:Math.min(i(p),i(f)),rangeEnd:Math.max(o(p),o(f))}}var nu="\uFEFF",eu=Symbol("cursor");async function uu(e,t,r=0){if(!e||e.trim().length===0)return{formatted:"",cursorOffset:-1,comments:[]};let{ast:n,text:u}=await fe(e,t);t.cursorOffset>=0&&(t={...t,...Gn(n,t)});let i=await He(n,t,r);r>0&&(i=Ze([K,i],r,t.tabWidth));let o=Ce(i,t);if(r>0){let a=o.formatted.trim();o.cursorNodeStart!==void 0&&(o.cursorNodeStart-=o.formatted.indexOf(a),o.cursorNodeStart<0&&(o.cursorNodeStart=0,o.cursorNodeText=o.cursorNodeText.trimStart()),o.cursorNodeStart+o.cursorNodeText.length>a.length&&(o.cursorNodeText=o.cursorNodeText.trimEnd())),o.formatted=a+be(t.endOfLine)}let s=t[Symbol.for("comments")];if(t.cursorOffset>=0){let a,D,l,p;if((t.cursorNode||t.nodeBeforeCursor||t.nodeAfterCursor)&&o.cursorNodeText)if(l=o.cursorNodeStart,p=o.cursorNodeText,t.cursorNode)a=t.locStart(t.cursorNode),D=u.slice(a,t.locEnd(t.cursorNode));else{if(!t.nodeBeforeCursor&&!t.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");a=t.nodeBeforeCursor?t.locEnd(t.nodeBeforeCursor):0;let h=t.nodeAfterCursor?t.locStart(t.nodeAfterCursor):u.length;D=u.slice(a,h)}else a=0,D=u,l=0,p=o.formatted;let f=t.cursorOffset-a;if(D===p)return{formatted:o.formatted,cursorOffset:l+f,comments:s};let d=D.split("");d.splice(f,0,eu);let c=p.split(""),F=yr(d,c),m=l;for(let h of F)if(h.removed){if(h.value.includes(eu))break}else m+=h.count;return{formatted:o.formatted,cursorOffset:m,comments:s}}return{formatted:o.formatted,cursorOffset:-1,comments:s}}async function Hi(e,t){let{ast:r,text:n}=await fe(e,t),{rangeStart:u,rangeEnd:i}=Zn(n,t,r),o=n.slice(u,i),s=Math.min(u,n.lastIndexOf(`
|
|
33
33
|
`,u)+1),a=n.slice(s,u).match(/^\s*/u)[0],D=ge(a,t.tabWidth),l=await uu(o,{...t,rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:t.cursorOffset>u&&t.cursorOffset<=i?t.cursorOffset-u:-1,endOfLine:"lf"},D),p=l.formatted.trimEnd(),{cursorOffset:f}=t;f>i?f+=p.length-o.length:l.cursorOffset>=0&&(f=l.cursorOffset+u);let d=n.slice(0,u)+p+n.slice(i);if(t.endOfLine!=="lf"){let c=be(t.endOfLine);f>=0&&c===`\r
|
|
34
34
|
`&&(f+=Nt(d.slice(0,f),`
|
|
35
35
|
`)),d=ne(!1,d,`
|
|
36
36
|
`,c)}return{formatted:d,cursorOffset:f,comments:l.comments}}function sr(e,t,r){return typeof t!="number"||Number.isNaN(t)||t<0||t>e.length?r:t}function tu(e,t){let{cursorOffset:r,rangeStart:n,rangeEnd:u}=t;return r=sr(e,r,-1),n=sr(e,n,0),u=sr(e,u,e.length),{...t,cursorOffset:r,rangeStart:n,rangeEnd:u}}function iu(e,t){let{cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i}=tu(e,t),o=e.charAt(0)===nu;if(o&&(e=e.slice(1),r--,n--,u--),i==="auto"&&(i=Ar(e)),e.includes("\r")){let s=a=>Nt(e.slice(0,Math.max(a,0)),`\r
|
|
37
|
-
`);r-=s(r),n-=s(n),u-=s(u),e=vr(e)}return{hasBOM:o,text:e,options:tu(e,{...t,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i})}}async function ru(e,t){let r=await Et(t);return!r.hasPragma||r.hasPragma(e)}async function ar(e,t){let{hasBOM:r,text:n,options:u}=iu(e,await se(t));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await ru(n,u))return{formatted:e,cursorOffset:t.cursorOffset,comments:[]};let i;return u.rangeStart>0||u.rangeEnd<n.length?i=await Hi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await ru(n,u)&&(n=u.printer.insertPragma(n)),i=await uu(n,u)),r&&(i.formatted=nu+i.formatted,i.cursorOffset>=0&&i.cursorOffset++),i}async function ou(e,t,r){let{text:n,options:u}=iu(e,await se(t)),i=await fe(n,u);return r&&(r.preprocessForPrint&&(i.ast=await ir(i.ast,u)),r.massage&&(i.ast=Kn(i.ast,u))),i}async function su(e,t){t=await se(t);let r=await He(e,t);return Ce(r,t)}async function au(e,t){let r=Vr(e),{formatted:n}=await ar(r,{...t,parser:"__js_expression"});return n}async function Du(e,t){t=await se(t);let{ast:r}=await fe(e,t);return He(r,t)}async function lu(e,t){return Ce(e,await se(t))}var Dr={};vt(Dr,{builders:()=>$i,printer:()=>Mi,utils:()=>Vi});var $i={join:Se,line:Qe,softline:$r,hardline:K,literalline:Xe,group:kt,conditionalGroup:Ir,fill:Rr,lineSuffix:Te,lineSuffixBoundary:Hr,cursor:Z,breakParent:he,ifBreak:Yr,trim:Wr,indent:le,indentIfBreak:jr,align:De,addAlignmentToDoc:Ze,markAsRoot:Lr,dedentToRoot:kr,dedent:Pr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Lt,label:Mr,concat:e=>e},Mi={printDocToString:Ce},Vi={willBreak:xr,traverseDoc:Fe,findInDoc:Je,mapDoc:Oe,removeLines:Nr,stripTrailingHardline:qe,replaceEndOfLine:Or,canBreak:Sr};var cu="3.5.
|
|
37
|
+
`);r-=s(r),n-=s(n),u-=s(u),e=vr(e)}return{hasBOM:o,text:e,options:tu(e,{...t,cursorOffset:r,rangeStart:n,rangeEnd:u,endOfLine:i})}}async function ru(e,t){let r=await Et(t);return!r.hasPragma||r.hasPragma(e)}async function ar(e,t){let{hasBOM:r,text:n,options:u}=iu(e,await se(t));if(u.rangeStart>=u.rangeEnd&&n!==""||u.requirePragma&&!await ru(n,u))return{formatted:e,cursorOffset:t.cursorOffset,comments:[]};let i;return u.rangeStart>0||u.rangeEnd<n.length?i=await Hi(n,u):(!u.requirePragma&&u.insertPragma&&u.printer.insertPragma&&!await ru(n,u)&&(n=u.printer.insertPragma(n)),i=await uu(n,u)),r&&(i.formatted=nu+i.formatted,i.cursorOffset>=0&&i.cursorOffset++),i}async function ou(e,t,r){let{text:n,options:u}=iu(e,await se(t)),i=await fe(n,u);return r&&(r.preprocessForPrint&&(i.ast=await ir(i.ast,u)),r.massage&&(i.ast=Kn(i.ast,u))),i}async function su(e,t){t=await se(t);let r=await He(e,t);return Ce(r,t)}async function au(e,t){let r=Vr(e),{formatted:n}=await ar(r,{...t,parser:"__js_expression"});return n}async function Du(e,t){t=await se(t);let{ast:r}=await fe(e,t);return He(r,t)}async function lu(e,t){return Ce(e,await se(t))}var Dr={};vt(Dr,{builders:()=>$i,printer:()=>Mi,utils:()=>Vi});var $i={join:Se,line:Qe,softline:$r,hardline:K,literalline:Xe,group:kt,conditionalGroup:Ir,fill:Rr,lineSuffix:Te,lineSuffixBoundary:Hr,cursor:Z,breakParent:he,ifBreak:Yr,trim:Wr,indent:le,indentIfBreak:jr,align:De,addAlignmentToDoc:Ze,markAsRoot:Lr,dedentToRoot:kr,dedent:Pr,hardlineWithoutBreakParent:ke,literallineWithoutBreakParent:Lt,label:Mr,concat:e=>e},Mi={printDocToString:Ce},Vi={willBreak:xr,traverseDoc:Fe,findInDoc:Je,mapDoc:Oe,removeLines:Nr,stripTrailingHardline:qe,replaceEndOfLine:Or,canBreak:Sr};var cu="3.5.3";var cr={};vt(cr,{addDanglingComment:()=>re,addLeadingComment:()=>ue,addTrailingComment:()=>ie,getAlignmentSize:()=>ge,getIndentSize:()=>fu,getMaxContinuousCount:()=>du,getNextNonSpaceNonCommentCharacter:()=>pu,getNextNonSpaceNonCommentCharacterIndex:()=>no,getPreferredQuote:()=>mu,getStringWidth:()=>Le,hasNewline:()=>V,hasNewlineInRange:()=>hu,hasSpaces:()=>Eu,isNextLineEmpty:()=>so,isNextLineEmptyAfterIndex:()=>Ct,isPreviousLineEmpty:()=>io,makeString:()=>Cu,skip:()=>Ae,skipEverythingButNewLine:()=>nt,skipInlineComment:()=>Be,skipNewline:()=>W,skipSpaces:()=>S,skipToLineEnd:()=>rt,skipTrailingComment:()=>we,skipWhitespace:()=>tn});function Ui(e,t){if(t===!1)return!1;if(e.charAt(t)==="/"&&e.charAt(t+1)==="*"){for(let r=t+2;r<e.length;++r)if(e.charAt(r)==="*"&&e.charAt(r+1)==="/")return r+2}return t}var Be=Ui;function zi(e,t){return t===!1?!1:e.charAt(t)==="/"&&e.charAt(t+1)==="/"?nt(e,t):t}var we=zi;function Gi(e,t){let r=null,n=t;for(;n!==r;)r=n,n=S(e,n),n=Be(e,n),n=we(e,n),n=W(e,n);return n}var We=Gi;function Ki(e,t){let r=null,n=t;for(;n!==r;)r=n,n=rt(e,n),n=Be(e,n),n=S(e,n);return n=we(e,n),n=W(e,n),n!==!1&&V(e,n)}var Ct=Ki;function Ji(e,t){let r=e.lastIndexOf(`
|
|
38
38
|
`);return r===-1?0:ge(e.slice(r+1).match(/^[\t ]*/u)[0],t)}var fu=Ji;function lr(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function qi(e,t){let r=e.match(new RegExp(`(${lr(t)})+`,"gu"));return r===null?0:r.reduce((n,u)=>Math.max(n,u.length/t.length),0)}var du=qi;function Xi(e,t){let r=We(e,t);return r===!1?"":e.charAt(r)}var pu=Xi;var gt="'",Fu='"';function Qi(e,t){let r=t===!0||t===gt?gt:Fu,n=r===gt?Fu:gt,u=0,i=0;for(let o of e)o===r?u++:o===n&&i++;return u>i?n:r}var mu=Qi;function Zi(e,t,r){for(let n=t;n<r;++n)if(e.charAt(n)===`
|
|
39
39
|
`)return!0;return!1}var hu=Zi;function eo(e,t,r={}){return S(e,r.backwards?t-1:t,r)!==t}var Eu=eo;function to(e,t,r){let n=t==='"'?"'":'"',i=ne(!1,e,/\\(.)|(["'])/gsu,(o,s,a)=>s===n?s:a===t?"\\"+a:a||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/u.test(s)?s:"\\"+s));return t+i+t}var Cu=to;function ro(e,t,r){return We(e,r(t))}function no(e,t){return arguments.length===2||typeof t=="number"?We(e,t):ro(...arguments)}function uo(e,t,r){return Ie(e,r(t))}function io(e,t){return arguments.length===2||typeof t=="number"?Ie(e,t):uo(...arguments)}function oo(e,t,r){return Ct(e,r(t))}function so(e,t){return arguments.length===2||typeof t=="number"?Ct(e,t):oo(...arguments)}function de(e,t=1){return async(...r)=>{let n=r[t]??{},u=n.plugins??[];return r[t]={...n,plugins:Array.isArray(u)?u:Object.values(u)},e(...r)}}var gu=de(ar);async function yu(e,t){let{formatted:r}=await gu(e,{...t,cursorOffset:-1});return r}async function ao(e,t){return await yu(e,t)===e}var Do=de(it,0),lo={parse:de(ou),formatAST:de(su),formatDoc:de(au),printToDoc:de(Du),printDocToString:de(lu)};var mc=fr;export{lo as __debug,ao as check,mc as default,Dr as doc,yu as format,gu as formatWithCursor,Do as getSupportInfo,cr as util,cu as version};
|