@slicemachine/adapter-sveltekit 0.3.77-beta.1 → 0.3.77-beta.2

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.
@@ -17,6 +17,35 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
17
17
  helpers,
18
18
  options
19
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 Claude 3.7 Sonnet (recommended for optimal output)
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: TODO
48
+ -->`;
20
49
  if (data.componentContents) {
21
50
  contents = data.componentContents;
22
51
  } else if (isTypeScriptProject) {
@@ -24,9 +53,9 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
24
53
  <script lang="ts">
25
54
  import type { Content } from '@prismicio/client';
26
55
 
27
- export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
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);
28
57
  } else {
29
- 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 Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
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);
30
59
  }
31
60
  await fs.writeSliceFile({
32
61
  libraryID: data.libraryID,
@@ -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\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\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\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\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\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,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AAC/B,eAAWC,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIuB,4NAAV,CAAA,IAAA,UAAA;AAAA,EAAA,OAOxB;AACK,eAAAA,WAAA,OAAA,OAAA,KAAM,kFAE4C,sPAAV,CAAA,IAAA,UAAA;AAAA,EAQpD;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\";\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 Claude 3.7 Sonnet (recommended for optimal output)\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: TODO\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;;"}
@@ -15,6 +15,35 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
15
15
  helpers,
16
16
  options
17
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 Claude 3.7 Sonnet (recommended for optimal output)
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: TODO
46
+ -->`;
18
47
  if (data.componentContents) {
19
48
  contents = data.componentContents;
20
49
  } else if (isTypeScriptProject) {
@@ -22,9 +51,9 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
22
51
  <script lang="ts">
23
52
  import type { Content } from '@prismicio/client';
24
53
 
25
- export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
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);
26
55
  } else {
27
- 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 Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
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);
28
57
  }
29
58
  await writeSliceFile({
30
59
  libraryID: data.libraryID,
@@ -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\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\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\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\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\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,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AAC/B,eAAW,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIuB,4NAAV,CAAA,IAAA,UAAA;AAAA,EAAA,OAOxB;AACK,eAAA,OAAA,OAAA,KAAM,kFAE4C,sPAAV,CAAA,IAAA,UAAA;AAAA,EAQpD;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\";\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 Claude 3.7 Sonnet (recommended for optimal output)\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: TODO\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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-sveltekit",
3
- "version": "0.3.77-beta.1",
3
+ "version": "0.3.77-beta.2",
4
4
  "description": "Slice Machine adapter for SvelteKit.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -64,7 +64,7 @@
64
64
  "dependencies": {
65
65
  "@prismicio/simulator": "^0.1.4",
66
66
  "@prismicio/types-internal": "3.8.0",
67
- "@slicemachine/plugin-kit": "0.4.76-beta.1",
67
+ "@slicemachine/plugin-kit": "0.4.76-beta.2",
68
68
  "common-tags": "^1.8.2",
69
69
  "fp-ts": "^2.13.1",
70
70
  "io-ts": "^2.2.20",
@@ -36,6 +36,36 @@ const createComponentFile = async ({
36
36
  options,
37
37
  });
38
38
 
39
+ const placeholder = `
40
+ Placeholder component for {slice.slice_type} (variation: {slice.variation}) slices.
41
+ <br />
42
+ <strong>You can edit this slice directly in your code editor.</strong>
43
+ <!--
44
+ 💡 Use Prismic MCP with your code editor
45
+
46
+ Get AI-powered help to build your slice components — based on your actual model.
47
+
48
+ ▶️ Setup:
49
+ 1. Add a new MCP Server in your code editor:
50
+
51
+ {
52
+ "mcpServers": {
53
+ "Prismic MCP": {
54
+ "command": "npx",
55
+ "args": ["-y", "@prismicio/mcp-server"]
56
+ }
57
+ }
58
+ }
59
+
60
+ 2. Select Claude 3.7 Sonnet (recommended for optimal output)
61
+
62
+ ✅ Then open your slice file and ask your code editor:
63
+ "Code this slice"
64
+
65
+ Your code editor reads your slice model and helps you code faster ⚡
66
+ 📚 Give your feedback: TODO
67
+ -->`;
68
+
39
69
  if (data.componentContents) {
40
70
  contents = data.componentContents;
41
71
  } else if (isTypeScriptProject) {
@@ -47,7 +77,7 @@ const createComponentFile = async ({
47
77
  </script>
48
78
 
49
79
  <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>
50
- Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices
80
+ ${placeholder}
51
81
  </section>
52
82
  `;
53
83
  } else {
@@ -58,7 +88,7 @@ const createComponentFile = async ({
58
88
  </script>
59
89
 
60
90
  <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>
61
- Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices
91
+ ${placeholder}
62
92
  </section>
63
93
  `;
64
94
  }