prettier 3.0.0-alpha.0 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +49 -65
  2. package/{bin-prettier.js → bin/prettier.cjs} +2 -2
  3. package/doc.js +438 -221
  4. package/doc.mjs +1490 -0
  5. package/index.cjs +532 -0
  6. package/{index.js → index.mjs} +4335 -5702
  7. package/{cli.mjs → internal/cli.mjs} +148 -92
  8. package/{third-party.js → internal/third-party.mjs} +123 -100
  9. package/package.json +139 -6
  10. package/plugins/acorn-and-espree.js +13 -0
  11. package/plugins/acorn-and-espree.mjs +13 -0
  12. package/{parser-angular.js → plugins/angular.js} +0 -0
  13. package/{esm/parser-angular.mjs → plugins/angular.mjs} +1 -1
  14. package/plugins/babel.js +16 -0
  15. package/plugins/babel.mjs +16 -0
  16. package/plugins/flow.js +21 -0
  17. package/plugins/flow.mjs +21 -0
  18. package/{parser-glimmer.js → plugins/glimmer.js} +9 -9
  19. package/{esm/parser-glimmer.mjs → plugins/glimmer.mjs} +10 -10
  20. package/plugins/graphql.js +9 -0
  21. package/plugins/graphql.mjs +9 -0
  22. package/plugins/html.js +29 -0
  23. package/plugins/html.mjs +29 -0
  24. package/plugins/markdown.js +39 -0
  25. package/plugins/markdown.mjs +39 -0
  26. package/plugins/meriyah.js +6 -0
  27. package/plugins/meriyah.mjs +6 -0
  28. package/plugins/postcss.js +50 -0
  29. package/plugins/postcss.mjs +50 -0
  30. package/plugins/typescript.js +242 -0
  31. package/plugins/typescript.mjs +242 -0
  32. package/{parser-yaml.js → plugins/yaml.js} +1 -1
  33. package/{esm/parser-yaml.mjs → plugins/yaml.mjs} +1 -1
  34. package/standalone.js +69 -87
  35. package/standalone.mjs +106 -0
  36. package/esm/parser-babel.mjs +0 -18
  37. package/esm/parser-espree.mjs +0 -15
  38. package/esm/parser-flow.mjs +0 -23
  39. package/esm/parser-graphql.mjs +0 -9
  40. package/esm/parser-html.mjs +0 -28
  41. package/esm/parser-markdown.mjs +0 -60
  42. package/esm/parser-meriyah.mjs +0 -8
  43. package/esm/parser-postcss.mjs +0 -53
  44. package/esm/parser-typescript.mjs +0 -269
  45. package/esm/standalone.mjs +0 -124
  46. package/parser-babel.js +0 -18
  47. package/parser-espree.js +0 -15
  48. package/parser-flow.js +0 -23
  49. package/parser-graphql.js +0 -9
  50. package/parser-html.js +0 -28
  51. package/parser-markdown.js +0 -60
  52. package/parser-meriyah.js +0 -8
  53. package/parser-postcss.js +0 -53
  54. package/parser-typescript.js +0 -269
@@ -145,4 +145,4 @@ ${a.commentBefore}`:i}n.comment=t.after.join(`
145
145
  `)||null}}function Gf({tagPrefixes:n},e){let[t,r]=e.parameters;if(!t||!r){let s="Insufficient parameters given for %TAG directive";throw new Y.YAMLSemanticError(e,s)}if(n.some(s=>s.handle===t)){let s="The %TAG directive must only be given at most once per handle in the same document.";throw new Y.YAMLSemanticError(e,s)}return{handle:t,prefix:r}}function zf(n,e){let[t]=e.parameters;if(e.name==="YAML:1.0"&&(t="1.0"),!t){let r="Insufficient parameters given for %YAML directive";throw new Y.YAMLSemanticError(e,r)}if(!ta[t]){let s=`Document will be parsed as YAML ${n.version||n.options.version} rather than YAML ${t}`;n.warnings.push(new Y.YAMLWarning(e,s))}return t}function Zf(n,e,t){let r=[],s=!1;for(let i of e){let{comment:a,name:o}=i;switch(o){case"TAG":try{n.tagPrefixes.push(Gf(n,i))}catch(c){n.errors.push(c)}s=!0;break;case"YAML":case"YAML:1.0":if(n.version){let c="The %YAML directive must only be given at most once per document.";n.errors.push(new Y.YAMLSemanticError(i,c))}try{n.version=zf(n,i)}catch(c){n.errors.push(c)}s=!0;break;default:if(o){let c=`YAML only supports %TAG and %YAML directives, and not %${o}`;n.warnings.push(new Y.YAMLWarning(i,c))}}a&&r.push(a)}if(t&&!s&&(n.version||t.version||n.options.version)==="1.1"){let i=({handle:a,prefix:o})=>({handle:a,prefix:o});n.tagPrefixes=t.tagPrefixes.map(i),n.version=t.version}n.commentBefore=r.join(`
146
146
  `)||null}function Oe(n){if(n instanceof w.Collection)return!0;throw new Error("Expected a YAML collection as document contents")}var ye=class{constructor(e){this.anchors=new We(e.anchorPrefix),this.commentBefore=null,this.comment=null,this.contents=null,this.directivesEndMarker=null,this.errors=[],this.options=e,this.schema=null,this.tagPrefixes=[],this.version=null,this.warnings=[]}add(e){return Oe(this.contents),this.contents.add(e)}addIn(e,t){Oe(this.contents),this.contents.addIn(e,t)}delete(e){return Oe(this.contents),this.contents.delete(e)}deleteIn(e){return w.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):(Oe(this.contents),this.contents.deleteIn(e))}getDefaults(){return ye.defaults[this.version]||ye.defaults[this.options.version]||{}}get(e,t){return this.contents instanceof w.Collection?this.contents.get(e,t):void 0}getIn(e,t){return w.isEmptyPath(e)?!t&&this.contents instanceof w.Scalar?this.contents.value:this.contents:this.contents instanceof w.Collection?this.contents.getIn(e,t):void 0}has(e){return this.contents instanceof w.Collection?this.contents.has(e):!1}hasIn(e){return w.isEmptyPath(e)?this.contents!==void 0:this.contents instanceof w.Collection?this.contents.hasIn(e):!1}set(e,t){Oe(this.contents),this.contents.set(e,t)}setIn(e,t){w.isEmptyPath(e)?this.contents=t:(Oe(this.contents),this.contents.setIn(e,t))}setSchema(e,t){if(!e&&!t&&this.schema)return;typeof e=="number"&&(e=e.toFixed(1)),e==="1.0"||e==="1.1"||e==="1.2"?(this.version?this.version=e:this.options.version=e,delete this.options.schema):e&&typeof e=="string"&&(this.options.schema=e),Array.isArray(t)&&(this.options.customTags=t);let r=Object.assign({},this.getDefaults(),this.options);this.schema=new Xi.Schema(r)}parse(e,t){this.options.keepCstNodes&&(this.cstNode=e),this.options.keepNodeTypes&&(this.type="DOCUMENT");let{directives:r=[],contents:s=[],directivesEndMarker:i,error:a,valueRange:o}=e;if(a&&(a.source||(a.source=this),this.errors.push(a)),Zf(this,r,t),i&&(this.directivesEndMarker=!0),this.range=o?[o.start,o.end]:null,this.setSchema(),this.anchors._cstAliases=[],Hf(this,s),this.anchors.resolveNodes(),this.options.prettyErrors){for(let c of this.errors)c instanceof Y.YAMLError&&c.makePretty();for(let c of this.warnings)c instanceof Y.YAMLError&&c.makePretty()}return this}listNonDefaultTags(){return Jf(this.contents).filter(e=>e.indexOf(Xi.Schema.defaultPrefix)!==0)}setTagPrefix(e,t){if(e[0]!=="!"||e[e.length-1]!=="!")throw new Error("Handle must start and end with !");if(t){let r=this.tagPrefixes.find(s=>s.handle===e);r?r.prefix=t:this.tagPrefixes.push({handle:e,prefix:t})}else this.tagPrefixes=this.tagPrefixes.filter(r=>r.handle!==e)}toJSON(e,t){let{keepBlobsInJSON:r,mapAsMap:s,maxAliasCount:i}=this.options,a=r&&(typeof e!="string"||!(this.contents instanceof w.Scalar)),o={doc:this,indentStep:" ",keep:a,mapAsMap:a&&!!s,maxAliasCount:i,stringify:wt},c=Object.keys(this.anchors.map);c.length>0&&(o.anchors=new Map(c.map(u=>[this.anchors.map[u],{alias:[],aliasCount:0,count:1}])));let l=w.toJSON(this.contents,e,o);if(typeof t=="function"&&o.anchors)for(let{count:u,res:p}of o.anchors.values())t(p,u);return l}toString(){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");let e=this.options.indent;if(!Number.isInteger(e)||e<=0){let c=JSON.stringify(e);throw new Error(`"indent" option must be a positive integer, not ${c}`)}this.setSchema();let t=[],r=!1;if(this.version){let c="%YAML 1.2";this.schema.name==="yaml-1.1"&&(this.version==="1.0"?c="%YAML:1.0":this.version==="1.1"&&(c="%YAML 1.1")),t.push(c),r=!0}let s=this.listNonDefaultTags();this.tagPrefixes.forEach(({handle:c,prefix:l})=>{s.some(u=>u.indexOf(l)===0)&&(t.push(`%TAG ${c} ${l}`),r=!0)}),(r||this.directivesEndMarker)&&t.push("---"),this.commentBefore&&((r||!this.directivesEndMarker)&&t.unshift(""),t.unshift(this.commentBefore.replace(/^/gm,"#")));let i={anchors:Object.create(null),doc:this,indent:"",indentStep:" ".repeat(e),stringify:wt},a=!1,o=null;if(this.contents){this.contents instanceof w.Node&&(this.contents.spaceBefore&&(r||this.directivesEndMarker)&&t.push(""),this.contents.commentBefore&&t.push(this.contents.commentBefore.replace(/^/gm,"#")),i.forceBlockIndent=!!this.comment,o=this.contents.comment);let c=o?null:()=>a=!0,l=wt(this.contents,i,()=>o=null,c);t.push(w.addComment(l,"",o))}else this.contents!==void 0&&t.push(wt(this.contents,i));return this.comment&&((!a||o)&&t[t.length-1]!==""&&t.push(""),t.push(this.comment.replace(/^/gm,"#"))),t.join(`
147
147
  `)+`
148
- `}};Y._defineProperty(ye,"defaults",ta);Mt.Document=ye;Mt.defaultOptions=Kf;Mt.scalarOptions=Wf});var ia=_(sa=>{"use strict";f();var $r=Mi(),ve=na(),Xf=Rr(),eh=ee(),th=kr();Me();function nh(n,e=!0,t){t===void 0&&typeof e=="string"&&(t=e,e=!0);let r=Object.assign({},ve.Document.defaults[ve.defaultOptions.version],ve.defaultOptions);return new Xf.Schema(r).createNode(n,e,t)}var Le=class extends ve.Document{constructor(e){super(Object.assign({},ve.defaultOptions,e))}};function rh(n,e){let t=[],r;for(let s of $r.parse(n)){let i=new Le(e);i.parse(s,r),t.push(i),r=i}return t}function ra(n,e){let t=$r.parse(n),r=new Le(e).parse(t[0]);if(t.length>1){let s="Source contains multiple documents; please use YAML.parseAllDocuments()";r.errors.unshift(new eh.YAMLSemanticError(t[1],s))}return r}function sh(n,e){let t=ra(n,e);if(t.warnings.forEach(r=>th.warn(r)),t.errors.length>0)throw t.errors[0];return t.toJSON()}function ih(n,e){let t=new Le(e);return t.contents=n,String(t)}var ah={createNode:nh,defaultOptions:ve.defaultOptions,Document:Le,parse:sh,parseAllDocuments:rh,parseCST:$r.parse,parseDocument:ra,scalarOptions:ve.scalarOptions,stringify:ih};sa.YAML=ah});var Br=_((cm,aa)=>{f();aa.exports=ia().YAML});var oa=_(K=>{"use strict";f();var Ae=Me(),Ne=ee();K.findPair=Ae.findPair;K.parseMap=Ae.resolveMap;K.parseSeq=Ae.resolveSeq;K.stringifyNumber=Ae.stringifyNumber;K.stringifyString=Ae.stringifyString;K.toJSON=Ae.toJSON;K.Type=Ne.Type;K.YAMLError=Ne.YAMLError;K.YAMLReferenceError=Ne.YAMLReferenceError;K.YAMLSemanticError=Ne.YAMLSemanticError;K.YAMLSyntaxError=Ne.YAMLSyntaxError;K.YAMLWarning=Ne.YAMLWarning});var ca=_(W=>{f();var Q=oa();W.findPair=Q.findPair;W.toJSON=Q.toJSON;W.parseMap=Q.parseMap;W.parseSeq=Q.parseSeq;W.stringifyNumber=Q.stringifyNumber;W.stringifyString=Q.stringifyString;W.Type=Q.Type;W.YAMLError=Q.YAMLError;W.YAMLReferenceError=Q.YAMLReferenceError;W.YAMLSemanticError=Q.YAMLSemanticError;W.YAMLSyntaxError=Q.YAMLSyntaxError;W.YAMLWarning=Q.YAMLWarning});var la=_(be=>{"use strict";f();be.__esModule=!0;var oh=Br();be.Document=oh.Document;var ch=Br();be.parseCST=ch.parseCST;var xr=ca();be.YAMLError=xr.YAMLError;be.YAMLSyntaxError=xr.YAMLSyntaxError;be.YAMLSemanticError=xr.YAMLSemanticError});var ua=_(Dr=>{"use strict";f();Dr.__esModule=!0;var lh=Gr(),uh=es(),fh=rs(),hh=ss(),ph=oi(),mh=Jt(),gh=li(),dh=fi(),_h=hi(),yh=pi(),vh=gi(),bh=bi(),Yr=la();function Eh(n){var e=Yr.parseCST(n);yh.addOrigRange(e);for(var t=e.map(function(v){return new Yr.Document({merge:!1,keepCstNodes:!0}).parse(v)}),r=new lh.default(n),s=[],i={text:n,locator:r,comments:s,transformOffset:function(v){return dh.transformOffset(v,i)},transformRange:function(v){return _h.transformRange(v,i)},transformNode:function(v){return ph.transformNode(v,i)},transformContent:function(v){return mh.transformContent(v,i)}},a=0,o=t;a<o.length;a++)for(var c=o[a],l=0,u=c.errors;l<u.length;l++){var p=u[l];if(!(p instanceof Yr.YAMLSemanticError&&p.message==='Map keys must be unique; "<<" is repeated'))throw gh.transformError(p,i)}t.forEach(function(v){return hh.removeCstBlankLine(v.cstNode)});var d=fh.createRoot(i.transformRange({origStart:0,origEnd:i.text.length}),t.map(i.transformNode),s);return uh.attachComments(d),bh.updatePositions(d),vh.removeFakeNodes(d),d}Dr.parse=Eh});var Lh={};jr(Lh,{default:()=>Oh});f();f();function va(n,e){let t=new SyntaxError(n+" ("+e.start.line+":"+e.start.column+")");return t.loc=e,t}var Kr=va;f();function Wr(n){return/^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(n)}f();function Qr(n){return n.position.start.offset}function Vr(n){return n.position.end.offset}async function wh(n){let{parse:e}=await Promise.resolve().then(()=>_a(ua(),1));try{let t=e(n);return delete t.comments,t}catch(t){throw t!=null&&t.position?Kr(t.message,t.position):t}}var Sh={astFormat:"yaml",parse:wh,hasPragma:Wr,locStart:Qr,locEnd:Vr},Mh={parsers:{yaml:Sh}},Oh=Mh;return A(Lh);});
148
+ `}};Y._defineProperty(ye,"defaults",ta);Mt.Document=ye;Mt.defaultOptions=Kf;Mt.scalarOptions=Wf});var ia=_(sa=>{"use strict";f();var $r=Mi(),ve=na(),Xf=Rr(),eh=ee(),th=kr();Me();function nh(n,e=!0,t){t===void 0&&typeof e=="string"&&(t=e,e=!0);let r=Object.assign({},ve.Document.defaults[ve.defaultOptions.version],ve.defaultOptions);return new Xf.Schema(r).createNode(n,e,t)}var Le=class extends ve.Document{constructor(e){super(Object.assign({},ve.defaultOptions,e))}};function rh(n,e){let t=[],r;for(let s of $r.parse(n)){let i=new Le(e);i.parse(s,r),t.push(i),r=i}return t}function ra(n,e){let t=$r.parse(n),r=new Le(e).parse(t[0]);if(t.length>1){let s="Source contains multiple documents; please use YAML.parseAllDocuments()";r.errors.unshift(new eh.YAMLSemanticError(t[1],s))}return r}function sh(n,e){let t=ra(n,e);if(t.warnings.forEach(r=>th.warn(r)),t.errors.length>0)throw t.errors[0];return t.toJSON()}function ih(n,e){let t=new Le(e);return t.contents=n,String(t)}var ah={createNode:nh,defaultOptions:ve.defaultOptions,Document:Le,parse:sh,parseAllDocuments:rh,parseCST:$r.parse,parseDocument:ra,scalarOptions:ve.scalarOptions,stringify:ih};sa.YAML=ah});var Br=_((jg,aa)=>{f();aa.exports=ia().YAML});var oa=_(K=>{"use strict";f();var Ae=Me(),Ne=ee();K.findPair=Ae.findPair;K.parseMap=Ae.resolveMap;K.parseSeq=Ae.resolveSeq;K.stringifyNumber=Ae.stringifyNumber;K.stringifyString=Ae.stringifyString;K.toJSON=Ae.toJSON;K.Type=Ne.Type;K.YAMLError=Ne.YAMLError;K.YAMLReferenceError=Ne.YAMLReferenceError;K.YAMLSemanticError=Ne.YAMLSemanticError;K.YAMLSyntaxError=Ne.YAMLSyntaxError;K.YAMLWarning=Ne.YAMLWarning});var ca=_(W=>{f();var Q=oa();W.findPair=Q.findPair;W.toJSON=Q.toJSON;W.parseMap=Q.parseMap;W.parseSeq=Q.parseSeq;W.stringifyNumber=Q.stringifyNumber;W.stringifyString=Q.stringifyString;W.Type=Q.Type;W.YAMLError=Q.YAMLError;W.YAMLReferenceError=Q.YAMLReferenceError;W.YAMLSemanticError=Q.YAMLSemanticError;W.YAMLSyntaxError=Q.YAMLSyntaxError;W.YAMLWarning=Q.YAMLWarning});var la=_(be=>{"use strict";f();be.__esModule=!0;var oh=Br();be.Document=oh.Document;var ch=Br();be.parseCST=ch.parseCST;var xr=ca();be.YAMLError=xr.YAMLError;be.YAMLSyntaxError=xr.YAMLSyntaxError;be.YAMLSemanticError=xr.YAMLSemanticError});var ua=_(Dr=>{"use strict";f();Dr.__esModule=!0;var lh=Gr(),uh=es(),fh=rs(),hh=ss(),ph=oi(),mh=Jt(),gh=li(),dh=fi(),_h=hi(),yh=pi(),vh=gi(),bh=bi(),Yr=la();function Eh(n){var e=Yr.parseCST(n);yh.addOrigRange(e);for(var t=e.map(function(v){return new Yr.Document({merge:!1,keepCstNodes:!0}).parse(v)}),r=new lh.default(n),s=[],i={text:n,locator:r,comments:s,transformOffset:function(v){return dh.transformOffset(v,i)},transformRange:function(v){return _h.transformRange(v,i)},transformNode:function(v){return ph.transformNode(v,i)},transformContent:function(v){return mh.transformContent(v,i)}},a=0,o=t;a<o.length;a++)for(var c=o[a],l=0,u=c.errors;l<u.length;l++){var p=u[l];if(!(p instanceof Yr.YAMLSemanticError&&p.message==='Map keys must be unique; "<<" is repeated'))throw gh.transformError(p,i)}t.forEach(function(v){return hh.removeCstBlankLine(v.cstNode)});var d=fh.createRoot(i.transformRange({origStart:0,origEnd:i.text.length}),t.map(i.transformNode),s);return uh.attachComments(d),bh.updatePositions(d),vh.removeFakeNodes(d),d}Dr.parse=Eh});var Lh={};jr(Lh,{default:()=>Oh});f();f();function va(n,e){let t=new SyntaxError(n+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(t,e)}var Kr=va;f();function Wr(n){return/^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(n)}f();function Qr(n){return n.position.start.offset}function Vr(n){return n.position.end.offset}async function wh(n){let{parse:e}=await Promise.resolve().then(()=>_a(ua(),1));try{let t=e(n);return delete t.comments,t}catch(t){throw t!=null&&t.position?Kr(t.message,{loc:t.position,cause:t}):t}}var Sh={astFormat:"yaml",parse:wh,hasPragma:Wr,locStart:Qr,locEnd:Vr},Mh={parsers:{yaml:Sh}},Oh=Mh;return A(Lh);});
@@ -145,4 +145,4 @@ ${a.commentBefore}`:i}n.comment=t.after.join(`
145
145
  `)||null}}function Gf({tagPrefixes:n},e){let[t,r]=e.parameters;if(!t||!r){let s="Insufficient parameters given for %TAG directive";throw new Y.YAMLSemanticError(e,s)}if(n.some(s=>s.handle===t)){let s="The %TAG directive must only be given at most once per handle in the same document.";throw new Y.YAMLSemanticError(e,s)}return{handle:t,prefix:r}}function zf(n,e){let[t]=e.parameters;if(e.name==="YAML:1.0"&&(t="1.0"),!t){let r="Insufficient parameters given for %YAML directive";throw new Y.YAMLSemanticError(e,r)}if(!ea[t]){let s=`Document will be parsed as YAML ${n.version||n.options.version} rather than YAML ${t}`;n.warnings.push(new Y.YAMLWarning(e,s))}return t}function Zf(n,e,t){let r=[],s=!1;for(let i of e){let{comment:a,name:o}=i;switch(o){case"TAG":try{n.tagPrefixes.push(Gf(n,i))}catch(c){n.errors.push(c)}s=!0;break;case"YAML":case"YAML:1.0":if(n.version){let c="The %YAML directive must only be given at most once per document.";n.errors.push(new Y.YAMLSemanticError(i,c))}try{n.version=zf(n,i)}catch(c){n.errors.push(c)}s=!0;break;default:if(o){let c=`YAML only supports %TAG and %YAML directives, and not %${o}`;n.warnings.push(new Y.YAMLWarning(i,c))}}a&&r.push(a)}if(t&&!s&&(n.version||t.version||n.options.version)==="1.1"){let i=({handle:a,prefix:o})=>({handle:a,prefix:o});n.tagPrefixes=t.tagPrefixes.map(i),n.version=t.version}n.commentBefore=r.join(`
146
146
  `)||null}function Oe(n){if(n instanceof w.Collection)return!0;throw new Error("Expected a YAML collection as document contents")}var ye=class{constructor(e){this.anchors=new We(e.anchorPrefix),this.commentBefore=null,this.comment=null,this.contents=null,this.directivesEndMarker=null,this.errors=[],this.options=e,this.schema=null,this.tagPrefixes=[],this.version=null,this.warnings=[]}add(e){return Oe(this.contents),this.contents.add(e)}addIn(e,t){Oe(this.contents),this.contents.addIn(e,t)}delete(e){return Oe(this.contents),this.contents.delete(e)}deleteIn(e){return w.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):(Oe(this.contents),this.contents.deleteIn(e))}getDefaults(){return ye.defaults[this.version]||ye.defaults[this.options.version]||{}}get(e,t){return this.contents instanceof w.Collection?this.contents.get(e,t):void 0}getIn(e,t){return w.isEmptyPath(e)?!t&&this.contents instanceof w.Scalar?this.contents.value:this.contents:this.contents instanceof w.Collection?this.contents.getIn(e,t):void 0}has(e){return this.contents instanceof w.Collection?this.contents.has(e):!1}hasIn(e){return w.isEmptyPath(e)?this.contents!==void 0:this.contents instanceof w.Collection?this.contents.hasIn(e):!1}set(e,t){Oe(this.contents),this.contents.set(e,t)}setIn(e,t){w.isEmptyPath(e)?this.contents=t:(Oe(this.contents),this.contents.setIn(e,t))}setSchema(e,t){if(!e&&!t&&this.schema)return;typeof e=="number"&&(e=e.toFixed(1)),e==="1.0"||e==="1.1"||e==="1.2"?(this.version?this.version=e:this.options.version=e,delete this.options.schema):e&&typeof e=="string"&&(this.options.schema=e),Array.isArray(t)&&(this.options.customTags=t);let r=Object.assign({},this.getDefaults(),this.options);this.schema=new Zi.Schema(r)}parse(e,t){this.options.keepCstNodes&&(this.cstNode=e),this.options.keepNodeTypes&&(this.type="DOCUMENT");let{directives:r=[],contents:s=[],directivesEndMarker:i,error:a,valueRange:o}=e;if(a&&(a.source||(a.source=this),this.errors.push(a)),Zf(this,r,t),i&&(this.directivesEndMarker=!0),this.range=o?[o.start,o.end]:null,this.setSchema(),this.anchors._cstAliases=[],Hf(this,s),this.anchors.resolveNodes(),this.options.prettyErrors){for(let c of this.errors)c instanceof Y.YAMLError&&c.makePretty();for(let c of this.warnings)c instanceof Y.YAMLError&&c.makePretty()}return this}listNonDefaultTags(){return Jf(this.contents).filter(e=>e.indexOf(Zi.Schema.defaultPrefix)!==0)}setTagPrefix(e,t){if(e[0]!=="!"||e[e.length-1]!=="!")throw new Error("Handle must start and end with !");if(t){let r=this.tagPrefixes.find(s=>s.handle===e);r?r.prefix=t:this.tagPrefixes.push({handle:e,prefix:t})}else this.tagPrefixes=this.tagPrefixes.filter(r=>r.handle!==e)}toJSON(e,t){let{keepBlobsInJSON:r,mapAsMap:s,maxAliasCount:i}=this.options,a=r&&(typeof e!="string"||!(this.contents instanceof w.Scalar)),o={doc:this,indentStep:" ",keep:a,mapAsMap:a&&!!s,maxAliasCount:i,stringify:wt},c=Object.keys(this.anchors.map);c.length>0&&(o.anchors=new Map(c.map(u=>[this.anchors.map[u],{alias:[],aliasCount:0,count:1}])));let l=w.toJSON(this.contents,e,o);if(typeof t=="function"&&o.anchors)for(let{count:u,res:p}of o.anchors.values())t(p,u);return l}toString(){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");let e=this.options.indent;if(!Number.isInteger(e)||e<=0){let c=JSON.stringify(e);throw new Error(`"indent" option must be a positive integer, not ${c}`)}this.setSchema();let t=[],r=!1;if(this.version){let c="%YAML 1.2";this.schema.name==="yaml-1.1"&&(this.version==="1.0"?c="%YAML:1.0":this.version==="1.1"&&(c="%YAML 1.1")),t.push(c),r=!0}let s=this.listNonDefaultTags();this.tagPrefixes.forEach(({handle:c,prefix:l})=>{s.some(u=>u.indexOf(l)===0)&&(t.push(`%TAG ${c} ${l}`),r=!0)}),(r||this.directivesEndMarker)&&t.push("---"),this.commentBefore&&((r||!this.directivesEndMarker)&&t.unshift(""),t.unshift(this.commentBefore.replace(/^/gm,"#")));let i={anchors:Object.create(null),doc:this,indent:"",indentStep:" ".repeat(e),stringify:wt},a=!1,o=null;if(this.contents){this.contents instanceof w.Node&&(this.contents.spaceBefore&&(r||this.directivesEndMarker)&&t.push(""),this.contents.commentBefore&&t.push(this.contents.commentBefore.replace(/^/gm,"#")),i.forceBlockIndent=!!this.comment,o=this.contents.comment);let c=o?null:()=>a=!0,l=wt(this.contents,i,()=>o=null,c);t.push(w.addComment(l,"",o))}else this.contents!==void 0&&t.push(wt(this.contents,i));return this.comment&&((!a||o)&&t[t.length-1]!==""&&t.push(""),t.push(this.comment.replace(/^/gm,"#"))),t.join(`
147
147
  `)+`
148
- `}};Y._defineProperty(ye,"defaults",ea);Mt.Document=ye;Mt.defaultOptions=Kf;Mt.scalarOptions=Wf});var sa=_(ra=>{"use strict";f();var $r=Si(),ve=ta(),Xf=Rr(),eh=ee(),th=kr();Me();function nh(n,e=!0,t){t===void 0&&typeof e=="string"&&(t=e,e=!0);let r=Object.assign({},ve.Document.defaults[ve.defaultOptions.version],ve.defaultOptions);return new Xf.Schema(r).createNode(n,e,t)}var Le=class extends ve.Document{constructor(e){super(Object.assign({},ve.defaultOptions,e))}};function rh(n,e){let t=[],r;for(let s of $r.parse(n)){let i=new Le(e);i.parse(s,r),t.push(i),r=i}return t}function na(n,e){let t=$r.parse(n),r=new Le(e).parse(t[0]);if(t.length>1){let s="Source contains multiple documents; please use YAML.parseAllDocuments()";r.errors.unshift(new eh.YAMLSemanticError(t[1],s))}return r}function sh(n,e){let t=na(n,e);if(t.warnings.forEach(r=>th.warn(r)),t.errors.length>0)throw t.errors[0];return t.toJSON()}function ih(n,e){let t=new Le(e);return t.contents=n,String(t)}var ah={createNode:nh,defaultOptions:ve.defaultOptions,Document:Le,parse:sh,parseAllDocuments:rh,parseCST:$r.parse,parseDocument:na,scalarOptions:ve.scalarOptions,stringify:ih};ra.YAML=ah});var Br=_((am,ia)=>{f();ia.exports=sa().YAML});var aa=_(K=>{"use strict";f();var Ae=Me(),Ne=ee();K.findPair=Ae.findPair;K.parseMap=Ae.resolveMap;K.parseSeq=Ae.resolveSeq;K.stringifyNumber=Ae.stringifyNumber;K.stringifyString=Ae.stringifyString;K.toJSON=Ae.toJSON;K.Type=Ne.Type;K.YAMLError=Ne.YAMLError;K.YAMLReferenceError=Ne.YAMLReferenceError;K.YAMLSemanticError=Ne.YAMLSemanticError;K.YAMLSyntaxError=Ne.YAMLSyntaxError;K.YAMLWarning=Ne.YAMLWarning});var oa=_(W=>{f();var Q=aa();W.findPair=Q.findPair;W.toJSON=Q.toJSON;W.parseMap=Q.parseMap;W.parseSeq=Q.parseSeq;W.stringifyNumber=Q.stringifyNumber;W.stringifyString=Q.stringifyString;W.Type=Q.Type;W.YAMLError=Q.YAMLError;W.YAMLReferenceError=Q.YAMLReferenceError;W.YAMLSemanticError=Q.YAMLSemanticError;W.YAMLSyntaxError=Q.YAMLSyntaxError;W.YAMLWarning=Q.YAMLWarning});var ca=_(be=>{"use strict";f();be.__esModule=!0;var oh=Br();be.Document=oh.Document;var ch=Br();be.parseCST=ch.parseCST;var xr=oa();be.YAMLError=xr.YAMLError;be.YAMLSyntaxError=xr.YAMLSyntaxError;be.YAMLSemanticError=xr.YAMLSemanticError});var la=_(Dr=>{"use strict";f();Dr.__esModule=!0;var lh=Hr(),uh=Xr(),fh=ns(),hh=rs(),ph=ai(),mh=Jt(),gh=ci(),dh=ui(),_h=fi(),yh=hi(),vh=mi(),bh=vi(),Yr=ca();function Eh(n){var e=Yr.parseCST(n);yh.addOrigRange(e);for(var t=e.map(function(v){return new Yr.Document({merge:!1,keepCstNodes:!0}).parse(v)}),r=new lh.default(n),s=[],i={text:n,locator:r,comments:s,transformOffset:function(v){return dh.transformOffset(v,i)},transformRange:function(v){return _h.transformRange(v,i)},transformNode:function(v){return ph.transformNode(v,i)},transformContent:function(v){return mh.transformContent(v,i)}},a=0,o=t;a<o.length;a++)for(var c=o[a],l=0,u=c.errors;l<u.length;l++){var p=u[l];if(!(p instanceof Yr.YAMLSemanticError&&p.message==='Map keys must be unique; "<<" is repeated'))throw gh.transformError(p,i)}t.forEach(function(v){return hh.removeCstBlankLine(v.cstNode)});var d=fh.createRoot(i.transformRange({origStart:0,origEnd:i.text.length}),t.map(i.transformNode),s);return uh.attachComments(d),bh.updatePositions(d),vh.removeFakeNodes(d),d}Dr.parse=Eh});f();f();function va(n,e){let t=new SyntaxError(n+" ("+e.start.line+":"+e.start.column+")");return t.loc=e,t}var Ur=va;f();function Kr(n){return/^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(n)}f();function Wr(n){return n.position.start.offset}function Qr(n){return n.position.end.offset}async function wh(n){let{parse:e}=await Promise.resolve().then(()=>_a(la(),1));try{let t=e(n);return delete t.comments,t}catch(t){throw t!=null&&t.position?Ur(t.message,t.position):t}}var Sh={astFormat:"yaml",parse:wh,hasPragma:Kr,locStart:Wr,locEnd:Qr},Mh={parsers:{yaml:Sh}},mm=Mh;export{mm as default};
148
+ `}};Y._defineProperty(ye,"defaults",ea);Mt.Document=ye;Mt.defaultOptions=Kf;Mt.scalarOptions=Wf});var sa=_(ra=>{"use strict";f();var $r=Si(),ve=ta(),Xf=Rr(),eh=ee(),th=kr();Me();function nh(n,e=!0,t){t===void 0&&typeof e=="string"&&(t=e,e=!0);let r=Object.assign({},ve.Document.defaults[ve.defaultOptions.version],ve.defaultOptions);return new Xf.Schema(r).createNode(n,e,t)}var Le=class extends ve.Document{constructor(e){super(Object.assign({},ve.defaultOptions,e))}};function rh(n,e){let t=[],r;for(let s of $r.parse(n)){let i=new Le(e);i.parse(s,r),t.push(i),r=i}return t}function na(n,e){let t=$r.parse(n),r=new Le(e).parse(t[0]);if(t.length>1){let s="Source contains multiple documents; please use YAML.parseAllDocuments()";r.errors.unshift(new eh.YAMLSemanticError(t[1],s))}return r}function sh(n,e){let t=na(n,e);if(t.warnings.forEach(r=>th.warn(r)),t.errors.length>0)throw t.errors[0];return t.toJSON()}function ih(n,e){let t=new Le(e);return t.contents=n,String(t)}var ah={createNode:nh,defaultOptions:ve.defaultOptions,Document:Le,parse:sh,parseAllDocuments:rh,parseCST:$r.parse,parseDocument:na,scalarOptions:ve.scalarOptions,stringify:ih};ra.YAML=ah});var Br=_((Dg,ia)=>{f();ia.exports=sa().YAML});var aa=_(K=>{"use strict";f();var Ae=Me(),Ne=ee();K.findPair=Ae.findPair;K.parseMap=Ae.resolveMap;K.parseSeq=Ae.resolveSeq;K.stringifyNumber=Ae.stringifyNumber;K.stringifyString=Ae.stringifyString;K.toJSON=Ae.toJSON;K.Type=Ne.Type;K.YAMLError=Ne.YAMLError;K.YAMLReferenceError=Ne.YAMLReferenceError;K.YAMLSemanticError=Ne.YAMLSemanticError;K.YAMLSyntaxError=Ne.YAMLSyntaxError;K.YAMLWarning=Ne.YAMLWarning});var oa=_(W=>{f();var Q=aa();W.findPair=Q.findPair;W.toJSON=Q.toJSON;W.parseMap=Q.parseMap;W.parseSeq=Q.parseSeq;W.stringifyNumber=Q.stringifyNumber;W.stringifyString=Q.stringifyString;W.Type=Q.Type;W.YAMLError=Q.YAMLError;W.YAMLReferenceError=Q.YAMLReferenceError;W.YAMLSemanticError=Q.YAMLSemanticError;W.YAMLSyntaxError=Q.YAMLSyntaxError;W.YAMLWarning=Q.YAMLWarning});var ca=_(be=>{"use strict";f();be.__esModule=!0;var oh=Br();be.Document=oh.Document;var ch=Br();be.parseCST=ch.parseCST;var xr=oa();be.YAMLError=xr.YAMLError;be.YAMLSyntaxError=xr.YAMLSyntaxError;be.YAMLSemanticError=xr.YAMLSemanticError});var la=_(Dr=>{"use strict";f();Dr.__esModule=!0;var lh=Hr(),uh=Xr(),fh=ns(),hh=rs(),ph=ai(),mh=Jt(),gh=ci(),dh=ui(),_h=fi(),yh=hi(),vh=mi(),bh=vi(),Yr=ca();function Eh(n){var e=Yr.parseCST(n);yh.addOrigRange(e);for(var t=e.map(function(v){return new Yr.Document({merge:!1,keepCstNodes:!0}).parse(v)}),r=new lh.default(n),s=[],i={text:n,locator:r,comments:s,transformOffset:function(v){return dh.transformOffset(v,i)},transformRange:function(v){return _h.transformRange(v,i)},transformNode:function(v){return ph.transformNode(v,i)},transformContent:function(v){return mh.transformContent(v,i)}},a=0,o=t;a<o.length;a++)for(var c=o[a],l=0,u=c.errors;l<u.length;l++){var p=u[l];if(!(p instanceof Yr.YAMLSemanticError&&p.message==='Map keys must be unique; "<<" is repeated'))throw gh.transformError(p,i)}t.forEach(function(v){return hh.removeCstBlankLine(v.cstNode)});var d=fh.createRoot(i.transformRange({origStart:0,origEnd:i.text.length}),t.map(i.transformNode),s);return uh.attachComments(d),bh.updatePositions(d),vh.removeFakeNodes(d),d}Dr.parse=Eh});f();f();function va(n,e){let t=new SyntaxError(n+" ("+e.loc.start.line+":"+e.loc.start.column+")");return Object.assign(t,e)}var Ur=va;f();function Kr(n){return/^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/.test(n)}f();function Wr(n){return n.position.start.offset}function Qr(n){return n.position.end.offset}async function wh(n){let{parse:e}=await Promise.resolve().then(()=>_a(la(),1));try{let t=e(n);return delete t.comments,t}catch(t){throw t!=null&&t.position?Ur(t.message,{loc:t.position,cause:t}):t}}var Sh={astFormat:"yaml",parse:wh,hasPragma:Kr,locStart:Wr,locEnd:Qr},Mh={parsers:{yaml:Sh}},Xg=Mh;export{Xg as default};