prismic 1.24.0 → 1.25.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 → adapters-tDtRqaKl.mjs} +3 -3
- package/dist/auth-BC_g5X7z.mjs +2 -0
- package/dist/index.mjs +96 -96
- package/dist/{nextjs-D65xFGap.mjs → nextjs-BM8JHpu_.mjs} +1 -1
- package/dist/{nuxt-YzpEi3A5.mjs → nuxt-rya84-wM.mjs} +10 -10
- package/dist/package-CCUFIjT-.mjs +1 -0
- package/dist/{packageJson-B1_pkZr8.mjs → packageJson-uZy38HFJ.mjs} +1 -1
- package/dist/request-BlAQgJGK.mjs +31 -0
- package/dist/segment-CnBu6dod.mjs +1 -0
- package/dist/subprocesses/refreshToken.mjs +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/sveltekit-B6vlxr5A.mjs +1 -0
- package/dist/{sveltekit-7mpC1weE.mjs → sveltekit-yB_4IpMe.mjs} +1 -1
- package/dist/{sveltekit2-C9cZPBvU.mjs → sveltekit2-Gu3WwRkF.mjs} +3 -3
- package/dist/{update-notifier-d8fLG6jz.mjs → update-notifier-BTNGZzaI.mjs} +1 -1
- package/package.json +9 -9
- package/dist/auth-CsokWsVo.mjs +0 -2
- package/dist/package-DCbOjRWH.mjs +0 -1
- package/dist/request-Dx4vx1nN.mjs +0 -30
- package/dist/segment-DkMwCXor.mjs +0 -1
- package/dist/sveltekit-CpIdkani.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e,r as t}from"./auth-BC_g5X7z.mjs";import{C as n,F as r,I as i,M as a,N as o,P as s,_ as c,b as l,c as u,d,f,h as p,k as m,l as h,m as g,s as _,u as v,v as y,w as b,z as x}from"./request-BlAQgJGK.mjs";import{a as S,l as C,r as w,t as ee}from"./packageJson-uZy38HFJ.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,t.exports),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
2
|
`))&&!t?.force?e:e+`
|
|
3
3
|
`}function K(e,t){return Ne(t)+e}function Pe(e,t){return(!e||e.endsWith(`
|
|
4
4
|
|
|
@@ -178,7 +178,7 @@ crawlWithOptions(e,t){return this.options={...this.options,...t},new fn(e||`.`,t
|
|
|
178
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
179
|
/* node:coverage ignore next 2 */
|
|
180
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=
|
|
181
|
+
`)}const er=e()!==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
182
|
--task-id and --user-intent group the commands of one user request together.
|
|
183
183
|
Run \`prismic task-id\` when the user asks for something, then pass that id on
|
|
184
184
|
every command until they ask for something else — creating a slice, adding its
|
|
@@ -186,4 +186,4 @@ const Dn=/^[A-Z]:\/$/i,On=wn?e=>Dn.test(e):e=>e===`/`;function kn(e,t,n){if(e===
|
|
|
186
186
|
what the user asked for as --user-intent. Analytics only — no effect on behavior.
|
|
187
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
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};
|
|
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=o({id:i(),label:i(),url:i()}),lr=o({results:b(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=o({kind:n([`prod`,`stage`,`dev`]),name:i(),domain:i(),users:b(o({id:i()}))});async function mr(e){let{repo:t,host:n}=e;return(await Z(new URL(`core/environments`,Q(t,n)),e,{schema:o({results:b(pr)})})).results}const hr=o({simulator_url:s(i())});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=o({total:a()});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:n,host:r}=t;return(await Z(new URL(`core/releases`,Q(n,r)),t,{method:`POST`,json:e,schema:m({id:i()}),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 _(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=o({values:o({url:i(),fields:r(i(),i())}),imgixEndpoint:i()}),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 _(s.values.url,{method:`POST`,body:u});let d=new URL(l,y(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),_(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),_(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=o({type:i(),path:i(),uid:s(i()),lang:s(i()),resolvers:s(r(i(),i()))}),ai=o({repositoryName:i(),documentAPIEndpoint:s(x()),libraries:s(b(i())),routes:s(b(ii))});async function oi(e){let t=await fi();return await te(t,u(e)),t}async function si(){let e=await ui();try{return await f(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,u(n)),n}async function ui(){let e=await v(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=o({repositoryName:i(),libraries:s(b(i()))});async function xi(){let e=await wi();try{return await f(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 v(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 y(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=>y(new URL(e.replace(/^\//,``),t)))}async function ki(){let e=await Ei();return h(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-BM8JHpu_.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-rya84-wM.mjs`);return new e}if(`@sveltejs/kit`in r){if(await S(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-Gu3WwRkF.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-B6vlxr5A.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 h(n))return;let a=l(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 h(e)||await c(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 n={repo:await Di(),...await t()};await gr(n)||await _r(this.localSimulatorUrl,n),(await ur(n)).length===0&&await dr(this.localPreviewConfig,n)}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=y(new URL(Te(e.name),y(t)));await Ii(`slice`,e.id,n,await this.getSlices()),await c(new URL(`model.json`,n),u(Kr(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await c(t.modelPath,u(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=y(new URL(e.id,y(t)));if(await Ii(`type`,e.id,n,await this.getCustomTypes()),await c(new URL(`index.json`,n),u(Gr(e))),e.format!==`page`)return[];await mi(e);let r=await Ei();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${l(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 h(t.path)?r.push(t):await c(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await c(t.modelPath,u(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 c(e,t),e}async getEnvironment(){let e=await Hi();if(await h(e))return(await d(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await g(await Hi(),this.environmentEnvVarName,e)}async unsetEnvironment(){await p(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 f(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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as e,D as t,H as n,I as r,L as i,M as a,N as o,O as s,P as c,R as ee,S as l,T as u,U as d,V as te,_ as f,c as p,f as m,k as h,l as ne,s as g,v as _,x as re}from"./request-BlAQgJGK.mjs";import{i as v,r as y,t as ie}from"./segment-CnBu6dod.mjs";import{readFile as ae,rm as b}from"node:fs/promises";import{fileURLToPath as oe,pathToFileURL as x}from"node:url";import{spawn as S}from"node:child_process";import{createServer as C}from"node:http";import{homedir as w}from"node:os";import{existsSync as T}from"node:fs";// @__NO_SIDE_EFFECTS__
|
|
2
|
+
function E(t){return e(re,t)}const se=`prismic.io`,ce=o({PROD:i(),PRISMIC_SENTRY_DSN:l(t(),`https://e1886b1775bd397cd1afc60bfd2ebfc8@o146123.ingest.us.sentry.io/4510445143588864`),PRISMIC_SENTRY_ENVIRONMENT:c(r()),PRISMIC_SENTRY_ENABLED:c(i()),PRISMIC_TELEMETRY_ENABLED:c(i()),PRISMIC_HOST:c(r()),PRISMIC_TOKEN:c(r()),PRISMIC_DOCS_HOST:c(r()),PRISMIC_CONFIG_DIR:c(r()),PRISMIC_TYPE_BUILDER_ENABLED:c(i()),PRISMIC_SYNC_POLL_MS:c((/* @__PURE__ */ E()).check(te(100)))}),D=d(ce,{...process.env,PROD:`true`});function le(e,t){if(t)return _(x(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,_(x(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,_(x(t)))}let n=_(x(w()));return new URL(`.config/${e}/`,n)}const O=le(`prismic`,D.PRISMIC_CONFIG_DIR),k=new URL(`credentials.json`,O),ue=new URL(`update-notifier.json`,O),A=new URL(`analytics.json`,O);async function de(e,t){let n=new URL(`refreshtoken`,j(t.host));return n.searchParams.set(`token`,e),g(n,{schema:r()})}const fe=ee([o({type:s(`USER`),email:r(),shortId:r()}),o({type:s(`Machine2Machine`),domain:r(),appName:r()})]);async function pe(e,t){let n=new URL(`validate`,j(t.host));return e&&n.searchParams.set(`token`,e),g(n,{schema:fe})}function j(e){return new URL(`https://auth.${e}/`)}function M(){if(process.env.AI_AGENT?.toLowerCase().startsWith(`claude-code_`))return`claude-code`;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`&&T(`/opt/.devin`))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const me=h({exp:c(a()),type:c(r())});function N(e){try{let[,t]=e.split(`.`);if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString());return d(me,n)}catch{return}}const P=o({anonymousId:r(),userId:c(r())}),F=!D.PRISMIC_TOKEN;let I=!1,L,R,z,B,V,H,U,W;async function he(e){let{host:t,repo:n}=e;n&&(L=n),H=e.userIntent,U=e.taskId;let r=t===`prismic.io`?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;R=M(),z=ve(e.token),{runtime:B,runtimeProvider:V}=ye();let i=await q();W=i??{anonymousId:crypto.randomUUID()},i||await J(W),ie({writeKey:r,anonymousId:W.anonymousId,userId:G()})}function ge(e){v({userId:e.shortId,intercomHash:e.intercomHash}),F&&!I&&W&&(W.userId=e.shortId,J(W))}function G(){return F?W?.userId:void 0}function _e(){if(!W)return{};let e=G();return{"Prismic-Anonymous-Id":W.anonymousId,...e?{"Prismic-User-Id":e}:{}}}async function K(){I=!0;let e=await q();e?.userId&&await J({anonymousId:e.anonymousId})}function ve(e){if(!e)return`none`;if(!D.PRISMIC_TOKEN)return`login`;let t=N(e);return t?t.type===`machine2machine`?`write-token`:`user-token`:`unknown-token`}function ye(){let e=be();if(e)return{runtime:`cloud`,runtimeProvider:e};let t=xe();return t||process.env.CI?{runtime:`ci`,runtimeProvider:t}:T(`/.dockerenv`)||T(`/run/.containerenv`)||process.env.KUBERNETES_SERVICE_HOST?{runtime:`container`}:process.platform!==`linux`||process.env.WSL_DISTRO_NAME?{runtime:`local`}:{runtime:`unknown`}}function be(){if(process.env.CLAUDE_CODE_REMOTE===`true`)return`claude-code`;if(process.env.CODEX_EXEC_SERVER_REMOTE_BASE_URL)return`codex`;if(process.env.CURSOR_AGENT&&process.env.CLOUD_AGENT_ALL_SECRET_NAMES!==void 0)return`cursor`;if(process.env.CODESPACES===`true`)return`codespaces`;if(process.env.GITPOD_WORKSPACE_ID)return`gitpod`;if(process.versions.webcontainer)return`stackblitz`;if(process.env.REPL_ID)return`replit`;if(process.env.CODESANDBOX_HOST)return`codesandbox`;if(process.env.MODAL_SANDBOX_ID)return`modal`;if(process.env.E2B_SANDBOX)return`e2b`;if(T(`/opt/.devin`))return`devin`}function xe(){if(process.env.GITHUB_ACTIONS===`true`)return`github-actions`;if(process.env.GITLAB_CI)return`gitlab`;if(process.env.CIRCLECI)return`circleci`;if(process.env.BITBUCKET_BUILD_NUMBER)return`bitbucket`;if(process.env.TF_BUILD)return`azure-pipelines`;if(process.env.JENKINS_URL)return`jenkins`;if(process.env.BUILDKITE)return`buildkite`;if(process.env.CODEBUILD_BUILD_ID)return`codebuild`;if(process.env.TEAMCITY_VERSION)return`teamcity`;if(process.env.VERCEL&&process.env.CI)return`vercel`;if(process.env.NETLIFY)return`netlify`;if(process.env.CF_PAGES)return`cloudflare-pages`}async function q(){return m(A,{schema:P}).catch(()=>void 0)}async function J(e){await f(A,p(e)).catch(()=>{})}function Se(e,t={}){let{watch:n}=t;y(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:L,watch:n,agent:R,auth:z,runtime:B,runtimeProvider:V,userIntent:H,taskId:U},groupId:L?{Repository:L}:void 0})}function Ce(e,t={}){let{watch:n,error:r}=t,i=r?r instanceof Error?r.message:String(r):void 0;y(`Prismic CLI End`,{properties:{commandType:e,fullCommand:process.argv.join(` `),success:!process.exitCode,repository:L,watch:n,error:i?.slice(0,512),agent:R,auth:z,runtime:B,runtimeProvider:V,userIntent:H,taskId:U},groupId:L?{Repository:L}:void 0})}const we=o({telemetry:u()});async function Te(){try{return!(await Y(w())||await Y(process.cwd()))}catch{return!0}}async function Y(e){return(await m(new URL(`.prismicrc`,_(x(e))),{schema:we}).catch(()=>void 0))?.telemetry===!1}const Ee=h({token:c(r().check(n(1))),host:c(r().check(n(1)))});async function X(){let e=await Oe();return{token:D.PRISMIC_TOKEN||e?.token,host:D.PRISMIC_HOST||e?.host||`prismic.io`}}async function Z(){if(D.PRISMIC_TOKEN)return;let{token:e,host:t}=await X();if(!e)return;let n=await de(e,{host:t});return await Q({token:n,host:t}),n}async function De(){if(!await ne(k))return!0;try{return await b(k,{force:!0}),await K(),!0}catch{return!1}}async function Oe(){return m(k,{schema:Ee}).catch(()=>void 0)}async function Q(e){await f(k,p(e))}async function ke(e){let{host:t}=await X(),n=`https://${t}`;return new Promise((r,i)=>{let a=C((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 je(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`,_(x(w())));async function Ae(){let e;try{e=await ae($,`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 b($,{force:!0})}catch{}}async function je(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 Me(){try{let e=oe(new URL(`./subprocesses/refreshToken.mjs`,import.meta.url));S(process.execPath,[e],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{O as _,Z as a,D as b,G as c,Ce as d,Se as f,pe as g,M as h,De as i,he as l,N as m,ke as n,Me as o,ge as p,X as r,_e as s,Ae as t,Te as u,ue as v,se as y};
|