@caiquecamargo/vite-plugin-netlify-cms 0.0.2 → 0.0.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/dist/index.cjs.js +1 -1
- package/dist/index.es.js +35 -34
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Be=require("fs/promises"),_s=require("url"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Be=require("fs/promises"),Te=require("path"),_s=require("url"),ht=Symbol.for("yaml.alias"),lt=Symbol.for("yaml.document"),W=Symbol.for("yaml.map"),qt=Symbol.for("yaml.pair"),R=Symbol.for("yaml.scalar"),ce=Symbol.for("yaml.seq"),M=Symbol.for("yaml.node.type"),X=s=>!!s&&typeof s=="object"&&s[M]===ht,ke=s=>!!s&&typeof s=="object"&&s[M]===lt,z=s=>!!s&&typeof s=="object"&&s[M]===W,I=s=>!!s&&typeof s=="object"&&s[M]===qt,A=s=>!!s&&typeof s=="object"&&s[M]===R,fe=s=>!!s&&typeof s=="object"&&s[M]===ce;function L(s){if(s&&typeof s=="object")switch(s[M]){case W:case ce:return!0}return!1}function T(s){if(s&&typeof s=="object")switch(s[M]){case ht:case W:case R:case ce:return!0}return!1}const vs=s=>(A(s)||L(s))&&!!s.anchor;class dt{constructor(e){Object.defineProperty(this,M,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}}const _=Symbol("break visit"),Ut=Symbol("skip children"),K=Symbol("remove node");function J(s,e){const t=Rt(e);ke(s)?ne(null,s.contents,t,Object.freeze([s]))===K&&(s.contents=null):ne(null,s,t,Object.freeze([]))}J.BREAK=_;J.SKIP=Ut;J.REMOVE=K;function ne(s,e,t,n){const i=Vt(s,e,t,n);if(T(i)||I(i))return Wt(s,n,i),ne(s,i,t,n);if(typeof i!="symbol"){if(L(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){const o=ne(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===_)return _;o===K&&(e.items.splice(r,1),r-=1)}}}else if(I(e)){n=Object.freeze(n.concat(e));const r=ne("key",e.key,t,n);if(r===_)return _;r===K&&(e.key=null);const o=ne("value",e.value,t,n);if(o===_)return _;o===K&&(e.value=null)}}return i}async function Ke(s,e){const t=Rt(e);ke(s)?await ie(null,s.contents,t,Object.freeze([s]))===K&&(s.contents=null):await ie(null,s,t,Object.freeze([]))}Ke.BREAK=_;Ke.SKIP=Ut;Ke.REMOVE=K;async function ie(s,e,t,n){const i=await Vt(s,e,t,n);if(T(i)||I(i))return Wt(s,n,i),ie(s,i,t,n);if(typeof i!="symbol"){if(L(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){const o=await ie(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===_)return _;o===K&&(e.items.splice(r,1),r-=1)}}}else if(I(e)){n=Object.freeze(n.concat(e));const r=await ie("key",e.key,t,n);if(r===_)return _;r===K&&(e.key=null);const o=await ie("value",e.value,t,n);if(o===_)return _;o===K&&(e.value=null)}}return i}function Rt(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function Vt(s,e,t,n){if(typeof t=="function")return t(s,e,n);if(z(e))return t.Map?.(s,e,n);if(fe(e))return t.Seq?.(s,e,n);if(I(e))return t.Pair?.(s,e,n);if(A(e))return t.Scalar?.(s,e,n);if(X(e))return t.Alias?.(s,e,n)}function Wt(s,e,t){const n=e[e.length-1];if(L(n))n.items[s]=t;else if(I(n))s==="key"?n.key=t:n.value=t;else if(ke(n))n.contents=t;else{const i=X(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Bs={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},js=s=>s.replace(/[!,[\]{}]/g,e=>Bs[e]);class C{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},C.defaultYaml,e),this.tags=Object.assign({},C.defaultTags,t)}clone(){const e=new C(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new C(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:C.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},C.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:C.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},C.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}const[,n,i]=e.match(/^(.*!)([^!]*)$/);i||t(`The ${e} tag has no suffix`);const r=this.tags[n];return r?r+decodeURIComponent(i):n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+js(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let i;if(e&&n.length>0&&T(e.contents)){const r={};J(e.contents,(o,l)=>{T(l)&&l.tag&&(r[l.tag]=!0)}),i=Object.keys(r)}else i=[];for(const[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
|
|
2
2
|
`)}}C.defaultYaml={explicit:!1,version:"1.2"};C.defaultTags={"!!":"tag:yaml.org,2002:"};function Jt(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function Yt(s){const e=new Set;return J(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function Gt(s,e){for(let t=1;;++t){const n=`${s}${t}`;if(!e.has(n))return n}}function Ms(s,e){const t=[],n=new Map;let i=null;return{onAnchor:r=>{t.push(r),i||(i=Yt(s));const o=Gt(e,i);return i.add(o),o},setAnchors:()=>{for(const r of t){const o=n.get(r);if(typeof o=="object"&&o.anchor&&(A(o.node)||L(o.node)))o.node.anchor=o.anchor;else{const l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=r,l}}},sourceObjects:n}}class Fe extends dt{constructor(e){super(ht),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return J(e,{Node:(n,i)=>{if(i===this)return J.BREAK;i.anchor===this.source&&(t=i)}}),t}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:i,maxAliasCount:r}=t,o=this.resolve(i);if(!o){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}const l=n.get(o);if(!l||l.res===void 0){const a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(r>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=$e(i,o,n)),l.count*l.aliasCount>r)){const a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return l.res}toString(e,t,n){const i=`*${this.source}`;if(e){if(Jt(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`${i} `}return i}}function $e(s,e,t){if(X(e)){const n=e.resolve(s),i=t&&n&&t.get(n);return i?i.count*i.aliasCount:0}else if(L(e)){let n=0;for(const i of e.items){const r=$e(s,i,t);r>n&&(n=r)}return n}else if(I(e)){const n=$e(s,e.key,t),i=$e(s,e.value,t);return Math.max(n,i)}return 1}function F(s,e,t){if(Array.isArray(s))return s.map((n,i)=>F(n,String(i),t));if(s&&typeof s.toJSON=="function"){if(!t||!vs(s))return s.toJSON(e,t);const n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=r=>{n.res=r,delete t.onCreate};const i=s.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof s=="bigint"&&!t?.keep?Number(s):s}const Qt=s=>!s||typeof s!="function"&&typeof s!="object";class N extends dt{constructor(e){super(R),this.value=e}toJSON(e,t){return t?.keep?this.value:F(this.value,e,t)}toString(){return String(this.value)}}N.BLOCK_FOLDED="BLOCK_FOLDED";N.BLOCK_LITERAL="BLOCK_LITERAL";N.PLAIN="PLAIN";N.QUOTE_DOUBLE="QUOTE_DOUBLE";N.QUOTE_SINGLE="QUOTE_SINGLE";const Ps="tag:yaml.org,2002:";function Ds(s,e,t){if(e){const n=t.filter(r=>r.tag===e),i=n.find(r=>!r.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(n=>n.identify?.(s)&&!n.format)}function be(s,e,t){if(ke(s)&&(s=s.contents),T(s))return s;if(I(s)){const f=t.schema[W].createNode?.(t.schema,null,t);return f.items.push(s),f}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());const{aliasDuplicateObjects:n,onAnchor:i,onTagObj:r,schema:o,sourceObjects:l}=t;let a;if(n&&s&&typeof s=="object"){if(a=l.get(s),a)return a.anchor||(a.anchor=i(s)),new Fe(a.anchor);a={anchor:null,node:null},l.set(s,a)}e?.startsWith("!!")&&(e=Ps+e.slice(2));let c=Ds(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){const f=new N(s);return a&&(a.node=f),f}c=s instanceof Map?o[W]:Symbol.iterator in Object(s)?o[ce]:o[W]}r&&(r(c),delete t.onTagObj);const u=c?.createNode?c.createNode(t.schema,s,t):new N(s);return e&&(u.tag=e),a&&(a.node=u),u}function je(s,e,t){let n=t;for(let i=e.length-1;i>=0;--i){const r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=n,n=o}else n=new Map([[r,n]])}return be(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}const me=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done;class qe extends dt{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>T(n)||I(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(me(e))this.add(t);else{const[n,...i]=e,r=this.get(n,!0);if(L(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,je(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){const[t,...n]=e;if(n.length===0)return this.delete(t);const i=this.get(t,!0);if(L(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...i]=e,r=this.get(n,!0);return i.length===0?!t&&A(r)?r.value:r:L(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!I(t))return!1;const n=t.value;return n==null||e&&A(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(n.length===0)return this.has(t);const i=this.get(t,!0);return L(i)?i.hasIn(n):!1}setIn(e,t){const[n,...i]=e;if(i.length===0)this.set(n,t);else{const r=this.get(n,!0);if(L(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,je(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}qe.maxFlowStringSingleLineLength=60;const Ks=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function U(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}const V=(s,e,t)=>s.endsWith(`
|
|
3
3
|
`)?U(t,e):t.includes(`
|
|
4
4
|
`)?`
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdir as Cs, mkdir as _s, writeFile as vs, readFile as Bs } from "fs/promises";
|
|
2
|
+
import Te from "path";
|
|
2
3
|
import { fileURLToPath as js } from "url";
|
|
3
|
-
const
|
|
4
|
+
const ut = Symbol.for("yaml.alias"), ot = Symbol.for("yaml.document"), W = Symbol.for("yaml.map"), Ft = Symbol.for("yaml.pair"), R = Symbol.for("yaml.scalar"), ce = Symbol.for("yaml.seq"), M = Symbol.for("yaml.node.type"), X = (s) => !!s && typeof s == "object" && s[M] === ut, ke = (s) => !!s && typeof s == "object" && s[M] === ot, z = (s) => !!s && typeof s == "object" && s[M] === W, I = (s) => !!s && typeof s == "object" && s[M] === Ft, A = (s) => !!s && typeof s == "object" && s[M] === R, fe = (s) => !!s && typeof s == "object" && s[M] === ce;
|
|
4
5
|
function L(s) {
|
|
5
6
|
if (s && typeof s == "object")
|
|
6
7
|
switch (s[M]) {
|
|
@@ -4681,43 +4682,43 @@ const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4681
4682
|
stringify: Yn,
|
|
4682
4683
|
visit: J,
|
|
4683
4684
|
visitAsync: De
|
|
4684
|
-
}, Symbol.toStringTag, { value: "Module" })), rt = Te.dirname(js(import.meta.url)),
|
|
4685
|
+
}, Symbol.toStringTag, { value: "Module" })), rt = Te.dirname(js(import.meta.url)), ei = (s) => s, ti = (s) => s, si = (s) => s, ni = (s) => ({
|
|
4685
4686
|
widget: "boolean",
|
|
4686
4687
|
...s
|
|
4687
|
-
}),
|
|
4688
|
+
}), ii = (s) => ({
|
|
4688
4689
|
widget: "code",
|
|
4689
4690
|
...s
|
|
4690
|
-
}),
|
|
4691
|
+
}), ri = (s) => ({
|
|
4691
4692
|
widget: "color",
|
|
4692
4693
|
...s
|
|
4693
|
-
}),
|
|
4694
|
+
}), oi = (s) => ({ widget: "datetime", ...s }), li = (s) => ({
|
|
4694
4695
|
widget: "hidden",
|
|
4695
4696
|
...s
|
|
4696
|
-
}),
|
|
4697
|
+
}), ai = (s) => ({
|
|
4697
4698
|
widget: "file",
|
|
4698
4699
|
...s
|
|
4699
|
-
}),
|
|
4700
|
+
}), ci = (s) => ({
|
|
4700
4701
|
widget: "image",
|
|
4701
4702
|
...s
|
|
4702
|
-
}),
|
|
4703
|
+
}), fi = (s) => ({
|
|
4703
4704
|
widget: "list",
|
|
4704
4705
|
...s
|
|
4705
|
-
}),
|
|
4706
|
+
}), ui = (s) => ({
|
|
4706
4707
|
widget: "map",
|
|
4707
4708
|
...s
|
|
4708
|
-
}),
|
|
4709
|
+
}), hi = (s) => ({
|
|
4709
4710
|
widget: "number",
|
|
4710
4711
|
...s
|
|
4711
|
-
}),
|
|
4712
|
+
}), di = (s) => ({
|
|
4712
4713
|
widget: "object",
|
|
4713
4714
|
...s
|
|
4714
|
-
}),
|
|
4715
|
+
}), pi = (s) => ({ widget: "relation", ...s }), mi = (s) => ({
|
|
4715
4716
|
widget: "select",
|
|
4716
4717
|
...s
|
|
4717
|
-
}),
|
|
4718
|
+
}), gi = (s) => ({
|
|
4718
4719
|
widget: "string",
|
|
4719
4720
|
...s
|
|
4720
|
-
}),
|
|
4721
|
+
}), yi = (s) => ({
|
|
4721
4722
|
widget: "text",
|
|
4722
4723
|
...s
|
|
4723
4724
|
}), Qn = async (s) => {
|
|
@@ -4745,7 +4746,7 @@ const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4745
4746
|
const i = t ?? await xn(Te.join(rt, e)), r = Gn.stringify(i);
|
|
4746
4747
|
await Hn(r, Te.join(rt, n, "config.yml"));
|
|
4747
4748
|
};
|
|
4748
|
-
async function
|
|
4749
|
+
async function bi(s) {
|
|
4749
4750
|
return {
|
|
4750
4751
|
name: "vite-plugin-netlify-cms",
|
|
4751
4752
|
buildStart: async () => {
|
|
@@ -4757,23 +4758,23 @@ async function yi(s) {
|
|
|
4757
4758
|
};
|
|
4758
4759
|
}
|
|
4759
4760
|
export {
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4761
|
+
bi as default,
|
|
4762
|
+
ni as defineBooleanWidget,
|
|
4763
|
+
ii as defineCodeWidget,
|
|
4764
|
+
ri as defineColorWidget,
|
|
4765
|
+
ei as defineConfig,
|
|
4766
|
+
oi as defineDateTimeWidget,
|
|
4767
|
+
si as defineFileCollection,
|
|
4768
|
+
ai as defineFileWidget,
|
|
4769
|
+
ti as defineFolderCollection,
|
|
4770
|
+
li as defineHiddenWidget,
|
|
4771
|
+
ci as defineImageWidget,
|
|
4772
|
+
fi as defineListWidget,
|
|
4773
|
+
ui as defineMapWidget,
|
|
4774
|
+
hi as defineNumberWidget,
|
|
4775
|
+
di as defineObjectWidget,
|
|
4776
|
+
pi as defineRelationWidget,
|
|
4777
|
+
mi as defineSelectWidget,
|
|
4778
|
+
gi as defineStringWidget,
|
|
4779
|
+
yi as defineTextWidget
|
|
4779
4780
|
};
|
package/package.json
CHANGED