@caiquecamargo/vite-plugin-netlify-cms 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1245 -0
- package/dist/src/plugin.d.ts +38 -0
- package/dist/src/types.d.ts +321 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("fs/promises");const Ne=require("url"),Ae={},oe=Symbol.for("yaml.alias"),Ce=Symbol.for("yaml.document"),T=Symbol.for("yaml.map"),ye=Symbol.for("yaml.pair"),le=Symbol.for("yaml.scalar"),q=Symbol.for("yaml.seq"),C=Symbol.for("yaml.node.type"),K=t=>!!t&&typeof t=="object"&&t[C]===oe,fe=t=>!!t&&typeof t=="object"&&t[C]===Ce,we=t=>!!t&&typeof t=="object"&&t[C]===T,j=t=>!!t&&typeof t=="object"&&t[C]===ye,L=t=>!!t&&typeof t=="object"&&t[C]===le,ce=t=>!!t&&typeof t=="object"&&t[C]===q;function A(t){if(t&&typeof t=="object")switch(t[C]){case T:case q:return!0}return!1}function N(t){if(t&&typeof t=="object")switch(t[C]){case oe:case T:case le:case q:return!0}return!1}const Me=t=>(L(t)||A(t))&&!!t.anchor;class ae{constructor(e){Object.defineProperty(this,C,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}}const B=Symbol("break visit"),ke=Symbol("skip children"),R=Symbol("remove node");function Q(t,e){const n=Pe(e);fe(t)?_(null,t.contents,n,Object.freeze([t]))===R&&(t.contents=null):_(null,t,n,Object.freeze([]))}Q.BREAK=B;Q.SKIP=ke;Q.REMOVE=R;function _(t,e,n,i){const s=Ie(t,e,n,i);if(N(s)||j(s))return Be(t,i,s),_(t,s,n,i);if(typeof s!="symbol"){if(A(e)){i=Object.freeze(i.concat(e));for(let r=0;r<e.items.length;++r){const o=_(r,e.items[r],n,i);if(typeof o=="number")r=o-1;else{if(o===B)return B;o===R&&(e.items.splice(r,1),r-=1)}}}else if(j(e)){i=Object.freeze(i.concat(e));const r=_("key",e.key,n,i);if(r===B)return B;r===R&&(e.key=null);const o=_("value",e.value,n,i);if(o===B)return B;o===R&&(e.value=null)}}return s}function Pe(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Ie(t,e,n,i){if(typeof n=="function")return n(t,e,i);if(we(e))return n.Map?.(t,e,i);if(ce(e))return n.Seq?.(t,e,i);if(j(e))return n.Pair?.(t,e,i);if(L(e))return n.Scalar?.(t,e,i);if(K(e))return n.Alias?.(t,e,i)}function Be(t,e,n){const i=e[e.length-1];if(A(i))i.items[t]=n;else if(j(i))t==="key"?i.key=n:i.value=n;else if(fe(i))i.contents=n;else{const s=K(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}function Se(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}class We extends ae{constructor(e){super(oe),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let n;return Q(e,{Node:(i,s)=>{if(s===this)return Q.BREAK;s.anchor===this.source&&(n=s)}}),n}toJSON(e,n){if(!n)return{source:this.source};const{anchors:i,doc:s,maxAliasCount:r}=n,o=this.resolve(s);if(!o){const l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}const f=i.get(o);if(!f||f.res===void 0){const l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(f.count+=1,f.aliasCount===0&&(f.aliasCount=z(s,o,i)),f.count*f.aliasCount>r)){const l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return f.res}toString(e,n,i){const s=`*${this.source}`;if(e){if(Se(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${s} `}return s}}function z(t,e,n){if(K(e)){const i=e.resolve(t),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}else if(A(e)){let i=0;for(const s of e.items){const r=z(t,s,n);r>i&&(i=r)}return i}else if(j(e)){const i=z(t,e.key,n),s=z(t,e.value,n);return Math.max(i,s)}return 1}function M(t,e,n){if(Array.isArray(t))return t.map((i,s)=>M(i,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Me(t))return t.toJSON(e,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(t,i),n.onCreate=r=>{i.res=r,delete n.onCreate};const s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}const Oe=t=>!t||typeof t!="function"&&typeof t!="object";class E extends ae{constructor(e){super(le),this.value=e}toJSON(e,n){return n?.keep?this.value:M(this.value,e,n)}toString(){return String(this.value)}}E.BLOCK_FOLDED="BLOCK_FOLDED";E.BLOCK_LITERAL="BLOCK_LITERAL";E.PLAIN="PLAIN";E.QUOTE_DOUBLE="QUOTE_DOUBLE";E.QUOTE_SINGLE="QUOTE_SINGLE";const Fe="tag:yaml.org,2002:";function Te(t,e,n){if(e){const i=n.filter(r=>r.tag===e),s=i.find(r=>!r.format)??i[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(i=>i.identify?.(t)&&!i.format)}function De(t,e,n){if(fe(t)&&(t=t.contents),N(t))return t;if(j(t)){const d=n.schema[T].createNode?.(n.schema,null,n);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());const{aliasDuplicateObjects:i,onAnchor:s,onTagObj:r,schema:o,sourceObjects:f}=n;let l;if(i&&t&&typeof t=="object"){if(l=f.get(t),l)return l.anchor||(l.anchor=s(t)),new We(l.anchor);l={anchor:null,node:null},f.set(t,l)}e?.startsWith("!!")&&(e=Fe+e.slice(2));let u=Te(t,e,o.tags);if(!u){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){const d=new E(t);return l&&(l.node=d),d}u=t instanceof Map?o[T]:Symbol.iterator in Object(t)?o[q]:o[T]}r&&(r(u),delete n.onTagObj);const b=u?.createNode?u.createNode(n.schema,t,n):new E(t);return e&&(b.tag=e),l&&(l.node=b),b}function pe(t,e,n){let i=n;for(let s=e.length-1;s>=0;--s){const r=e[s];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return De(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}const _e=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done;class v extends ae{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(i=>N(i)||j(i)?i.clone(e):i),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(_e(e))this.add(n);else{const[i,...s]=e,r=this.get(i,!0);if(A(r))r.addIn(s,n);else if(r===void 0&&this.schema)this.set(i,pe(this.schema,s,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${s}`)}}deleteIn(e){const[n,...i]=e;if(i.length===0)return this.delete(n);const s=this.get(n,!0);if(A(s))return s.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(e,n){const[i,...s]=e,r=this.get(i,!0);return s.length===0?!n&&L(r)?r.value:r:A(r)?r.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!j(n))return!1;const i=n.value;return i==null||e&&L(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){const[n,...i]=e;if(i.length===0)return this.has(n);const s=this.get(n,!0);return A(s)?s.hasIn(i):!1}setIn(e,n){const[i,...s]=e;if(s.length===0)this.set(i,n);else{const r=this.get(i,!0);if(A(r))r.setIn(s,n);else if(r===void 0&&this.schema)this.set(i,pe(this.schema,s,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${s}`)}}}v.maxFlowStringSingleLineLength=60;const Je=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function V(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}const W=(t,e,n)=>t.endsWith(`
|
|
2
|
+
`)?V(n,e):n.includes(`
|
|
3
|
+
`)?`
|
|
4
|
+
`+V(n,e):(t.endsWith(" ")?"":" ")+n,$e="flow",se="block",G="quoted";function x(t,e,n="flow",{indentAtStart:i,lineWidth:s=80,minContentWidth:r=20,onFold:o,onOverflow:f}={}){if(!s||s<0)return t;const l=Math.max(1+r,1+s-e.length);if(t.length<=l)return t;const u=[],b={};let d=s-e.length;typeof i=="number"&&(i>s-Math.max(2,r)?u.push(0):d=s-i);let g,c,m=!1,a=-1,h=-1,S=-1;n===se&&(a=me(t,a),a!==-1&&(d=a+l));for(let y;y=t[a+=1];){if(n===G&&y==="\\"){switch(h=a,t[a+1]){case"x":a+=3;break;case"u":a+=5;break;case"U":a+=9;break;default:a+=1}S=a}if(y===`
|
|
5
|
+
`)n===se&&(a=me(t,a)),d=a+l,g=void 0;else{if(y===" "&&c&&c!==" "&&c!==`
|
|
6
|
+
`&&c!==" "){const w=t[a+1];w&&w!==" "&&w!==`
|
|
7
|
+
`&&w!==" "&&(g=a)}if(a>=d)if(g)u.push(g),d=g+l,g=void 0;else if(n===G){for(;c===" "||c===" ";)c=y,y=t[a+=1],m=!0;const w=a>S+1?a-2:h-1;if(b[w])return t;u.push(w),b[w]=!0,d=w+l,g=void 0}else m=!0}c=y}if(m&&f&&f(),u.length===0)return t;o&&o();let p=t.slice(0,u[0]);for(let y=0;y<u.length;++y){const w=u[y],O=u[y+1]||t.length;w===0?p=`
|
|
8
|
+
${e}${t.slice(0,O)}`:(n===G&&b[w]&&(p+=`${t[w]}\\`),p+=`
|
|
9
|
+
${e}${t.slice(w+1,O)}`)}return p}function me(t,e){let n=t[e+1];for(;n===" "||n===" ";){do n=t[e+=1];while(n&&n!==`
|
|
10
|
+
`);n=t[e+1]}return e}const ee=t=>({indentAtStart:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),te=t=>/^(%|---|\.\.\.)/m.test(t);function Ke(t,e,n){if(!e||e<0)return!1;const i=e-n,s=t.length;if(s<=i)return!1;for(let r=0,o=0;r<s;++r)if(t[r]===`
|
|
11
|
+
`){if(r-o>i)return!0;if(o=r+1,s-o<=i)return!1}return!0}function U(t,e){const n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;const{implicitKey:i}=e,s=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(te(t)?" ":"");let o="",f=0;for(let l=0,u=n[l];u;u=n[++l])if(u===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(f,l)+"\\ ",l+=1,f=l,u="\\"),u==="\\")switch(n[l+1]){case"u":{o+=n.slice(f,l);const b=n.substr(l+2,4);switch(b){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:b.substr(0,2)==="00"?o+="\\x"+b.substr(2):o+=n.substr(l,6)}l+=5,f=l+1}break;case"n":if(i||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(f,l)+`
|
|
12
|
+
|
|
13
|
+
`;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
|
|
14
|
+
`,l+=2;o+=r,n[l+2]===" "&&(o+="\\"),l+=1,f=l+1}break;default:l+=1}return o=f?o+n.slice(f):n,i?o:x(o,r,G,ee(e))}function re(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
15
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return U(t,e);const n=e.indent||(te(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
16
|
+
${n}`)+"'";return e.implicitKey?i:x(i,n,$e,ee(e))}function J(t,e){const{singleQuote:n}=e.options;let i;if(n===!1)i=U;else{const s=t.includes('"'),r=t.includes("'");s&&!r?i=re:r&&!s?i=U:i=n?re:U}return i(t,e)}function H({comment:t,type:e,value:n},i,s,r){const{blockQuote:o,commentString:f,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return J(n,i);const u=i.indent||(i.forceBlockIndent||te(n)?" ":""),b=o==="literal"?!0:o==="folded"||e===E.BLOCK_FOLDED?!1:e===E.BLOCK_LITERAL?!0:!Ke(n,l,u.length);if(!n)return b?`|
|
|
17
|
+
`:`>
|
|
18
|
+
`;let d,g;for(g=n.length;g>0;--g){const $=n[g-1];if($!==`
|
|
19
|
+
`&&$!==" "&&$!==" ")break}let c=n.substring(g);const m=c.indexOf(`
|
|
20
|
+
`);m===-1?d="-":n===c||m!==c.length-1?(d="+",r&&r()):d="",c&&(n=n.slice(0,-c.length),c[c.length-1]===`
|
|
21
|
+
`&&(c=c.slice(0,-1)),c=c.replace(/\n+(?!\n|$)/g,`$&${u}`));let a=!1,h,S=-1;for(h=0;h<n.length;++h){const $=n[h];if($===" ")a=!0;else if($===`
|
|
22
|
+
`)S=h;else break}let p=n.substring(0,S<h?S+1:h);p&&(n=n.substring(p.length),p=p.replace(/\n+/g,`$&${u}`));let w=(b?"|":">")+(a?u?"2":"1":"")+d;if(t&&(w+=" "+f(t.replace(/ ?[\r\n]+/g," ")),s&&s()),b)return n=n.replace(/\n+/g,`$&${u}`),`${w}
|
|
23
|
+
${u}${p}${n}${c}`;n=n.replace(/\n+/g,`
|
|
24
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`);const O=x(`${p}${n}${c}`,u,se,ee(i));return`${w}
|
|
25
|
+
${u}${O}`}function Re(t,e,n,i){const{type:s,value:r}=t,{actualString:o,implicitKey:f,indent:l,indentStep:u,inFlow:b}=e;if(f&&/[\n[\]{},]/.test(r)||b&&/[[\]{},]/.test(r))return J(r,e);if(!r||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return f||b||!r.includes(`
|
|
26
|
+
`)?J(r,e):H(t,e,n,i);if(!f&&!b&&s!==E.PLAIN&&r.includes(`
|
|
27
|
+
`))return H(t,e,n,i);if(te(r)){if(l==="")return e.forceBlockIndent=!0,H(t,e,n,i);if(f&&l===u)return J(r,e)}const d=r.replace(/\n+/g,`$&
|
|
28
|
+
${l}`);if(o){const g=a=>a.default&&a.tag!=="tag:yaml.org,2002:str"&&a.test?.test(d),{compat:c,tags:m}=e.doc.schema;if(m.some(g)||c?.some(g))return J(r,e)}return f?d:x(d,l,$e,ee(e))}function Ue(t,e,n,i){const{implicitKey:s,inFlow:r}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)});let{type:f}=t;f!==E.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(f=E.QUOTE_DOUBLE);const l=b=>{switch(b){case E.BLOCK_FOLDED:case E.BLOCK_LITERAL:return s||r?J(o.value,e):H(o,e,n,i);case E.QUOTE_DOUBLE:return U(o.value,e);case E.QUOTE_SINGLE:return re(o.value,e);case E.PLAIN:return Re(o,e,n,i);default:return null}};let u=l(f);if(u===null){const{defaultKeyType:b,defaultStringType:d}=e.options,g=s&&b||d;if(u=l(g),u===null)throw new Error(`Unsupported default string type ${g}`)}return u}function Qe(t,e){const n=Object.assign({blockQuote:!0,commentString:Je,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e);let i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:i,options:n}}function Ve(t,e){if(e.tag){const s=t.filter(r=>r.tag===e.tag);if(s.length>0)return s.find(r=>r.format===e.format)??s[0]}let n,i;if(L(e)){i=e.value;const s=t.filter(r=>r.identify?.(i));n=s.find(r=>r.format===e.format)??s.find(r=>!r.format)}else i=e,n=t.find(s=>s.nodeClass&&i instanceof s.nodeClass);if(!n){const s=i?.constructor?.name??typeof i;throw new Error(`Tag not resolved for ${s} value`)}return n}function qe(t,e,{anchors:n,doc:i}){if(!i.directives)return"";const s=[],r=(L(t)||A(t))&&t.anchor;r&&Se(r)&&(n.add(r),s.push(`&${r}`));const o=t.tag?t.tag:e.default?null:e.tag;return o&&s.push(i.directives.tagString(o)),s.join(" ")}function X(t,e,n,i){if(j(t))return t.toString(e,n,i);if(K(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s;const r=N(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s||(s=Ve(e.doc.schema.tags,r));const o=qe(r,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const f=typeof s.stringify=="function"?s.stringify(r,e,n,i):L(r)?Ue(r,e,n,i):r.toString(e,n,i);return o?L(r)||f[0]==="{"||f[0]==="["?`${o} ${f}`:`${o}
|
|
29
|
+
${e.indent}${f}`:f}function Ye({key:t,value:e},n,i,s){const{allNullValues:r,doc:o,indent:f,indentStep:l,options:{commentString:u,indentSeq:b,simpleKeys:d}}=n;let g=N(t)&&t.comment||null;if(d){if(g)throw new Error("With simple keys, key nodes cannot have comments");if(A(t)){const P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let c=!d&&(!t||g&&e==null&&!n.inFlow||A(t)||(L(t)?t.type===E.BLOCK_FOLDED||t.type===E.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!c&&(d||!r),indent:f+l});let m=!1,a=!1,h=X(t,n,()=>m=!0,()=>a=!0);if(!c&&!n.inFlow&&h.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");c=!0}if(n.inFlow){if(r||e==null)return m&&i&&i(),h===""?"?":c?`? ${h}`:h}else if(r&&!d||e==null&&c)return h=`? ${h}`,g&&!m?h+=W(h,n.indent,u(g)):a&&s&&s(),h;m&&(g=null),c?(g&&(h+=W(h,n.indent,u(g))),h=`? ${h}
|
|
30
|
+
${f}:`):(h=`${h}:`,g&&(h+=W(h,n.indent,u(g))));let S,p,y;N(e)?(S=!!e.spaceBefore,p=e.commentBefore,y=e.comment):(S=!1,p=null,y=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!c&&!g&&L(e)&&(n.indentAtStart=h.length+1),a=!1,!b&&l.length>=2&&!n.inFlow&&!c&&ce(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let w=!1;const O=X(e,n,()=>w=!0,()=>a=!0);let $=" ";if(g||S||p){if($=S?`
|
|
31
|
+
`:"",p){const P=u(p);$+=`
|
|
32
|
+
${V(P,n.indent)}`}O===""&&!n.inFlow?$===`
|
|
33
|
+
`&&($=`
|
|
34
|
+
|
|
35
|
+
`):$+=`
|
|
36
|
+
${n.indent}`}else if(!c&&A(e)){const P=O[0],ne=O.indexOf(`
|
|
37
|
+
`),ge=ne!==-1,je=n.inFlow??e.flow??e.items.length===0;if(ge||!je){let he=!1;if(ge&&(P==="&"||P==="!")){let I=O.indexOf(" ");P==="&"&&I!==-1&&I<ne&&O[I+1]==="!"&&(I=O.indexOf(" ",I+1)),(I===-1||ne<I)&&(he=!0)}he||($=`
|
|
38
|
+
${n.indent}`)}}else(O===""||O[0]===`
|
|
39
|
+
`)&&($="");return h+=$+O,n.inFlow?w&&i&&i():y&&!w?h+=W(h,n.indent,u(y)):a&&s&&s(),h}function ze(t,e){(t==="debug"||t==="warn")&&(typeof process<"u"&&process.emitWarning?process.emitWarning(e):console.warn(e))}const be="<<";function Ee(t,e,{key:n,value:i}){if(t?.doc.schema.merge&&Ge(n))if(i=K(i)?i.resolve(t.doc):i,ce(i))for(const s of i.items)ie(t,e,s);else if(Array.isArray(i))for(const s of i)ie(t,e,s);else ie(t,e,i);else{const s=M(n,"",t);if(e instanceof Map)e.set(s,M(i,s,t));else if(e instanceof Set)e.add(s);else{const r=He(n,s,t),o=M(i,r,t);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}const Ge=t=>t===be||L(t)&&t.value===be&&(!t.type||t.type===E.PLAIN);function ie(t,e,n){const i=t&&K(n)?n.resolve(t.doc):n;if(!we(i))throw new Error("Merge sources must be maps or map aliases");const s=i.toJSON(null,t,Map);for(const[r,o]of s)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function He(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(N(t)&&n&&n.doc){const i=Qe(n.doc,{});i.anchors=new Set;for(const r of n.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;const s=t.toString(i);if(!n.mapKeyWarned){let r=JSON.stringify(s);r.length>40&&(r=r.substring(0,36)+'..."'),ze(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}class k{constructor(e,n=null){Object.defineProperty(this,C,{value:ye}),this.key=e,this.value=n}clone(e){let{key:n,value:i}=this;return N(n)&&(n=n.clone(e)),N(i)&&(i=i.clone(e)),new k(n,i)}toJSON(e,n){const i=n?.mapAsMap?new Map:{};return Ee(n,i,this)}toString(e,n,i){return e?.doc?Ye(this,e,n,i):JSON.stringify(this)}}function Le(t,e,n){return(e.inFlow??t.flow?Ze:Xe)(t,e,n)}function Xe({comment:t,items:e},n,{blockItemPrefix:i,flowChars:s,itemIndent:r,onChompKeep:o,onComment:f}){const{indent:l,options:{commentString:u}}=n,b=Object.assign({},n,{indent:r,type:null});let d=!1;const g=[];for(let m=0;m<e.length;++m){const a=e[m];let h=null;if(N(a))!d&&a.spaceBefore&&g.push(""),Z(n,g,a.commentBefore,d),a.comment&&(h=a.comment);else if(j(a)){const p=N(a.key)?a.key:null;p&&(!d&&p.spaceBefore&&g.push(""),Z(n,g,p.commentBefore,d))}d=!1;let S=X(a,b,()=>h=null,()=>d=!0);h&&(S+=W(S,r,u(h))),d&&h&&(d=!1),g.push(i+S)}let c;if(g.length===0)c=s.start+s.end;else{c=g[0];for(let m=1;m<g.length;++m){const a=g[m];c+=a?`
|
|
40
|
+
${l}${a}`:`
|
|
41
|
+
`}}return t?(c+=`
|
|
42
|
+
`+V(u(t),l),f&&f()):d&&o&&o(),c}function Ze({comment:t,items:e},n,{flowChars:i,itemIndent:s,onComment:r}){const{indent:o,indentStep:f,flowCollectionPadding:l,options:{commentString:u}}=n;s+=f;const b=Object.assign({},n,{indent:s,inFlow:!0,type:null});let d=!1,g=0;const c=[];for(let S=0;S<e.length;++S){const p=e[S];let y=null;if(N(p))p.spaceBefore&&c.push(""),Z(n,c,p.commentBefore,!1),p.comment&&(y=p.comment);else if(j(p)){const O=N(p.key)?p.key:null;O&&(O.spaceBefore&&c.push(""),Z(n,c,O.commentBefore,!1),O.comment&&(d=!0));const $=N(p.value)?p.value:null;$?($.comment&&(y=$.comment),$.commentBefore&&(d=!0)):p.value==null&&O&&O.comment&&(y=O.comment)}y&&(d=!0);let w=X(p,b,()=>y=null);S<e.length-1&&(w+=","),y&&(w+=W(w,s,u(y))),!d&&(c.length>g||w.includes(`
|
|
43
|
+
`))&&(d=!0),c.push(w),g=c.length}let m;const{start:a,end:h}=i;if(c.length===0)m=a+h;else if(d||(d=c.reduce((p,y)=>p+y.length+2,2)>v.maxFlowStringSingleLineLength),d){m=a;for(const S of c)m+=S?`
|
|
44
|
+
${f}${o}${S}`:`
|
|
45
|
+
`;m+=`
|
|
46
|
+
${o}${h}`}else m=`${a}${l}${c.join(" ")}${l}${h}`;return t&&(m+=W(m,u(t),o),r&&r()),m}function Z({indent:t,options:{commentString:e}},n,i,s){if(i&&s&&(i=i.replace(/^\n+/,"")),i){const r=V(e(i),t);n.push(r.trimStart())}}function F(t,e){const n=L(e)?e.value:e;for(const i of t)if(j(i)&&(i.key===e||i.key===n||L(i.key)&&i.key.value===n))return i}class D extends v{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(T,e),this.items=[]}add(e,n){let i;j(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new k(e,e?.value):i=new k(e.key,e.value);const s=F(this.items,i.key),r=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${i.key} already set`);L(s.value)&&Oe(i.value)?s.value.value=i.value:s.value=i.value}else if(r){const o=this.items.findIndex(f=>r(i,f)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){const n=F(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){const s=F(this.items,e)?.value;return(!n&&L(s)?s.value:s)??void 0}has(e){return!!F(this.items,e)}set(e,n){this.add(new k(e,n),!0)}toJSON(e,n,i){const s=i?new i:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(const r of this.items)Ee(n,s,r);return s}toString(e,n,i){if(!e)return JSON.stringify(this);for(const s of this.items)if(!j(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Le(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:n})}}class ve extends v{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(q,e),this.items=[]}add(e){this.items.push(e)}delete(e){const n=Y(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){const i=Y(e);if(typeof i!="number")return;const s=this.items[i];return!n&&L(s)?s.value:s}has(e){const n=Y(e);return typeof n=="number"&&n<this.items.length}set(e,n){const i=Y(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);const s=this.items[i];L(s)&&Oe(n)?s.value=n:this.items[i]=n}toJSON(e,n){const i=[];n?.onCreate&&n.onCreate(i);let s=0;for(const r of this.items)i.push(M(r,String(s++),n));return i}toString(e,n,i){return e?Le(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:n}):JSON.stringify(this)}}function Y(t){let e=L(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}class ue extends ve{constructor(){super(),this.add=D.prototype.add.bind(this),this.delete=D.prototype.delete.bind(this),this.get=D.prototype.get.bind(this),this.has=D.prototype.has.bind(this),this.set=D.prototype.set.bind(this),this.tag=ue.tag}toJSON(e,n){if(!n)return super.toJSON(e);const i=new Map;n?.onCreate&&n.onCreate(i);for(const s of this.items){let r,o;if(j(s)?(r=M(s.key,"",n),o=M(s.value,r,n)):r=M(s,"",n),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}}ue.tag="tag:yaml.org,2002:omap";class de extends D{constructor(e){super(e),this.tag=de.tag}add(e){let n;j(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new k(e.key,null):n=new k(e,null),F(this.items,n.key)||this.items.push(n)}get(e,n){const i=F(this.items,e);return!n&&j(i)?L(i.key)?i.key.value:i.key:i}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);const i=F(this.items,e);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new k(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,i);throw new Error("Set items must all have null values")}}de.tag="tag:yaml.org,2002:set";Ae.dirname(Ne.fileURLToPath(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs.js",document.baseURI).href));const xe=t=>t,et=t=>t,tt=t=>t,nt=t=>({widget:"boolean",...t}),it=t=>({widget:"code",...t}),st=t=>({widget:"color",...t}),rt=t=>({widget:"datetime",...t}),ot=t=>({widget:"hidden",...t}),lt=t=>({widget:"file",...t}),ft=t=>({widget:"image",...t}),ct=t=>({widget:"list",...t}),at=t=>({widget:"map",...t}),ut=t=>({widget:"number",...t}),dt=t=>({widget:"object",...t}),gt=t=>({widget:"relation",...t}),ht=t=>({widget:"select",...t}),pt=t=>({widget:"string",...t}),mt=t=>({widget:"text",...t});exports.defineBooleanWidget=nt;exports.defineCodeWidget=it;exports.defineColorWidget=st;exports.defineConfig=xe;exports.defineDateTimeWidget=rt;exports.defineFileCollection=tt;exports.defineFileWidget=lt;exports.defineFolderCollection=et;exports.defineHiddenWidget=ot;exports.defineImageWidget=ft;exports.defineListWidget=ct;exports.defineMapWidget=at;exports.defineNumberWidget=ut;exports.defineObjectWidget=dt;exports.defineRelationWidget=gt;exports.defineSelectWidget=ht;exports.defineStringWidget=pt;exports.defineTextWidget=mt;
|
package/dist/index.d.ts
ADDED