prismic 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters-CuXozoyY.mjs +189 -0
- package/dist/{auth-NkX7Docj.mjs → auth-CsokWsVo.mjs} +2 -2
- package/dist/index.mjs +94 -94
- package/dist/{nextjs-TJI3bKFA.mjs → nextjs-D65xFGap.mjs} +51 -51
- package/dist/{nuxt-DfWyc1bJ.mjs → nuxt-YzpEi3A5.mjs} +11 -11
- package/dist/package-DCbOjRWH.mjs +1 -0
- package/dist/packageJson-B1_pkZr8.mjs +2 -0
- package/dist/request-Dx4vx1nN.mjs +30 -0
- package/dist/{segment-yGieXuDf.mjs → segment-DkMwCXor.mjs} +1 -1
- package/dist/subprocesses/refreshToken.mjs +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/sveltekit-7mpC1weE.mjs +273 -0
- package/dist/sveltekit-CpIdkani.mjs +1 -0
- package/dist/sveltekit2-C9cZPBvU.mjs +50 -0
- package/dist/{update-notifier-ChP_LYxw.mjs → update-notifier-d8fLG6jz.mjs} +1 -1
- package/package.json +7 -7
- package/dist/adapters-Bt9QKcJb.mjs +0 -191
- package/dist/package-Dyw1b366.mjs +0 -1
- package/dist/packageJson-Bxht6H4y.mjs +0 -2
- package/dist/request-DJTl_0US.mjs +0 -30
- package/dist/sveltekit-CC1sBn9O.mjs +0 -302
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import{S as e,ct as t,d as n,f as r,ft as i,s as a,st as o,t as s,u as c,v as l}from"./adapters-Bt9QKcJb.mjs";import{_ as u,l as d}from"./request-DJTl_0US.mjs";import{n as f,o as p}from"./packageJson-Bxht6H4y.mjs";import{t as m}from"./taggedTemplateLiteral-DygvE_Ih.mjs";import{readFile as h,rm as g}from"node:fs/promises";import{relative as _}from"node:path";import{fileURLToPath as v}from"node:url";var y,b,x,S,C,w,T,E,D,O;function k({typescript:e}){return e?o`
|
|
2
|
-
import { createClient as baseCreateClient } from "@prismicio/client";
|
|
3
|
-
import { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';
|
|
4
|
-
import { env } from '$env/dynamic/public';
|
|
5
|
-
import prismicConfig from "../../prismic.config.json";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The project's Prismic repository name.
|
|
9
|
-
*/
|
|
10
|
-
export const repositoryName =
|
|
11
|
-
env.PUBLIC_PRISMIC_ENVIRONMENT || prismicConfig.repositoryName;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a Prismic client for the project's repository. The client is used to
|
|
15
|
-
* query content from the Prismic API.
|
|
16
|
-
*
|
|
17
|
-
* @param config - Configuration for the Prismic client.
|
|
18
|
-
*/
|
|
19
|
-
export const createClient = ({ cookies, ...config }: CreateClientConfig = {}) => {
|
|
20
|
-
const client = baseCreateClient(repositoryName, {
|
|
21
|
-
routes: prismicConfig.routes,
|
|
22
|
-
...config,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
enableAutoPreviews({ client, cookies });
|
|
26
|
-
|
|
27
|
-
return client;
|
|
28
|
-
};
|
|
29
|
-
`:o`
|
|
30
|
-
import { createClient as baseCreateClient } from "@prismicio/client";
|
|
31
|
-
import { enableAutoPreviews } from '@prismicio/svelte/kit';
|
|
32
|
-
import { env } from '$env/dynamic/public';
|
|
33
|
-
import prismicConfig from "../../prismic.config.json";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The project's Prismic repository name.
|
|
37
|
-
*/
|
|
38
|
-
export const repositoryName =
|
|
39
|
-
env.PUBLIC_PRISMIC_ENVIRONMENT || prismicConfig.repositoryName;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a Prismic client for the project's repository. The client is used to
|
|
43
|
-
* query content from the Prismic API.
|
|
44
|
-
*
|
|
45
|
-
* @param {import('@prismicio/svelte/kit').CreateClientConfig} config - Configuration for the Prismic client.
|
|
46
|
-
*/
|
|
47
|
-
export const createClient = ({ cookies, ...config } = {}) => {
|
|
48
|
-
const client = baseCreateClient(repositoryName, {
|
|
49
|
-
routes: prismicConfig.routes,
|
|
50
|
-
...config,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
enableAutoPreviews({ client, cookies });
|
|
54
|
-
|
|
55
|
-
return client;
|
|
56
|
-
};
|
|
57
|
-
`}function A({version:e}){let t=o(y||=m([`
|
|
58
|
-
<script>
|
|
59
|
-
import { SliceSimulator, SliceZone } from '@prismicio/svelte';
|
|
60
|
-
import { components } from '$lib/slices';
|
|
61
|
-
<\/script>
|
|
62
|
-
|
|
63
|
-
<!-- Slot syntax is used for backward compatibility with Svelte <=4. -->
|
|
64
|
-
<SliceSimulator let:slices>
|
|
65
|
-
<SliceZone {slices} {components} />
|
|
66
|
-
</SliceSimulator>
|
|
67
|
-
`])),n=o(b||=m([`
|
|
68
|
-
<script>
|
|
69
|
-
import { SliceSimulator, SliceZone } from '@prismicio/svelte';
|
|
70
|
-
import { components } from '$lib/slices';
|
|
71
|
-
<\/script>
|
|
72
|
-
|
|
73
|
-
<SliceSimulator let:slices>
|
|
74
|
-
<SliceZone {slices} {components} />
|
|
75
|
-
</SliceSimulator>
|
|
76
|
-
`]));return e<=4?n:t}function j({typescript:e}){return e?o`
|
|
77
|
-
import { redirectToPreviewURL } from '@prismicio/svelte/kit';
|
|
78
|
-
import { createClient } from '$lib/prismicio';
|
|
79
|
-
import type { RequestHandler } from "./$types";
|
|
80
|
-
|
|
81
|
-
export const GET: RequestHandler = async ({ fetch, request, cookies }) => {
|
|
82
|
-
const client = createClient({ fetch });
|
|
83
|
-
|
|
84
|
-
return await redirectToPreviewURL({ client, request, cookies });
|
|
85
|
-
}
|
|
86
|
-
`:o`
|
|
87
|
-
import { redirectToPreviewURL } from '@prismicio/svelte/kit';
|
|
88
|
-
import { createClient } from '$lib/prismicio';
|
|
89
|
-
|
|
90
|
-
/* @type {import("./$types").RequestHandler} */
|
|
91
|
-
export async function GET({ fetch, request, cookies }) {
|
|
92
|
-
const client = createClient({ fetch });
|
|
93
|
-
|
|
94
|
-
return await redirectToPreviewURL({ client, request, cookies });
|
|
95
|
-
}
|
|
96
|
-
`}const M=o`
|
|
97
|
-
<svelte:head>
|
|
98
|
-
<title>{page.data.page?.data.meta_title}</title>
|
|
99
|
-
<meta property="og:title" content={page.data.page?.data.meta_title} />
|
|
100
|
-
{#if isFilled.keyText(page.data.page?.data.meta_description)}
|
|
101
|
-
<meta name="description" content={page.data.page.data.meta_description} />
|
|
102
|
-
<meta property="og:description" content={page.data.page.data.meta_description} />
|
|
103
|
-
{/if}
|
|
104
|
-
{#if isFilled.image(page.data.page?.data.meta_image)}
|
|
105
|
-
<meta property="og:image" content={asImageSrc(page.data.page.data.meta_image)} />
|
|
106
|
-
{/if}
|
|
107
|
-
</svelte:head>
|
|
108
|
-
`;function N(){return o`
|
|
109
|
-
import { repositoryName } from "$lib/prismicio";
|
|
110
|
-
|
|
111
|
-
export const prerender = "auto";
|
|
112
|
-
|
|
113
|
-
export function load() {
|
|
114
|
-
return { repositoryName };
|
|
115
|
-
}
|
|
116
|
-
`}function P({version:e}){let t=o(x||=m([`
|
|
117
|
-
<script>
|
|
118
|
-
import { isFilled, asImageSrc } from '@prismicio/client';
|
|
119
|
-
import { PrismicPreview } from '@prismicio/svelte/kit';
|
|
120
|
-
import { page } from '$app/state';
|
|
121
|
-
|
|
122
|
-
const { data, children } = $props();
|
|
123
|
-
<\/script>
|
|
124
|
-
|
|
125
|
-
`,`
|
|
126
|
-
{@render children()}
|
|
127
|
-
<PrismicPreview repositoryName={data.repositoryName} />
|
|
128
|
-
`]),M),n=o(S||=m([`
|
|
129
|
-
<script>
|
|
130
|
-
import { isFilled, asImageSrc } from '@prismicio/client';
|
|
131
|
-
import { PrismicPreview } from '@prismicio/svelte/kit';
|
|
132
|
-
import { page } from '$app/state';
|
|
133
|
-
|
|
134
|
-
export let data;
|
|
135
|
-
<\/script>
|
|
136
|
-
|
|
137
|
-
`,`
|
|
138
|
-
<slot />
|
|
139
|
-
<PrismicPreview repositoryName={data.repositoryName} />
|
|
140
|
-
`]),M);return e<=4?n:t}function F({typescript:e}){return o(e?C||=m([`
|
|
141
|
-
<script lang="ts">
|
|
142
|
-
import { SliceZone } from "@prismicio/svelte";
|
|
143
|
-
import { components } from "$lib/slices";
|
|
144
|
-
import type { PageProps } from "./$types";
|
|
145
|
-
|
|
146
|
-
const { data }: PageProps = $props();
|
|
147
|
-
<\/script>
|
|
148
|
-
|
|
149
|
-
<SliceZone slices={data.page.data.slices} {components} />
|
|
150
|
-
`]):w||=m([`
|
|
151
|
-
<script>
|
|
152
|
-
import { SliceZone } from "@prismicio/svelte";
|
|
153
|
-
import { components } from "$lib/slices";
|
|
154
|
-
|
|
155
|
-
const { data } = $props();
|
|
156
|
-
<\/script>
|
|
157
|
-
|
|
158
|
-
<SliceZone slices={data.page.data.slices} {components} />
|
|
159
|
-
`]))}function I({model:e,typescript:t}){return e.repeatable?t?o`
|
|
160
|
-
import type { PageServerLoad } from "./$types";
|
|
161
|
-
import { createClient } from "$lib/prismicio";
|
|
162
|
-
|
|
163
|
-
export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
|
|
164
|
-
const client = createClient({ fetch, cookies });
|
|
165
|
-
const page = await client.getByUID("${e.id}", params.uid);
|
|
166
|
-
|
|
167
|
-
return { page };
|
|
168
|
-
};
|
|
169
|
-
`:o`
|
|
170
|
-
import { createClient } from "$lib/prismicio";
|
|
171
|
-
|
|
172
|
-
/** @type {import("./$types").PageServerLoad} */
|
|
173
|
-
export async function load({ params, fetch, cookies }) {
|
|
174
|
-
const client = createClient({ fetch, cookies });
|
|
175
|
-
const page = await client.getByUID("${e.id}", params.uid);
|
|
176
|
-
|
|
177
|
-
return { page };
|
|
178
|
-
}
|
|
179
|
-
`:t?o`
|
|
180
|
-
import type { PageServerLoad } from "./$types";
|
|
181
|
-
import { createClient } from "$lib/prismicio";
|
|
182
|
-
|
|
183
|
-
export const load: PageServerLoad = async ({ fetch, cookies }) => {
|
|
184
|
-
const client = createClient({ fetch, cookies });
|
|
185
|
-
const page = await client.getSingle("${e.id}");
|
|
186
|
-
|
|
187
|
-
return { page };
|
|
188
|
-
};
|
|
189
|
-
`:o`
|
|
190
|
-
import { createClient } from "$lib/prismicio";
|
|
191
|
-
|
|
192
|
-
/* @type {import("./$types").PageServerLoad} */
|
|
193
|
-
export async function load({ fetch, cookies }) {
|
|
194
|
-
const client = createClient({ fetch, cookies });
|
|
195
|
-
const page = await client.getSingle("${e.id}");
|
|
196
|
-
|
|
197
|
-
return { page };
|
|
198
|
-
}
|
|
199
|
-
`}const L=o`
|
|
200
|
-
<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>
|
|
201
|
-
Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
|
|
202
|
-
<br />
|
|
203
|
-
<strong>You can edit this slice directly in your code editor.</strong>
|
|
204
|
-
</section>
|
|
205
|
-
`;function R({name:e,typescript:t,version:n}){let r=i(e),a=o(T||=m([`
|
|
206
|
-
<script lang="ts">
|
|
207
|
-
import type { Content } from '@prismicio/client';
|
|
208
|
-
import type { SliceComponentProps } from '@prismicio/svelte';
|
|
209
|
-
|
|
210
|
-
type Props = SliceComponentProps<Content.`,`Slice>;
|
|
211
|
-
|
|
212
|
-
const { slice }: Props = $props();
|
|
213
|
-
<\/script>
|
|
214
|
-
|
|
215
|
-
`,`
|
|
216
|
-
`]),r,L),s=o(E||=m([`
|
|
217
|
-
<script>
|
|
218
|
-
/* @typedef {import("@prismicio/client").Content} Content */
|
|
219
|
-
/* @typedef {import("@prismicio/svelte").SliceComponentProps} SliceComponentProps */
|
|
220
|
-
|
|
221
|
-
/* @type {SliceComponentProps<Content.`,`Slice>} */
|
|
222
|
-
const { slice } = $props();
|
|
223
|
-
<\/script>
|
|
224
|
-
|
|
225
|
-
`,`
|
|
226
|
-
`]),r,L),c=o(D||=m([`
|
|
227
|
-
<script lang="ts">
|
|
228
|
-
import type { Content } from '@prismicio/client';
|
|
229
|
-
|
|
230
|
-
export let slice: Content.`,`Slice;
|
|
231
|
-
<\/script>
|
|
232
|
-
|
|
233
|
-
`,`
|
|
234
|
-
`]),r,L),l=o(O||=m([`
|
|
235
|
-
<script>
|
|
236
|
-
/** @type {import("@prismicio/client").Content.`,`Slice} */
|
|
237
|
-
export let slice;
|
|
238
|
-
<\/script>
|
|
239
|
-
|
|
240
|
-
`,`
|
|
241
|
-
`]),r,L);return t?n<=4?c:a:n<=4?l:s}var z,B;const V=[`<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 H=class extends s{id=`sveltekit`;environmentEnvVarName=`PUBLIC_PRISMIC_ENVIRONMENT`;localPreviewConfig={name:`Development`,websiteURL:`http://localhost:5173`,resolverPath:`/api/preview`};async setupProject(){await f({"@prismicio/client":`^${await p(`@prismicio/client`)}`,"@prismicio/svelte":`^${await p(`@prismicio/svelte`)}`});let t=await e(),i=await n(),a=await l(),s=await c(`svelte`);await r(new URL(`src/lib/prismicio.${i}`,t),k({typescript:a})),await r(new URL(`src/routes/slice-simulator/+page.svelte`,t),A({version:s})),await r(new URL(`src/params/preview.${i}`,t),o`
|
|
242
|
-
export function match(param) {
|
|
243
|
-
return param === 'preview';
|
|
244
|
-
}
|
|
245
|
-
`),await r(new URL(`src/routes/api/preview/+server.${i}`,t),j({typescript:a})),await r(new URL(`src/routes/[[preview=preview]]/README.md`,t),o`
|
|
246
|
-
This directory adds support for optional \`/preview\` routes. Do not remove this directory.
|
|
247
|
-
|
|
248
|
-
All routes within this directory will be served using the following URLs:
|
|
249
|
-
|
|
250
|
-
- \`/example-route\` (prerendered)
|
|
251
|
-
- \`/preview/example-route\` (server-rendered)
|
|
252
|
-
|
|
253
|
-
See <https://prismic.io/docs/svelte-preview> for more information.
|
|
254
|
-
`);let d=await W();d||await u(new URL(`src/routes/+layout.server.${i}`,t),N()),(!d||(await h(new URL(d,t),`utf8`)).includes(`repositoryName`))&&await r(new URL(`src/routes/+layout.svelte`,t),P({version:s})),await U()}async getSetupInstructions(){let t=await e(),n=await d(new URL(`src/routes/+page.svelte`,t))&&await d(new URL(`src/routes/[[preview=preview]]/+page.svelte`,t))&&o`
|
|
255
|
-
Action required: delete src/routes/+page.svelte.
|
|
256
|
-
|
|
257
|
-
It also serves / and hides your Prismic home page in
|
|
258
|
-
src/routes/[[preview=preview]]/+page.svelte. Move anything you need
|
|
259
|
-
from it first.
|
|
260
|
-
`;return[await this.getPreviewStep(),n].filter(Boolean).join(`
|
|
261
|
-
|
|
262
|
-
`)||void 0}async getPreviewStep(){if(await a(`PrismicPreview`))return;let t=await c(`svelte`)<=4?o(z||=m([`
|
|
263
|
-
Add the lines marked + to src/routes/+layout.svelte:
|
|
264
|
-
|
|
265
|
-
<script>
|
|
266
|
-
+ import { PrismicPreview } from "@prismicio/svelte/kit";
|
|
267
|
-
+
|
|
268
|
-
+ export let data;
|
|
269
|
-
<\/script>
|
|
270
|
-
|
|
271
|
-
<slot />
|
|
272
|
-
+ <PrismicPreview repositoryName={data.repositoryName} />
|
|
273
|
-
`])):o(B||=m([`
|
|
274
|
-
Change the lines marked - and + in src/routes/+layout.svelte:
|
|
275
|
-
|
|
276
|
-
<script>
|
|
277
|
-
+ import { PrismicPreview } from "@prismicio/svelte/kit";
|
|
278
|
-
|
|
279
|
-
- let { children } = $props();
|
|
280
|
-
+ let { data, children } = $props();
|
|
281
|
-
<\/script>
|
|
282
|
-
|
|
283
|
-
{@render children()}
|
|
284
|
-
+ <PrismicPreview repositoryName={data.repositoryName} />
|
|
285
|
-
`])),r=await W()??`src/routes/+layout.server.${await n()}`,i=!(await h(new URL(r,await e()),`utf8`).catch(()=>``)).includes(`repositoryName`)&&`Return repositoryName from load in ${r}, creating the file if needed:\n\n${N().replace(/^/gm,` `)}`;return[o`
|
|
286
|
-
Action required: add <PrismicPreview> to your root layout.
|
|
287
|
-
|
|
288
|
-
Previews do not work until you do this, and the CLI cannot edit your
|
|
289
|
-
layout for you. Make the change now.
|
|
290
|
-
`,t,i,"Run `prismic docs view sveltekit` for details."].filter(Boolean).join(`
|
|
291
|
-
|
|
292
|
-
`)}async createSliceIndexFile(e){let r=(await this.getSlices()).filter(t=>t.library.href===e.href),a=r.map(t=>{let n=_(v(e),v(t.directory));return`import ${i(t.model.name)} from "./${n}/index.svelte";`}),s=r.map(e=>`${t(e.model.id)}: ${i(e.model.name)}`),c=o`
|
|
293
|
-
// Code generated by Prismic. DO NOT EDIT.
|
|
294
|
-
|
|
295
|
-
${a.join(`
|
|
296
|
-
`)}
|
|
297
|
-
|
|
298
|
-
export const components = {
|
|
299
|
-
${s.join(`,
|
|
300
|
-
`)}
|
|
301
|
-
};
|
|
302
|
-
`;await u(new URL(`index.${await n()}`,e),c)}async getDefaultSliceLibrary(){return new URL(`src/lib/slices/`,await e())}async createSliceComponent(e,t){let n=R({name:e.name,typescript:await l(),version:await c(`svelte`)});await u(new URL(`index.svelte`,t),n)}async getPageFiles(t,r){let i=new URL(`src/routes/[[preview=preview]]/${r}/`,await e()),a=await l();return[{path:new URL(`+page.svelte`,i),contents:F({typescript:a})},{path:new URL(`+page.server.${await n()}`,i),contents:I({model:t,typescript:a})}]}};async function U(){let t=new URL(`src/routes/+page.svelte`,await e()),n=await h(t,`utf8`).catch(()=>void 0);V.includes(n?.replace(/\s/g,``)??``)&&await g(t)}async function W(){let t=await e();for(let e of[`src/routes/+layout.server.js`,`src/routes/+layout.server.ts`])if(await d(new URL(e,t)))return e}export{H as SvelteKitAdapter};
|