@slicemachine/adapter-sveltekit 0.3.78-beta.9 → 0.3.78

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.
Files changed (70) hide show
  1. package/dist/AlternateGrid/javascript.4.svelte +227 -0
  2. package/dist/AlternateGrid/javascript.svelte +6 -5
  3. package/dist/AlternateGrid/typescript.4.svelte +224 -0
  4. package/dist/AlternateGrid/typescript.svelte +9 -4
  5. package/dist/CallToAction/javascript.4.svelte +127 -0
  6. package/dist/CallToAction/javascript.svelte +6 -5
  7. package/dist/CallToAction/typescript.4.svelte +124 -0
  8. package/dist/CallToAction/typescript.svelte +4 -2
  9. package/dist/CustomerLogos/javascript.4.svelte +124 -0
  10. package/dist/CustomerLogos/javascript.svelte +6 -5
  11. package/dist/CustomerLogos/typescript.4.svelte +121 -0
  12. package/dist/CustomerLogos/typescript.svelte +4 -2
  13. package/dist/Hero/javascript.4.svelte +190 -0
  14. package/dist/Hero/javascript.svelte +5 -4
  15. package/dist/Hero/typescript.4.svelte +187 -0
  16. package/dist/Hero/typescript.svelte +4 -2
  17. package/dist/hooks/documentation-read.cjs +14 -51
  18. package/dist/hooks/documentation-read.cjs.map +1 -1
  19. package/dist/hooks/documentation-read.js +14 -51
  20. package/dist/hooks/documentation-read.js.map +1 -1
  21. package/dist/hooks/documentation-read.templates.cjs +114 -0
  22. package/dist/hooks/documentation-read.templates.cjs.map +1 -0
  23. package/dist/hooks/documentation-read.templates.d.ts +9 -0
  24. package/dist/hooks/documentation-read.templates.js +114 -0
  25. package/dist/hooks/documentation-read.templates.js.map +1 -0
  26. package/dist/hooks/project-init.cjs +44 -143
  27. package/dist/hooks/project-init.cjs.map +1 -1
  28. package/dist/hooks/project-init.js +44 -143
  29. package/dist/hooks/project-init.js.map +1 -1
  30. package/dist/hooks/project-init.templates.cjs +181 -0
  31. package/dist/hooks/project-init.templates.cjs.map +1 -0
  32. package/dist/hooks/project-init.templates.d.ts +12 -0
  33. package/dist/hooks/project-init.templates.js +181 -0
  34. package/dist/hooks/project-init.templates.js.map +1 -0
  35. package/dist/hooks/slice-create.cjs +5 -52
  36. package/dist/hooks/slice-create.cjs.map +1 -1
  37. package/dist/hooks/slice-create.js +5 -52
  38. package/dist/hooks/slice-create.js.map +1 -1
  39. package/dist/hooks/slice-create.templates.cjs +61 -0
  40. package/dist/hooks/slice-create.templates.cjs.map +1 -0
  41. package/dist/hooks/slice-create.templates.d.ts +6 -0
  42. package/dist/hooks/slice-create.templates.js +61 -0
  43. package/dist/hooks/slice-create.templates.js.map +1 -0
  44. package/dist/lib/getSvelteMajor.cjs +38 -0
  45. package/dist/lib/getSvelteMajor.cjs.map +1 -0
  46. package/dist/lib/getSvelteMajor.d.ts +1 -0
  47. package/dist/lib/getSvelteMajor.js +16 -0
  48. package/dist/lib/getSvelteMajor.js.map +1 -0
  49. package/dist/lib/requireResolve.cjs +16 -0
  50. package/dist/lib/requireResolve.cjs.map +1 -0
  51. package/dist/lib/requireResolve.d.ts +10 -0
  52. package/dist/lib/requireResolve.js +16 -0
  53. package/dist/lib/requireResolve.js.map +1 -0
  54. package/dist/plugin.cjs +4 -2
  55. package/dist/plugin.cjs.map +1 -1
  56. package/dist/plugin.js +4 -2
  57. package/dist/plugin.js.map +1 -1
  58. package/dist/simulator/SliceSimulator.svelte +3 -2
  59. package/dist/simulator/SliceSimulator.svelte.d.ts +7 -19
  60. package/package.json +8 -8
  61. package/src/hooks/documentation-read.templates.ts +170 -0
  62. package/src/hooks/documentation-read.ts +21 -59
  63. package/src/hooks/project-init.templates.ts +208 -0
  64. package/src/hooks/project-init.ts +57 -147
  65. package/src/hooks/slice-create.templates.ts +103 -0
  66. package/src/hooks/slice-create.ts +7 -66
  67. package/src/lib/getSvelteMajor.ts +23 -0
  68. package/src/lib/requireResolve.ts +30 -0
  69. package/src/plugin.ts +5 -2
  70. package/src/simulator/SliceSimulator.svelte +3 -2
@@ -0,0 +1,181 @@
1
+ import { source } from "common-tags";
2
+ import { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from "../constants.js";
3
+ var __freeze = Object.freeze;
4
+ var __defProp = Object.defineProperty;
5
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
6
+ var _a, _b, _c, _d;
7
+ function prismicIOFileTemplate(args) {
8
+ const { typescript } = args;
9
+ const TS = source`
10
+ import { createClient as baseCreateClient, type Route } from "@prismicio/client";
11
+ import { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';
12
+ import sm from "../../slicemachine.config.json";
13
+
14
+ /**
15
+ * The project's Prismic repository name.
16
+ */
17
+ export const repositoryName =
18
+ import${"."}meta${"."}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;
19
+
20
+ /**
21
+ * A list of Route Resolver objects that define how a document's \`url\` field is resolved.
22
+ *
23
+ * {@link https://prismic.io/docs/route-resolver}
24
+ */
25
+ // TODO: Update the routes array to match your project's route structure.
26
+ const routes: Route[] = [
27
+ // Examples:
28
+ // { type: "homepage", path: "/" },
29
+ // { type: "page", path: "/:uid" },
30
+ ];
31
+
32
+ /**
33
+ * Creates a Prismic client for the project's repository. The client is used to
34
+ * query content from the Prismic API.
35
+ *
36
+ * @param config - Configuration for the Prismic client.
37
+ */
38
+ export const createClient = ({ cookies, ...config }: CreateClientConfig = {}) => {
39
+ const client = baseCreateClient(repositoryName, {
40
+ routes,
41
+ ...config,
42
+ });
43
+
44
+ enableAutoPreviews({ client, cookies });
45
+
46
+ return client;
47
+ };
48
+ `;
49
+ const JS = source`
50
+ import { createClient as baseCreateClient } from "@prismicio/client";
51
+ import { enableAutoPreviews } from '@prismicio/svelte/kit';
52
+ import sm from "../../slicemachine.config.json";
53
+
54
+ /**
55
+ * The project's Prismic repository name.
56
+ */
57
+ export const repositoryName =
58
+ import${"."}meta${"."}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;
59
+
60
+ /**
61
+ * A list of Route Resolver objects that define how a document's \`url\` field is resolved.
62
+ *
63
+ * {@link https://prismic.io/docs/route-resolver#route-resolver}
64
+ *
65
+ * @type {import("@prismicio/client").Route[]}
66
+ */
67
+ // TODO: Update the routes array to match your project's route structure.
68
+ const routes = [
69
+ // Examples:
70
+ // { type: "homepage", path: "/" },
71
+ // { type: "page", path: "/:uid" },
72
+ ];
73
+
74
+ /**
75
+ * Creates a Prismic client for the project's repository. The client is used to
76
+ * query content from the Prismic API.
77
+ *
78
+ * @param {import('@prismicio/svelte/kit').CreateClientConfig} config - Configuration for the Prismic client.
79
+ */
80
+ export const createClient = ({ cookies, ...config } = {}) => {
81
+ const client = prismic.createClient(repositoryName, {
82
+ routes,
83
+ ...config,
84
+ });
85
+
86
+ enableAutoPreviews({ client, cookies });
87
+
88
+ return client;
89
+ };
90
+ `;
91
+ return typescript ? TS : JS;
92
+ }
93
+ function sliceSimulatorPageTemplate(args) {
94
+ const { version } = args;
95
+ const v5 = source(_a || (_a = __template(["\n <script>\n import { SliceSimulator } from '@slicemachine/adapter-sveltekit/simulator';\n import { SliceZone } from '@prismicio/svelte';\n import { components } from '$lib/slices';\n <\/script>\n\n <!-- Slot syntax is used for backward compatibility with Svelte <=4. -->\n <SliceSimulator let:slices>\n <SliceZone {slices} {components} />\n </SliceSimulator>\n "])));
96
+ const v4 = source(_b || (_b = __template(["\n <script>\n import { SliceSimulator } from '@slicemachine/adapter-sveltekit/simulator';\n import { SliceZone } from '@prismicio/svelte';\n import { components } from '$lib/slices';\n <\/script>\n\n <SliceSimulator let:slices>\n <SliceZone {slices} {components} />\n </SliceSimulator>\n "])));
97
+ return version <= 4 ? v4 : v5;
98
+ }
99
+ function previewAPIRouteTemplate(args) {
100
+ const { typescript } = args;
101
+ const TS = source`
102
+ import { redirectToPreviewURL } from '@prismicio/svelte/kit';
103
+ import { createClient } from '$lib/prismicio';
104
+ import type { RequestHandler } from "./$types";
105
+
106
+ export const GET: RequestHandler = async ({ fetch, request, cookies }) => {
107
+ const client = createClient({ fetch });
108
+
109
+ return await redirectToPreviewURL({ client, request, cookies });
110
+ }
111
+ `;
112
+ const JS = source`
113
+ import { redirectToPreviewURL } from '@prismicio/svelte/kit';
114
+ import { createClient } from '$lib/prismicio';
115
+
116
+ /* @type {import("./$types").RequestHandler} */
117
+ export async function GET({ fetch, request, cookies }) {
118
+ const client = createClient({ fetch });
119
+
120
+ return await redirectToPreviewURL({ client, request, cookies });
121
+ }
122
+ `;
123
+ return typescript ? TS : JS;
124
+ }
125
+ function rootLayoutTemplate(args) {
126
+ const { version } = args;
127
+ const v5 = source(_c || (_c = __template([`
128
+ <script>
129
+ import { isFilled, asImageSrc } from '@prismicio/client';
130
+ import { PrismicPreview } from '@prismicio/svelte/kit';
131
+ import { page } from '$app/state';
132
+ import { repositoryName } from '$lib/prismicio';
133
+
134
+ const { children } = $props();
135
+ <\/script>
136
+
137
+ <svelte:head>
138
+ <title>{page.data.page?.data.meta_title}</title>
139
+ <meta property="og:title" content={page.data.page?.data.meta_title} />
140
+ {#if isFilled.keyText(page.data.page?.data.meta_description)}
141
+ <meta name="description" content={page.data.page.data.meta_description} />
142
+ <meta property="og:description" content={page.data.page.data.meta_description} />
143
+ {/if}
144
+ {#if isFilled.image(page.data.page?.data.meta_image)}
145
+ <meta property="og:image" content={asImageSrc(page.data.page.data.meta_image)} />
146
+ {/if}
147
+ </svelte:head>
148
+ {@render children()}
149
+ <PrismicPreview {repositoryName} />
150
+ `])));
151
+ const v4 = source(_d || (_d = __template([`
152
+ <script>
153
+ import { isFilled, asImageSrc } from '@prismicio/client';
154
+ import { PrismicPreview } from '@prismicio/svelte/kit';
155
+ import { page } from '$app/state';
156
+ import { repositoryName } from '$lib/prismicio';
157
+ <\/script>
158
+
159
+ <svelte:head>
160
+ <title>{page.data.page?.data.meta_title}</title>
161
+ <meta property="og:title" content={page.data.page?.data.meta_title} />
162
+ {#if isFilled.keyText(page.data.page?.data.meta_description)}
163
+ <meta name="description" content={page.data.page.data.meta_description} />
164
+ <meta property="og:description" content={page.data.page.data.meta_description} />
165
+ {/if}
166
+ {#if isFilled.image(page.data.page?.data.meta_image)}
167
+ <meta property="og:image" content={asImageSrc(page.data.page.data.meta_image)} />
168
+ {/if}
169
+ </svelte:head>
170
+ <slot />
171
+ <PrismicPreview {repositoryName} />
172
+ `])));
173
+ return version <= 4 ? v4 : v5;
174
+ }
175
+ export {
176
+ previewAPIRouteTemplate,
177
+ prismicIOFileTemplate,
178
+ rootLayoutTemplate,
179
+ sliceSimulatorPageTemplate
180
+ };
181
+ //# sourceMappingURL=project-init.templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-init.templates.js","sources":["../../../src/hooks/project-init.templates.ts"],"sourcesContent":["import { source as svelte, source as ts, source as js } from \"common-tags\";\n\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\n\nexport function prismicIOFileTemplate(args: { typescript: boolean }): string {\n\tconst { typescript } = args;\n\n\tconst TS = ts`\n\t\timport { createClient as baseCreateClient, type Route } from \"@prismicio/client\";\n\t\timport { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';\n\t\timport sm from \"../../slicemachine.config.json\";\n\n\t\t/**\n\t\t * The project's Prismic repository name.\n\t\t */\n\t\texport const repositoryName =\n\t\t\timport${\".\"}meta${\".\"}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t/**\n\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t *\n\t\t * {@link https://prismic.io/docs/route-resolver}\n\t\t */\n\t\t// TODO: Update the routes array to match your project's route structure.\n\t\tconst routes: Route[] = [\n\t\t\t// Examples:\n\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t];\n\n\t\t/**\n\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t * query content from the Prismic API.\n\t\t *\n\t\t * @param config - Configuration for the Prismic client.\n\t\t */\n\t\texport const createClient = ({ cookies, ...config }: CreateClientConfig = {}) => {\n\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\troutes,\n\t\t\t\t...config,\n\t\t\t});\n\n\t\t\tenableAutoPreviews({ client, cookies });\n\n\t\t\treturn client;\n\t\t};\n\t`;\n\n\tconst JS = js`\n\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\timport { enableAutoPreviews } from '@prismicio/svelte/kit';\n\t\timport sm from \"../../slicemachine.config.json\";\n\n\t\t/**\n\t\t * The project's Prismic repository name.\n\t\t */\n\t\texport const repositoryName =\n\t\t\timport${\".\"}meta${\".\"}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t/**\n\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t *\n\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t *\n\t\t * @type {import(\"@prismicio/client\").Route[]}\n\t\t */\n\t\t// TODO: Update the routes array to match your project's route structure.\n\t\tconst routes = [\n\t\t\t// Examples:\n\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t];\n\n\t\t/**\n\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t * query content from the Prismic API.\n\t\t *\n\t\t * @param {import('@prismicio/svelte/kit').CreateClientConfig} config - Configuration for the Prismic client.\n\t\t */\n\t\texport const createClient = ({ cookies, ...config } = {}) => {\n\t\t\tconst client = prismic.createClient(repositoryName, {\n\t\t\t\troutes,\n\t\t\t\t...config,\n\t\t\t});\n\n\t\t\tenableAutoPreviews({ client, cookies });\n\n\t\t\treturn client;\n\t\t};\n\t`;\n\n\treturn typescript ? TS : JS;\n}\n\nexport function sliceSimulatorPageTemplate(args: { version: number }): string {\n\tconst { version } = args;\n\n\tconst v5 = svelte`\n\t\t<script>\n\t\t\timport { SliceSimulator } from '@slicemachine/adapter-sveltekit/simulator';\n\t\t\timport { SliceZone } from '@prismicio/svelte';\n\t\t\timport { components } from '$lib/slices';\n\t\t</script>\n\n\t\t<!-- Slot syntax is used for backward compatibility with Svelte <=4. -->\n\t\t<SliceSimulator let:slices>\n\t\t\t<SliceZone {slices} {components} />\n\t\t</SliceSimulator>\n\t`;\n\n\tconst v4 = svelte`\n\t\t<script>\n\t\t\timport { SliceSimulator } from '@slicemachine/adapter-sveltekit/simulator';\n\t\t\timport { SliceZone } from '@prismicio/svelte';\n\t\t\timport { components } from '$lib/slices';\n\t\t</script>\n\n\t\t<SliceSimulator let:slices>\n\t\t\t<SliceZone {slices} {components} />\n\t\t</SliceSimulator>\n\t`;\n\n\treturn version <= 4 ? v4 : v5;\n}\n\nexport function previewAPIRouteTemplate(args: { typescript: boolean }): string {\n\tconst { typescript } = args;\n\n\tconst TS = ts`\n\t\timport { redirectToPreviewURL } from '@prismicio/svelte/kit';\n\t\timport { createClient } from '$lib/prismicio';\n\t\timport type { RequestHandler } from \"./$types\";\n\n\t\texport const GET: RequestHandler = async ({ fetch, request, cookies }) => {\n\t\t\tconst client = createClient({ fetch });\n\n\t\t\treturn await redirectToPreviewURL({ client, request, cookies });\n\t\t}\n\t`;\n\n\tconst JS = js`\n\t\timport { redirectToPreviewURL } from '@prismicio/svelte/kit';\n\t\timport { createClient } from '$lib/prismicio';\n\n\t\t/* @type {import(\"./$types\").RequestHandler} */\n\t\texport async function GET({ fetch, request, cookies }) {\n\t\t\tconst client = createClient({ fetch });\n\n\t\t\treturn await redirectToPreviewURL({ client, request, cookies });\n\t\t}\n\t`;\n\n\treturn typescript ? TS : JS;\n}\n\nexport function rootLayoutTemplate(args: { version: number }): string {\n\tconst { version } = args;\n\n\tconst v5 = svelte`\n\t\t<script>\n\t\t\timport { isFilled, asImageSrc } from '@prismicio/client';\n\t\t\timport { PrismicPreview } from '@prismicio/svelte/kit';\n\t\t\timport { page } from '$app/state';\n\t\t\timport { repositoryName } from '$lib/prismicio';\n\n\t\t\tconst { children } = $props();\n\t\t</script>\n\n\t\t<svelte:head>\n\t\t\t<title>{page.data.page?.data.meta_title}</title>\n\t\t\t<meta property=\"og:title\" content={page.data.page?.data.meta_title} />\n\t\t\t{#if isFilled.keyText(page.data.page?.data.meta_description)}\n\t\t\t\t<meta name=\"description\" content={page.data.page.data.meta_description} />\n\t\t\t\t<meta property=\"og:description\" content={page.data.page.data.meta_description} />\n\t\t\t{/if}\n\t\t\t{#if isFilled.image(page.data.page?.data.meta_image)}\n\t\t\t\t<meta property=\"og:image\" content={asImageSrc(page.data.page.data.meta_image)} />\n\t\t\t{/if}\n\t\t</svelte:head>\n\t\t{@render children()}\n\t\t<PrismicPreview {repositoryName} />\n\t`;\n\n\tconst v4 = svelte`\n\t\t<script>\n\t\t\timport { isFilled, asImageSrc } from '@prismicio/client';\n\t\t\timport { PrismicPreview } from '@prismicio/svelte/kit';\n\t\t\timport { page } from '$app/state';\n\t\t\timport { repositoryName } from '$lib/prismicio';\n\t\t</script>\n\n\t\t<svelte:head>\n\t\t\t<title>{page.data.page?.data.meta_title}</title>\n\t\t\t<meta property=\"og:title\" content={page.data.page?.data.meta_title} />\n\t\t\t{#if isFilled.keyText(page.data.page?.data.meta_description)}\n\t\t\t\t<meta name=\"description\" content={page.data.page.data.meta_description} />\n\t\t\t\t<meta property=\"og:description\" content={page.data.page.data.meta_description} />\n\t\t\t{/if}\n\t\t\t{#if isFilled.image(page.data.page?.data.meta_image)}\n\t\t\t\t<meta property=\"og:image\" content={asImageSrc(page.data.page.data.meta_image)} />\n\t\t\t{/if}\n\t\t</svelte:head>\n\t\t<slot />\n\t\t<PrismicPreview {repositoryName} />\n\t`;\n\n\treturn version <= 4 ? v4 : v5;\n}\n"],"names":["ts","js","svelte"],"mappings":";;;;;AAAA,IAAA,IAAA,IAAA,IAAA;AAIM,SAAU,sBAAsB,MAA6B;AAC5D,QAAA,EAAE,WAAe,IAAA;AAEvB,QAAM,KAAKA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,WASD,GAAG,OAAO,GAAG,OAAO,6CAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgC3E,QAAM,KAAKC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,WASD,GAAG,OAAO,GAAG,OAAO,6CAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkC3E,SAAO,aAAa,KAAK;AAC1B;AAEM,SAAU,2BAA2B,MAAyB;AAC7D,QAAA,EAAE,QAAY,IAAA;AAEpB,QAAM,KAAKC,OAAM,OAAA,KAAA,WAAA,CAAA,0XAAA,CAAA,EAAA;AAajB,QAAM,KAAKA,OAAM,OAAA,KAAA,WAAA,CAAA,8SAAA,CAAA,EAAA;AAYV,SAAA,WAAW,IAAI,KAAK;AAC5B;AAEM,SAAU,wBAAwB,MAA6B;AAC9D,QAAA,EAAE,WAAe,IAAA;AAEvB,QAAM,KAAKF;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAYX,QAAM,KAAKC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAYX,SAAO,aAAa,KAAK;AAC1B;AAEM,SAAU,mBAAmB,MAAyB;AACrD,QAAA,EAAE,QAAY,IAAA;AAEpB,QAAM,KAAKC,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA,EAAA;AAyBjB,QAAM,KAAKA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA,EAAA;AAuBV,SAAA,WAAW,IAAI,KAAK;AAC5B;"}
@@ -1,62 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const fs = require("@slicemachine/plugin-kit/fs");
4
- const commonTags = require("common-tags");
5
4
  const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
6
- const pascalCase = require("../lib/pascalCase.cjs");
5
+ const getSvelteMajor = require("../lib/getSvelteMajor.cjs");
7
6
  const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
8
7
  const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
9
- var __freeze = Object.freeze;
10
- var __defProp = Object.defineProperty;
11
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
12
- var _a, _b;
8
+ const sliceCreate_templates = require("./slice-create.templates.cjs");
13
9
  const createComponentFile = async ({ data, helpers, actions, options }) => {
14
- const pascalName = pascalCase.pascalCase(data.model.name);
15
- let contents;
16
- const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
17
- helpers,
18
- options
19
- });
20
- const placeholder = `
21
- Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
22
- <br />
23
- <strong>You can edit this slice directly in your code editor.</strong>
24
- <!--
25
- 💡 Use Prismic MCP with your code editor
26
-
27
- Get AI-powered help to build your slice components — based on your actual model.
28
-
29
- ▶️ Setup:
30
- 1. Add a new MCP Server in your code editor:
31
-
32
- {
33
- "mcpServers": {
34
- "Prismic MCP": {
35
- "command": "npx",
36
- "args": ["-y", "@prismicio/mcp-server"]
37
- }
38
- }
39
- }
40
-
41
- 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
42
-
43
- ✅ Then open your slice file and ask your code editor:
44
- "Code this slice"
45
-
46
- Your code editor reads your slice model and helps you code faster ⚡
47
- 📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
48
- -->`;
49
- if (data.componentContents) {
50
- contents = data.componentContents;
51
- } else if (isTypeScriptProject) {
52
- contents = commonTags.source(_a || (_a = __template([`
53
- <script lang="ts">
54
- import type { Content } from '@prismicio/client';
55
-
56
- export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, placeholder);
57
- } else {
58
- contents = commonTags.source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, placeholder);
59
- }
10
+ const { model, componentContents } = data;
11
+ const typescript = await checkIsTypeScriptProject.checkIsTypeScriptProject({ helpers, options });
12
+ const contents = componentContents ?? sliceCreate_templates.sliceTemplate({ model, typescript, version: await getSvelteMajor.getSvelteMajor() });
60
13
  await fs.writeSliceFile({
61
14
  libraryID: data.libraryID,
62
15
  model: data.model,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholder = `\n\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) slices.\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t💡 Use Prismic MCP with your code editor\n\n\tGet AI-powered help to build your slice components — based on your actual model.\n\n\t▶️ Setup:\n\t1. Add a new MCP Server in your code editor:\n\n\t{\n\t\t\"mcpServers\": {\n\t\t\t\"Prismic MCP\": {\n\t\t\t\t\"command\": \"npx\",\n\t\t\t\t\"args\": [\"-y\", \"@prismicio/mcp-server\"]\n\t\t\t}\n\t\t}\n\t}\n\n\t2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\n\t✅ Then open your slice file and ask your code editor:\n\t\t\"Code this slice\"\n\n\tYour code editor reads your slice model and helps you code faster ⚡\n\t📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\t${placeholder}\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\t${placeholder}\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["pascalCase","checkIsTypeScriptProject","source","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,aAAaA,WAAA,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BpB,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AAC/B,eAAWC,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIuB,yHAIzB,0BAJe,YAI1B,WAAA;AAAA,EAAA,OAGE;AACN,eAAWA,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA,sEAE4C,mJAK9C,qBAAA,CAAA,IALoC,YAK/C,WAAA;AAAA,EAGL;AAEA,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
1
+ {"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getSvelteMajor } from \"../lib/getSvelteMajor\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { sliceTemplate } from \"./slice-create.templates\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst { model, componentContents } = data;\n\n\tconst typescript = await checkIsTypeScriptProject({ helpers, options });\n\tconst contents =\n\t\tcomponentContents ??\n\t\tsliceTemplate({ model, typescript, version: await getSvelteMajor() });\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["checkIsTypeScriptProject","sliceTemplate","getSvelteMajor","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;AAuBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACJ,QAAA,EAAE,OAAO,kBAAsB,IAAA;AAErC,QAAM,aAAa,MAAMA,yBAAA,yBAAyB,EAAE,SAAS,QAAS,CAAA;AAChE,QAAA,WACL,qBACAC,sBAAAA,cAAc,EAAE,OAAO,YAAY,SAAS,MAAMC,8BAAgB,EAAA,CAAE;AAErE,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
@@ -1,60 +1,13 @@
1
1
  import { writeSliceModel, upsertGlobalTypeScriptTypes, writeSliceFile } from "@slicemachine/plugin-kit/fs";
2
- import { source } from "common-tags";
3
2
  import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
4
- import { pascalCase } from "../lib/pascalCase.js";
3
+ import { getSvelteMajor } from "../lib/getSvelteMajor.js";
5
4
  import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
6
5
  import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
7
- var __freeze = Object.freeze;
8
- var __defProp = Object.defineProperty;
9
- var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
10
- var _a, _b;
6
+ import { sliceTemplate } from "./slice-create.templates.js";
11
7
  const createComponentFile = async ({ data, helpers, actions, options }) => {
12
- const pascalName = pascalCase(data.model.name);
13
- let contents;
14
- const isTypeScriptProject = await checkIsTypeScriptProject({
15
- helpers,
16
- options
17
- });
18
- const placeholder = `
19
- Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
20
- <br />
21
- <strong>You can edit this slice directly in your code editor.</strong>
22
- <!--
23
- 💡 Use Prismic MCP with your code editor
24
-
25
- Get AI-powered help to build your slice components — based on your actual model.
26
-
27
- ▶️ Setup:
28
- 1. Add a new MCP Server in your code editor:
29
-
30
- {
31
- "mcpServers": {
32
- "Prismic MCP": {
33
- "command": "npx",
34
- "args": ["-y", "@prismicio/mcp-server"]
35
- }
36
- }
37
- }
38
-
39
- 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
40
-
41
- ✅ Then open your slice file and ask your code editor:
42
- "Code this slice"
43
-
44
- Your code editor reads your slice model and helps you code faster ⚡
45
- 📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
46
- -->`;
47
- if (data.componentContents) {
48
- contents = data.componentContents;
49
- } else if (isTypeScriptProject) {
50
- contents = source(_a || (_a = __template([`
51
- <script lang="ts">
52
- import type { Content } from '@prismicio/client';
53
-
54
- export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, placeholder);
55
- } else {
56
- contents = source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, placeholder);
57
- }
8
+ const { model, componentContents } = data;
9
+ const typescript = await checkIsTypeScriptProject({ helpers, options });
10
+ const contents = componentContents ?? sliceTemplate({ model, typescript, version: await getSvelteMajor() });
58
11
  await writeSliceFile({
59
12
  libraryID: data.libraryID,
60
13
  model: data.model,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst placeholder = `\n\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) slices.\n\t\t<br />\n\t\t<strong>You can edit this slice directly in your code editor.</strong>\n\t\t<!--\n\t💡 Use Prismic MCP with your code editor\n\n\tGet AI-powered help to build your slice components — based on your actual model.\n\n\t▶️ Setup:\n\t1. Add a new MCP Server in your code editor:\n\n\t{\n\t\t\"mcpServers\": {\n\t\t\t\"Prismic MCP\": {\n\t\t\t\t\"command\": \"npx\",\n\t\t\t\t\"args\": [\"-y\", \"@prismicio/mcp-server\"]\n\t\t\t}\n\t\t}\n\t}\n\n\t2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\n\t✅ Then open your slice file and ask your code editor:\n\t\t\"Code this slice\"\n\n\tYour code editor reads your slice model and helps you code faster ⚡\n\t📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n-->`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\t${placeholder}\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\t${placeholder}\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BpB,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AAC/B,eAAW,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIuB,yHAIzB,0BAJe,YAI1B,WAAA;AAAA,EAAA,OAGE;AACN,eAAW,OAAM,OAAA,KAAA,WAAA,CAAA,sEAE4C,mJAK9C,qBAAA,CAAA,IALoC,YAK/C,WAAA;AAAA,EAGL;AAEA,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;"}
1
+ {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getSvelteMajor } from \"../lib/getSvelteMajor\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { sliceTemplate } from \"./slice-create.templates\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst { model, componentContents } = data;\n\n\tconst typescript = await checkIsTypeScriptProject({ helpers, options });\n\tconst contents =\n\t\tcomponentContents ??\n\t\tsliceTemplate({ model, typescript, version: await getSvelteMajor() });\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;AAuBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACJ,QAAA,EAAE,OAAO,kBAAsB,IAAA;AAErC,QAAM,aAAa,MAAM,yBAAyB,EAAE,SAAS,QAAS,CAAA;AAChE,QAAA,WACL,qBACA,cAAc,EAAE,OAAO,YAAY,SAAS,MAAM,eAAgB,EAAA,CAAE;AAErE,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const commonTags = require("common-tags");
4
+ const pascalCase = require("../lib/pascalCase.cjs");
5
+ var __freeze = Object.freeze;
6
+ var __defProp = Object.defineProperty;
7
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
8
+ var _a, _b, _c, _d;
9
+ const PLACEHOLDER = `
10
+ Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
11
+ <br />
12
+ <strong>You can edit this slice directly in your code editor.</strong>
13
+ <!--
14
+ 💡 Use Prismic MCP with your code editor
15
+
16
+ Get AI-powered help to build your slice components — based on your actual model.
17
+
18
+ ▶️ Setup:
19
+ 1. Add a new MCP Server in your code editor:
20
+
21
+ {
22
+ "mcpServers": {
23
+ "Prismic MCP": {
24
+ "command": "npx",
25
+ "args": ["-y", "@prismicio/mcp-server"]
26
+ }
27
+ }
28
+ }
29
+
30
+ 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
31
+
32
+ ✅ Then open your slice file and ask your code editor:
33
+ "Code this slice"
34
+
35
+ Your code editor reads your slice model and helps you code faster ⚡
36
+ 📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
37
+ -->
38
+ `;
39
+ function sliceTemplate(args) {
40
+ const { model, typescript, version } = args;
41
+ const pascalName = pascalCase.pascalCase(model.name);
42
+ const v5TS = commonTags.source(_a || (_a = __template([`
43
+ <script lang="ts">
44
+ import type { Content } from '@prismicio/client';
45
+ import type { SliceComponentProps } from '@prismicio/svelte';
46
+
47
+ type Props = SliceComponentProps<Content.`, "Slice>;\n\n const { slice }: Props = $props();\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
48
+ const v5JS = commonTags.source(_b || (_b = __template(['\n <script>\n /* @typedef {import("@prismicio/client").Content} Content */\n /* @typedef {import("@prismicio/svelte").SliceComponentProps} SliceComponentProps */\n\n /* @type {SliceComponentProps<Content.', "Slice>} */\n const { slice } = $props();\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
49
+ const v4TS = commonTags.source(_c || (_c = __template([`
50
+ <script lang="ts">
51
+ import type { Content } from '@prismicio/client';
52
+
53
+ export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
54
+ const v4JS = commonTags.source(_d || (_d = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
55
+ if (typescript) {
56
+ return version <= 4 ? v4TS : v5TS;
57
+ }
58
+ return version <= 4 ? v4JS : v5JS;
59
+ }
60
+ exports.sliceTemplate = sliceTemplate;
61
+ //# sourceMappingURL=slice-create.templates.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice-create.templates.cjs","sources":["../../../src/hooks/slice-create.templates.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport { source as svelte } from \"common-tags\";\n\nimport { pascalCase } from \"../lib/pascalCase\";\n\nconst PLACEHOLDER = `\nPlaceholder component for {slice.slice_type} (variation: {slice.variation}) slices.\n<br />\n<strong>You can edit this slice directly in your code editor.</strong>\n<!--\n💡 Use Prismic MCP with your code editor\n\nGet AI-powered help to build your slice components — based on your actual model.\n\n▶️ Setup:\n1. Add a new MCP Server in your code editor:\n\n{\n \"mcpServers\": {\n \"Prismic MCP\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@prismicio/mcp-server\"]\n }\n }\n}\n\n2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\n✅ Then open your slice file and ask your code editor:\n\t\"Code this slice\"\n\nYour code editor reads your slice model and helps you code faster ⚡\n📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n-->\n`;\n\nexport function sliceTemplate(args: {\n\tmodel: SharedSlice;\n\ttypescript: boolean;\n\tversion: number;\n}): string {\n\tconst { model, typescript, version } = args;\n\n\tconst pascalName = pascalCase(model.name);\n\n\tconst v5TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport type { Content } from '@prismicio/client';\n\t\t\timport type { SliceComponentProps } from '@prismicio/svelte';\n\n\t\t\ttype Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\tconst { slice }: Props = $props();\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v5JS = svelte`\n\t\t<script>\n\t\t\t/* @typedef {import(\"@prismicio/client\").Content} Content */\n\t\t\t/* @typedef {import(\"@prismicio/svelte\").SliceComponentProps} SliceComponentProps */\n\n\t\t\t/* @type {SliceComponentProps<Content.${pascalName}Slice>} */\n\t\t\tconst { slice } = $props();\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v4TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v4JS = svelte`\n\t\t<script>\n\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\texport let slice;\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tif (typescript) {\n\t\treturn version <= 4 ? v4TS : v5TS;\n\t}\n\n\treturn version <= 4 ? v4JS : v5JS;\n}\n"],"names":["pascalCase","svelte"],"mappings":";;;;;;;AACA,IAAA,IAAA,IAAA,IAAA;AAIA,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+Bd,SAAU,cAAc,MAI7B;AACA,QAAM,EAAE,OAAO,YAAY,QAAA,IAAY;AAEjC,QAAA,aAAaA,WAAAA,WAAW,MAAM,IAAI;AAExC,QAAM,OAAOC,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+CAKoC,gKAMxC,wBAN8B,YAMzC,WAAA;AAIJ,QAAM,OAAOA,WAAA,OAAA,OAAA,KAAM,WAKiC,CAAA,uNAAA,0JAKrC,wBAL2B,YAKtC,WAAA;AAIJ,QAAM,OAAOA,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,gCAIqB,sHAIzB,wBAJe,YAI1B,WAAA;AAIJ,QAAM,OAAOA,WAAA,OAAA,OAAA,KAAM,WAE0C,CAAA,oEAAA,+IAK9C,wBALoC,YAK/C,WAAA;AAIJ,MAAI,YAAY;AACR,WAAA,WAAW,IAAI,OAAO;AAAA,EAC9B;AAEO,SAAA,WAAW,IAAI,OAAO;AAC9B;;"}
@@ -0,0 +1,6 @@
1
+ import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ export declare function sliceTemplate(args: {
3
+ model: SharedSlice;
4
+ typescript: boolean;
5
+ version: number;
6
+ }): string;
@@ -0,0 +1,61 @@
1
+ import { source } from "common-tags";
2
+ import { pascalCase } from "../lib/pascalCase.js";
3
+ var __freeze = Object.freeze;
4
+ var __defProp = Object.defineProperty;
5
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
6
+ var _a, _b, _c, _d;
7
+ const PLACEHOLDER = `
8
+ Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
9
+ <br />
10
+ <strong>You can edit this slice directly in your code editor.</strong>
11
+ <!--
12
+ 💡 Use Prismic MCP with your code editor
13
+
14
+ Get AI-powered help to build your slice components — based on your actual model.
15
+
16
+ ▶️ Setup:
17
+ 1. Add a new MCP Server in your code editor:
18
+
19
+ {
20
+ "mcpServers": {
21
+ "Prismic MCP": {
22
+ "command": "npx",
23
+ "args": ["-y", "@prismicio/mcp-server"]
24
+ }
25
+ }
26
+ }
27
+
28
+ 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
29
+
30
+ ✅ Then open your slice file and ask your code editor:
31
+ "Code this slice"
32
+
33
+ Your code editor reads your slice model and helps you code faster ⚡
34
+ 📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
35
+ -->
36
+ `;
37
+ function sliceTemplate(args) {
38
+ const { model, typescript, version } = args;
39
+ const pascalName = pascalCase(model.name);
40
+ const v5TS = source(_a || (_a = __template([`
41
+ <script lang="ts">
42
+ import type { Content } from '@prismicio/client';
43
+ import type { SliceComponentProps } from '@prismicio/svelte';
44
+
45
+ type Props = SliceComponentProps<Content.`, "Slice>;\n\n const { slice }: Props = $props();\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
46
+ const v5JS = source(_b || (_b = __template(['\n <script>\n /* @typedef {import("@prismicio/client").Content} Content */\n /* @typedef {import("@prismicio/svelte").SliceComponentProps} SliceComponentProps */\n\n /* @type {SliceComponentProps<Content.', "Slice>} */\n const { slice } = $props();\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
47
+ const v4TS = source(_c || (_c = __template([`
48
+ <script lang="ts">
49
+ import type { Content } from '@prismicio/client';
50
+
51
+ export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
52
+ const v4JS = source(_d || (_d = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n ", "\n </section>\n "])), pascalName, PLACEHOLDER);
53
+ if (typescript) {
54
+ return version <= 4 ? v4TS : v5TS;
55
+ }
56
+ return version <= 4 ? v4JS : v5JS;
57
+ }
58
+ export {
59
+ sliceTemplate
60
+ };
61
+ //# sourceMappingURL=slice-create.templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice-create.templates.js","sources":["../../../src/hooks/slice-create.templates.ts"],"sourcesContent":["import { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport { source as svelte } from \"common-tags\";\n\nimport { pascalCase } from \"../lib/pascalCase\";\n\nconst PLACEHOLDER = `\nPlaceholder component for {slice.slice_type} (variation: {slice.variation}) slices.\n<br />\n<strong>You can edit this slice directly in your code editor.</strong>\n<!--\n💡 Use Prismic MCP with your code editor\n\nGet AI-powered help to build your slice components — based on your actual model.\n\n▶️ Setup:\n1. Add a new MCP Server in your code editor:\n\n{\n \"mcpServers\": {\n \"Prismic MCP\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@prismicio/mcp-server\"]\n }\n }\n}\n\n2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\n✅ Then open your slice file and ask your code editor:\n\t\"Code this slice\"\n\nYour code editor reads your slice model and helps you code faster ⚡\n📚 Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n-->\n`;\n\nexport function sliceTemplate(args: {\n\tmodel: SharedSlice;\n\ttypescript: boolean;\n\tversion: number;\n}): string {\n\tconst { model, typescript, version } = args;\n\n\tconst pascalName = pascalCase(model.name);\n\n\tconst v5TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport type { Content } from '@prismicio/client';\n\t\t\timport type { SliceComponentProps } from '@prismicio/svelte';\n\n\t\t\ttype Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\tconst { slice }: Props = $props();\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v5JS = svelte`\n\t\t<script>\n\t\t\t/* @typedef {import(\"@prismicio/client\").Content} Content */\n\t\t\t/* @typedef {import(\"@prismicio/svelte\").SliceComponentProps} SliceComponentProps */\n\n\t\t\t/* @type {SliceComponentProps<Content.${pascalName}Slice>} */\n\t\t\tconst { slice } = $props();\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v4TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tconst v4JS = svelte`\n\t\t<script>\n\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\texport let slice;\n\t\t</script>\n\n\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t${PLACEHOLDER}\n\t\t</section>\n\t`;\n\n\tif (typescript) {\n\t\treturn version <= 4 ? v4TS : v5TS;\n\t}\n\n\treturn version <= 4 ? v4JS : v5JS;\n}\n"],"names":["svelte"],"mappings":";;;;;AACA,IAAA,IAAA,IAAA,IAAA;AAIA,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+Bd,SAAU,cAAc,MAI7B;AACA,QAAM,EAAE,OAAO,YAAY,QAAA,IAAY;AAEjC,QAAA,aAAa,WAAW,MAAM,IAAI;AAExC,QAAM,OAAOA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+CAKoC,gKAMxC,wBAN8B,YAMzC,WAAA;AAIJ,QAAM,OAAOA,OAAA,OAAA,KAAM,WAKiC,CAAA,uNAAA,0JAKrC,wBAL2B,YAKtC,WAAA;AAIJ,QAAM,OAAOA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,gCAIqB,sHAIzB,wBAJe,YAI1B,WAAA;AAIJ,QAAM,OAAOA,OAAA,OAAA,KAAM,WAE0C,CAAA,oEAAA,+IAK9C,wBALoC,YAK/C,WAAA;AAIJ,MAAI,YAAY;AACR,WAAA,WAAW,IAAI,OAAO;AAAA,EAC9B;AAEO,SAAA,WAAW,IAAI,OAAO;AAC9B;"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
+ const path = require("node:path");
26
+ const requireResolve = require("./requireResolve.cjs");
27
+ const getSvelteMajor = async () => {
28
+ const { readFile } = await import("node:fs/promises");
29
+ const packageJSONPath = requireResolve.requireResolve("svelte/package.json", path.join(process.cwd(), "package.json"));
30
+ const { version } = JSON.parse(await readFile(packageJSONPath, "utf8"));
31
+ const major = Number.parseInt(version.split(".")[0]);
32
+ if (major === Number.NaN) {
33
+ throw new Error(`Unable to parse svelte's installed version number: "${version}"`);
34
+ }
35
+ return major;
36
+ };
37
+ exports.getSvelteMajor = getSvelteMajor;
38
+ //# sourceMappingURL=getSvelteMajor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSvelteMajor.cjs","sources":["../../../src/lib/getSvelteMajor.ts"],"sourcesContent":["import { join } from \"node:path\";\n\nimport { requireResolve } from \"./requireResolve\";\n\nexport const getSvelteMajor = async (): Promise<number> => {\n\t// A dynamic import lets us easily mock the module.\n\tconst { readFile } = await import(\"node:fs/promises\");\n\n\tconst packageJSONPath = requireResolve(\n\t\t\"svelte/package.json\",\n\t\tjoin(process.cwd(), \"package.json\"),\n\t);\n\tconst { version } = JSON.parse(await readFile(packageJSONPath, \"utf8\"));\n\n\tconst major = Number.parseInt(version.split(\".\")[0]);\n\tif (major === Number.NaN) {\n\t\tthrow new Error(\n\t\t\t`Unable to parse svelte's installed version number: \"${version}\"`,\n\t\t);\n\t}\n\n\treturn major;\n};\n"],"names":["requireResolve","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,iBAAiB,YAA4B;AAEzD,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,kBAAkB;AAE9C,QAAA,kBAAkBA,8BACvB,uBACAC,KAAAA,KAAK,QAAQ,IAAK,GAAE,cAAc,CAAC;AAE9B,QAAA,EAAE,QAAY,IAAA,KAAK,MAAM,MAAM,SAAS,iBAAiB,MAAM,CAAC;AAEhE,QAAA,QAAQ,OAAO,SAAS,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC;AAC/C,MAAA,UAAU,OAAO,KAAK;AACzB,UAAM,IAAI,MACT,uDAAuD,OAAO,GAAG;AAAA,EAEnE;AAEO,SAAA;AACR;;"}
@@ -0,0 +1 @@
1
+ export declare const getSvelteMajor: () => Promise<number>;
@@ -0,0 +1,16 @@
1
+ import { join } from "node:path";
2
+ import { requireResolve } from "./requireResolve.js";
3
+ const getSvelteMajor = async () => {
4
+ const { readFile } = await import("node:fs/promises");
5
+ const packageJSONPath = requireResolve("svelte/package.json", join(process.cwd(), "package.json"));
6
+ const { version } = JSON.parse(await readFile(packageJSONPath, "utf8"));
7
+ const major = Number.parseInt(version.split(".")[0]);
8
+ if (major === Number.NaN) {
9
+ throw new Error(`Unable to parse svelte's installed version number: "${version}"`);
10
+ }
11
+ return major;
12
+ };
13
+ export {
14
+ getSvelteMajor
15
+ };
16
+ //# sourceMappingURL=getSvelteMajor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSvelteMajor.js","sources":["../../../src/lib/getSvelteMajor.ts"],"sourcesContent":["import { join } from \"node:path\";\n\nimport { requireResolve } from \"./requireResolve\";\n\nexport const getSvelteMajor = async (): Promise<number> => {\n\t// A dynamic import lets us easily mock the module.\n\tconst { readFile } = await import(\"node:fs/promises\");\n\n\tconst packageJSONPath = requireResolve(\n\t\t\"svelte/package.json\",\n\t\tjoin(process.cwd(), \"package.json\"),\n\t);\n\tconst { version } = JSON.parse(await readFile(packageJSONPath, \"utf8\"));\n\n\tconst major = Number.parseInt(version.split(\".\")[0]);\n\tif (major === Number.NaN) {\n\t\tthrow new Error(\n\t\t\t`Unable to parse svelte's installed version number: \"${version}\"`,\n\t\t);\n\t}\n\n\treturn major;\n};\n"],"names":[],"mappings":";;AAIO,MAAM,iBAAiB,YAA4B;AAEzD,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,kBAAkB;AAE9C,QAAA,kBAAkB,eACvB,uBACA,KAAK,QAAQ,IAAK,GAAE,cAAc,CAAC;AAE9B,QAAA,EAAE,QAAY,IAAA,KAAK,MAAM,MAAM,SAAS,iBAAiB,MAAM,CAAC;AAEhE,QAAA,QAAQ,OAAO,SAAS,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC;AAC/C,MAAA,UAAU,OAAO,KAAK;AACzB,UAAM,IAAI,MACT,uDAAuD,OAAO,GAAG;AAAA,EAEnE;AAEO,SAAA;AACR;"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _module = require("node:module");
4
+ const requireResolve = (id, from) => {
5
+ let resolvedID = id;
6
+ if (process.versions.pnp && "findPnpApi" in _module && typeof _module.findPnpApi === "function") {
7
+ const pnpApi = _module.findPnpApi(from);
8
+ if (pnpApi) {
9
+ resolvedID = pnpApi.resolveRequest(id, from);
10
+ }
11
+ }
12
+ const require2 = _module.createRequire(from);
13
+ return require2.resolve(resolvedID);
14
+ };
15
+ exports.requireResolve = requireResolve;
16
+ //# sourceMappingURL=requireResolve.cjs.map