prismic 1.30.0 → 1.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{n as e}from"./package-DZJSt_MI.mjs";import{$ as t,A as n,B as r,D as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,N as f,O as p,P as m,Q as h,R as g,S as _,T as v,U as ee,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,at as E,b as D,et as O,g as te,h as ne,it as k,j as A,l as re,m as j,nt as M,ot as N,p as P,q as F,r as ie,rt as I,t as L,tt as R,w as z,y as B,z as V}from"./packageJson-BEVwXn1i.mjs";import{i as H,r as ae,t as oe}from"./segment-BpOvsf06.mjs";import{parseArgs as U}from"node:util";import{chmod as se,lstat as W,mkdir as ce,open as le,readFile as ue,realpath as de,rename as fe,rm as pe,stat as me,utimes as he,writeFile as ge}from"node:fs/promises";import{sep as _e}from"node:path";import{fileURLToPath as ve,pathToFileURL as ye}from"node:url";import*as be from"node:crypto";import{createCipheriv as xe,createDecipheriv as Se,createHash as Ce,randomBytes as we,randomUUID as Te}from"node:crypto";import*as Ee from"fs";import{readdir as De,readdirSync as Oe,realpath as ke,realpathSync as Ae,stat as je,statSync as Me}from"fs";import{basename as Ne,dirname as Pe,isAbsolute as Fe,normalize as Ie,posix as Le,relative as Re,resolve as ze,sep as Be}from"path";import{fileURLToPath as Ve}from"url";import{createRequire as He}from"module";import{homedir as Ue,hostname as We,release as Ge}from"node:os";import{setTimeout as Ke}from"node:timers/promises";import{constants as qe,existsSync as Je}from"node:fs";import{exec as Ye,spawn as Xe}from"node:child_process";var Ze=Object.create,Qe=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,tt=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,rt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),it=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=et(t),a=0,o=i.length,s;a<o;a++)s=i[a],!nt.call(e,s)&&s!==n&&Qe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=$e(t,s))||r.enumerable});return e},at=(e,t,n)=>(n=e==null?{}:Ze(tt(e)),it(t||!e||!e.__esModule||!nt.call(e,`default`)?Qe(n,`default`,{value:e,enumerable:!0}):n,e));const ot=/([\p{Ll}\d])(\p{Lu})/gu,st=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,ct=/(\d)\p{Ll}|(\p{L})\d/u,lt=/[^\p{L}\d]+/giu,ut=`$1\0$2`;function dt(e){let t=e.trim();t=t.replace(ot,ut).replace(st,ut),t=t.replace(lt,`\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 ft(e){let t=dt(e);for(let e=0;e<t.length;e++){let n=t[e],r=ct.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 pt(e,t){let[n,r,i]=St(e,t);return n+r.map(vt(t?.locale)).join(t?.delimiter??` `)+i}function mt(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale),s=t?.mergeAmbiguousCharacters?bt(a,o):xt(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function ht(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale),s=t?.mergeAmbiguousCharacters?bt(a,o):xt(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function gt(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale);return n+r.map(bt(a,o)).join(t?.delimiter??` `)+i}function _t(e,t){return pt(e,{delimiter:`_`,...t})}function vt(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function bt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function xt(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function St(e,t={}){let n=t.split??(t.separateNumbers?ft:dt),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 Ct(e,t){return(!e||e.endsWith(`
1
+ import{n as e}from"./package-_vugy-j4.mjs";import{$ as t,A as n,B as r,D as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,N as f,O as p,P as m,Q as h,R as g,S as _,T as v,U as ee,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,at as E,b as D,et as O,g as te,h as ne,it as k,j as A,l as re,m as j,nt as M,ot as N,p as P,q as F,r as ie,rt as I,t as L,tt as R,w as z,y as B,z as V}from"./packageJson-BEVwXn1i.mjs";import{i as H,r as ae,t as oe}from"./segment-rgJUUL0P.mjs";import{parseArgs as U}from"node:util";import{chmod as se,lstat as W,mkdir as ce,open as le,readFile as ue,realpath as de,rename as fe,rm as pe,stat as me,utimes as he,writeFile as ge}from"node:fs/promises";import{sep as _e}from"node:path";import{fileURLToPath as ve,pathToFileURL as ye}from"node:url";import*as be from"node:crypto";import{createCipheriv as xe,createDecipheriv as Se,createHash as Ce,randomBytes as we,randomUUID as Te}from"node:crypto";import*as Ee from"fs";import{readdir as De,readdirSync as Oe,realpath as ke,realpathSync as Ae,stat as je,statSync as Me}from"fs";import{basename as Ne,dirname as Pe,isAbsolute as Fe,normalize as Ie,posix as Le,relative as Re,resolve as ze,sep as Be}from"path";import{fileURLToPath as Ve}from"url";import{createRequire as He}from"module";import{homedir as Ue,hostname as We,release as Ge}from"node:os";import{setTimeout as Ke}from"node:timers/promises";import{constants as qe,existsSync as Je}from"node:fs";import{exec as Ye,spawn as Xe}from"node:child_process";var Ze=Object.create,Qe=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,tt=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,rt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),it=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=et(t),a=0,o=i.length,s;a<o;a++)s=i[a],!nt.call(e,s)&&s!==n&&Qe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=$e(t,s))||r.enumerable});return e},at=(e,t,n)=>(n=e==null?{}:Ze(tt(e)),it(t||!e||!e.__esModule||!nt.call(e,`default`)?Qe(n,`default`,{value:e,enumerable:!0}):n,e));const ot=/([\p{Ll}\d])(\p{Lu})/gu,st=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,ct=/(\d)\p{Ll}|(\p{L})\d/u,lt=/[^\p{L}\d]+/giu,ut=`$1\0$2`;function dt(e){let t=e.trim();t=t.replace(ot,ut).replace(st,ut),t=t.replace(lt,`\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 ft(e){let t=dt(e);for(let e=0;e<t.length;e++){let n=t[e],r=ct.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 pt(e,t){let[n,r,i]=St(e,t);return n+r.map(vt(t?.locale)).join(t?.delimiter??` `)+i}function mt(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale),s=t?.mergeAmbiguousCharacters?bt(a,o):xt(a,o);return n+r.map((e,t)=>t===0?a(e):s(e,t)).join(t?.delimiter??``)+i}function ht(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale),s=t?.mergeAmbiguousCharacters?bt(a,o):xt(a,o);return n+r.map(s).join(t?.delimiter??``)+i}function gt(e,t){let[n,r,i]=St(e,t),a=vt(t?.locale),o=yt(t?.locale);return n+r.map(bt(a,o)).join(t?.delimiter??` `)+i}function _t(e,t){return pt(e,{delimiter:`_`,...t})}function vt(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function bt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function xt(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function St(e,t={}){let n=t.split??(t.separateNumbers?ft:dt),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 Ct(e,t){return(!e||e.endsWith(`
2
2
  `))&&!t?.force?e:e+`
3
3
  `}function G(e,t){return Ct(t)+e}function wt(e,t){return(!e||e.endsWith(`
4
4
 
@@ -194,4 +194,4 @@ function Br(e){return M(a,e)}const Vr=`prismic.io`,Hr=l({PROD:h(),PRISMIC_SENTRY
194
194
  ${r??n}
195
195
  ${r===void 0?`Enter the code ${t}.`:`Check that the page shows the code ${t}.`}
196
196
  Waiting for the login (the code expires in ${i} ${i===1?`minute`:`minutes`})...
197
- `)}async function ec(e,t){let n=new AbortController,r=setInterval(async()=>{let r=await Z().catch(()=>void 0);e.cancelled||r&&r.login?.session.pendingLogin?.deviceCode!==t.deviceCode&&n.abort()},js),i=Number.isFinite(e.deadline)?AbortSignal.timeout(Math.max(0,e.deadline-Date.now())):void 0;try{return await ri(t,{signal:i?AbortSignal.any([i,n.signal]):n.signal,onUpdate:n=>tc(t,{...n,host:e.host})})}catch(e){if(e instanceof X)throw await tc(t,void 0),e;if(n.signal.aborted)return{status:`logged-out`};if(i?.aborted)return{status:`wait-limit`};throw e}finally{clearInterval(r)}}async function tc(e,t){await Wi(async n=>{let r=(await Z()).login;r?.session.pendingLogin?.deviceCode===e.deviceCode&&await Hi(n,{...r,session:{...r.session,pendingLogin:t}})}).catch(()=>{})}async function nc(e,t,n){return Wi(async r=>{let i=await Z().catch(()=>void 0);if(i&&i.login?.session.pendingLogin?.deviceCode!==t.deviceCode){await oi(n.refreshToken,t).catch(()=>{});return}let a=i?.login?{store:i.login.store,storeReason:i.login.storeReason}:await Vi(r),o={host:e.host,...e.auth0,...n};await Hi(r,{...a,session:o}),e.saved={...a,token:n.accessToken};let s=i?.login?.session;return s?.refreshToken&&await oi(s.refreshToken,s).catch(()=>{}),e.saved})}async function rc(){let e;try{e=await ue(Ns,`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 pe(Ns,{force:!0})}catch{}}function ic(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 ac(e){return e.insert.length+e.update.length+e.delete.length>0}const oc=[`Slices`,`UID`,`Choice`];function sc(e,t,n){if(t in e)throw new Sc(t);e[t]=n}function cc(e,t){let n=e[t];if(!n)throw new Cc(t);return n}function lc(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new Tc(`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 Tc(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(oc.includes(s.type)||e===`uid`)throw new Tc(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new Tc(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new Tc(`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 Tc(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new Tc(`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 Tc(`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 Tc(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function uc(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new Ec(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new Cc(n)}return bc(e,r)}function dc(e,t,n,r=!1){let i=t.variations.find(e=>e.id===n);if(!i)throw new Dc(n,t.id);if(r){if(!i.items||Object.keys(i.items).length===0)throw new Oc(n,t.id);return bc(e,i.items)}return i.primary??={},bc(e,i.primary)}async function fc(e){let[t,n]=await Promise.all([La(e),Ra(e)]);return{customTypes:t,slices:n}}async function pc({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 za(i,n)}function mc(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:ic(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(hc(e))===JSON.stringify(r?t:hc(t))}),slices:ic(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(gc(e))===JSON.stringify(r?t:gc(t))})}}function hc(e){return{...yc(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,_c(t)]))}}function gc(e){return{...yc(e),variations:e.variations.map(e=>{let t=yc(e);return e.primary&&(t.primary=_c(e.primary)),e.items&&(t.items=_c(e.items)),t})}}function _c(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=yc(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=_c(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=vc(t.config.choices)),[e,n]}))}function vc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=yc(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=_c(t[`non-repeat`])),t.repeat&&(n.repeat=_c(t.repeat))),[e,n]}))}function yc(e){return Array.isArray(e)?e.map(yc):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,yc(t)]))}function bc(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=cc(t,n);if(i.type!==`Group`)throw new wc(n);return i.config??={},i.config.fields??={},bc(r.join(`.`),i.config.fields)}function xc(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 Sc=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},Cc=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},wc=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},Tc=class extends Error{name=`FieldSelectionError`},Ec=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},Dc=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}},Oc=class extends Error{name=`SliceItemsNotFoundError`;constructor(e,t){super(`Variation "${e}" of slice "${t}" has no legacy items zone. To add repeatable fields, add a repeatable group to the slice.`)}};const kc=`prismic.config.json`,Ac=l({type:C(),path:C(),uid:S(C()),lang:S(C()),resolvers:S(x(C(),C()))}),jc=l({repositoryName:C(),documentAPIEndpoint:S(R()),libraries:S(V(C())),routes:S(V(Ac))});async function Mc(e){let t=await Rc();return await ge(t,P(e)),t}async function Nc(){let e=await Ic();try{return await w(e,{schema:jc})}catch{throw new Pc}}var Pc=class extends Error{name=`InvalidPrismicConfigError`;message=`${kc} is invalid. Run \`prismic init\` to re-create a config.`};async function Fc(e){let t=await Ic(),n={...await Nc(),...e};return await ge(t,P(n)),n}async function Ic(){let e=await ne(kc,{stop:`package.json`});if(!e)throw new Lc;return e}var Lc=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${kc} file. Run \`prismic init\` to create a config.`};async function Rc(){try{let e=await ie();return new URL(kc,e)}catch(e){throw e instanceof L?new zc({cause:e}):e}}var zc=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Bc(e){let{routes:t=[]}=await Nc();if(t.some(t=>t.type===e.id))return;let n=Wc(e),r={type:e.id,path:n};await Fc({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Vc(e){e.format===`page`?await Bc(e):await Hc(e.id)}async function Hc(e){let{routes:t=[]}=await Nc(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await Fc({routes:n})}function Uc(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function Wc(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const Gc=`slicemachine.config.json`,Kc=l({repositoryName:C(),libraries:S(V(C()))});async function qc(){let e=await Xc();try{return await w(e,{schema:Kc})}catch{throw new Jc}}var Jc=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${Gc} is invalid.`};async function Yc(){let e=await Xc();await pe(e)}async function Xc(){let e=await ne(Gc,{stop:`package.json`});if(!e)throw new Zc;return e}var Zc=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${Gc} file.`};async function Qc(){let e;try{e=await Ic()}catch(t){if(t instanceof Lc)e=await Rc();else throw t}let t=new URL(`.`,e);return A(ye(await de(ve(t))))}async function $c(){try{return(await Nc()).repositoryName}catch(e){if(e instanceof Lc)try{return(await qc()).repositoryName}catch{}throw e}}async function el(){let e=(await Nc()).libraries;if(!e||e.length<1)return;let t=await Qc();return e.map(e=>A(new URL(e.replace(/^\//,``),t)))}async function tl(){let e=await Qc();return j(new URL(`tsconfig.json`,e))}const nl=[`next`,`nuxt`,`sveltekit`];async function rl(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await re(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-4lBT3LWb.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-CXMFa4cT.mjs`);return new e}if(`@sveltejs/kit`in r){if(await T(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-xFDbKhF_.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-B-_UPD7T.mjs`);return new e}throw new il}var il=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},al=class extends Error{name=`ModelExistsError`},ol=class extends Error{name=`SliceNotFoundError`;constructor(e){super(`Slice "${e}" does not exist. Run \`prismic slice list\` to see available IDs.`)}},sl=class extends Error{name=`CustomTypeNotFoundError`;constructor(e){super(`Type "${e}" does not exist. Run \`prismic type list\` to see available IDs.`)}};async function cl(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await j(n))return;let a=m(await Qc(),i?.directory??n),o=i?` (id: ${i.model.id})`:``;throw new al(`A ${e} already exists at ${a}${_e}${o}.`)}async function ll(){return await(await rl()).getEnvironment()??await $c()}async function ul(e){let t=await zr(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ve(await Qc()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await ue(n,`utf8`)).includes(e))return!0}catch{}return!1}async function dl(e,t){await j(e)||await _(e,t)}async function fl(){return await tl()?`ts`:`js`}var pl=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 $c(),getToken:Rs,host:await zs()};(await ao(t)).simulator_url||await oo(this.localSimulatorUrl,t),(await eo(t)).results.length===0&&await to(this.localPreviewConfig,t)}async getSliceLibraries(){return await el()??[await this.getDefaultSliceLibrary()]}async getSlices(){return hl(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=xc((await this.getCustomTypes()).map(e=>e.model)).find(t=>t.id===e);if(n){let{customTypeId:t,sliceZoneId:r}=n;throw new Q(`"${e}" is a legacy slice in "${t}". Upgrade it first: \`prismic slice upgrade-legacy ${e} --from ${t}${r===`body`?``:` --slice-zone ${r}`}\`.`)}throw new ol(e)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=A(new URL(ht(e.name),A(t)));await cl(`slice`,e.id,n,await this.getSlices()),await _(new URL(`model.json`,n),P(gc(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await _(t.modelPath,P(gc(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await pe(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await Qc())]}async getCustomTypes(){return hl(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw new sl(e);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=A(new URL(e.id,A(t)));if(await cl(`type`,e.id,n,await this.getCustomTypes()),await _(new URL(`index.json`,n),P(hc(e))),e.format!==`page`)return[];await Bc(e);let r=await Qc();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${m(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await Nc(),n=(Uc(t,e.id)?.path??Wc(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await j(t.path)?r.push(t):await _(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await _(t.modelPath,P(hc(e))),await Vc(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await pe(t.directory,{recursive:!0}),await Hc(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 Qc()),t=Qt({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 _(e,t),e}async getEnvironment(){let e=await ml();if(await j(e))return(await te(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await B(await ml(),this.environmentEnvVarName,e)}async unsetEnvironment(){await D(await ml(),this.environmentEnvVarName)}};async function ml(){return new URL(`.env.local`,await Qc())}async function hl(e,t){let n=[];for(let r of e){let e=await zr(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=ye(e),n=await w(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{us as $,ua as $t,Dc as A,Co as At,uc as B,jo as Bt,Nc as C,Ma as Ct,Cc as D,so as Dt,Sc as E,Ho as Et,gc as F,ao as Ft,zs as G,Wa as Gt,pc as H,oo as Ht,mc as I,Da as It,Us as J,Q as Jt,Rs as K,Xa as Kt,xc as L,Oa as Lt,wc as M,eo as Mt,sc as N,ja as Nt,Tc as O,io as Ot,hc as P,Ao as Pt,fs as Q,xa as Qt,fc as R,mo as Rt,$c as S,ko as St,Fc as T,Uo as Tt,ac as U,Fa as Ut,dc as V,Mo as Vt,rc as W,go as Wt,ms as X,ga as Xt,Gs as Y,ha as Yt,ps as Z,ba as Zt,tl as _,ht as _n,Eo as _t,il as a,Ui as an,Fo as at,Uc as b,Ua as bt,ll as c,Wi as cn,to as ct,dl as d,Y as dn,To as dt,da as en,Os as et,Jc as f,Yr as fn,co as ft,Wc as g,gt as gn,Za as gt,zc as h,mt as hn,Oo as ht,al as i,qi as in,ds as it,Ec as j,Pa as jt,Oc as k,Ya as kt,rl as l,X as ln,Io as lt,Lc as m,Ur as mn,ho as mt,sl as n,ca as nn,Ss as nt,ol as o,Z as on,Ka as ot,Pc as p,Vr as pn,Lo as pt,Ks as q,Ca as qt,nl as r,sa as rn,xs as rt,ul as s,zi as sn,fo as st,pl as t,fa as tn,ws as tt,fl as u,oi as un,wo as ut,Mc as v,_t as vn,no as vt,qc as w,Vo as wt,Qc as x,_o as xt,Yc as y,lo as yt,lc as z,Do as zt};
197
+ `)}async function ec(e,t){let n=new AbortController,r=setInterval(async()=>{let r=await Z().catch(()=>void 0);e.cancelled||r&&r.login?.session.pendingLogin?.deviceCode!==t.deviceCode&&n.abort()},js),i=Number.isFinite(e.deadline)?AbortSignal.timeout(Math.max(0,e.deadline-Date.now())):void 0;try{return await ri(t,{signal:i?AbortSignal.any([i,n.signal]):n.signal,onUpdate:n=>tc(t,{...n,host:e.host})})}catch(e){if(e instanceof X)throw await tc(t,void 0),e;if(n.signal.aborted)return{status:`logged-out`};if(i?.aborted)return{status:`wait-limit`};throw e}finally{clearInterval(r)}}async function tc(e,t){await Wi(async n=>{let r=(await Z()).login;r?.session.pendingLogin?.deviceCode===e.deviceCode&&await Hi(n,{...r,session:{...r.session,pendingLogin:t}})}).catch(()=>{})}async function nc(e,t,n){return Wi(async r=>{let i=await Z().catch(()=>void 0);if(i&&i.login?.session.pendingLogin?.deviceCode!==t.deviceCode){await oi(n.refreshToken,t).catch(()=>{});return}let a=i?.login?{store:i.login.store,storeReason:i.login.storeReason}:await Vi(r),o={host:e.host,...e.auth0,...n};await Hi(r,{...a,session:o}),e.saved={...a,token:n.accessToken};let s=i?.login?.session;return s?.refreshToken&&await oi(s.refreshToken,s).catch(()=>{}),e.saved})}async function rc(){let e;try{e=await ue(Ns,`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 pe(Ns,{force:!0})}catch{}}function ic(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 ac(e){return e.insert.length+e.update.length+e.delete.length>0}const oc=[`Slices`,`UID`,`Choice`];function sc(e,t,n){if(t in e)throw new Sc(t);e[t]=n}function cc(e,t){let n=e[t];if(!n)throw new Cc(t);return n}function lc(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=r.get(t);if(!i)throw new Tc(`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 Tc(`Field "${e}" does not exist on type "${n}".`);let c=o.filter(Boolean);if(c.length===0){if(oc.includes(s.type)||e===`uid`)throw new Tc(`Field "${e}" cannot be fetched from a content relationship.`);if(s.type===`Group`)throw new Tc(`Field "${e}" is a group. Select specific subfields.`);return e}if(c.length!==o.length)throw new Tc(`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 Tc(`Content relationships cannot be nested more than once.`);let t=s.config?.customtypes;if(!t||t.length!==1)throw new Tc(`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 Tc(`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 Tc(`Field "${e}" is not a group or content relationship field.`)})};return a(e,Object.assign({},...Object.values(i.json)),i.id,!0)}function uc(e,t,n){let r;if(n){if(r=t.json[n],!r)throw new Ec(n,t.id)}else{let[n]=e.split(`.`);if(r=Object.values(t.json).find(e=>n in e),!r)throw new Cc(n)}return bc(e,r)}function dc(e,t,n,r=!1){let i=t.variations.find(e=>e.id===n);if(!i)throw new Dc(n,t.id);if(r){if(!i.items||Object.keys(i.items).length===0)throw new Oc(n,t.id);return bc(e,i.items)}return i.primary??={},bc(e,i.primary)}async function fc(e){let[t,n]=await Promise.all([La(e),Ra(e)]);return{customTypes:t,slices:n}}async function pc({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 za(i,n)}function mc(e,t,n={}){let{treatNonCanonicalAsChanged:r=!1}=n;return{customTypes:ic(e.customTypes,t.customTypes,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(hc(e))===JSON.stringify(r?t:hc(t))}),slices:ic(e.slices,t.slices,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(gc(e))===JSON.stringify(r?t:gc(t))})}}function hc(e){return{...yc(e),json:Object.fromEntries(Object.entries(e.json).map(([e,t])=>[e,_c(t)]))}}function gc(e){return{...yc(e),variations:e.variations.map(e=>{let t=yc(e);return e.primary&&(t.primary=_c(e.primary)),e.items&&(t.items=_c(e.items)),t})}}function _c(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=yc(t);return t.type===`Group`&&t.config?.fields&&n.type===`Group`&&n.config?.fields&&(n.config.fields=_c(t.config.fields)),t.type===`Slices`&&t.config?.choices&&n.type===`Slices`&&n.config?.choices&&(n.config.choices=vc(t.config.choices)),[e,n]}))}function vc(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=yc(t);return t.type===`Slice`&&n.type===`Slice`&&(t[`non-repeat`]&&(n[`non-repeat`]=_c(t[`non-repeat`])),t.repeat&&(n.repeat=_c(t.repeat))),[e,n]}))}function yc(e){return Array.isArray(e)?e.map(yc):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,yc(t)]))}function bc(e,t){let[n,...r]=e.split(`.`);if(r.length===0)return{fields:t,fieldId:n};let i=cc(t,n);if(i.type!==`Group`)throw new wc(n);return i.config??={},i.config.fields??={},bc(r.join(`.`),i.config.fields)}function xc(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 Sc=class extends Error{name=`FieldExistsError`;constructor(e){super(`Field "${e}" already exists.`)}},Cc=class extends Error{name=`FieldNotFoundError`;constructor(e){super(`Field "${e}" does not exist.`)}},wc=class extends Error{name=`UnsupportedNestedFieldError`;constructor(e){super(`Field "${e}" does not support nested fields.`)}},Tc=class extends Error{name=`FieldSelectionError`},Ec=class extends Error{name=`TabNotFoundError`;constructor(e,t){super(`Tab "${e}" does not exist on type "${t}".`)}},Dc=class extends Error{name=`SliceVariationNotFoundError`;constructor(e,t){super(`Variation "${e}" does not exist on slice "${t}".`)}},Oc=class extends Error{name=`SliceItemsNotFoundError`;constructor(e,t){super(`Variation "${e}" of slice "${t}" has no legacy items zone. To add repeatable fields, add a repeatable group to the slice.`)}};const kc=`prismic.config.json`,Ac=l({type:C(),path:C(),uid:S(C()),lang:S(C()),resolvers:S(x(C(),C()))}),jc=l({repositoryName:C(),documentAPIEndpoint:S(R()),libraries:S(V(C())),routes:S(V(Ac))});async function Mc(e){let t=await Rc();return await ge(t,P(e)),t}async function Nc(){let e=await Ic();try{return await w(e,{schema:jc})}catch{throw new Pc}}var Pc=class extends Error{name=`InvalidPrismicConfigError`;message=`${kc} is invalid. Run \`prismic init\` to re-create a config.`};async function Fc(e){let t=await Ic(),n={...await Nc(),...e};return await ge(t,P(n)),n}async function Ic(){let e=await ne(kc,{stop:`package.json`});if(!e)throw new Lc;return e}var Lc=class extends Error{name=`MissingPrismicConfigError`;message=`Could not find a ${kc} file. Run \`prismic init\` to create a config.`};async function Rc(){try{let e=await ie();return new URL(kc,e)}catch(e){throw e instanceof L?new zc({cause:e}):e}}var zc=class extends Error{name=`UnknownProjectRootError`;constructor(e){super(`Could not find your project root.`,e)}};async function Bc(e){let{routes:t=[]}=await Nc();if(t.some(t=>t.type===e.id))return;let n=Wc(e),r={type:e.id,path:n};await Fc({routes:[...t,r].sort((e,t)=>e.type.localeCompare(t.type))})}async function Vc(e){e.format===`page`?await Bc(e):await Hc(e.id)}async function Hc(e){let{routes:t=[]}=await Nc(),n=t.filter(t=>t.type!==e);t.length!==n.length&&await Fc({routes:n})}function Uc(e,t){return e.find(e=>e.type===t&&!e.uid&&!/[?*+]/.test(e.path))}function Wc(e){let{id:t,repeatable:n}=e,r=t.replaceAll(`_`,`-`).toLowerCase();return n?t===`page`?`/:uid`:`/${r}/:uid`:t===`homepage`?`/`:`/${r}`}const Gc=`slicemachine.config.json`,Kc=l({repositoryName:C(),libraries:S(V(C()))});async function qc(){let e=await Xc();try{return await w(e,{schema:Kc})}catch{throw new Jc}}var Jc=class extends Error{name=`InvalidLegacySliceMachineConfigError`;message=`${Gc} is invalid.`};async function Yc(){let e=await Xc();await pe(e)}async function Xc(){let e=await ne(Gc,{stop:`package.json`});if(!e)throw new Zc;return e}var Zc=class extends Error{name=`MissingLegacySliceMachineConfigError`;message=`Could not find a ${Gc} file.`};async function Qc(){let e;try{e=await Ic()}catch(t){if(t instanceof Lc)e=await Rc();else throw t}let t=new URL(`.`,e);return A(ye(await de(ve(t))))}async function $c(){try{return(await Nc()).repositoryName}catch(e){if(e instanceof Lc)try{return(await qc()).repositoryName}catch{}throw e}}async function el(){let e=(await Nc()).libraries;if(!e||e.length<1)return;let t=await Qc();return e.map(e=>A(new URL(e.replace(/^\//,``),t)))}async function tl(){let e=await Qc();return j(new URL(`tsconfig.json`,e))}const nl=[`next`,`nuxt`,`sveltekit`];async function rl(){let{dependencies:e,devDependencies:t,peerDependencies:n}=await re(),r={...e,...t,...n};if(`next`in r){let{NextJsAdapter:e}=await import(`./nextjs-CJp_PYnD.mjs`);return new e}if(`nuxt`in r){let{NuxtAdapter:e}=await import(`./nuxt-R6UZmndR.mjs`);return new e}if(`@sveltejs/kit`in r){if(await T(`@sveltejs/kit`)<3){let{SvelteKit2Adapter:e}=await import(`./sveltekit2-BVa2TtAH.mjs`);return new e}let{SvelteKitAdapter:e}=await import(`./sveltekit-C4efXOa6.mjs`);return new e}throw new il}var il=class extends Error{name=`NoSupportedFrameworkError`;message=`No supported framework found. Run this command in a Next.js, Nuxt, or SvelteKit project.`},al=class extends Error{name=`ModelExistsError`},ol=class extends Error{name=`SliceNotFoundError`;constructor(e){super(`Slice "${e}" does not exist. Run \`prismic slice list\` to see available IDs.`)}},sl=class extends Error{name=`CustomTypeNotFoundError`;constructor(e){super(`Type "${e}" does not exist. Run \`prismic type list\` to see available IDs.`)}};async function cl(e,t,n,r){let i=r.find(e=>e.model.id===t||e.directory.href===n.href);if(!i&&!await j(n))return;let a=m(await Qc(),i?.directory??n),o=i?` (id: ${i.model.id})`:``;throw new al(`A ${e} already exists at ${a}${_e}${o}.`)}async function ll(){return await(await rl()).getEnvironment()??await $c()}async function ul(e){let t=await zr(`**/*.{js,jsx,mjs,ts,tsx,mts,svelte}`,{cwd:ve(await Qc()),absolute:!0,ignore:`**/{node_modules,build,dist,out}/**`});for(let n of t)try{if((await ue(n,`utf8`)).includes(e))return!0}catch{}return!1}async function dl(e,t){await j(e)||await _(e,t)}async function fl(){return await tl()?`ts`:`js`}var pl=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 $c(),getToken:Rs,host:await zs()};(await ao(t)).simulator_url||await oo(this.localSimulatorUrl,t),(await eo(t)).results.length===0&&await to(this.localPreviewConfig,t)}async getSliceLibraries(){return await el()??[await this.getDefaultSliceLibrary()]}async getSlices(){return hl(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=xc((await this.getCustomTypes()).map(e=>e.model)).find(t=>t.id===e);if(n){let{customTypeId:t,sliceZoneId:r}=n;throw new Q(`"${e}" is a legacy slice in "${t}". Upgrade it first: \`prismic slice upgrade-legacy ${e} --from ${t}${r===`body`?``:` --slice-zone ${r}`}\`.`)}throw new ol(e)}async createSlice(e){let[t]=await this.getSliceLibraries(),n=A(new URL(ht(e.name),A(t)));await cl(`slice`,e.id,n,await this.getSlices()),await _(new URL(`model.json`,n),P(gc(e))),await this.createSliceIndexFile(t),await this.createSliceComponent(e,n)}async updateSlice(e){let t=await this.getSlice(e.id);await _(t.modelPath,P(gc(e))),await this.createSliceIndexFile(t.library)}async deleteSlice(e){let t=await this.getSlice(e);await pe(t.directory,{recursive:!0}),await this.createSliceIndexFile(t.library)}async getCustomTypeLibraries(){return[new URL(`customtypes/`,await Qc())]}async getCustomTypes(){return hl(await this.getCustomTypeLibraries(),`*/index.json`)}async getCustomType(e){let t=(await this.getCustomTypes()).find(t=>t.model.id===e);if(!t)throw new sl(e);return t}async createCustomType(e){let[t]=await this.getCustomTypeLibraries(),n=A(new URL(e.id,A(t)));if(await cl(`type`,e.id,n,await this.getCustomTypes()),await _(new URL(`index.json`,n),P(hc(e))),e.format!==`page`)return[];await Bc(e);let r=await Qc();return(await this.writePageFiles(e)).map(({path:t})=>`Skipped ${m(r,t)} (already exists). Run \`prismic gen page ${e.id}\` to get the code.`)}async writePageFiles(e){let{routes:t=[]}=await Nc(),n=(Uc(t,e.id)?.path??Wc(e)).split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`[${e.slice(1)}]`:e).join(`/`),r=[];for(let t of await this.getPageFiles(e,n))await j(t.path)?r.push(t):await _(t.path,t.contents);return r}async updateCustomType(e){let t=await this.getCustomType(e.id);await _(t.modelPath,P(hc(e))),await Vc(e)}async deleteCustomType(e){let t=await this.getCustomType(e);await pe(t.directory,{recursive:!0}),await Hc(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 Qc()),t=Qt({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 _(e,t),e}async getEnvironment(){let e=await ml();if(await j(e))return(await te(e))[this.environmentEnvVarName]||void 0}async setEnvironment(e){await B(await ml(),this.environmentEnvVarName,e)}async unsetEnvironment(){await D(await ml(),this.environmentEnvVarName)}};async function ml(){return new URL(`.env.local`,await Qc())}async function hl(e,t){let n=[];for(let r of e){let e=await zr(t,{absolute:!0,cwd:r}),i=await Promise.all(e.map(async e=>{let t=ye(e),n=await w(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{us as $,ua as $t,Dc as A,Co as At,uc as B,jo as Bt,Nc as C,Ma as Ct,Cc as D,so as Dt,Sc as E,Ho as Et,gc as F,ao as Ft,zs as G,Wa as Gt,pc as H,oo as Ht,mc as I,Da as It,Us as J,Q as Jt,Rs as K,Xa as Kt,xc as L,Oa as Lt,wc as M,eo as Mt,sc as N,ja as Nt,Tc as O,io as Ot,hc as P,Ao as Pt,fs as Q,xa as Qt,fc as R,mo as Rt,$c as S,ko as St,Fc as T,Uo as Tt,ac as U,Fa as Ut,dc as V,Mo as Vt,rc as W,go as Wt,ms as X,ga as Xt,Gs as Y,ha as Yt,ps as Z,ba as Zt,tl as _,ht as _n,Eo as _t,il as a,Ui as an,Fo as at,Uc as b,Ua as bt,ll as c,Wi as cn,to as ct,dl as d,Y as dn,To as dt,da as en,Os as et,Jc as f,Yr as fn,co as ft,Wc as g,gt as gn,Za as gt,zc as h,mt as hn,Oo as ht,al as i,qi as in,ds as it,Ec as j,Pa as jt,Oc as k,Ya as kt,rl as l,X as ln,Io as lt,Lc as m,Ur as mn,ho as mt,sl as n,ca as nn,Ss as nt,ol as o,Z as on,Ka as ot,Pc as p,Vr as pn,Lo as pt,Ks as q,Ca as qt,nl as r,sa as rn,xs as rt,ul as s,zi as sn,fo as st,pl as t,fa as tn,ws as tt,fl as u,oi as un,wo as ut,Mc as v,_t as vn,no as vt,qc as w,Vo as wt,Qc as x,_o as xt,Yc as y,lo as yt,lc as z,Do as zt};
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{n as e,t}from"./package-DZJSt_MI.mjs";import{$ as n,$t as r,A as i,At as a,B as o,Bt as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as v,Ht as y,I as b,It as ee,J as x,Jt as S,K as C,Kt as w,L as te,Lt as ne,M as re,Mt as ie,N as T,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,Qt as de,R as E,Rt as D,S as O,St as fe,T as pe,Tt as me,U as k,Ut as he,V as ge,Vt as _e,W as ve,Wt as ye,X as be,Xt as A,Y as xe,Yt as j,Z as Se,Zt as Ce,_n as we,_t as Te,a as Ee,an as De,at as Oe,b as ke,bt as Ae,c as M,cn as je,ct as Me,dn as Ne,dt as Pe,et as Fe,f as Ie,fn as Le,ft as Re,g as ze,gn as N,gt as Be,h as Ve,hn as He,ht as Ue,i as We,in as Ge,it as Ke,j as qe,jt as Je,k as Ye,kt as Xe,l as P,ln as Ze,lt as Qe,m as $e,mn as F,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot,p as st,pt as ct,q as lt,qt as ut,r as I,rn as dt,rt as ft,sn as pt,st as mt,tn as L,tt as ht,un as gt,ut as _t,v as vt,vn as yt,vt as bt,w as xt,wt as St,x as R,xt as Ct,y as wt,yt as Tt,z as Et,zt as Dt}from"./adapters-DWhQeyDo.mjs";import{C as Ot,D as kt,E as At,J as z,M as B,N as jt,O as V,P as H,S as Mt,T as Nt,U as Pt,X as Ft,Z as U,_ as It,at as Lt,c as Rt,d as zt,f as Bt,i as Vt,j as Ht,k as Ut,l as W,o as Wt,p as G,q as Gt,t as Kt,u as qt,v as Jt,w as K,x as Yt,z as Xt}from"./packageJson-BEVwXn1i.mjs";import{t as Zt}from"./update-notifier-B86qEI1j.mjs";import{isDeepStrictEqual as Qt,parseArgs as $t}from"node:util";import{realpath as en,rm as tn}from"node:fs/promises";import{fileURLToPath as nn,pathToFileURL as rn}from"node:url";import{createHash as an,randomBytes as on}from"node:crypto";import{setTimeout as sn}from"node:timers/promises";const cn=z({error:Pt(`invalid_auth_context`)});function ln(e){return e instanceof V&&Lt(cn,e.body).success}const un={expired:`The login code expired. Run the command again.`,declined:`The login was declined in the browser.`,"email-unverified":`Prismic sent you an email to verify your address. Verify it, then run the command again.`,"invalid-grant":`The login code was already used or isn't valid. Run the command again.`,unavailable:`Can't reach the Prismic login service. Check your connection, then run the command again.`};async function dn(e){if(e instanceof Ze)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await g()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:un[e.reason];if(e instanceof V||e instanceof K)return await C().catch(()=>void 0)?F.PRISMIC_TOKEN?ln(e)?"This token cannot run administrative commands. Unset PRISMIC_TOKEN and run `prismic login`.":`PRISMIC_TOKEN is invalid or expired, or doesn't have access to this repository. Unset it to log in with a browser, or replace it with a valid token.`:e instanceof V?"Your session is invalid or expired. Run `prismic login` to sign in again.":`You do not have access to this repository. Check the repository name or log in with an account that has access.`:"Not logged in. Run `prismic login` first.";if(e instanceof Nt)return`Can't reach Prismic. Check your connection, then run the command again.`;if(e instanceof Ot||e instanceof Ut){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return r`
2
+ import{n as e,t}from"./package-_vugy-j4.mjs";import{$ as n,$t as r,A as i,At as a,B as o,Bt as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as v,Ht as y,I as b,It as ee,J as x,Jt as S,K as C,Kt as w,L as te,Lt as ne,M as re,Mt as ie,N as T,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,Qt as de,R as E,Rt as D,S as O,St as fe,T as pe,Tt as me,U as k,Ut as he,V as ge,Vt as _e,W as ve,Wt as ye,X as be,Xt as A,Y as xe,Yt as j,Z as Se,Zt as Ce,_n as we,_t as Te,a as Ee,an as De,at as Oe,b as ke,bt as Ae,c as M,cn as je,ct as Me,dn as Ne,dt as Pe,et as Fe,f as Ie,fn as Le,ft as Re,g as ze,gn as N,gt as Be,h as Ve,hn as He,ht as Ue,i as We,in as Ge,it as Ke,j as qe,jt as Je,k as Ye,kt as Xe,l as P,ln as Ze,lt as Qe,m as $e,mn as F,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot,p as st,pt as ct,q as lt,qt as ut,r as I,rn as dt,rt as ft,sn as pt,st as mt,tn as L,tt as ht,un as gt,ut as _t,v as vt,vn as yt,vt as bt,w as xt,wt as St,x as R,xt as Ct,y as wt,yt as Tt,z as Et,zt as Dt}from"./adapters-uuvKwdQo.mjs";import{C as Ot,D as kt,E as At,J as z,M as B,N as jt,O as V,P as H,S as Mt,T as Nt,U as Pt,X as Ft,Z as U,_ as It,at as Lt,c as Rt,d as zt,f as Bt,i as Vt,j as Ht,k as Ut,l as W,o as Wt,p as G,q as Gt,t as Kt,u as qt,v as Jt,w as K,x as Yt,z as Xt}from"./packageJson-BEVwXn1i.mjs";import{t as Zt}from"./update-notifier-CKCgVCBE.mjs";import{isDeepStrictEqual as Qt,parseArgs as $t}from"node:util";import{realpath as en,rm as tn}from"node:fs/promises";import{fileURLToPath as nn,pathToFileURL as rn}from"node:url";import{createHash as an,randomBytes as on}from"node:crypto";import{setTimeout as sn}from"node:timers/promises";const cn=z({error:Pt(`invalid_auth_context`)});function ln(e){return e instanceof V&&Lt(cn,e.body).success}const un={expired:`The login code expired. Run the command again.`,declined:`The login was declined in the browser.`,"email-unverified":`Prismic sent you an email to verify your address. Verify it, then run the command again.`,"invalid-grant":`The login code was already used or isn't valid. Run the command again.`,unavailable:`Can't reach the Prismic login service. Check your connection, then run the command again.`};async function dn(e){if(e instanceof Ze)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await g()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:un[e.reason];if(e instanceof V||e instanceof K)return await C().catch(()=>void 0)?F.PRISMIC_TOKEN?ln(e)?"This token cannot run administrative commands. Unset PRISMIC_TOKEN and run `prismic login`.":`PRISMIC_TOKEN is invalid or expired, or doesn't have access to this repository. Unset it to log in with a browser, or replace it with a valid token.`:e instanceof V?"Your session is invalid or expired. Run `prismic login` to sign in again.":`You do not have access to this repository. Check the repository name or log in with an account that has access.`:"Not logged in. Run `prismic login` first.";if(e instanceof Nt)return`Can't reach Prismic. Check your connection, then run the command again.`;if(e instanceof Ot||e instanceof Ut){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return r`
3
3
  ${n}Prismic responded with an unexpected error. Try again, and report it if it keeps happening.
4
4
 
5
5
  Status: ${e.status} ${e.statusText}
@@ -1,4 +1,4 @@
1
- import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./adapters-DWhQeyDo.mjs";import{S as l,a as u,m as d,n as f,s as p}from"./packageJson-BEVwXn1i.mjs";import{readFile as m}from"node:fs/promises";import{relative as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=e`
1
+ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./adapters-uuvKwdQo.mjs";import{S as l,a as u,m as d,n as f,s as p}from"./packageJson-BEVwXn1i.mjs";import{readFile as m}from"node:fs/promises";import{relative as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=e`
2
2
  return (
3
3
  <section
4
4
  data-slice-type={slice.slice_type}
@@ -1,4 +1,4 @@
1
- import{S as e,f as t,m as n,n as r,s as i}from"./packageJson-BEVwXn1i.mjs";import{$t as a,C as o,T as s,_ as c,_n as l,d as u,en as d,t as f,u as p,x as m}from"./adapters-DWhQeyDo.mjs";import{t as h}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as g,rm as _}from"node:fs/promises";import{relative as v}from"node:path";import{fileURLToPath as y}from"node:url";var b,x,S,C,w;const T=a`
1
+ import{S as e,f as t,m as n,n as r,s as i}from"./packageJson-BEVwXn1i.mjs";import{$t as a,C as o,T as s,_ as c,_n as l,d as u,en as d,t as f,u as p,x as m}from"./adapters-uuvKwdQo.mjs";import{t as h}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as g,rm as _}from"node:fs/promises";import{relative as v}from"node:path";import{fileURLToPath as y}from"node:url";var b,x,S,C,w;const T=a`
2
2
  <template>
3
3
  <section
4
4
  :data-slice-type="slice.slice_type"
@@ -0,0 +1 @@
1
+ var e=`prismic`,t=`1.30.1`;export{t as n,e as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./package-DZJSt_MI.mjs";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";const i=[],a=[];let o,s;function c(e){let{writeKey:t}=e;o=e.anonymousId,s=e.userId,process.on(`exit`,()=>d({writeKey:t}))}function l(n){s=n.userId,a.push({userId:n.userId,anonymousId:o,integrations:{Intercom:{user_hash:n.intercomHash}},context:{app:{name:t,version:e}},timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function u(n,r={}){let{properties:a,groupId:c}=r;i.push({event:n,properties:{nodeVersion:process.versions.node,os:process.platform,...a},context:{app:{name:t,version:e},groupId:c},userId:s,anonymousId:o,timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function d(e){let{writeKey:t}=e;if(i.length!==0||a.length!==0){try{let e=Buffer.from(JSON.stringify({trackEvents:i.map(e=>({...e,userId:e.userId||s})),identifyEvents:a,writeKey:t})).toString(`base64`),o=n(new URL(`./subprocesses/sendSegmentEvents.mjs`,import.meta.url));r(process.execPath,[o,e],{detached:!0,stdio:`ignore`}).unref()}catch{}i.length=0,a.length=0}}async function f(e,t,n){let r={"Content-Type":`application/json`,Authorization:`Basic ${btoa(n+`:`)}`};await Promise.allSettled([...e.map(e=>fetch(`https://api.segment.io/v1/track`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{})),...t.map(e=>fetch(`https://api.segment.io/v1/identify`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{}))])}export{l as i,f as n,u as r,c as t};
1
+ import{n as e,t}from"./package-_vugy-j4.mjs";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";const i=[],a=[];let o,s;function c(e){let{writeKey:t}=e;o=e.anonymousId,s=e.userId,process.on(`exit`,()=>d({writeKey:t}))}function l(n){s=n.userId,a.push({userId:n.userId,anonymousId:o,integrations:{Intercom:{user_hash:n.intercomHash}},context:{app:{name:t,version:e}},timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function u(n,r={}){let{properties:a,groupId:c}=r;i.push({event:n,properties:{nodeVersion:process.versions.node,os:process.platform,...a},context:{app:{name:t,version:e},groupId:c},userId:s,anonymousId:o,timestamp:(/* @__PURE__ */ new Date()).toISOString()})}function d(e){let{writeKey:t}=e;if(i.length!==0||a.length!==0){try{let e=Buffer.from(JSON.stringify({trackEvents:i.map(e=>({...e,userId:e.userId||s})),identifyEvents:a,writeKey:t})).toString(`base64`),o=n(new URL(`./subprocesses/sendSegmentEvents.mjs`,import.meta.url));r(process.execPath,[o,e],{detached:!0,stdio:`ignore`}).unref()}catch{}i.length=0,a.length=0}}async function f(e,t,n){let r={"Content-Type":`application/json`,Authorization:`Basic ${btoa(n+`:`)}`};await Promise.allSettled([...e.map(e=>fetch(`https://api.segment.io/v1/track`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{})),...t.map(e=>fetch(`https://api.segment.io/v1/identify`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{}))])}export{l as i,f as n,u as r,c as t};
@@ -1 +1 @@
1
- import{n as e}from"../segment-BpOvsf06.mjs";const{trackEvents:t,identifyEvents:n,writeKey:r}=JSON.parse(Buffer.from(process.argv[2],`base64`).toString());try{await e(t,n,r)}catch{}export{};
1
+ import{n as e}from"../segment-rgJUUL0P.mjs";const{trackEvents:t,identifyEvents:n,writeKey:r}=JSON.parse(Buffer.from(process.argv[2],`base64`).toString());try{await e(t,n,r)}catch{}export{};
@@ -1 +1 @@
1
- import{n as e}from"../update-notifier-B86qEI1j.mjs";const[t,n]=process.argv.slice(2);try{await e(t,new URL(n))}catch{}export{};
1
+ import{n as e}from"../update-notifier-CKCgVCBE.mjs";const[t,n]=process.argv.slice(2);try{await e(t,new URL(n))}catch{}export{};
@@ -0,0 +1 @@
1
+ export{t as SvelteKitAdapter}from"./sveltekit-MgsxU8tu.mjs";
@@ -1,4 +1,4 @@
1
- import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./adapters-DWhQeyDo.mjs";import{S as l,m as u,n as d,s as f}from"./packageJson-BEVwXn1i.mjs";import{t as p}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as m,rm as h}from"node:fs/promises";import{relative as g}from"node:path";import{fileURLToPath as _}from"node:url";var v,y,b,x,S,C;function w({typescript:t}){return t?e`
1
+ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./adapters-uuvKwdQo.mjs";import{S as l,m as u,n as d,s as f}from"./packageJson-BEVwXn1i.mjs";import{t as p}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as m,rm as h}from"node:fs/promises";import{relative as g}from"node:path";import{fileURLToPath as _}from"node:url";var v,y,b,x,S,C;function w({typescript:t}){return t?e`
2
2
  import { createClient as baseCreateClient } from "@prismicio/client";
3
3
  import { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';
4
4
  import { PUBLIC_PRISMIC_ENVIRONMENT } from '$app/env/public';
@@ -66,7 +66,13 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
66
66
  export const variables = defineEnvVars({
67
67
  ${T()}
68
68
  });
69
- `}function D({extension:t}){return e(v||=p([`
69
+ `}function D(){return`preview: (param) => (param === "preview" ? param : undefined),`}function O(){return e`
70
+ import { defineParams } from "@sveltejs/kit/params";
71
+
72
+ export const params = defineParams({
73
+ ${D()}
74
+ });
75
+ `}function k({extension:t}){return e(v||=p([`
70
76
  <script>
71
77
  import { SliceSimulator, SliceZone } from '@prismicio/svelte';
72
78
  import { components } from '#lib/slices/index.`,`';
@@ -77,7 +83,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
77
83
  <SliceZone {slices} {components} />
78
84
  {/snippet}
79
85
  </SliceSimulator>
80
- `]),t)}function O({typescript:t}){return t?e`
86
+ `]),t)}function A({typescript:t}){return t?e`
81
87
  import { redirectToPreviewURL } from '@prismicio/svelte/kit';
82
88
  import { createClient } from '#lib/prismicio.ts';
83
89
  import type { RequestHandler } from "./$types";
@@ -97,7 +103,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
97
103
 
98
104
  return await redirectToPreviewURL({ client, request, cookies });
99
105
  }
100
- `}function k({extension:t}){return e`
106
+ `}function j({extension:t}){return e`
101
107
  import { repositoryName } from "#lib/prismicio.${t}";
102
108
 
103
109
  export const prerender = "auto";
@@ -105,7 +111,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
105
111
  export function load() {
106
112
  return { repositoryName };
107
113
  }
108
- `}function A(){return e(y||=p([`
114
+ `}function M(){return e(y||=p([`
109
115
  <script>
110
116
  import { isFilled, asImageSrc } from '@prismicio/client';
111
117
  import { PrismicPreview } from '@prismicio/svelte/kit';
@@ -127,7 +133,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
127
133
  </svelte:head>
128
134
  {@render children()}
129
135
  <PrismicPreview repositoryName={data.repositoryName} />
130
- `]))}function j({typescript:t}){return e(t?b||=p([`
136
+ `]))}function N({typescript:t}){return e(t?b||=p([`
131
137
  <script lang="ts">
132
138
  import { SliceZone } from "@prismicio/svelte";
133
139
  import { components } from "#lib/slices/index.ts";
@@ -146,7 +152,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
146
152
  <\/script>
147
153
 
148
154
  <SliceZone slices={data.page.data.slices} {components} />
149
- `]))}function M({model:t,typescript:n}){return t.repeatable?n?e`
155
+ `]))}function P({model:t,typescript:n}){return t.repeatable?n?e`
150
156
  import type { PageServerLoad } from "./$types";
151
157
  import { createClient } from "#lib/prismicio.ts";
152
158
 
@@ -186,13 +192,13 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
186
192
 
187
193
  return { page };
188
194
  }
189
- `}const N=e`
195
+ `}const F=e`
190
196
  <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>
191
197
  Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
192
198
  <br />
193
199
  <strong>You can edit this slice directly in your code editor.</strong>
194
200
  </section>
195
- `;function P({name:t,typescript:r}){let i=n(t);return e(r?S||=p([`
201
+ `;function I({name:t,typescript:r}){let i=n(t);return e(r?S||=p([`
196
202
  <script lang="ts">
197
203
  import type { Content } from '@prismicio/client';
198
204
  import type { SliceComponentProps } from '@prismicio/svelte';
@@ -213,11 +219,7 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
213
219
  <\/script>
214
220
 
215
221
  `,`
216
- `]),i,N)}var F;const I=[`<h1>WelcometoSvelteKit</h1><p>Visit<ahref="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a>toreadthedocumentation</p>`,`<h1>WelcometoSvelteKit</h1><p>Visit<ahref="https://kit.svelte.dev">kit.svelte.dev</a>toreadthedocumentation</p>`];var L=class extends o{id=`sveltekit`;environmentEnvVarName=`PUBLIC_PRISMIC_ENVIRONMENT`;localPreviewConfig={name:`Development`,websiteURL:`http://localhost:5173`,resolverPath:`/api/preview`};async setupProject(){await d({"@prismicio/client":`^${await f(`@prismicio/client`)}`,"@prismicio/svelte":`^${await f(`@prismicio/svelte`)}`});let n=await c(),i=await s(),a=await t();await r(new URL(`src/lib/prismicio.${i}`,n),w({typescript:a})),await z(`src/env`)||await l(new URL(`src/env.${i}`,n),E()),await r(new URL(`src/routes/slice-simulator/+page.svelte`,n),D({extension:i})),await r(new URL(`src/params/preview.${i}`,n),e`
217
- export function match(param) {
218
- return param === 'preview';
219
- }
220
- `),await r(new URL(`src/routes/api/preview/+server.${i}`,n),O({typescript:a})),await r(new URL(`src/routes/[[preview=preview]]/README.md`,n),e`
222
+ `]),i,F)}var L;const R=[`<h1>WelcometoSvelteKit</h1><p>Visit<ahref="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a>toreadthedocumentation</p>`,`<h1>WelcometoSvelteKit</h1><p>Visit<ahref="https://kit.svelte.dev">kit.svelte.dev</a>toreadthedocumentation</p>`];var z=class extends o{id=`sveltekit`;environmentEnvVarName=`PUBLIC_PRISMIC_ENVIRONMENT`;localPreviewConfig={name:`Development`,websiteURL:`http://localhost:5173`,resolverPath:`/api/preview`};async setupProject(){await d({"@prismicio/client":`^${await f(`@prismicio/client`)}`,"@prismicio/svelte":`^${await f(`@prismicio/svelte`)}`});let n=await c(),i=await s(),a=await t();await r(new URL(`src/lib/prismicio.${i}`,n),w({typescript:a})),await H(`src/env`)||await l(new URL(`src/env.${i}`,n),E()),await r(new URL(`src/routes/slice-simulator/+page.svelte`,n),k({extension:i})),await V()||await l(new URL(`src/params.${i}`,n),O()),await r(new URL(`src/routes/api/preview/+server.${i}`,n),A({typescript:a})),await r(new URL(`src/routes/[[preview=preview]]/README.md`,n),e`
221
223
  This directory adds support for optional \`/preview\` routes. Do not remove this directory.
222
224
 
223
225
  All routes within this directory will be served using the following URLs:
@@ -226,22 +228,29 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
226
228
  - \`/preview/example-route\` (server-rendered)
227
229
 
228
230
  See <https://prismic.io/docs/svelte-preview> for more information.
229
- `);let o=await z(`src/routes/+layout.server`);o||await l(new URL(`src/routes/+layout.server.${i}`,n),k({extension:i})),(!o||(await m(new URL(o,n),`utf8`)).includes(`repositoryName`))&&await r(new URL(`src/routes/+layout.svelte`,n),A()),await R()}async getSetupInstructions(){let t=await c(),n=await u(new URL(`src/routes/+page.svelte`,t))&&await u(new URL(`src/routes/[[preview=preview]]/+page.svelte`,t))&&e`
231
+ `);let o=await H(`src/routes/+layout.server`);o||await l(new URL(`src/routes/+layout.server.${i}`,n),j({extension:i})),(!o||(await m(new URL(o,n),`utf8`)).includes(`repositoryName`))&&await r(new URL(`src/routes/+layout.svelte`,n),M()),await B()}async getSetupInstructions(){let t=await c(),n=await u(new URL(`src/routes/+page.svelte`,t))&&await u(new URL(`src/routes/[[preview=preview]]/+page.svelte`,t))&&e`
230
232
  Action required: delete src/routes/+page.svelte.
231
233
 
232
234
  It also serves / and hides your Prismic home page in
233
235
  src/routes/[[preview=preview]]/+page.svelte. Move anything you need
234
236
  from it first.
235
- `;return[await this.getEnvStep(),await this.getPreviewStep(),n].filter(Boolean).join(`
237
+ `;return[await this.getEnvStep(),await this.getParamsStep(),await this.getPreviewStep(),n].filter(Boolean).join(`
236
238
 
237
- `)||void 0}async getEnvStep(){let t=await z(`src/env`);if(t&&!(await m(new URL(t,await c()),`utf8`)).includes(`PUBLIC_PRISMIC_ENVIRONMENT`))return e`
239
+ `)||void 0}async getEnvStep(){let t=await H(`src/env`);if(t&&!(await m(new URL(t,await c()),`utf8`)).includes(`PUBLIC_PRISMIC_ENVIRONMENT`))return e`
238
240
  Action required: add PUBLIC_PRISMIC_ENVIRONMENT to ${t}.
239
241
 
240
242
  Your project does not build until you do this. Add these lines to
241
243
  defineEnvVars({ ... }):
242
244
 
243
245
  ${T().replace(/^/gm,` `)}
244
- `}async getPreviewStep(){if(await a(`PrismicPreview`))return;let t=await z(`src/routes/+layout.server`)??`src/routes/+layout.server.${await s()}`,n=!(await m(new URL(t,await c()),`utf8`).catch(()=>``)).includes(`repositoryName`)&&`Return repositoryName from load in ${t}, creating the file if needed:\n\n${k({extension:t.split(`.`).pop()}).replace(/^/gm,` `)}`;return[e(F||=p([`
246
+ `}async getParamsStep(){let t=await V();if(t&&!(await m(new URL(t,await c()),`utf8`)).includes(`preview`))return e`
247
+ Action required: add a preview matcher to ${t}.
248
+
249
+ Your project does not build until you do this. Add this line to
250
+ defineParams({ ... }):
251
+
252
+ ${D()}
253
+ `}async getPreviewStep(){if(await a(`PrismicPreview`))return;let t=await H(`src/routes/+layout.server`)??`src/routes/+layout.server.${await s()}`,n=!(await m(new URL(t,await c()),`utf8`).catch(()=>``)).includes(`repositoryName`)&&`Return repositoryName from load in ${t}, creating the file if needed:\n\n${j({extension:t.split(`.`).pop()}).replace(/^/gm,` `)}`;return[e(L||=p([`
245
254
  Action required: add <PrismicPreview> to your root layout.
246
255
 
247
256
  Previews do not work until you do this, and the CLI cannot edit your
@@ -270,4 +279,4 @@ import{$t as e,_ as t,_n as n,d as r,en as i,s as a,t as o,u as s,x as c}from"./
270
279
  ${o.join(`,
271
280
  `)}
272
281
  };
273
- `;await l(new URL(`index.${await s()}`,t),c)}async getDefaultSliceLibrary(){return new URL(`src/lib/slices/`,await c())}async createSliceComponent(e,n){let r=P({name:e.name,typescript:await t()});await l(new URL(`index.svelte`,n),r)}async getPageFiles(e,n){let r=new URL(`src/routes/[[preview=preview]]/${n}/`,await c()),i=await t();return[{path:new URL(`+page.svelte`,r),contents:j({typescript:i})},{path:new URL(`+page.server.${await s()}`,r),contents:M({model:e,typescript:i})}]}};async function R(){let e=new URL(`src/routes/+page.svelte`,await c()),t=await m(e,`utf8`).catch(()=>void 0);I.includes(t?.replace(/\s/g,``)??``)&&await h(e)}async function z(e){let t=await c();for(let n of[`js`,`ts`])if(await u(new URL(`${e}.${n}`,t)))return`${e}.${n}`}export{M as a,w as c,k as i,A as l,R as n,j as o,z as r,O as s,L as t};
282
+ `;await l(new URL(`index.${await s()}`,t),c)}async getDefaultSliceLibrary(){return new URL(`src/lib/slices/`,await c())}async createSliceComponent(e,n){let r=I({name:e.name,typescript:await t()});await l(new URL(`index.svelte`,n),r)}async getPageFiles(e,n){let r=new URL(`src/routes/[[preview=preview]]/${n}/`,await c()),i=await t();return[{path:new URL(`+page.svelte`,r),contents:N({typescript:i})},{path:new URL(`+page.server.${await s()}`,r),contents:P({model:e,typescript:i})}]}};async function B(){let e=new URL(`src/routes/+page.svelte`,await c()),t=await m(e,`utf8`).catch(()=>void 0);R.includes(t?.replace(/\s/g,``)??``)&&await h(e)}async function V(){return await H(`src/params/index`)??await H(`src/params`)}async function H(e){let t=await c();for(let n of[`js`,`ts`])if(await u(new URL(`${e}.${n}`,t)))return`${e}.${n}`}export{P as a,w as c,j as i,M as l,B as n,N as o,H as r,A as s,z as t};
@@ -1,4 +1,4 @@
1
- import{$t as e,_ as t,d as n,s as r,u as i,x as a}from"./adapters-DWhQeyDo.mjs";import{S as o,m as s,n as c,s as l}from"./packageJson-BEVwXn1i.mjs";import{a as u,c as d,i as f,l as p,n as m,o as h,r as g,s as _,t as v}from"./sveltekit-D7e5u5rg.mjs";import{t as y}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as b}from"node:fs/promises";var x;function S(e){return e.replace(/#lib\/(\w+)(?:\/index)?\.\w+/g,`$lib/$1`)}function C({typescript:e}){return d({typescript:e}).replace(`{ PUBLIC_PRISMIC_ENVIRONMENT } from '$app/env/public'`,`{ env } from '$env/dynamic/public'`).replace(`PUBLIC_PRISMIC_ENVIRONMENT ||`,`env.PUBLIC_PRISMIC_ENVIRONMENT ||`)}function w(){return e(x||=y([`
1
+ import{$t as e,_ as t,d as n,s as r,u as i,x as a}from"./adapters-uuvKwdQo.mjs";import{S as o,m as s,n as c,s as l}from"./packageJson-BEVwXn1i.mjs";import{a as u,c as d,i as f,l as p,n as m,o as h,r as g,s as _,t as v}from"./sveltekit-MgsxU8tu.mjs";import{t as y}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as b}from"node:fs/promises";var x;function S(e){return e.replace(/#lib\/(\w+)(?:\/index)?\.\w+/g,`$lib/$1`)}function C({typescript:e}){return d({typescript:e}).replace(`{ PUBLIC_PRISMIC_ENVIRONMENT } from '$app/env/public'`,`{ env } from '$env/dynamic/public'`).replace(`PUBLIC_PRISMIC_ENVIRONMENT ||`,`env.PUBLIC_PRISMIC_ENVIRONMENT ||`)}function w(){return e(x||=y([`
2
2
  <script>
3
3
  import { SliceSimulator, SliceZone } from '@prismicio/svelte';
4
4
  import { components } from '$lib/slices';
@@ -1 +1 @@
1
- import{n as e}from"./package-DZJSt_MI.mjs";import{S as t,W as n,Y as r,Z as i,_ as a,p as o,q as s,s as c}from"./packageJson-BEVwXn1i.mjs";import{fileURLToPath as l}from"node:url";import{spawn as u}from"node:child_process";const d=n({latestKnownVersion:r(i()),lastUpdateCheckAt:r(s())});async function f(t){try{if(p())return;let n=await m(t.statePath),r=e;if(n?.latestKnownVersion&&h(n.latestKnownVersion,r)){let e=`Update available: ${r} → ${n.latestKnownVersion}. Run \`npx ${t.npmPackageName}@latest --version\` to update.`;process.on(`exit`,()=>{try{console.error(`\n${e}`)}catch{}})}(!n?.lastUpdateCheckAt||Date.now()-n.lastUpdateCheckAt>864e5)&&process.on(`exit`,()=>{_(t.npmPackageName,t.statePath)})}catch{}}function p(){return process.env.NO_UPDATE_NOTIFIER!==`0`&&!(process.env.NO_UPDATE_NOTIFIER!==`1`&&!process.env.CI&&process.stderr.isTTY)}async function m(e){return a(e,{schema:d}).catch(()=>void 0)}function h(e,t){if(e.includes(`-`)||t.includes(`-`))return!1;let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);if(n.length!==3||r.length!==3||n.some(e=>!Number.isFinite(e))||r.some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!1}async function g(e,n){let r=await c(e);await t(n,o({latestKnownVersion:r,lastUpdateCheckAt:Date.now()}))}function _(e,t){try{let n=l(new URL(`./subprocesses/updateVersionState.mjs`,import.meta.url));u(process.execPath,[n,e,t.href],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{g as n,f as t};
1
+ import{n as e}from"./package-_vugy-j4.mjs";import{S as t,W as n,Y as r,Z as i,_ as a,p as o,q as s,s as c}from"./packageJson-BEVwXn1i.mjs";import{fileURLToPath as l}from"node:url";import{spawn as u}from"node:child_process";const d=n({latestKnownVersion:r(i()),lastUpdateCheckAt:r(s())});async function f(t){try{if(p())return;let n=await m(t.statePath),r=e;if(n?.latestKnownVersion&&h(n.latestKnownVersion,r)){let e=`Update available: ${r} → ${n.latestKnownVersion}. Run \`npx ${t.npmPackageName}@latest --version\` to update.`;process.on(`exit`,()=>{try{console.error(`\n${e}`)}catch{}})}(!n?.lastUpdateCheckAt||Date.now()-n.lastUpdateCheckAt>864e5)&&process.on(`exit`,()=>{_(t.npmPackageName,t.statePath)})}catch{}}function p(){return process.env.NO_UPDATE_NOTIFIER!==`0`&&!(process.env.NO_UPDATE_NOTIFIER!==`1`&&!process.env.CI&&process.stderr.isTTY)}async function m(e){return a(e,{schema:d}).catch(()=>void 0)}function h(e,t){if(e.includes(`-`)||t.includes(`-`))return!1;let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);if(n.length!==3||r.length!==3||n.some(e=>!Number.isFinite(e))||r.some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!1}async function g(e,n){let r=await c(e);await t(n,o({latestKnownVersion:r,lastUpdateCheckAt:Date.now()}))}function _(e,t){try{let n=l(new URL(`./subprocesses/updateVersionState.mjs`,import.meta.url));u(process.execPath,[n,e,t.href],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{g as n,f as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prismic",
3
- "version": "1.30.0",
3
+ "version": "1.30.1",
4
4
  "description": "Prismic's official command line tool",
5
5
  "keywords": [
6
6
  "prismic",
@@ -1 +0,0 @@
1
- var e=`prismic`,t=`1.30.0`;export{t as n,e as t};
@@ -1 +0,0 @@
1
- export{t as SvelteKitAdapter}from"./sveltekit-D7e5u5rg.mjs";