prismic 1.23.0 → 1.24.0
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/adapters-CuXozoyY.mjs +189 -0
- package/dist/{auth-NkX7Docj.mjs → auth-CsokWsVo.mjs} +2 -2
- package/dist/index.mjs +94 -94
- package/dist/{nextjs-TJI3bKFA.mjs → nextjs-D65xFGap.mjs} +51 -51
- package/dist/{nuxt-DfWyc1bJ.mjs → nuxt-YzpEi3A5.mjs} +11 -11
- package/dist/package-DCbOjRWH.mjs +1 -0
- package/dist/packageJson-B1_pkZr8.mjs +2 -0
- package/dist/request-Dx4vx1nN.mjs +30 -0
- package/dist/{segment-yGieXuDf.mjs → segment-DkMwCXor.mjs} +1 -1
- package/dist/subprocesses/refreshToken.mjs +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/sveltekit-7mpC1weE.mjs +273 -0
- package/dist/sveltekit-CpIdkani.mjs +1 -0
- package/dist/sveltekit2-C9cZPBvU.mjs +50 -0
- package/dist/{update-notifier-ChP_LYxw.mjs → update-notifier-d8fLG6jz.mjs} +1 -1
- package/package.json +7 -7
- package/dist/adapters-Bt9QKcJb.mjs +0 -191
- package/dist/package-Dyw1b366.mjs +0 -1
- package/dist/packageJson-Bxht6H4y.mjs +0 -2
- package/dist/request-DJTl_0US.mjs +0 -30
- package/dist/sveltekit-CC1sBn9O.mjs +0 -302
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import{C as e,F as t,I as n,M as r,N as i,P as a,_ as o,b as s,c,d as l,f as u,h as d,k as f,l as p,m,s as h,u as g,v as _,w as v,z as y}from"./request-Dx4vx1nN.mjs";import{m as b,r as x}from"./auth-CsokWsVo.mjs";import{a as S,l as C,r as w,t as ee}from"./packageJson-B1_pkZr8.mjs";import"node:module";import{parseArgs as T}from"node:util";import{readFile as E,realpath as D,rm as O,writeFile as te}from"node:fs/promises";import{sep as ne}from"node:path";import{fileURLToPath as k,pathToFileURL as A}from"node:url";import*as re from"node:crypto";import{createHash as ie}from"node:crypto";import*as j from"fs";import{readdir as M,readdirSync as N,realpath as P,realpathSync as F,stat as I,statSync as L}from"fs";import{basename as R,dirname as z,isAbsolute as B,normalize as V,posix as H,relative as ae,resolve as oe,sep as U}from"path";import{fileURLToPath as W}from"url";import{createRequire as G}from"module";var se=Object.create,ce=Object.defineProperty,le=Object.getOwnPropertyDescriptor,ue=Object.getOwnPropertyNames,de=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty,pe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),me=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ue(t),a=0,o=i.length,s;a<o;a++)s=i[a],!fe.call(e,s)&&s!==n&&ce(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=le(t,s))||r.enumerable});return e},he=(e,t,n)=>(n=e==null?{}:se(de(e)),me(t||!e||!e.__esModule||!fe.call(e,`default`)?ce(n,`default`,{value:e,enumerable:!0}):n,e));const ge=/([\p{Ll}\d])(\p{Lu})/gu,_e=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,ve=/(\d)\p{Ll}|(\p{L})\d/u,ye=/[^\p{L}\d]+/giu,be=`$1\0$2`;function xe(e){let t=e.trim();t=t.replace(ge,be).replace(_e,be),t=t.replace(ye,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}function Se(e){let t=xe(e);for(let e=0;e<t.length;e++){let n=t[e],r=ve.exec(n);if(r){let i=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,i),n.slice(i))}}return t}function Ce(e,t){let[n,r,i]=Me(e,t);return n+r.map(Oe(t?.locale)).join(t?.delimiter??` `)+i}function we(e,t){let[n,r,i]=Me(e,t),a=Oe(t?.locale),o=ke(t?.locale),s=t?.mergeAmbiguousCharacters?Ae(a,o):je(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function Te(e,t){let[n,r,i]=Me(e,t),a=Oe(t?.locale),o=ke(t?.locale),s=t?.mergeAmbiguousCharacters?Ae(a,o):je(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function Ee(e,t){let[n,r,i]=Me(e,t),a=Oe(t?.locale),o=ke(t?.locale);return n+r.map(Ae(a,o)).join(t?.delimiter??` `)+i}function De(e,t){return Ce(e,{delimiter:`_`,...t})}function Oe(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function ke(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function Ae(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function je(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function Me(e,t={}){let n=t.split??(t.separateNumbers?Se:xe),r=t.prefixCharacters??``,i=t.suffixCharacters??``,a=0,o=e.length;for(;a<e.length;){let t=e.charAt(a);if(!r.includes(t))break;a++}for(;o>a;){let t=o-1,n=e.charAt(t);if(!i.includes(n))break;o=t}return[e.slice(0,a),n(e.slice(a,o)),e.slice(o)]}function Ne(e,t){return(!e||e.endsWith(`
|
|
2
|
+
`))&&!t?.force?e:e+`
|
|
3
|
+
`}function K(e,t){return Ne(t)+e}function Pe(e,t){return(!e||e.endsWith(`
|
|
4
|
+
|
|
5
|
+
`))&&!t?.force?e:Ne(e)+`
|
|
6
|
+
`}function q(e,t){return Pe(t)+e}function Fe(e){return e.filter(Boolean).join(` | `)||`never`}function Ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Le(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ie(Object(n),!0).forEach(function(t){Re(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ie(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Re(e,t,n){return t=ze(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ze(e){var t=Be(e,`string`);return typeof t==`symbol`?t:String(t)}function Be(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}const Ve=He({});function He(e){return t.withOptions=t=>He(Le(Le({},e),t)),t;function t(t,...n){let r=typeof t==`string`?[t]:t.raw,{alignValues:i=!1,escapeSpecialCharacters:a=Array.isArray(t),trimWhitespace:o=!0}=e,s=``;for(let e=0;e<r.length;e++){let t=r[e];if(a&&(t=t.replace(/\\\n[ \t]*/g,``).replace(/\\`/g,"`").replace(/\\\$/g,`$`).replace(/\\\{/g,`{`)),s+=t,e<n.length){let t=i?Ue(n[e],s):n[e];s+=t}}let c=s.split(`
|
|
7
|
+
`),l=null;for(let e of c){let t=e.match(/^(\s+)\S+/);if(t){let e=t[1].length;l=l?Math.min(l,e):e}}if(l!==null){let e=l;s=c.map(t=>t[0]===` `||t[0]===` `?t.slice(e):t).join(`
|
|
8
|
+
`)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
|
|
9
|
+
`).replace(/\\t/g,` `).replace(/\\r/g,`\r`).replace(/\\v/g,`\v`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\0/g,`\0`).replace(/\\x([\da-fA-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/\\u([\da-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))),typeof Bun<`u`&&(s=s.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,(e,t,n)=>{let r=t??n??``;return String.fromCodePoint(parseInt(r,16))})),s}}function Ue(e,t){if(typeof e!=`string`||!e.includes(`
|
|
10
|
+
`))return e;let n=t.slice(t.lastIndexOf(`
|
|
11
|
+
`)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}const We=Ve.withOptions({alignValues:!0}),J=(e,...t)=>{let n=Array.from(e);return We(Object.assign(n,{raw:n}),...t)},Ge=`https://prismic.io/docs/slices`,Ke={UID:`https://prismic.io/docs/fields/uid`,Boolean:`https://prismic.io/docs/fields/boolean`,Color:`https://prismic.io/docs/fields/color`,Date:`https://prismic.io/docs/fields/date`,Timestamp:`https://prismic.io/docs/fields/timestamp`,Number:`https://prismic.io/docs/fields/number`,Text:`https://prismic.io/docs/fields/text`,Select:`https://prismic.io/docs/fields/select`,StructuredText:`https://prismic.io/docs/fields/rich-text`,Image:`https://prismic.io/docs/fields/image`,Link:{contentRelationship:`https://prismic.io/docs/fields/content-relationship`,link:`https://prismic.io/docs/fields/link`,linkToMedia:`https://prismic.io/docs/fields/link-to-media`},Embed:`https://prismic.io/docs/fields/embed`,GeoPoint:`https://prismic.io/docs/fields/geopoint`,Table:`https://prismic.io/docs/fields/table`,Group:`https://prismic.io/docs/fields/repeatable-group`,IntegrationFields:`https://prismic.io/docs/fields/integration`,Slices:`https://prismic.io/docs/slices`,Choice:`https://prismic.io/docs/slices`},Y=(...e)=>{let t=Te(e.filter(Boolean).join(` `).replace(/[^A-Z0-9]+/gi,` `),{mergeAmbiguousCharacters:!0});return/^[0-9]/.test(t)&&(t=`_${t}`),t},qe=e=>{if(`json`in e.model)return e.model.label||e.model.id;if(`type`in e.model&&e.model.type===`SharedSlice`)return e.model.name;if(`type`in e.model&&e.model.type===`Slice`)return e.model.fieldset||e.name;if(`type`in e.model){if(e.model.config&&`label`in e.model.config)return e.model.config.label||e.name;if(e.model.config&&`fieldset`in e.model)return e.model.fieldset||e.name}return`\`${e.name}\``};function Je(e){return e.path.map(e=>e.label?e.label:e.model?qe({model:e.model,name:e.name}):e.name).join(` → `)}function Ye(e){let t=``;for(let n=0;n<e.path.length;n++){n>0&&(t+=`.`);let r=e.path[n];if(r.model&&`type`in r.model&&(r.model.type===`Group`||r.model.type===`Slices`))t+=`${r.name}[]`;else{if(r.name===`items`){let i=e.path[n-1];if(i.model&&`json`in i.model||i.model&&`type`in i.model&&i.model.type===`SharedSlice`){t+=`${r.name}[]`;continue}}t+=r.name}}return t}function Xe(e){switch(e.field.type){case`StructuredText`:return`Rich Text`;case`IntegrationFields`:{let t=e.field.config?.catalog;return`Integration Fields (Catalog: ${t?`\`${t}\``:`*unknown*`})`}case`Link`:switch(e.field.config?.select){case`document`:return`Content Relationship`;case`media`:return`Link to Media`;default:return`Link`}case`Slices`:return`Slice Zone`;default:return e.field.type}}function Ze(e){switch(e.field.type){case`Link`:{let t=Ke.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Ke[e.field.type];if(typeof t==`string`)return t}}}function Qe(e){let t=`/**`,n=qe({model:e.field,name:e.name}),r=Je({path:e.path}),i=Xe({field:e.field});t=K(` * ${n} field in *${r}*`,t),t=K(` *`,t),t=K(` * - **Field Type**: ${i}`,t),t=K(` * - **Placeholder**: ${e.field.config&&`placeholder`in e.field.config&&e.field.config.placeholder||`*None*`}`,t);let a=e.field.config&&`default_value`in e.field.config?e.field.config.default_value:void 0;a!==void 0&&(t=K(` * - **Default Value**: ${typeof a==`boolean`?`${a}`:a}`,t)),t=K(` * - **API ID Path**: ${Ye({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=K(` * - **Tab**: ${e.tabName}`,t));let o=Ze({field:e.field});return o&&(t=K(` * - **Documentation**: ${o}`,t)),t=K(` */`,t),t}const $e={Boolean:`Boolean`,Color:`Color`,Date:`Date`,Embed:`Embed`,GeoPoint:`GeoPoint`,Group:`Group`,Image:`Image`,Integration:`IntegrationFields`,Link:`Link`,Number:`Number`,Select:`Select`,Slices:`Slices`,StructuredText:`StructuredText`,Table:`Table`,Text:`Text`,Timestamp:`Timestamp`,UID:`UID`,IntegrationFields:`IntegrationFields`,Range:`Range`,Separator:`Separator`,LegacySlices:`Choice`};function et(e){let t=Qe({name:e.name,field:e.field,path:e.path,tabName:e.tabName}),n=[],r=[],i=e.name.includes(`-`)||e.name.includes(`:`)||/^[0-9]/.test(e.name)?`"${e.name}"`:e.name;switch(e.field.type){case`UID`:break;case`Boolean`:t=K(`${i}: prismic.BooleanField;`,t);break;case`Color`:t=K(`${i}: prismic.ColorField;`,t);break;case`Date`:t=K(`${i}: prismic.DateField;`,t);break;case`Embed`:{let n=[];if(e.fieldConfigs.embed?.providerTypes)for(let t in e.fieldConfigs.embed?.providerTypes){let r=e.fieldConfigs.embed?.providerTypes[t];n.push(`({ provider_name: "${t}" } & ${r})`)}let r=Fe(n);t=n.length>0?K(`${i}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${r})>`,t):K(`${i}: prismic.EmbedField`,t);break}case`GeoPoint`:t=K(`${i}: prismic.GeoPointField;`,t);break;case`Image`:t=e.field.config?.thumbnails&&e.field.config.thumbnails.length>0?K(`${i}: prismic.ImageField<${Fe(e.field.config.thumbnails.map(e=>`"${e.name}"`))}>;`,t):K(`${i}: prismic.ImageField<never>;`,t);break;case`IntegrationFields`:{let n=e.field.config?.catalog?e.fieldConfigs.integrationFields?.catalogTypes?.[e.field.config.catalog]:void 0;t=K(n?`${i}: prismic.IntegrationField<${n}>;`:`${i}: prismic.IntegrationField;`,t);break}case`Link`:{let n=e.field.config&&`variants`in e.field.config&&Array.isArray(e.field.config.variants)&&e.field.config.variants.length>0?e.field.config.variants.map(e=>`"${e.replace(/"/g,`\\"`)}"`).join(` | `):`never`;switch(e.field.config?.select){case`document`:t=`customtypes`in e.field.config&&e.field.config.customtypes&&e.field.config.customtypes.length>0?K(`${i}: ${Fe(e.field.config.customtypes.map(e=>typeof e==`string`?`prismic.ContentRelationshipField<"${e}">`:`ContentRelationshipFieldWithData<${JSON.stringify([e])}>`))};`,t):K(`${i}: prismic.ContentRelationshipField;`,t);break;case`media`:t=K(`${i}: prismic.LinkToMediaField<prismic.FieldState, ${n}>;`,t);break;default:{let r=`prismic.LinkField<string, string, unknown, prismic.FieldState, ${n}>`;e.field.config?.repeat&&(r=`prismic.Repeatable<${r}>`),t=K(`${i}: ${r};`,t);break}}break}case`Number`:t=K(`${i}: prismic.NumberField;`,t);break;case`StructuredText`:t=K(`${i}: prismic.RichTextField;`,t);break;case`Select`:{let n=e.field.config?.options?.map(e=>`"${e}"`)||[],r=n.length?Fe(n):`string`;t=e.field.config?.default_value?K(`${i}: prismic.SelectField<${r}, "filled">;`,t):K(`${i}: prismic.SelectField${n.length>0?`<${r}>`:``};`,t);break}case`Table`:t=K(`${i}: prismic.TableField;`,t);break;case`Text`:t=K(`${i}: prismic.KeyTextField;`,t);break;case`Timestamp`:t=K(`${i}: prismic.TimestampField;`,t);break;case`Group`:{let a=e.path.filter(e=>e.model!==void 0&&`type`in e.model&&e.model.type===$e.Group),o=a.length>0,s;if(e.path[0].model&&`type`in e.path[0].model&&e.path[0].model.type===`SharedSlice`){let[t,n,r]=e.path;s=Y(t.name,`Slice`,n.name,r.name,...a.map(e=>e.name),e.name,`Item`)}else s=Y(e.path[0].name,`Document`,`Data`,...a.map(e=>e.name),e.name,`Item`);let c=[...e.path,{name:i,model:e.field}],l=Je({path:c}),u=tt({fields:e.field.config?.fields||{},fieldConfigs:e.fieldConfigs,path:c});n.push(...u.auxiliaryTypes),r.push(...u.contentTypeNames),n.push({name:s,code:J`
|
|
12
|
+
/**
|
|
13
|
+
* Item in *${l}*
|
|
14
|
+
*/
|
|
15
|
+
export interface ${s} {
|
|
16
|
+
${u.code}
|
|
17
|
+
}
|
|
18
|
+
`}),r.push(s),t=K(o?`${i}: prismic.NestedGroupField<Simplify<${s}>>;`:`${i}: prismic.GroupField<Simplify<${s}>>;`,t);break}case`Slices`:{let a=[];if(e.field.config?.choices)for(let t in e.field.config.choices){let i=e.field.config.choices[t];if(i.type===`SharedSlice`)a.push(Y(t,`Slice`));else if(i.type===`Slice`){let o=Y(e.path[0].name,`Document`,`Data`,e.name,t,`Slice`),s;if(i[`non-repeat`]&&Object.keys(i[`non-repeat`]).length>0){s=Y(o,`Primary`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`primary`,label:`Primary`}],c=Je({path:a}),l=tt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=J`
|
|
19
|
+
/**
|
|
20
|
+
* Primary content in *${c}*
|
|
21
|
+
*/
|
|
22
|
+
`;u=l.code?K(J`
|
|
23
|
+
export interface ${s} {
|
|
24
|
+
${l.code}
|
|
25
|
+
}
|
|
26
|
+
`,u):K(`export interface ${s} {}`,u),n.push({name:s,code:u}),r.push(s)}let c;if(i.repeat&&Object.keys(i.repeat).length>0){c=Y(o,`Item`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`items`,label:`Items`}],s=Je({path:a}),l=tt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=J`
|
|
27
|
+
/**
|
|
28
|
+
* Item content in *${s}*
|
|
29
|
+
*/
|
|
30
|
+
`;u=l.code?K(J`
|
|
31
|
+
export interface ${c} {
|
|
32
|
+
${l.code}
|
|
33
|
+
}
|
|
34
|
+
`,u):K(`export interface ${c} {}`,u),n.push({name:c,code:u}),r.push(c)}n.push({name:o,code:J`
|
|
35
|
+
/**
|
|
36
|
+
* Slice for *${Je({path:[...e.path,{name:e.name,model:e.field}]})}*
|
|
37
|
+
*/
|
|
38
|
+
export type ${o} = prismic.Slice<"${t}", ${s?`Simplify<${s}>`:`Record<string, never>`}, ${c?`Simplify<${c}>`:`never`}>
|
|
39
|
+
`}),a.push(o)}}let o=Y(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=Fe(a);n.push({name:o,code:`type ${o} = ${s}`}),r.push(o),t=K(`${i}: prismic.SliceZone<${o}>;`,t);break}default:t=K(`${i}: unknown;`,t)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function tt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=et({name:i,field:a,path:e.path,fieldConfigs:e.fieldConfigs,tabName:e.tabName});t=q(o.code,t),n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function nt(e){let t=``,n=[],r=[],i=Y(e.model.id,`Document`,`Data`),a=qe({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=tt({fields:a,fieldConfigs:e.fieldConfigs,path:[{name:e.model.id,model:e.model}],tabName:t});o+=s.code,n.push(...s.auxiliaryTypes),r.push(...s.contentTypeNames)}return t=o?J`
|
|
40
|
+
/**
|
|
41
|
+
* Content for ${a} documents
|
|
42
|
+
*/
|
|
43
|
+
interface ${i} {
|
|
44
|
+
${o}
|
|
45
|
+
}
|
|
46
|
+
`:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function rt(e){return`uid`in Object.assign({},...Object.values(e.json))}const it=e=>re.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function at(e){if(e.cache){let t=it(e.model),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=Y(e.model.id,`Document`),a=e.localeIDs&&e.localeIDs.length>0?Fe(e.localeIDs.map(e=>`"${e}"`)):`string`,o=rt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=qe({name:e.model.id,model:e.model}),c=nt({model:e.model,fieldConfigs:e.fieldConfigs});n.push(...c.auxiliaryTypes),r.push(c.name),r.push(...c.contentTypeNames),t=q(c.code,t),t=q(J`
|
|
47
|
+
/**
|
|
48
|
+
* ${s} document from Prismic
|
|
49
|
+
*
|
|
50
|
+
* - **API ID**: \`${e.model.id}\`
|
|
51
|
+
* - **Repeatable**: \`${e.model.repeatable.toString()}\`
|
|
52
|
+
* - **Documentation**: ${`https://prismic.io/docs/content-modeling`}
|
|
53
|
+
*
|
|
54
|
+
* @typeParam Lang - Language API ID of the document.
|
|
55
|
+
*/
|
|
56
|
+
export type ${i}<Lang extends string = ${a}> = prismic.${o}<Simplify<${c.name}>, "${e.model.id}", Lang>;
|
|
57
|
+
`,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=it(e.model);e.cache.set(t,l)}return l}function ot(e){if(e.cache){let t=it([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=Y(e.model.id,`Slice`),a=qe({name:e.model.id,model:e.model}),o=[];for(let s of e.model.variations){let c=Y(i,s.id),l;if(s.primary&&Object.keys(s.primary).length>0){l=Y(c,`Primary`);let i=[{name:e.model.id,model:e.model},{name:s.id,label:s.name},{name:`primary`,label:`Primary`}],a=Je({path:i}),o=tt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=J`
|
|
58
|
+
/**
|
|
59
|
+
* Primary content in *${a}*
|
|
60
|
+
*/
|
|
61
|
+
`;t=q(o.code?J`
|
|
62
|
+
${u}
|
|
63
|
+
export interface ${l} {
|
|
64
|
+
${o.code}
|
|
65
|
+
}
|
|
66
|
+
`:J`
|
|
67
|
+
${u}
|
|
68
|
+
export interface ${l} {}
|
|
69
|
+
`,t)}let u;if(s.items&&Object.keys(s.items).length>0){u=Y(c,`Item`);let i=[{name:e.model.id,model:e.model},{name:`items`,label:`Items`}],a=Je({path:i}),o=tt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=J`
|
|
70
|
+
/**
|
|
71
|
+
* Primary content in *${a}*
|
|
72
|
+
*/
|
|
73
|
+
`;t=q(o.code?J`
|
|
74
|
+
${l}
|
|
75
|
+
export interface ${u} {
|
|
76
|
+
${o.code}
|
|
77
|
+
}
|
|
78
|
+
`:J`
|
|
79
|
+
${l}
|
|
80
|
+
export interface ${u} {}
|
|
81
|
+
`,t)}t=q(J`
|
|
82
|
+
/**
|
|
83
|
+
* ${s.name} variation for ${a} Slice
|
|
84
|
+
*
|
|
85
|
+
* - **API ID**: \`${s.id}\`
|
|
86
|
+
* - **Description**: ${s.description||`*None*`}
|
|
87
|
+
* - **Documentation**: ${Ge}
|
|
88
|
+
*/
|
|
89
|
+
export type ${c} = prismic.SharedSliceVariation<"${s.id}", ${l?`Simplify<${l}>`:`Record<string, never>`}, ${u?`Simplify<${u}>`:`never`}>;
|
|
90
|
+
`,t),o.push(c)}let s=Y(i,`Variation`),c=Fe(o);r.push(s),r.push(...o),t=q(J`
|
|
91
|
+
/**
|
|
92
|
+
* Slice variation for *${a}*
|
|
93
|
+
*/
|
|
94
|
+
type ${s} = ${o.length>0?c:`never`}
|
|
95
|
+
`,t),t=q(J`
|
|
96
|
+
/**
|
|
97
|
+
* ${a} Shared Slice
|
|
98
|
+
*
|
|
99
|
+
* - **API ID**: \`${e.model.id}\`
|
|
100
|
+
* - **Description**: ${e.model.description||`*None*`}
|
|
101
|
+
* - **Documentation**: ${Ge}
|
|
102
|
+
*/
|
|
103
|
+
export type ${i} = prismic.SharedSlice<"${e.model.id}", ${s}>;
|
|
104
|
+
`,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=it([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const st=new class extends Map{#e=0;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;#r;#i;#a;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.#r=e.maxSize,this.#i=e.maxAge||1/0,this.#a=e.onEviction}get __oldCache(){return this.#n}#o(e){if(typeof this.#a==`function`)for(let[t,n]of e)this.#a(t,n.value)}#s(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()&&(typeof this.#a==`function`&&this.#a(e,t.value),this.delete(e))}#c(e,t){if(this.#s(e,t)===!1)return t.value}#l(e,t){return t.expiry?this.#c(e,t):t.value}#u(e,t){let n=t.get(e);return this.#l(e,n)}#d(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#r&&(this.#e=0,this.#o(this.#n),this.#n=this.#t,this.#t=/* @__PURE__ */ new Map)}#f(e,t){this.#n.delete(e),this.#d(e,t)}*#p(){for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield e)}for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield e)}}get(e){if(this.#t.has(e)){let t=this.#t.get(e);return this.#l(e,t)}if(this.#n.has(e)){let t=this.#n.get(e);if(this.#s(e,t)===!1)return this.#f(e,t),t.value}}set(e,t,{maxAge:n=this.#i}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:r}):this.#d(e,{value:t,expiry:r}),this}has(e){return this.#t.has(e)?!this.#s(e,this.#t.get(e)):this.#n.has(e)?!this.#s(e,this.#n.get(e)):!1}peek(e){if(this.#t.has(e))return this.#u(e,this.#t);if(this.#n.has(e))return this.#u(e,this.#n)}expiresIn(e){let t=this.#t.get(e)??this.#n.get(e);if(t)return t.expiry?t.expiry-Date.now():1/0}delete(e){let t=this.#t.delete(e);return t&&this.#e--,this.#n.delete(e)||t}clear(){this.#t.clear(),this.#n.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this.#p()],n=t.length-e;n<0?(this.#t=new Map(t),this.#n=/* @__PURE__ */ new Map,this.#e=t.length):(n>0&&this.#o(t.slice(0,n)),this.#n=new Map(t.slice(n)),this.#t=/* @__PURE__ */ new Map,this.#e=0),this.#r=e}evict(e=1){let t=Number(e);if(!t||t<=0)return;let n=[...this.#p()],r=Math.trunc(Math.min(t,Math.max(n.length-1,0)));r<=0||(this.#o(n.slice(0,r)),this.#n=new Map(n.slice(r)),this.#t=/* @__PURE__ */ new Map,this.#e=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield[t,n.value])}for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#s(n,r)===!1&&(yield[n,r.value])}e=[...this.#n];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#t.has(n)||this.#s(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this.#p())yield[e,t.value]}get size(){if(!this.#e)return this.#n.size;let e=0;for(let t of this.#n.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#r)}get maxSize(){return this.#r}get maxAge(){return this.#i}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return`QuickLRU`}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}}({maxSize:1e3});function ct(e={}){let t=e.fieldConfigs||{},n=e.cache??!0,r=``,i=e.typesProvider||`@prismicio/types`,a=`prismic`;r=K(`import type * as prismic from "${i}";`,r),(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace)&&i!==`@prismicio/client`&&(a=`prismicClient`,r=K(`import type * as ${a} from "@prismicio/client";`,r)),r=q(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`,r),r=q(`
|
|
105
|
+
type PickContentRelationshipFieldData<
|
|
106
|
+
TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
|
|
107
|
+
TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
|
|
108
|
+
TLang extends string
|
|
109
|
+
> = |
|
|
110
|
+
// Content relationship fields
|
|
111
|
+
{
|
|
112
|
+
[TSubRelationship in Extract<
|
|
113
|
+
TRelationship["fields"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1
|
|
114
|
+
> as TSubRelationship["id"]]:
|
|
115
|
+
ContentRelationshipFieldWithData<TSubRelationship["customtypes"], TLang>;
|
|
116
|
+
} &
|
|
117
|
+
// Group
|
|
118
|
+
{
|
|
119
|
+
[TGroup in Extract<
|
|
120
|
+
TRelationship["fields"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2
|
|
121
|
+
> as TGroup["id"]]:
|
|
122
|
+
TData[TGroup["id"]] extends prismic.GroupField<infer TGroupData>
|
|
123
|
+
? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>
|
|
124
|
+
: never
|
|
125
|
+
} &
|
|
126
|
+
// Other fields
|
|
127
|
+
{
|
|
128
|
+
[TFieldKey in Extract<TRelationship["fields"][number], string>]:
|
|
129
|
+
TFieldKey extends keyof TData ? TData[TFieldKey] : never;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type ContentRelationshipFieldWithData<
|
|
133
|
+
TCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],
|
|
134
|
+
TLang extends string = string
|
|
135
|
+
> = {
|
|
136
|
+
[ID in Exclude<TCustomType[number], string>["id"]]:
|
|
137
|
+
prismic.ContentRelationshipField<
|
|
138
|
+
ID,
|
|
139
|
+
TLang,
|
|
140
|
+
PickContentRelationshipFieldData<
|
|
141
|
+
Extract<TCustomType[number], { id: ID }>,
|
|
142
|
+
Extract<prismic.Content.AllDocumentTypes, { type: ID }>["data"],
|
|
143
|
+
TLang
|
|
144
|
+
>
|
|
145
|
+
>
|
|
146
|
+
}[Exclude<TCustomType[number], string>["id"]];
|
|
147
|
+
`,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=at({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?st:void 0});for(let e of s.auxiliaryTypes)r=q(e.code,r);r=q(s.code,r),i.push(s.name),o.push(s.name),o.push(...s.contentTypeNames)}if(e.customTypeModels.length>0){let e=`AllDocumentTypes`;r=q(`export type ${e} = ${Fe(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=ot({model:i,fieldConfigs:t,cache:n?st:void 0});for(let t of e.auxiliaryTypes)r=q(t.code,r);r=q(e.code,r),o.push(e.name),o.push(...e.contentTypeNames)}if(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace){let t=``;e.clientIntegration.includeCreateClientInterface&&((e.customTypeModels?.length||0)>0?(t=q(`interface CreateClient {
|
|
148
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client<AllDocumentTypes>;
|
|
149
|
+
}`,t),t=q(`interface CreateWriteClient {
|
|
150
|
+
(repositoryNameOrEndpoint: string, options: ${a}.WriteClientConfig): ${a}.WriteClient<AllDocumentTypes>;
|
|
151
|
+
}`,t),t=q(`interface CreateMigration {
|
|
152
|
+
(): ${a}.Migration<AllDocumentTypes>;
|
|
153
|
+
}`,t)):(t=q(`interface CreateClient {
|
|
154
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client;
|
|
155
|
+
}`,t),t=q(`interface CreateWriteClient {
|
|
156
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.WriteClientConfig): ${a}.WriteClient;
|
|
157
|
+
}`,t),t=q(`interface CreateMigration {
|
|
158
|
+
(): ${a}.Migration;
|
|
159
|
+
}`,t))),e.clientIntegration.includeContentNamespace&&(t=q(J`
|
|
160
|
+
namespace Content {
|
|
161
|
+
export type {
|
|
162
|
+
${o.join(`,
|
|
163
|
+
`)}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`,t)),r=q(J`
|
|
167
|
+
declare module "@prismicio/client" {
|
|
168
|
+
${t}
|
|
169
|
+
}
|
|
170
|
+
`,r)}return r}var lt=/* @__PURE__ */ G(import.meta.url);function ut(e){let t=V(e);return t.length>1&&t[t.length-1]===U&&(t=t.substring(0,t.length-1)),t}const dt=/[\\/]/g;function ft(e,t){return e.replace(dt,t)}const pt=/^[a-z]:[\\/]$/i;function mt(e){return e===`/`||pt.test(e)}function ht(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=oe(e)),(r||a)&&(e=ut(e)),e===`.`?``:ft(e[e.length-1]===i?e:e+i,i)}function gt(e,t){return t+e}function _t(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:ft(ae(e,r),t.pathSeparator)+t.pathSeparator+n}}function vt(e){return e}function yt(e,t,n){return t+e+n}function bt(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?_t(e,t):r?gt:vt}function xt(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function St(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const Ct=(e,t)=>{t.push(e||`.`)},wt=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},Tt=()=>{};function Et(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?St(e):xt(e):r&&r.length?wt:Ct:Tt}const Dt=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Ot=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},kt=(e,t,n,r)=>{n.files++},At=(e,t)=>{t.push(e)},jt=()=>{};function Mt(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?jt:n&&n.length?r?Dt:Ot:r?kt:At}const Nt=e=>e,Pt=()=>[``].slice(0,0);function Ft(e){return e.group?Pt:Nt}const It=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},Lt=()=>{};function Rt(e){return e.group?It:Lt}const zt=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Ht(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Bt=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Ht(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Vt(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Bt:zt}function Ht(e,t,n){if(n.options.useRealPaths)return Ut(t,n);let r=z(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=z(r)}return n.symlinks.set(e,t),i>1}function Ut(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Wt=e=>e.counts,Gt=e=>e.groups,Kt=e=>e.paths,qt=e=>e.paths.slice(0,e.options.maxFiles),Jt=(e,t,n)=>(Qt(t,n,e.counts,e.options.suppressErrors),null),Yt=(e,t,n)=>(Qt(t,n,e.paths,e.options.suppressErrors),null),Xt=(e,t,n)=>(Qt(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Zt=(e,t,n)=>(Qt(t,n,e.groups,e.options.suppressErrors),null);function Qt(e,t,n,r){t(e&&!r?e:null,n)}function $t(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Wt:Jt:r?t?Gt:Zt:i?t?qt:Xt:t?Kt:Yt}const en={withFileTypes:!0},tn=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,en,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},nn=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,en)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function rn(e){return e?nn:tn}var an=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},on=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
|
|
171
|
+
/* c8 ignore next 3 */
|
|
172
|
+
get dirs(){return this._directories}},sn=class{aborted=!1;abort(){this.aborted=!0}},cn=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=$t(t,this.isSynchronous),this.root=ht(e,t),this.state={root:mt(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new on,options:t,queue:new an((e,t)=>this.callbackInvoker(t,e,n)),symlinks:/* @__PURE__ */ new Map,visited:[``].slice(0,0),controller:new sn,fs:t.fs||j},this.joinPath=bt(this.root,t),this.pushDirectory=Et(this.root,t),this.pushFile=Mt(t),this.getArray=Ft(t),this.groupFiles=Rt(t),this.resolveSymlink=Vt(t,this.isSynchronous),this.walkDirectory=rn(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:l,useRealPaths:u,pathSeparator:d},controller:f}=this.state;if(f.aborted||l&&l.aborted||c&&r.length>c)return;let p=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let l=e[c];if(l.isFile()||l.isSymbolicLink()&&!a&&!o){let e=this.joinPath(l.name,t);this.pushFile(e,p,this.state.counts,i)}else if(l.isDirectory()){let e=yt(l.name,t,this.state.options.pathSeparator);if(s&&s(l.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&l.isSymbolicLink()){let e=gt(l.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=ht(r,this.state.options),s&&s(l.name,u?r:e+d))return;this.walkDirectory(this.state,r,u?r:e+d,n-1,this.walk)}else{r=u?r:e;let t=R(r),n=ht(z(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,p,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,p)}};function ln(e,t){return new Promise((n,r)=>{un(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function un(e,t,n){new cn(e,t,n).start()}function dn(e,t){return new cn(e,t).start()}var fn=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return ln(this.root,this.options)}withCallback(e){un(this.root,this.options,e)}sync(){return dn(this.root,this.options)}};let pn=null;
|
|
173
|
+
/* c8 ignore next 6 */
|
|
174
|
+
try{lt.resolve(`picomatch`),pn=lt(`picomatch`)}catch{}var mn=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:U,filters:[]};globFunction;constructor(e){this.options={...this.options,...e},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(e){return this.options.pathSeparator=e,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(e){return this.options.maxDepth=e,this}withMaxFiles(e){return this.options.maxFiles=e,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:e=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=e,this.withFullPaths()}withAbortSignal(e){return this.options.signal=e,this}normalize(){return this.options.normalizePath=!0,this}filter(e){return this.options.filters.push(e),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(e){return this.options.exclude=e,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(e){return new fn(e||`.`,this.options)}withGlobFunction(e){return this.globFunction=e,this}
|
|
175
|
+
/* c8 ignore next 4 */
|
|
176
|
+
crawlWithOptions(e,t){return this.options={...this.options,...t},new fn(e||`.`,this.options)}glob(...e){return this.globFunction?this.globWithOptions(e):this.globWithOptions(e,{dot:!0})}globWithOptions(e,...t){let n=this.globFunction||pn;
|
|
177
|
+
/* c8 ignore next 5 */
|
|
178
|
+
if(!n)throw Error(`Please specify a glob function to use glob matching.`);var r=this.globCache[e.join(`\0`)];return r||(r=n(e,...t),this.globCache[e.join(`\0`)]=r),this.options.filters.push(e=>r(e)),this}},hn=/* @__PURE__ */ pe(((e,t)=>{let n=`[^\\\\/]`,r=`[^/]`,i=`(?:\\/|$)`,a=`(?:^|\\/)`,o=`\\.{1,2}${i}`,s={DOT_LITERAL:`\\.`,PLUS_LITERAL:`\\+`,QMARK_LITERAL:`\\?`,SLASH_LITERAL:`\\/`,ONE_CHAR:`(?=.)`,QMARK:r,END_ANCHOR:i,DOTS_SLASH:o,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!${a}${o})`,NO_DOT_SLASH:`(?!\\.{0,1}${i})`,NO_DOTS_SLASH:`(?!${o})`,QMARK_NO_DOT:`[^.\\/]`,STAR:`${r}*?`,START_ANCHOR:a,SEP:`/`},c={...s,SLASH_LITERAL:`[\\\\/]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`\\.{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!\\.{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!\\.{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:`[^.\\\\/]`,START_ANCHOR:`(?:^|[\\\\/])`,END_ANCHOR:`(?:[\\\\/]|$)`,SEP:`\\`};t.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{__proto__:null,alnum:`a-zA-Z0-9`,alpha:`a-zA-Z`,ascii:`\\x00-\\x7F`,blank:` \\t`,cntrl:`\\x00-\\x1F\\x7F`,digit:`0-9`,graph:`\\x21-\\x7E`,lower:`a-z`,print:`\\x20-\\x7E `,punct:`\\-!"#$%&'()\\*+,./:;<=>?@[\\]^_\`{|}~`,space:` \\t\\r\\n\\v\\f`,upper:`A-Z`,word:`A-Za-z0-9_`,xdigit:`A-Fa-f0-9`},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":`*`,"**/**":`**`,"**/**/**":`**`},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:`negate`,open:`(?:(?!(?:`,close:`))${e.STAR})`},"?":{type:`qmark`,open:`(?:`,close:`)?`},"+":{type:`plus`,open:`(?:`,close:`)+`},"*":{type:`star`,open:`(?:`,close:`)*`},"@":{type:`at`,open:`(?:`,close:`)`}}},globChars(e){return e===!0?c:s}}})),gn=/* @__PURE__ */ pe((e=>{let{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:r,REGEX_SPECIAL_CHARS_GLOBAL:i}=hn();e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e),e.hasRegexChars=e=>r.test(e),e.isRegexChar=t=>t.length===1&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(i,`\\$1`),e.toPosixSlashes=e=>e.replace(t,`/`),e.isWindows=()=>{if(typeof navigator<`u`&&navigator.platform){let e=navigator.platform.toLowerCase();return e===`win32`||e===`windows`}return typeof process<`u`&&process.platform?process.platform===`win32`:!1},e.removeBackslashes=e=>e.replace(n,e=>e===`\\`?``:e),e.escapeLast=(t,n,r)=>{let i=t.lastIndexOf(n,r);return i===-1?t:t[i-1]===`\\`?e.escapeLast(t,n,i-1):`${t.slice(0,i)}\\${t.slice(i)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith(`./`)&&(n=n.slice(2),t.prefix=`./`),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?``:`^`}(?:${e})${n.contains?``:`$`}`;return t.negated===!0&&(r=`(?:^(?!${r}).*$)`),r},e.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:`/`),r=n[n.length-1];return r===``?n[n.length-2]:r}})),_n=/* @__PURE__ */ pe(((e,t)=>{let n=gn(),{CHAR_ASTERISK:r,CHAR_AT:i,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:l,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:d,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:p,CHAR_QUESTION_MARK:m,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:g,CHAR_RIGHT_SQUARE_BRACKET:_}=hn(),v=e=>e===l||e===a,y=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let b=t||{},x=e.length-1,S=b.parts===!0||b.tokens===!0||b.scanToEnd===!0,C=[],w=[],ee=[],T=e,E=-1,D=0,O=0,te=!1,ne=!1,k=!1,A=!1,re=!1,ie=!1,j=!1,M=!1,N=!1,P=!1,F=0,I,L,R={value:``,depth:0,isGlob:!1},z=()=>E>=x,B=()=>T.charCodeAt(E+1),V=()=>(I=L,T.charCodeAt(++E));for(;E<x;){L=V();let e;if(L===a)j=R.backslashes=!0,L=V(),L===u&&(ie=!0);else{if(ie===!0||L===u){for(F++;z()!==!0&&(L=V());)if(L===a)j=R.backslashes=!0,V();else if(L===u)F++;else{if(ie!==!0&&L===s&&(L=V())===s||ie!==!0&&L===o){if(te=R.isBrace=!0,k=R.isGlob=!0,P=!0,S===!0)continue;break}if(L===h&&(F--,F===0)){ie=!1,te=R.isBrace=!0,P=!0;break}}if(S===!0)continue;break}if(L===l){if(C.push(E),w.push(R),R={value:``,depth:0,isGlob:!1},P===!0)continue;if(I===s&&E===D+1){D+=2;continue}O=E+1}else{if(b.noext!==!0&&(L===p||L===i||L===r||L===m||L===c)&&B()===d){if(k=R.isGlob=!0,A=R.isExtglob=!0,P=!0,L===c&&E===D&&(N=!0),S===!0){let e=0;for(;z()!==!0&&(L=V());)if(L===a)j=R.backslashes=!0,V();else if(L===d)e++;else if(L===g&&--e===0){P=!0;break}continue}break}if(L===r){if(I===r&&(re=R.isGlobstar=!0),k=R.isGlob=!0,P=!0,S===!0)continue;break}if(L===m){if(k=R.isGlob=!0,P=!0,S===!0)continue;break}if(L===f){for(;z()!==!0&&(e=V());)if(e===a)j=R.backslashes=!0,V();else if(e===_){ne=R.isBracket=!0,k=R.isGlob=!0,P=!0;break}if(S===!0)continue;break}if(b.nonegate!==!0&&L===c&&E===D)M=R.negated=!0,D++;else{if(b.noparen!==!0&&L===d){if(k=R.isGlob=!0,S===!0){let e=1;for(;z()!==!0&&(L=V());)if(L===a)j=R.backslashes=!0,V();else if(L===d)e++;else if(L===g&&--e===0){P=!0;break}continue}break}if(k===!0){if(P=!0,S===!0)continue;break}}}}}b.noext===!0&&(A=!1,k=!1);let H=T,ae=``,oe=``;D>0&&(ae=T.slice(0,D),T=T.slice(D),O-=D),H&&k===!0&&O>0?(H=T.slice(0,O),oe=T.slice(O)):k===!0?(H=``,oe=T):H=T,H&&H!==``&&H!==`/`&&H!==T&&v(H.charCodeAt(H.length-1))&&(H=H.slice(0,-1)),b.unescape===!0&&(oe&&=n.removeBackslashes(oe),H&&j===!0&&(H=n.removeBackslashes(H)));let U={prefix:ae,input:e,start:D,base:H,glob:oe,isBrace:te,isBracket:ne,isGlob:k,isExtglob:A,isGlobstar:re,negated:M,negatedExtglob:N};if(b.tokens===!0&&(U.maxDepth=0,v(L)||w.push(R),U.tokens=w),b.parts===!0||b.tokens===!0){let t;for(let n=0;n<C.length;n++){let r=t===void 0?D:t+1,i=C[n],a=e.slice(r,i);b.tokens&&(n===0&&D!==0?(w[n].isPrefix=!0,w[n].value=ae):w[n].value=a,y(w[n]),U.maxDepth+=w[n].depth),i>=D&&(ee.push(a),t=i)}let n=t===void 0?D:t+1,r=e.slice(n);ee.push(r),b.tokens&&t&&t+1<e.length&&(w[w.length-1].value=r,y(w[w.length-1]),U.maxDepth+=w[w.length-1].depth),U.slashes=C,U.parts=ee}return U}})),vn=/* @__PURE__ */ pe(((e,t)=>{let n=hn(),r=gn(),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:c}=n,l=(e,t)=>{if(typeof t.expandRange==`function`)return t.expandRange(...e,t);e.sort();let n=`[${e.join(`-`)}]`;try{new RegExp(n)}catch{return e.map(e=>r.escapeRegex(e)).join(`..`)}return n},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,d=e=>{let t=[],n=0,r=0,i=0,a=``,o=!1;for(let s of e)if(o===!0)a+=s,o=!1;else if(s===`\\`)a+=s,o=!0;else if(s===`"`)i=i===1?0:1,a+=s;else{if(i===0){if(s===`[`)n++;else if(s===`]`&&n>0)n--;else if(n===0){if(s===`(`)r++;else if(s===`)`&&r>0)r--;else if(s===`|`&&r===0){t.push(a),a=``;continue}}}a+=s}return t.push(a),t},f=e=>{let t=!1;for(let n of e)if(t===!0)t=!1;else if(n===`\\`)t=!0;else if(/[?*+@!()[\]{}]/.test(n))return!1;return!0},p=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(f(t))return t.replace(/\\(.)/g,`$1`)},m=e=>{let t=e.map(p).filter(Boolean);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=t[e],i=t[n],a=r[0];if(a&&r===a.repeat(r.length)&&i===a.repeat(i.length)&&(r===i||r.startsWith(i)||i.startsWith(r)))return!0}return!1},h=(e,t=!0)=>{if(e[0]!==`+`&&e[0]!==`*`||e[1]!==`(`)return;let n=0,r=0,i=0,a=!1;for(let o=1;o<e.length;o++){let s=e[o];if(a===!0)a=!1;else if(s===`\\`)a=!0;else if(s===`"`)i=i===1?0:1;else if(i!==1){if(s===`[`)n++;else if(s===`]`&&n>0)n--;else if(!(n>0)){if(s===`(`)r++;else if(s===`)`&&(r--,r===0))return t===!0&&o!==e.length-1?void 0:{type:e[0],body:e.slice(2,o),end:o}}}}},g=e=>`${e.length===1?r.escapeRegex(e[0]):`[${e.map(e=>r.escapeRegex(e)).join(``)}]`}*`,_=e=>{let t=0,n=[];for(;t<e.length;){let r=h(e.slice(t),!1);if(!r||r.type!==`*`)return;let i=d(r.body).map(e=>e.trim());if(i.length!==1)return;let a=p(i[0]);if(!a||a.length!==1)return;n.push(a),t+=r.end+1}if(!(n.length<1))return n},v=e=>{let t=0,n=e.trim(),r=h(n);for(;r;)t++,n=r.body.trim(),r=h(n);return t},y=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let r=typeof t.maxExtglobRecursion==`number`?t.maxExtglobRecursion:n.DEFAULT_MAX_EXTGLOB_RECURSION,i=d(e).map(e=>e.trim());if(i.length>1&&(i.some(e=>e===``)||i.some(e=>/^[*?]+$/.test(e))||m(i)))return{risky:!0};let a=[],o=!1,s=!0;for(let e of i){let t=_(e);if(t){o=!0,a.push(...t);continue}let n=p(e);if(n&&n.length===1)a.push(n);else if(s=!1,v(e)>r)return{risky:!0}}return o?s?{risky:!0,safeOutput:g([...new Set(a)])}:{risky:!0}:{risky:!1}},b=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected a string`);e=c[e]||e;let d={...t},f=typeof d.maxLength==`number`?Math.min(i,d.maxLength):i,p=e.length;if(p>f)throw SyntaxError(`Input length: ${p}, exceeds maximum allowed length: ${f}`);let m={type:`bos`,value:``,output:d.prepend||``},h=[m],g=d.capture?``:`?:`,_=n.globChars(d.windows),v=n.extglobChars(_),{DOT_LITERAL:x,PLUS_LITERAL:S,SLASH_LITERAL:C,ONE_CHAR:w,DOTS_SLASH:ee,NO_DOT:T,NO_DOT_SLASH:E,NO_DOTS_SLASH:D,QMARK:O,QMARK_NO_DOT:te,STAR:ne,START_ANCHOR:k}=_,A=e=>`(${g}(?:(?!${k}${e.dot?ee:x}).)*?)`,re=d.dot?``:T,ie=d.dot?O:te,j=d.bash===!0?A(d):ne;d.capture&&(j=`(${j})`),typeof d.noext==`boolean`&&(d.noextglob=d.noext);let M={input:e,index:-1,start:0,dot:d.dot===!0,consumed:``,output:``,prefix:``,backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:h};e=r.removePrefix(e,M),p=e.length;let N=[],P=[],F=[],I=m,L,R=()=>M.index===p-1,z=M.peek=(t=1)=>e[M.index+t],B=M.advance=()=>e[++M.index]||``,V=()=>e.slice(M.index+1),H=(e=``,t=0)=>{M.consumed+=e,M.index+=t},ae=e=>{M.output+=e.output==null?e.value:e.output,H(e.value)},oe=()=>{let e=1;for(;z()===`!`&&(z(2)!==`(`||z(3)===`?`);)B(),M.start++,e++;return e%2!=0&&(M.negated=!0,M.start++,!0)},U=e=>{M[e]++,F.push(e)},W=e=>{M[e]--,F.pop()},G=e=>{if(I.type===`globstar`){let t=M.braces>0&&(e.type===`comma`||e.type===`brace`),n=e.extglob===!0||N.length&&(e.type===`pipe`||e.type===`paren`);e.type!==`slash`&&e.type!==`paren`&&!t&&!n&&(M.output=M.output.slice(0,-I.output.length),I.type=`star`,I.value=`*`,I.output=j,M.output+=I.output)}N.length&&e.type!==`paren`&&(N[N.length-1].inner+=e.value),(e.value||e.output)&&ae(e),I&&I.type===`text`&&e.type===`text`?(I.output=(I.output||I.value)+e.value,I.value+=e.value):(e.prev=I,h.push(e),I=e)},se=(e,t)=>{let n={...v[t],conditions:1,inner:``};n.prev=I,n.parens=M.parens,n.output=M.output,n.startIndex=M.index,n.tokensIndex=h.length;let r=(d.capture?`(`:``)+n.open;U(`parens`),G({type:e,value:t,output:M.output?``:w}),G({type:`paren`,extglob:!0,value:B(),output:r}),N.push(n)},ce=n=>{let i=e.slice(n.startIndex,M.index+1),a=e.slice(n.startIndex+2,M.index),o=y(a,d);if((n.type===`plus`||n.type===`star`)&&o.risky){let e=o.safeOutput?(n.output?``:w)+(d.capture?`(${o.safeOutput})`:o.safeOutput):void 0,t=h[n.tokensIndex];t.type=`text`,t.value=i,t.output=e||r.escapeRegex(i);for(let e=n.tokensIndex+1;e<h.length;e++)h[e].value=``,h[e].output=``,delete h[e].suffix;M.output=n.output+t.output,M.backtrack=!0,G({type:`paren`,extglob:!0,value:L,output:``}),W(`parens`);return}let s=n.close+(d.capture?`)`:``),c;if(n.type===`negate`){let e=j;n.inner&&n.inner.length>1&&n.inner.includes(`/`)&&(e=A(d)),(e!==j||R()||/^\)+$/.test(V()))&&(s=n.close=`)$))${e}`),n.inner.includes(`*`)&&(c=V())&&/^\.[^\\/.]+$/.test(c)&&(s=n.close=`)${b(c,{...t,fastpaths:!1}).output})${e})`),n.prev.type===`bos`&&(M.negatedExtglob=!0)}G({type:`paren`,extglob:!0,value:L,output:s}),W(`parens`)};if(d.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let n=!1,i=e.replace(s,(e,t,r,i,a,o)=>i===`\\`?(n=!0,e):i===`?`?t?t+i+(a?O.repeat(a.length):``):o===0?ie+(a?O.repeat(a.length):``):O.repeat(r.length):i===`.`?x.repeat(r.length):i===`*`?t?t+i+(a?j:``):j:t?e:`\\${e}`);return n===!0&&(i=d.unescape===!0?i.replace(/\\/g,``):i.replace(/\\+/g,e=>e.length%2==0?`\\\\`:e?`\\`:``)),i===e&&d.contains===!0?(M.output=e,M):(M.output=r.wrapOutput(i,M,t),M)}for(;!R();){if(L=B(),L===`\0`)continue;if(L===`\\`){let e=z();if(e===`/`&&d.bash!==!0||e===`.`||e===`;`)continue;if(!e){L+=`\\`,G({type:`text`,value:L});continue}let t=/^\\+/.exec(V()),n=0;if(t&&t[0].length>2&&(n=t[0].length,M.index+=n,n%2!=0&&(L+=`\\`)),d.unescape===!0?L=B():L+=B(),M.brackets===0){G({type:`text`,value:L});continue}}if(M.brackets>0&&(L!==`]`||I.value===`[`||I.value===`[^`)){if(d.posix!==!1&&L===`:`){let e=I.value.slice(1);if(e.includes(`[`)&&(I.posix=!0,e.includes(`:`))){let e=I.value.lastIndexOf(`[`),t=I.value.slice(0,e),n=I.value.slice(e+2),r=a[n];if(r){I.value=t+r,M.backtrack=!0,B(),!m.output&&h.indexOf(I)===1&&(m.output=w);continue}}}(L===`[`&&z()!==`:`||L===`-`&&z()===`]`)&&(L=`\\${L}`),L===`]`&&(I.value===`[`||I.value===`[^`)&&(L=`\\${L}`),d.posix===!0&&L===`!`&&I.value===`[`&&(L=`^`),I.value+=L,ae({value:L});continue}if(M.quotes===1&&L!==`"`){L=r.escapeRegex(L),I.value+=L,ae({value:L});continue}if(L===`"`){M.quotes=M.quotes===1?0:1,d.keepQuotes===!0&&G({type:`text`,value:L});continue}if(L===`(`){U(`parens`),G({type:`paren`,value:L});continue}if(L===`)`){if(M.parens===0&&d.strictBrackets===!0)throw SyntaxError(u(`opening`,`(`));let e=N[N.length-1];if(e&&M.parens===e.parens+1){ce(N.pop());continue}G({type:`paren`,value:L,output:M.parens?`)`:`\\)`}),W(`parens`);continue}if(L===`[`){if(d.nobracket===!0||!V().includes(`]`)){if(d.nobracket!==!0&&d.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));L=`\\${L}`}else U(`brackets`);G({type:`bracket`,value:L});continue}if(L===`]`){if(d.nobracket===!0||I&&I.type===`bracket`&&I.value.length===1){G({type:`text`,value:L,output:`\\${L}`});continue}if(M.brackets===0){if(d.strictBrackets===!0)throw SyntaxError(u(`opening`,`[`));G({type:`text`,value:L,output:`\\${L}`});continue}W(`brackets`);let e=I.value.slice(1);if(I.posix!==!0&&e[0]===`^`&&!e.includes(`/`)&&(L=`/${L}`),I.value+=L,ae({value:L}),d.literalBrackets===!1||r.hasRegexChars(e))continue;let t=r.escapeRegex(I.value);if(M.output=M.output.slice(0,-I.value.length),d.literalBrackets===!0){M.output+=t,I.value=t;continue}I.value=`(${g}${t}|${I.value})`,M.output+=I.value;continue}if(L===`{`&&d.nobrace!==!0){U(`braces`);let e={type:`brace`,value:L,output:`(`,outputIndex:M.output.length,tokensIndex:M.tokens.length};P.push(e),G(e);continue}if(L===`}`){let e=P[P.length-1];if(d.nobrace===!0||!e){G({type:`text`,value:L,output:L});continue}let t=`)`;if(e.dots===!0){let e=h.slice(),n=[];for(let t=e.length-1;t>=0&&(h.pop(),e[t].type!==`brace`);t--)e[t].type!==`dots`&&n.unshift(e[t].value);t=l(n,d),M.backtrack=!0}if(e.comma!==!0&&e.dots!==!0){let n=M.output.slice(0,e.outputIndex),r=M.tokens.slice(e.tokensIndex);e.value=e.output=`\\{`,L=t=`\\}`,M.output=n;for(let e of r)M.output+=e.output||e.value}G({type:`brace`,value:L,output:t}),W(`braces`),P.pop();continue}if(L===`|`){N.length>0&&N[N.length-1].conditions++,G({type:`text`,value:L});continue}if(L===`,`){let e=L,t=P[P.length-1];t&&F[F.length-1]===`braces`&&(t.comma=!0,e=`|`),G({type:`comma`,value:L,output:e});continue}if(L===`/`){if(I.type===`dot`&&M.index===M.start+1){M.start=M.index+1,M.consumed=``,M.output=``,h.pop(),I=m;continue}G({type:`slash`,value:L,output:C});continue}if(L===`.`){if(M.braces>0&&I.type===`dot`){I.value===`.`&&(I.output=x);let e=P[P.length-1];I.type=`dots`,I.output+=L,I.value+=L,e.dots=!0;continue}if(M.braces+M.parens===0&&I.type!==`bos`&&I.type!==`slash`){G({type:`text`,value:L,output:x});continue}G({type:`dot`,value:L,output:x});continue}if(L===`?`){if(!(I&&I.value===`(`)&&d.noextglob!==!0&&z()===`(`&&z(2)!==`?`){se(`qmark`,L);continue}if(I&&I.type===`paren`){let e=z(),t=L;(I.value===`(`&&!/[!=<:]/.test(e)||e===`<`&&!/<([!=]|\w+>)/.test(V()))&&(t=`\\${L}`),G({type:`text`,value:L,output:t});continue}if(d.dot!==!0&&(I.type===`slash`||I.type===`bos`)){G({type:`qmark`,value:L,output:te});continue}G({type:`qmark`,value:L,output:O});continue}if(L===`!`){if(d.noextglob!==!0&&z()===`(`&&(z(2)!==`?`||!/[!=<:]/.test(z(3)))){se(`negate`,L);continue}if(d.nonegate!==!0&&M.index===0){oe();continue}}if(L===`+`){if(d.noextglob!==!0&&z()===`(`&&z(2)!==`?`){se(`plus`,L);continue}if(I&&I.value===`(`||d.regex===!1){G({type:`plus`,value:L,output:S});continue}if(I&&(I.type===`bracket`||I.type===`paren`||I.type===`brace`)||M.parens>0){G({type:`plus`,value:L});continue}G({type:`plus`,value:S});continue}if(L===`@`){if(d.noextglob!==!0&&z()===`(`&&z(2)!==`?`){G({type:`at`,extglob:!0,value:L,output:``});continue}G({type:`text`,value:L});continue}if(L!==`*`){(L===`$`||L===`^`)&&(L=`\\${L}`);let e=o.exec(V());e&&(L+=e[0],M.index+=e[0].length),G({type:`text`,value:L});continue}if(I&&(I.type===`globstar`||I.star===!0)){I.type=`star`,I.star=!0,I.value+=L,I.output=j,M.backtrack=!0,M.globstar=!0,H(L);continue}let t=V();if(d.noextglob!==!0&&/^\([^?]/.test(t)){se(`star`,L);continue}if(I.type===`star`){if(d.noglobstar===!0){H(L);continue}let n=I.prev,r=n.prev,i=n.type===`slash`||n.type===`bos`,a=r&&(r.type===`star`||r.type===`globstar`);if(d.bash===!0&&(!i||t[0]&&t[0]!==`/`)){G({type:`star`,value:L,output:``});continue}let o=M.braces>0&&(n.type===`comma`||n.type===`brace`),s=N.length&&(n.type===`pipe`||n.type===`paren`);if(!i&&n.type!==`paren`&&!o&&!s){G({type:`star`,value:L,output:``});continue}for(;t.slice(0,3)===`/**`;){let n=e[M.index+4];if(n&&n!==`/`)break;t=t.slice(3),H(`/**`,3)}let c=R()||M.parens>0&&t===`)`.repeat(M.parens)&&!N.some(e=>e.type===`negate`);if(n.type===`bos`&&R()){I.type=`globstar`,I.value+=L,I.output=A(d),M.output=I.output,M.globstar=!0,H(L);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&!a&&c){M.output=M.output.slice(0,-(n.output+I.output).length),n.output=`(?:${n.output}`,I.type=`globstar`,I.output=A(d)+(d.strictSlashes?`)`:`|$)`),I.value+=L,M.globstar=!0,M.output+=n.output+I.output,H(L);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&t[0]===`/`){let e=t[1]===void 0?``:`|$`;M.output=M.output.slice(0,-(n.output+I.output).length),n.output=`(?:${n.output}`,I.type=`globstar`,I.output=`${A(d)}${C}|${C}${e})`,I.value+=L,M.output+=n.output+I.output,M.globstar=!0,H(L+B()),G({type:`slash`,value:`/`,output:``});continue}if(n.type===`bos`&&t[0]===`/`){I.type=`globstar`,I.value+=L,I.output=`(?:^|${C}|${A(d)}${C})`,M.output=I.output,M.globstar=!0,H(L+B()),G({type:`slash`,value:`/`,output:``});continue}M.output=M.output.slice(0,-I.output.length),I.type=`globstar`,I.output=A(d),I.value+=L,M.output+=I.output,M.globstar=!0,H(L);continue}let n={type:`star`,value:L,output:j};d.bash===!0?(n.output=`.*?`,(I.type===`bos`||I.type===`slash`)&&(n.output=re+n.output),G(n)):I&&(I.type===`bracket`||I.type===`paren`)&&d.regex===!0?(n.output=L,G(n)):((M.index===M.start||I.type===`slash`||I.type===`dot`)&&(I.type===`dot`?(M.output+=E,I.output+=E):d.dot===!0?(M.output+=D,I.output+=D):(M.output+=re,I.output+=re),z()!==`*`&&(M.output+=w,I.output+=w)),G(n))}for(;M.brackets>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));M.output=r.escapeLast(M.output,`[`),W(`brackets`)}for(;M.parens>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`)`));M.output=r.escapeLast(M.output,`(`),W(`parens`)}for(;M.braces>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`}`));M.output=r.escapeLast(M.output,`{`),W(`braces`)}if(d.strictSlashes!==!0&&(I.type===`star`||I.type===`bracket`)&&G({type:`maybe_slash`,value:``,output:`${C}?`}),M.backtrack===!0){M.output=``;for(let e of M.tokens)M.output+=e.output==null?e.value:e.output,e.suffix&&(M.output+=e.suffix)}return M};b.fastpaths=(e,t)=>{let a={...t},o=typeof a.maxLength==`number`?Math.min(i,a.maxLength):i,s=e.length;if(s>o)throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);e=c[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:u,ONE_CHAR:d,DOTS_SLASH:f,NO_DOT:p,NO_DOTS:m,NO_DOTS_SLASH:h,STAR:g,START_ANCHOR:_}=n.globChars(a.windows),v=a.dot?m:p,y=a.dot?h:p,b=a.capture?``:`?:`,x={negated:!1,prefix:``},S=a.bash===!0?`.*?`:g;a.capture&&(S=`(${S})`);let C=e=>e.noglobstar===!0?S:`(${b}(?:(?!${_}${e.dot?f:l}).)*?)`,w=e=>{switch(e){case`*`:return`${v}${d}${S}`;case`.*`:return`${l}${d}${S}`;case`*.*`:return`${v}${S}${l}${d}${S}`;case`*/*`:return`${v}${S}${u}${d}${y}${S}`;case`**`:return v+C(a);case`**/*`:return`(?:${v}${C(a)}${u})?${y}${d}${S}`;case`**/*.*`:return`(?:${v}${C(a)}${u})?${y}${S}${l}${d}${S}`;case`**/.*`:return`(?:${v}${C(a)}${u})?${l}${d}${S}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let n=w(t[1]);return n?n+l+t[2]:void 0}}},ee=w(r.removePrefix(e,x));return ee&&a.strictSlashes!==!0&&(ee+=`${u}?`),ee},t.exports=b})),yn=/* @__PURE__ */ pe(((e,t)=>{let n=_n(),r=vn(),i=gn(),a=hn(),o=e=>e&&typeof e==`object`&&!Array.isArray(e),s=(e,t,n=!1)=>{if(Array.isArray(e)){let r=e.map(e=>s(e,t,n));return e=>{for(let t of r){let n=t(e);if(n)return n}return!1}}let r=o(e)&&e.tokens&&e.input;if(e===``||typeof e!=`string`&&!r)throw TypeError(`Expected pattern to be a non-empty string`);let i=t||{},a=i.windows,c=r?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=c.state;delete c.state;let u=()=>!1;if(i.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=s(i.ignore,e,n)}let d=(n,r=!1)=>{let{isMatch:o,match:d,output:f}=s.test(n,c,t,{glob:e,posix:a}),p={glob:e,state:l,regex:c,posix:a,input:n,output:f,match:d,isMatch:o};return typeof i.onResult==`function`&&i.onResult(p),o===!1?(p.isMatch=!1,r?p:!1):u(n)?(typeof i.onIgnore==`function`&&i.onIgnore(p),p.isMatch=!1,r?p:!1):(typeof i.onMatch==`function`&&i.onMatch(p),!r||p)};return n&&(d.state=l),d};s.test=(e,t,n,{glob:r,posix:a}={})=>{if(typeof e!=`string`)throw TypeError(`Expected input to be a string`);if(e===``)return{isMatch:!1,output:``};let o=n||{},c=o.format||(a?i.toPosixSlashes:null),l=e===r,u=l&&c?c(e):e;return l===!1&&(u=c?c(e):e,l=u===r),(l===!1||o.capture===!0)&&(l=o.matchBase===!0||o.basename===!0?s.matchBase(e,t,n,a):t.exec(u)),{isMatch:!!l,match:l,output:u}},s.matchBase=(e,t,n,r=n&&n.windows)=>(t instanceof RegExp?t:s.makeRe(t,n)).test(i.basename(e,{windows:r})),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map(e=>s.parse(e,t)):r(e,{...t,fastpaths:!1}),s.scan=(e,t)=>n(e,t),s.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let i=t||{},a=i.contains?``:`^`,o=i.contains?``:`$`,c=`${a}(?:${e.output})${o}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let l=s.toRegex(c,t);return r===!0&&(l.state=e),l},s.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!=`string`)throw TypeError(`Expected a non-empty string`);let a={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]===`.`||e[0]===`*`)&&(a.output=r.fastpaths(e,t)),a.output||(a=r(e,t)),s.compileRe(a,t,n,i)},s.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?`i`:``))}catch(e){if(t&&t.debug===!0)throw e;return/$^/}},s.constants=a,t.exports=s})),bn=/* @__PURE__ */ he((/* @__PURE__ */ pe(((e,t)=>{let n=yn(),r=gn();function i(e,t,i=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:r.isWindows()}),n(e,t,i)}Object.assign(i,n),t.exports=i})))(),1);const xn=Array.isArray,Sn=/\\/g,Cn=/^[A-Za-z]:$/,wn=process.platform===`win32`,Tn=/^(\/?\.\.)+$/;function En(e,t={}){let n=e.length,r=Array(n),i=Array(n),a,o;for(a=0;a<n;a++){let n=Nn(e[a]);r[a]=n;let s=n.length,c=Array(s);for(o=0;o<s;o++)c[o]=(0,bn.default)(n[o],t);i[a]=c}return e=>{let s=e.split(`/`);if(s[0]===`..`&&Tn.test(e))return!0;for(a=0;a<n;a++){let e=r[a],n=i[a],c=s.length,l=Math.min(c,e.length);for(o=0;o<l;){let r=e[o];if(r.includes(`/`))return!0;if(!n[o](s[o]))break;if(!t.noglobstar&&r===`**`)return!0;o++}if(o===c)return!0}return!1}}
|
|
179
|
+
/* node:coverage ignore next 2 */
|
|
180
|
+
const Dn=/^[A-Z]:\/$/i,On=wn?e=>Dn.test(e):e=>e===`/`;function kn(e,t,n){if(e===t||t.startsWith(`${e}/`)){if(n){let t=e.length+ +!On(e);return(e,n)=>e.slice(t,n?-1:void 0)||`.`}let r=t.slice(e.length+1);return r?(e,t)=>{if(e===`.`)return r;let n=`${r}/${e}`;return t?n.slice(0,-1):n}:(e,t)=>t&&e!==`.`?e.slice(0,-1):e}return n?t=>H.relative(e,t)||`.`:n=>H.relative(e,`${t}/${n}`)||`.`}function An(e,t){if(t.startsWith(`${e}/`)){let n=t.slice(e.length+1);return e=>`${n}/${e}`}return n=>{let r=H.relative(e,`${t}/${n}`);return n[n.length-1]===`/`&&r!==``?`${r}/`:r||`.`}}function jn(e){return e.replace(Cn,e=>`${e}/`)}const Mn={parts:!0};function Nn(e){let t=bn.default.scan(e,Mn);return t.parts?.length?t.parts:[e]}const Pn=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Fn=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,In=wn?e=>e.replace(Fn,`\\$&`):e=>e.replace(Pn,`\\$&`);function Ln(e,t){if(t?.caseSensitiveMatch===!1)return!0;let n=bn.default.scan(e);return n.isGlob||n.negated}function Rn(...e){console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString(`es`)}]`,...e)}function zn(e){return typeof e==`string`?[e]:e??[]}const Bn=/^(\/?\.\.)+/,Vn=/\\(?=[()[\]{}!*+?@|])/g;function Hn(e,t,n,r){let i=t.cwd,a=e;e[e.length-1]===`/`&&(a=e.slice(0,-1)),a[a.length-1]!==`*`&&t.expandDirectories&&(a+=`/**`);let o=In(i);a=B(a.replace(Vn,``))?H.relative(o,a):H.normalize(a);let s=Bn.exec(a)?.[0],c=Nn(a);if(s){let e=(s.length+1)/3,t=0,r=o.split(`/`);for(;t<e&&c[t+e]===r[r.length+t-e];)a=a.slice(0,(e-t-1)*3)+a.slice((e-t)*3+c[t+e].length+1)||`.`,t++;let l=H.join(i,s.slice(t*3));l[0]!==`.`&&n.root.length>l.length&&(n.root=jn(l),n.depthOffset=-e+t)}if(!r&&n.depthOffset>=0){n.commonPath??=c;let e=[],t=Math.min(n.commonPath.length,c.length);for(let r=0;r<t;r++){let t=c[r];if(t===`**`&&!c[r+1]){e.pop();break}if(r===c.length-1||t!==n.commonPath[r]||Ln(t))break;e.push(t)}n.depthOffset=e.length,n.commonPath=e,n.root=jn(e.length>0?H.join(i,...e):i)}return a}function Un(e,t,n){let r=[],i=[];for(let t of e.ignore)t&&(t[0]!==`!`||t[1]===`(`)&&i.push(Hn(t,e,n,!0));for(let a of t)a&&(a[0]!==`!`||a[1]===`(`?r.push(Hn(a,e,n,!1)):(a[1]!==`!`||a[2]===`(`)&&i.push(Hn(a.slice(1),e,n,!0)));return{match:r,ignore:i}}function Wn(e,t){let n=e.cwd,r={root:n,depthOffset:0},i=Un(e,t,r);e.debug&&Rn(`internal processing patterns:`,i);let{absolute:a,caseSensitiveMatch:o,debug:s,dot:c,followSymbolicLinks:l,onlyDirectories:u}=e,d=r.root.replace(Sn,``),f={dot:c,nobrace:e.braceExpansion===!1,nocase:!o,noextglob:e.extglob===!1,noglobstar:e.globstar===!1,posix:!0},p=(0,bn.default)(i.match,f),m=(0,bn.default)(i.ignore,f),h=En(i.match,f),g=kn(n,d,a),_=a?g:kn(n,d,!0),v=(e,t)=>{let n=_(t,!0);return n!==`.`&&!h(n)||m(n)},y;e.deep!==void 0&&(y=Math.round(e.deep-r.depthOffset));let b=new mn({filters:[s?(e,t)=>{let n=g(e,t),r=p(n)&&!m(n);return r&&Rn(`matched ${n}`),r}:(e,t)=>{let n=g(e,t);return p(n)&&!m(n)}],exclude:s?(e,t)=>{let n=v(e,t);return Rn(`${n?`skipped`:`crawling`} ${t}`),n}:v,fs:e.fs,pathSeparator:`/`,relativePaths:!a,resolvePaths:a,includeBasePath:a,resolveSymlinks:l,excludeSymlinks:!l,excludeFiles:u,includeDirs:u||!e.onlyFiles,maxDepth:y,signal:e.signal}).crawl(d);return e.debug&&Rn(`internal properties:`,{...r,root:d}),[b,n!==d&&!a&&An(n,d)]}function Gn(e,t){if(t)for(let n=e.length-1;n>=0;n--)e[n]=t(e[n]);return e}const Kn={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function qn(e){let t=Object.assign({},e);for(let e in Kn)t[e]===void 0&&Object.assign(t,{[e]:Kn[e]});return t.cwd=(t.cwd instanceof URL?W(t.cwd):oe(t.cwd||process.cwd())).replace(Sn,`/`),t.ignore=zn(t.ignore),t.fs&&={readdir:t.fs.readdir||M,readdirSync:t.fs.readdirSync||N,realpath:t.fs.realpath||P,realpathSync:t.fs.realpathSync||F,stat:t.fs.stat||I,statSync:t.fs.statSync||L},t.debug&&Rn(`globbing with options:`,t),t}function Jn(e,t={}){if(e&&t?.patterns)throw Error(`Cannot pass patterns as both an argument and an option`);let n=xn(e)||typeof e==`string`,r=zn((n?e:e.patterns)??`**/*`),i=qn(n?t:e);return r.length>0?Wn(i,r):[]}async function Yn(e,t){let[n,r]=Jn(e,t);return n?Gn(await n.withPromise(),r):[]}const Xn=Ve.withOptions({alignValues:!0});function Zn(e,...t){if(typeof e==`string`)return Xn(e);let n=Array.from(e);return Xn(Object.assign(n,{raw:n}),...t)}function Qn(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function $n(e,t){let n=t?.headers?[t.headers,...e]:e,r=[];for(let e of n)for(let t=0;t<e.length;t++)r[t]=Math.max(r[t]??0,e[t].length);return n.map(e=>e.map((t,n)=>n<e.length-1?t.padEnd(r[n]):t).join(` `).trimEnd()).join(`
|
|
181
|
+
`)}const er=b()!==void 0,tr={"user-intent":{type:`string`,description:`The user's overall task in one short US English sentence. Paraphrase their original request, not what this command does. Pass the same value on every command for the same task. Analytics only — no effect on behavior.`},"task-id":{type:`string`,description:"Groups the commands of one user request. One id covers the whole request, not one per command: a slice's create, field and push commands share it. Run `prismic task-id` when the user asks for something new. Analytics only — no effect on behavior."},"analytics-intent":{type:`string`,hidden:!0,description:`Renamed to --user-intent.`},"analytics-task-id":{type:`string`,hidden:!0,description:`Renamed to --task-id.`}};function nr(e,t){return async function(){let{positionals:n={},options:r={}}=e,i;try{i=T({args:process.argv.slice(1+e.name.split(` `).length),options:{...r,...tr,help:{type:`boolean`,short:`h`}},allowPositionals:Object.keys(n).length>0,strict:!0})}catch(e){throw e instanceof TypeError&&`code`in e&&typeof e.code==`string`&&e.code.startsWith(`ERR_PARSE_ARGS_`)?new X(e.message):e}if(i.values.help){let t=Object.keys(n),i={USAGE:` ${[e.name,...t.map(e=>`<${e}>`),`[options]`].join(` `)}`};t.length>0&&(i.ARGUMENTS=$n(Object.entries(n).map(([e,t])=>[` <${e}>`,t.description+(t.required?` (required)`:``)]))),i.OPTIONS=$n(ir(r)),console.info(ar(e.description,i,e.name.split(` `)[0],e.sections))}else{for(let[e,[t,r]]of Object.entries(n).entries())if(r.required&&!i.positionals[e])throw new X(`Missing required argument: <${t}>`);for(let[e,t]of Object.entries(r)){if(t.required&&!(e in i.values))throw new X(`Missing required option: --${e}`);if(e in i.values&&(t.deprecated&&console.warn(`--${e} is deprecated. ${t.deprecated}`),t.dependsOn&&!(t.dependsOn in i.values)))throw new X(`--${e} can only be used with --${t.dependsOn}.`)}await t(i)}}}function rr(e){return async function(){let{positionals:[t]}=T({args:process.argv.slice(1+e.name.split(` `).length),options:{...tr,help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});if(t){let n=e.commands[t];if(!n)throw new X(`Unknown command: ${t}`);await n.handler();return}let n={USAGE:` ${e.name} <command> [options]`,COMMANDS:$n(Object.entries(e.commands).filter(([,e])=>!e.hidden).map(([e,t])=>[` ${e}`,t.description])),OPTIONS:$n(ir({}))},r=er?{...e.sections,AGENTS:`
|
|
182
|
+
--task-id and --user-intent group the commands of one user request together.
|
|
183
|
+
Run \`prismic task-id\` when the user asks for something, then pass that id on
|
|
184
|
+
every command until they ask for something else — creating a slice, adding its
|
|
185
|
+
fields and pushing them are one request, and the next slice is another. Pass
|
|
186
|
+
what the user asked for as --user-intent. Analytics only — no effect on behavior.
|
|
187
|
+
`}:e.sections;console.info(ar(e.description,n,e.name,r))}}function ir(e){let t=er?{...e,...tr}:e,n=[];for(let[e,r]of Object.entries(t)){if(r.deprecated||r.hidden)continue;let t=r.short?`-${r.short}, `:` `,i=r.type===`string`?` string`:``,a=r.description+(r.required?` (required)`:``);n.push([` ${t}--${e}${i}`,a])}return n.push([` -h, --help`,`Show help for command`]),n}function ar(e,t,n,r={}){let i=[Zn(e)];for(let[e,n]of Object.entries(t))i.push(``,e,n);for(let[e,t]of Object.entries(r))i.push(``,e,...Zn(t).split(`
|
|
188
|
+
`).map(e=>e?` ${e}`:``));return i.push(``,`LEARN MORE`,` Use \`${n} <command> --help\` for more information about a command.`),i.join(`
|
|
189
|
+
`)}function or(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new X(`Only one of ${r} can be specified.`);if(n.length===0)throw new X(`Specify one of ${r}.`);return{key:n[0],value:e[n[0]]}}function sr(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new X(`Only one of ${r} can be specified.`)}var X=class extends Error{name=`CommandError`};const cr=i({id:n(),label:n(),url:n()}),lr=i({results:v(cr)});async function ur(e){let{repo:t,host:n}=e;return(await Z(new URL(`core/repository/preview_configs`,Q(t,n)),e,{schema:lr,unknownErrorMessage:`Failed to load previews`})).results}async function dr(e,t){let{repo:n,host:r}=t;await Z(new URL(`previews/new`,Q(n,r)),t,{method:`POST`,json:{name:e.name,websiteURL:e.websiteURL,resolverPath:e.resolverPath},unknownErrorMessage:`Failed to add preview`})}async function fr(e,t){let{repo:n,host:r}=t;await Z(new URL(`previews/delete/${encodeURIComponent(e)}`,Q(n,r)),t,{method:`POST`,json:{},notFoundMessage:`Preview not found: ${e}`,unknownErrorMessage:`Failed to remove preview`})}const pr=i({kind:e([`prod`,`stage`,`dev`]),name:n(),domain:n(),users:v(i({id:n()}))});async function mr(e){let{repo:t,host:n}=e;return(await Z(new URL(`core/environments`,Q(t,n)),e,{schema:i({results:v(pr)})})).results}const hr=i({simulator_url:a(n())});async function gr(e){let{repo:t,host:n}=e;return(await Z(new URL(`core/repository`,Q(t,n)),e,{schema:hr,unknownErrorMessage:`Failed to load simulator URL`})).simulator_url}async function _r(e,t){let{repo:n,host:r}=t;await Z(new URL(`core/repository`,Q(n,r)),t,{method:`PATCH`,json:{simulator_url:e},unknownErrorMessage:`Failed to set simulator URL`})}const vr=i({total:r()});async function yr(e,t){let{repo:n,host:r}=t;return(await Z(new URL(`core/documents/search`,Q(n,r)),t,{method:`POST`,json:{customTypes:[e],limit:0},schema:vr})).total}async function br(e,t){let{repo:r,host:i}=t;return(await Z(new URL(`core/releases`,Q(r,i)),t,{method:`POST`,json:e,schema:f({id:n()}),unknownErrorMessage:`Failed to create a release`})).id}async function xr(e,t){let{repo:n,host:r}=t;await Z(new URL(`core/releases/${encodeURIComponent(e)}`,Q(n,r)),t,{method:`DELETE`,notFoundMessage:`Release not found: ${e}`,unknownErrorMessage:`Failed to delete the release`})}function Z(e,t,n={}){return h(e,{credentials:{"prismic-auth":t.token},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Q(e,t){return new URL(`https://${e}.${t}/`)}function Sr(e,t,n){let{getKey:r,equals:i=(e,t)=>JSON.stringify(e)===JSON.stringify(t)}=n,a={insert:[],update:[],delete:[]};for(let n of e){let e=t.find(e=>r(e)===r(n));e?i(n,e)||a.update.push(n):a.insert.push(n)}for(let n of t)e.some(e=>r(e)===r(n))||a.delete.push(n);return a}function Cr(e){return e.insert.length+e.update.length+e.delete.length>0}function wr(e){return Mr(new URL(`customtypes`,Pr(e.host)),e)}function Tr(e){return Mr(new URL(`slices`,Pr(e.host)),e)}async function Er(e,t){await Mr(new URL(`bulk-update`,Pr(t.host)),t,{method:`POST`,json:{changes:e},unknownErrorMessage:`Failed to update models`})}const Dr=i({values:i({url:n(),fields:t(n(),n())}),imgixEndpoint:n()}),Or={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function kr(e,t){await Nr(new URL(`delete`,Fr(t.host)),t,{method:`POST`,json:{sliceId:e}})}async function Ar(e,t){let{sliceId:n,variationId:r,repo:i,host:a}=t,o=e.type;if(!(o in Or))throw new jr(o);let s=await Nr(new URL(`presigned-url`,Fr(a)),t,{schema:Dr}),c=Or[o],l=`${i}/shared-slices/${n}/${r}/${ie(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${c}`,u=new FormData;for(let[e,t]of Object.entries(s.values.fields))u.append(e,t);u.set(`key`,l),u.set(`Content-Type`,o),u.set(`file`,e),await h(s.values.url,{method:`POST`,body:u});let d=new URL(l,_(s.imgixEndpoint));return d.searchParams.set(`auto`,`compress,format`),d}var jr=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){let t=Object.keys(Or);super(`Unsupported file type: ${e||`unknown`}. Supported: ${t.join(`, `)}`)}};function Mr(e,t,n={}){return t.releaseId&&e.searchParams.set(`release`,t.releaseId),h(e,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Nr(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),h(r,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},...n})}function Pr(e){return new URL(`https://customtypes.${e}/`)}function Fr(e){return new URL(`https://api.internal.${e}/screenshot/`)}const Ir=[`Slices`,`UID`,`Choice`];function Lr(e,t,n){if(t in e)throw new Qr(t);e[t]=n}function Rr(e,t){let n=e[t];if(!n)throw new $r(t);return n}function zr(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new $(`Custom type "${t}" does not exist.`);let a=(e,t,n,i)=>{let o=/* @__PURE__ */ new Map;for(let t of e){let[e,...n]=t.split(`.`),r=o.get(e)??[];r.push(n.join(`.`)),o.set(e,r)}return Array.from(o,([e,o])=>{let s=t[e];if(!s)throw new $(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(Ir.includes(s.type)||e===`uid`)throw new $(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new $(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new $(`Field "${e}" cannot be selected both directly and through its subfields.`);if(s.type===`Group`)return{id:e,fields:a(c,s.config?.fields??{},n,i)};if(s.type===`Link`&&s.config?.select===`document`){if(!i)throw new $(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new $(`Field "${e}" must target exactly one custom type to select its fields.`);let n=typeof t[0]==`string`?t[0]:t[0].id,o=r.get(n);if(!o)throw new $(`Custom type "${n}" does not exist.`);let l=Object.assign({},...Object.values(o.json));return{id:e,customtypes:[{id:n,fields:a(c,l,n,!1)}]}}throw new $(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function Br(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new ti(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new $r(n)}return Xr(e,r)}function Vr(e,t,n){let r=t.variations.find(e=>e.id===n);if(!r)throw new ni(n,t.id);return r.primary??={},Xr(e,r.primary)}async function Hr(e){let[t,n]=await Promise.all([wr(e),Tr(e)]);return{customTypes:t,slices:n}}async function Ur({customTypes:e,slices:t},n){let r=(e,t)=>({type:e,id:t.id,payload:t}),i=[...e.insert.map(e=>r(`CUSTOM_TYPE_INSERT`,e)),...e.update.map(e=>r(`CUSTOM_TYPE_UPDATE`,e)),...e.delete.map(({id:e})=>r(`CUSTOM_TYPE_DELETE`,{id:e})),...t.insert.map(e=>r(`SLICE_INSERT`,e)),...t.update.map(e=>r(`SLICE_UPDATE`,e)),...t.delete.map(({id:e})=>r(`SLICE_DELETE`,{id:e}))];i.length>0&&await Er(i,n)}function Wr(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:Sr(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Gr(e))===JSON.stringify(r?t:Gr(t))}),slices:Sr(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(Kr(e))===JSON.stringify(r?t:Kr(t))})}}function Gr(e){return{...Yr(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,qr(t)]))}}function Kr(e){return{...Yr(e),variations:e.variations.map(e=>{let t=Yr(e);return e.primary&&(t.primary=qr(e.primary)),e.items&&(t.items=qr(e.items)),t})}}function qr(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Yr(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=qr(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=Jr(t.config.choices)),[e,n]}))}function Jr(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=Yr(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=qr(t[`non-repeat`])),t.repeat&&(n.repeat=qr(t.repeat))),[e,n]}))}function Yr(e){return Array.isArray(e)?e.map(Yr):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Yr(t)]))}function Xr(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=Rr(t,n);if(i.type!==`Group`)throw new ei(n);return i.config??={},i.config.fields??={},Xr(r.join(`.`),i.config.fields)}function Zr(e){return e.flatMap(e=>Object.values(e.json).flatMap(t=>Object.entries(t).flatMap(([t,n])=>n.type===`Slices`?Object.entries(n.config?.choices??{}).flatMap(([r,i])=>i.type===`SharedSlice`?[]:[{id:r,customTypeId:e.id,sliceZoneId:t,sliceZone:n,model:i}]):[])))}var Qr=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},$r=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},ei=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},$=class extends Error{name=`FieldSelectionError`},ti=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},ni=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}};const ri=`prismic.config.json`,ii=i({type:n(),path:n(),uid:a(n()),lang:a(n()),resolvers:a(t(n(),n()))}),ai=i({repositoryName:n(),documentAPIEndpoint:a(y()),libraries:a(v(n())),routes:a(v(ii))});async function oi(e){let t=await fi();return await te(t,c(e)),t}async function si(){let e=await ui();try{return await u(e,{schema:ai})}catch{throw new ci}}var ci=class extends Error{name=`InvalidPrismicConfigError`;message=`${ri} is invalid. Run \`prismic init\` to re-create a config.`};async function li(e){let t=await ui(),n={...await si(),...e};return await te(t,c(n)),n}async function ui(){let e=await g(ri,{stop:`package.json`});if(!e)throw new di;return e}var di=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${ri} file. Run \`prismic init\` to create a config.`};async function fi(){try{let e=await w();return new URL(ri,e)}catch(e){throw e instanceof ee?new pi({cause:e}):e}}var pi=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function mi(e){let{routes:t=[]}=await si();if(t.some(t=>t.type===e.id))return;let n=vi(e),r={type:e.id,path:n};await li({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function hi(e){e.format===`page`?await mi(e):await gi(e.id)}async function gi(e){let{routes:t=[]}=await si(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await li({routes:n})}function _i(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function vi(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const yi=`slicemachine.config.json`,bi=i({repositoryName:n(),libraries:a(v(n()))});async function xi(){let e=await wi();try{return await u(e,{schema:bi})}catch{throw new Si}}var Si=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${yi} is invalid.`};async function Ci(){let e=await wi();await O(e)}async function wi(){let e=await g(yi,{stop:`package.json`});if(!e)throw new Ti;return e}var Ti=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${yi} file.`};async function Ei(){let e;try{e=await ui()}catch(t){if(t instanceof di)e=await fi();else throw t}let t=new URL(`.`,e);return _(A(await D(k(t))))}async function Di(){try{return(await si()).repositoryName}catch(e){if(e instanceof di)try{return(await xi()).repositoryName}catch{}throw e}}async function Oi(){let e=(await si()).libraries;if(!e||e.length<1)return;let t=await Ei();return e.map(e=>_(new URL(e.replace(/^\//,``),t)))}async function ki(){let e=await Ei();return p(new URL(`tsconfig.json`,e))}const Ai=[`next`,`nuxt`,`sveltekit`];async function ji(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await C(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-D65xFGap.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-YzpEi3A5.mjs`);return new e}if(`@sveltejs/kit`in r){if(await S(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-C9cZPBvU.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-CpIdkani.mjs`);return new e}throw new Mi}var Mi=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},Ni=class extends Error{name=`ModelExistsError`},Pi=class extends Error{name=`SliceNotFoundError`;constructor(e){super(`Slice "${e}" does not exist. Run \`prismic slice list\` to see available IDs.`)}},Fi=class extends Error{name=`CustomTypeNotFoundError`;constructor(e){super(`Type "${e}" does not exist. Run \`prismic type list\` to see available IDs.`)}};async function Ii(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await p(n))return;let a=s(await Ei(),i?.directory??n),o=i?` (id: ${i.model.id})`:``;throw new Ni(`A ${e} already exists at ${a}${ne}${o}.`)}async function Li(){return await(await ji()).getEnvironment()??await Di()}async function Ri(e){let t=await Yn(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:k(await Ei()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await E(n,`utf8`)).includes(e))return!0}catch{}return!1}async function zi(e,t){await p(e)||await o(e,t)}async function Bi(){return await ki()?`ts`:`js`}var Vi=class{get localPreviewUrl(){return new URL(this.localPreviewConfig.resolverPath,this.localPreviewConfig.websiteURL).href}get localSimulatorUrl(){return new URL(`slice-simulator`,this.localPreviewConfig.websiteURL).href}async initProject({setup:e}){for(let e of await this.getSliceLibraries())await this.createSliceIndexFile(e);e&&await this.setupProject();let t={repo:await Di(),...await x()};await gr(t)||await _r(this.localSimulatorUrl,t),(await ur(t)).length===0&&await dr(this.localPreviewConfig,t)}async getSliceLibraries(){return await Oi()??[await this.getDefaultSliceLibrary()]}async getSlices(){return Ui(await this.getSliceLibraries(),`*/model.json`)}async getSlice(e){let t=(await this.getSlices()).find(t=>t.model.id===e);if(t)return t;let n=Zr((await this.getCustomTypes()).map(e=>e.model)).find(t=>t.id===e);if(n){let{customTypeId:t,sliceZoneId:r}=n;throw new X(`"${e}" is a legacy slice in "${t}". Upgrade it first: \`prismic slice upgrade-legacy ${e} --from ${t}${r===`body`?``:` --slice-zone ${r}`}\`.`)}throw new Pi(e)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=_(new URL(Te(e.name),_(t)));await Ii(`slice`,e.id,n,await this.getSlices()),await o(new URL(`model.json`,n),c(Kr(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await o(t.modelPath,c(Kr(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await O(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await Ei())]}async getCustomTypes(){return Ui(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw new Fi(e);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=_(new URL(e.id,_(t)));if(await Ii(`type`,e.id,n,await this.getCustomTypes()),await o(new URL(`index.json`,n),c(Gr(e))),e.format!==`page`)return[];await mi(e);let r=await Ei();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${s(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await si(),n=(_i(t,e.id)?.path??vi(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await p(t.path)?r.push(t):await o(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await o(t.modelPath,c(Gr(e))),await hi(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await O(t.directory,{recursive:!0}),await gi(e)}async getModels(){let[e,t]=await Promise.all([this.getCustomTypes(),this.getSlices()]);return{customTypes:e.map(e=>e.model),slices:t.map(e=>e.model)}}async writeModels(e){for(let t of e.slices.update)await this.updateSlice(t);for(let t of e.slices.delete)await this.deleteSlice(t.id);for(let t of e.slices.insert)await this.createSlice(t);for(let t of e.customTypes.update)await this.updateCustomType(t);for(let t of e.customTypes.delete)await this.deleteCustomType(t.id);let t=[];for(let n of e.customTypes.insert)t.push(...await this.createCustomType(n));return t}async generateTypes(){let e=new URL(`prismicio-types.d.ts`,await Ei()),t=ct({customTypeModels:(await this.getCustomTypes()).map(({model:e})=>({...e,label:e.label??null})),sharedSliceModels:(await this.getSlices()).map(e=>e.model),clientIntegration:{includeContentNamespace:!0,includeCreateClientInterface:!0},cache:!0,typesProvider:`@prismicio/client`});return await o(e,t),e}async getEnvironment(){let e=await Hi();if(await p(e))return(await l(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await m(await Hi(),this.environmentEnvVarName,e)}async unsetEnvironment(){await d(await Hi(),this.environmentEnvVarName)}};async function Hi(){return new URL(`.env.local`,await Ei())}async function Ui(e,t){let n=[];for(let r of e){let e=await Yn(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=A(e),n=await u(t);return{library:r,directory:new URL(`.`,t),modelPath:t,model:n}}));n.push(...i)}return n.sort((e,t)=>e.model.id.toLowerCase().localeCompare(t.model.id.toLowerCase()))}export{fr as $,ti as A,Vr as B,si as C,$r as D,Qr as E,Wr as F,Cr as G,jr as H,Zr as I,xr as J,dr as K,Hr as L,Lr as M,Gr as N,$ as O,Kr as P,gr as Q,zr as R,Di as S,li as T,kr as U,Ur as V,Ar as W,mr as X,yr as Y,ur as Z,ki as _,Mi as a,sr as at,_i as b,Li as c,$n as ct,zi as d,Te as dt,_r as et,Si as f,De as ft,vi as g,pi as h,Ni as i,or as it,ei as j,ni as k,ji as l,we as lt,di as m,Fi as n,nr as nt,Pi as o,Zn as ot,ci as p,br as q,Ai as r,rr as rt,Ri as s,Qn as st,Vi as t,X as tt,Bi as u,Ee as ut,oi as v,xi as w,Ei as x,Ci as y,Br as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as e,D as t,H as n,I as r,L as i,N as a,O as o,P as s,R as c,S as ee,T as l,U as u,V as te,_ as d,c as f,f as p,k as m,l as h,s as g,v as _,x as ne}from"./request-
|
|
2
|
-
function ae(t){return e(ne,t)}const oe=`prismic.io`,se=a({PROD:i(),PRISMIC_SENTRY_DSN:ee(t(),`https://e1886b1775bd397cd1afc60bfd2ebfc8@o146123.ingest.us.sentry.io/4510445143588864`),PRISMIC_SENTRY_ENVIRONMENT:s(r()),PRISMIC_SENTRY_ENABLED:s(i()),PRISMIC_TELEMETRY_ENABLED:s(i()),PRISMIC_HOST:s(r()),PRISMIC_TOKEN:s(r()),PRISMIC_DOCS_HOST:s(r()),PRISMIC_CONFIG_DIR:s(r()),PRISMIC_TYPE_BUILDER_ENABLED:s(i()),PRISMIC_SYNC_POLL_MS:s((/* @__PURE__ */ ae()).check(te(100)))}),D=u(se,{...process.env,PROD:`true`});function ce(e,t){if(t)return _(C(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,_(C(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,_(C(t)))}let n=_(C(E()));return new URL(`.config/${e}/`,n)}const O=ce(`prismic`,D.PRISMIC_CONFIG_DIR),k=new URL(`credentials.json`,O),le=new URL(`update-notifier.json`,O),A=new URL(`analytics.json`,O);async function j(e,t){let n=new URL(`refreshtoken`,P(t.host));return n.searchParams.set(`token`,e),g(n,{schema:r()})}const M=c([a({type:o(`USER`),email:r(),shortId:r()}),a({type:o(`Machine2Machine`),domain:r(),appName:r()})]);async function N(e,t){let n=new URL(`validate`,P(t.host));return e&&n.searchParams.set(`token`,e),g(n,{schema:M})}function P(e){return new URL(`https://auth.${e}/`)}function F(){if(process.env.AI_AGENT!==void 0)return process.env.AI_AGENT.toLowerCase()||void 0;if(process.env.CLAUDE_CODE_IS_COWORK===`1`||process.env.CLAUDE_CODE_IS_COWORK===`true`)return`claude-cowork`;if(process.env.CLAUDECODE===`1`||process.env.CLAUDE_CODE)return`claude-code`;if(process.env.CODEX_CI===`1`||process.env.CODEX_SANDBOX||process.env.CODEX_THREAD_ID)return`codex`;if(process.env.CURSOR_AGENT===`1`||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return`cursor`;if(process.env.CLINE_ACTIVE===`true`)return`cline`;if(process.env.ANTIGRAVITY_AGENT)return`antigravity`;if(process.env.AUGMENT_AGENT===`1`)return`augment`;if(process.env.OPENCODE_CLIENT===`1`)return`opencode`;if(process.env.GEMINI_CLI===`1`)return`gemini-cli`;if(process.env.TRAE_AI_SHELL_ID)return`trae`;if(process.env.REPL_ID)return`replit`;if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return`github-copilot`;let e=process.env.AGENT?.toLowerCase();if(e===`goose`||e===`amp`)return e;if(process.platform===`linux`&&ie(`/opt/.devin`))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const I=a({anonymousId:r(),userId:s(r())}),L=!D.PRISMIC_TOKEN;let R=!1,z,B,V,H,U;async function W(e){let{host:t,repo:n}=e;n&&(z=n),V=e.userIntent,H=e.taskId;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;B=F();let i=await q();U=i??{anonymousId:crypto.randomUUID()},i||await J(U),y({writeKey:r,anonymousId:U.anonymousId,userId:G()})}function ue(e){re({userId:e.shortId,intercomHash:e.intercomHash}),L&&!R&&U&&(U.userId=e.shortId,J(U))}function G(){return L?U?.userId:void 0}function de(){if(!U)return{};let e=G();return{"Prismic-Anonymous-Id":U.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function K(){R=!0;let e=await q();e?.userId&&await J({anonymousId:e.anonymousId})}async function q(){return p(A,{schema:I}).catch(()=>void 0)}async function J(e){await d(A,f(e)).catch(()=>{})}function fe(e,t={}){let{watch:n}=t;v(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:z,watch:n,agent:B,userIntent:V,taskId:H},groupId:z?{Repository:z}:void 0})}function pe(e,t={}){let{watch:n,error:r}=t,i=r?r instanceof Error?r.message:String(r):void 0;v(`Prismic CLI End`,{properties:{commandType:e,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:z,watch:n,error:i?.slice(0,512),agent:B,userIntent:V,taskId:H},groupId:z?{Repository:z}:void 0})}const me=a({telemetry:l()});async function he(){try{return!(await Y(E())||await Y(process.cwd()))}catch{return!0}}async function Y(e){return(await p(new URL(`.prismicrc`,_(C(e))),{schema:me}).catch(()=>void 0))?.telemetry===!1}const ge=m({token:s(r().check(n(1))),host:s(r().check(n(1)))});async function X(){let e=await Z();return{token:D.PRISMIC_TOKEN||e?.token,host:D.PRISMIC_HOST||e?.host||`prismic.io`}}async function _e(){if(D.PRISMIC_TOKEN)return;let{token:e,host:t}=await X();if(!e)return;let n=await j(e,{host:t});return await Q({token:n,host:t}),n}async function ve(){if(!await h(k))return!0;try{return await x(k,{force:!0}),await K(),!0}catch{return!1}}async function Z(){return p(k,{schema:ge}).catch(()=>void 0)}async function Q(e){await d(k,f(e))}async function ye(e){let{host:t}=await X(),n=`https://${t}`;return new Promise((r,i)=>{let a=T((e,i)=>{if(e.method===`OPTIONS`)
|
|
1
|
+
import{B as e,D as t,H as n,I as r,L as i,N as a,O as o,P as s,R as c,S as ee,T as l,U as u,V as te,_ as d,c as f,f as p,k as m,l as h,s as g,v as _,x as ne}from"./request-Dx4vx1nN.mjs";import{i as re,r as v,t as y}from"./segment-DkMwCXor.mjs";import{readFile as b,rm as x}from"node:fs/promises";import{fileURLToPath as S,pathToFileURL as C}from"node:url";import{spawn as w}from"node:child_process";import{createServer as T}from"node:http";import{homedir as E}from"node:os";import{existsSync as ie}from"node:fs";// @__NO_SIDE_EFFECTS__
|
|
2
|
+
function ae(t){return e(ne,t)}const oe=`prismic.io`,se=a({PROD:i(),PRISMIC_SENTRY_DSN:ee(t(),`https://e1886b1775bd397cd1afc60bfd2ebfc8@o146123.ingest.us.sentry.io/4510445143588864`),PRISMIC_SENTRY_ENVIRONMENT:s(r()),PRISMIC_SENTRY_ENABLED:s(i()),PRISMIC_TELEMETRY_ENABLED:s(i()),PRISMIC_HOST:s(r()),PRISMIC_TOKEN:s(r()),PRISMIC_DOCS_HOST:s(r()),PRISMIC_CONFIG_DIR:s(r()),PRISMIC_TYPE_BUILDER_ENABLED:s(i()),PRISMIC_SYNC_POLL_MS:s((/* @__PURE__ */ ae()).check(te(100)))}),D=u(se,{...process.env,PROD:`true`});function ce(e,t){if(t)return _(C(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,_(C(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,_(C(t)))}let n=_(C(E()));return new URL(`.config/${e}/`,n)}const O=ce(`prismic`,D.PRISMIC_CONFIG_DIR),k=new URL(`credentials.json`,O),le=new URL(`update-notifier.json`,O),A=new URL(`analytics.json`,O);async function j(e,t){let n=new URL(`refreshtoken`,P(t.host));return n.searchParams.set(`token`,e),g(n,{schema:r()})}const M=c([a({type:o(`USER`),email:r(),shortId:r()}),a({type:o(`Machine2Machine`),domain:r(),appName:r()})]);async function N(e,t){let n=new URL(`validate`,P(t.host));return e&&n.searchParams.set(`token`,e),g(n,{schema:M})}function P(e){return new URL(`https://auth.${e}/`)}function F(){if(process.env.AI_AGENT!==void 0)return process.env.AI_AGENT.toLowerCase()||void 0;if(process.env.CLAUDE_CODE_IS_COWORK===`1`||process.env.CLAUDE_CODE_IS_COWORK===`true`)return`claude-cowork`;if(process.env.CLAUDECODE===`1`||process.env.CLAUDE_CODE)return`claude-code`;if(process.env.CODEX_CI===`1`||process.env.CODEX_SANDBOX||process.env.CODEX_THREAD_ID)return`codex`;if(process.env.CURSOR_AGENT===`1`||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return`cursor`;if(process.env.CLINE_ACTIVE===`true`)return`cline`;if(process.env.ANTIGRAVITY_AGENT)return`antigravity`;if(process.env.AUGMENT_AGENT===`1`)return`augment`;if(process.env.OPENCODE_CLIENT===`1`)return`opencode`;if(process.env.GEMINI_CLI===`1`)return`gemini-cli`;if(process.env.TRAE_AI_SHELL_ID)return`trae`;if(process.env.REPL_ID)return`replit`;if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return`github-copilot`;let e=process.env.AGENT?.toLowerCase();if(e===`goose`||e===`amp`)return e;if(process.platform===`linux`&&ie(`/opt/.devin`))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const I=a({anonymousId:r(),userId:s(r())}),L=!D.PRISMIC_TOKEN;let R=!1,z,B,V,H,U;async function W(e){let{host:t,repo:n}=e;n&&(z=n),V=e.userIntent,H=e.taskId;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;B=F();let i=await q();U=i??{anonymousId:crypto.randomUUID()},i||await J(U),y({writeKey:r,anonymousId:U.anonymousId,userId:G()})}function ue(e){re({userId:e.shortId,intercomHash:e.intercomHash}),L&&!R&&U&&(U.userId=e.shortId,J(U))}function G(){return L?U?.userId:void 0}function de(){if(!U)return{};let e=G();return{"Prismic-Anonymous-Id":U.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function K(){R=!0;let e=await q();e?.userId&&await J({anonymousId:e.anonymousId})}async function q(){return p(A,{schema:I}).catch(()=>void 0)}async function J(e){await d(A,f(e)).catch(()=>{})}function fe(e,t={}){let{watch:n}=t;v(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:z,watch:n,agent:B,userIntent:V,taskId:H},groupId:z?{Repository:z}:void 0})}function pe(e,t={}){let{watch:n,error:r}=t,i=r?r instanceof Error?r.message:String(r):void 0;v(`Prismic CLI End`,{properties:{commandType:e,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:z,watch:n,error:i?.slice(0,512),agent:B,userIntent:V,taskId:H},groupId:z?{Repository:z}:void 0})}const me=a({telemetry:l()});async function he(){try{return!(await Y(E())||await Y(process.cwd()))}catch{return!0}}async function Y(e){return(await p(new URL(`.prismicrc`,_(C(e))),{schema:me}).catch(()=>void 0))?.telemetry===!1}const ge=m({token:s(r().check(n(1))),host:s(r().check(n(1)))});async function X(){let e=await Z();return{token:D.PRISMIC_TOKEN||e?.token,host:D.PRISMIC_HOST||e?.host||`prismic.io`}}async function _e(){if(D.PRISMIC_TOKEN)return;let{token:e,host:t}=await X();if(!e)return;let n=await j(e,{host:t});return await Q({token:n,host:t}),n}async function ve(){if(!await h(k))return!0;try{return await x(k,{force:!0}),await K(),!0}catch{return!1}}async function Z(){return p(k,{schema:ge}).catch(()=>void 0)}async function Q(e){await d(k,f(e))}async function ye(e){let{host:t}=await X(),n=`https://${t}`;return new Promise((r,i)=>{let a=T((e,i)=>{if(e.method===`OPTIONS`)i.writeHead(204,{"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();else if(e.method===`POST`){let s=(e,t)=>{i.writeHead(e,{"Access-Control-Allow-Origin":n,"Content-Type":`application/json`}),i.end(JSON.stringify(t))},c=``;e.on(`data`,e=>{c+=e.toString()}),e.on(`end`,async()=>{try{let{cookies:e,email:n}=JSON.parse(c),i=e.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!i){s(400,{error:`Invalid request`});return}await Q({token:i,host:t}),await K(),s(200,{success:!0}),clearTimeout(o),a.close(),r({email:n})}catch{s(400,{error:`Invalid request`})}})}else i.writeHead(404),i.end()}),o=setTimeout(()=>{a.close(),i(/* @__PURE__ */ Error(`Login timed out. Please try again.`))},18e4),s=async()=>{let n=a.address();if(!n||typeof n==`string`){clearTimeout(o),a.close(),i(/* @__PURE__ */ Error(`Failed to start login server`));return}let r=await xe(t,n.port);e.onReady(r)};a.on(`error`,e=>{e.code===`EADDRINUSE`&&a.listening===!1?a.listen(0,`0.0.0.0`,s):(clearTimeout(o),i(e))}),a.listen(5555,`0.0.0.0`,s)})}const $=new URL(`.prismic`,_(C(E())));async function be(){let e;try{e=await b($,`utf-8`)}catch{return}try{let t=JSON.parse(e);if(!t||t.latestKnownVersion===void 0&&t.lastUpdateCheckAt===void 0)return}catch{return}try{await x($,{force:!0})}catch{}}async function xe(e,t){let n=new URL(`dashboard/cli/login`,`https://${e}/`);return n.searchParams.set(`source`,`prismic-cli`),n.searchParams.set(`port`,t.toString()),n}function Se(){try{let e=S(new URL(`./subprocesses/refreshToken.mjs`,import.meta.url));w(process.execPath,[e],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{le as _,_e as a,G as c,pe as d,fe as f,O as g,N as h,ve as i,W as l,F as m,ye as n,Se as o,ue as p,X as r,de as s,be as t,he as u,oe as v,D as y};
|