@slicemachine/adapter-next 0.3.85-alpha.jp-allow-slice-index-generation.6 → 0.3.85-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,30 +21,8 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
21
21
  <br />
22
22
  <strong>You can edit this slice directly in your code editor.</strong>
23
23
  {/**
24
- * 💡 Use Prismic MCP with your code editor
25
- *
26
- * Get AI-powered help to build your slice components — based on your actual model.
27
- *
28
- * ▶️ Setup:
29
- * 1. Add a new MCP Server in your code editor:
30
- *
31
- * {
32
- * "mcpServers": {
33
- * "Prismic MCP": {
34
- * "command": "npx",
35
- * "args": ["-y", "@prismicio/mcp-server@latest"]
36
- * }
37
- * }
38
- * }
39
- *
40
- * 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
41
- *
42
- * ✅ Then open your slice file and ask your code editor:
43
- * "Code this slice"
44
- *
45
- * Your code editor reads your slice model and helps you code faster ⚡
46
- * 🎙️ Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
47
- * 📚 Documentation: https://prismic.io/docs/ai#code-with-prismics-mcp-server
24
+ * 💡 Use the Prismic MCP server with your code editor
25
+ * 📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server
48
26
  */}`;
49
27
  if (data.componentContents) {
50
28
  contents = data.componentContents;
@@ -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 { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\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 extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\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 ${data.model.id} (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\t * 💡 Use Prismic MCP with your code editor\n\t\t *\n\t\t * Get AI-powered help to build your slice components — based on your actual model.\n\t\t *\n\t\t * ▶️ Setup:\n\t\t * 1. Add a new MCP Server in your code editor:\n\t\t *\n\t\t * {\n\t\t * \"mcpServers\": {\n\t\t * \"Prismic MCP\": {\n\t\t * \"command\": \"npx\",\n\t\t * \"args\": [\"-y\", \"@prismicio/mcp-server@latest\"]\n\t\t * }\n\t\t * }\n\t\t * }\n\t\t *\n\t\t * 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\t\t *\n\t\t * ✅ Then open your slice file and ask your code editor:\n\t\t * \"Code this slice\"\n\t\t *\n\t\t * Your code editor reads your slice model and helps you code faster ⚡\n\t\t * 🎙️ Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n\t\t * 📚 Documentation: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t */}`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\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":["getJSFileExtension","pascalCase","checkIsTypeScriptProject","stripIndent","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,YAAY,MAAMA,sCAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAC1E,QAAM,WAAW,SAAS,SAAS;AACnC,QAAM,aAAaC,WAAAA,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,cAAc;AAAA,8BACS,KAAK,MAAM,EAAE;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;AA8B1C,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAWC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,oBAMO,UA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J;;"}
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 { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\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 extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\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 ${data.model.id} (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\t * 💡 Use the Prismic MCP server with your code editor\n\t\t * 📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t */}`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\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":["getJSFileExtension","pascalCase","checkIsTypeScriptProject","stripIndent","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,YAAY,MAAMA,sCAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAC1E,QAAM,WAAW,SAAS,SAAS;AACnC,QAAM,aAAaC,WAAAA,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,cAAc;AAAA,8BACS,KAAK,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ1C,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,EACjB,WAAW,qBAAqB;AAC/B,eAAWC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,oBAMO,UAAU;AAAA;AAAA,iBAEb,UAAU,uCAAuC,UAAU;AAAA;AAAA;AAAA,uBAGrD,KAAK,MAAM,IAAI;AAAA;AAAA,WAE3B,UAAU,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAM/B,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKC,UAAU;AAAA;AAAA,EAE7B,OAAO;AACN,eAAWA,WAAAA;AAAAA;AAAAA,sDAEyC,UAAU,UAAU,UAAU;AAAA,iEACnB,UAAU,WAAW,UAAU;AAAA,kCAC9D,UAAU;AAAA;AAAA,WAEjC,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMb,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKC,UAAU;AAAA;AAAA,EAE7B;AAEA,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACHC,sCACC,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,EAAA,CACxC,CAAC;AAGHD,sCACC,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,EAAA,CACD,CAAC;AAEJ;;"}
@@ -19,30 +19,8 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
19
19
  <br />
20
20
  <strong>You can edit this slice directly in your code editor.</strong>
21
21
  {/**
22
- * 💡 Use Prismic MCP with your code editor
23
- *
24
- * Get AI-powered help to build your slice components — based on your actual model.
25
- *
26
- * ▶️ Setup:
27
- * 1. Add a new MCP Server in your code editor:
28
- *
29
- * {
30
- * "mcpServers": {
31
- * "Prismic MCP": {
32
- * "command": "npx",
33
- * "args": ["-y", "@prismicio/mcp-server@latest"]
34
- * }
35
- * }
36
- * }
37
- *
38
- * 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
39
- *
40
- * ✅ Then open your slice file and ask your code editor:
41
- * "Code this slice"
42
- *
43
- * Your code editor reads your slice model and helps you code faster ⚡
44
- * 🎙️ Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
45
- * 📚 Documentation: https://prismic.io/docs/ai#code-with-prismics-mcp-server
22
+ * 💡 Use the Prismic MCP server with your code editor
23
+ * 📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server
46
24
  */}`;
47
25
  if (data.componentContents) {
48
26
  contents = data.componentContents;
@@ -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 { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\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 extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\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 ${data.model.id} (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\t * 💡 Use Prismic MCP with your code editor\n\t\t *\n\t\t * Get AI-powered help to build your slice components — based on your actual model.\n\t\t *\n\t\t * ▶️ Setup:\n\t\t * 1. Add a new MCP Server in your code editor:\n\t\t *\n\t\t * {\n\t\t * \"mcpServers\": {\n\t\t * \"Prismic MCP\": {\n\t\t * \"command\": \"npx\",\n\t\t * \"args\": [\"-y\", \"@prismicio/mcp-server@latest\"]\n\t\t * }\n\t\t * }\n\t\t * }\n\t\t *\n\t\t * 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)\n\t\t *\n\t\t * ✅ Then open your slice file and ask your code editor:\n\t\t * \"Code this slice\"\n\t\t *\n\t\t * Your code editor reads your slice model and helps you code faster ⚡\n\t\t * 🎙️ Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505\n\t\t * 📚 Documentation: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t */}`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\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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KAAK;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEO,MAAM,cAA8C,OAC1D,MACA,YACG;AACH,oBACC,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,EAAA,CACxC,CAAC;AAGH,oBACC,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,EAAA,CACD,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 { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\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 extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\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 ${data.model.id} (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\t * 💡 Use the Prismic MCP server with your code editor\n\t\t * 📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server\n\t\t */}`;\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\t${placeholder}\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\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":";;;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,YAAY,MAAM,mBAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAC1E,QAAM,WAAW,SAAS,SAAS;AACnC,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAE7C,MAAI;AAEJ,QAAM,sBAAsB,MAAM,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4B;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,EAAA,CACD,CAAC;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-next",
3
- "version": "0.3.85-alpha.jp-allow-slice-index-generation.6",
3
+ "version": "0.3.85-beta.1",
4
4
  "description": "Slice Machine adapter for Next.js.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "@prismicio/simulator": "^0.1.4",
70
70
  "@prismicio/types-internal": "3.11.2",
71
- "@slicemachine/plugin-kit": "0.4.83-alpha.jp-allow-slice-index-generation.6",
71
+ "@slicemachine/plugin-kit": "0.4.83-beta.1",
72
72
  "common-tags": "^1.8.2",
73
73
  "fp-ts": "^2.13.1",
74
74
  "io-ts": "^2.2.20",
@@ -44,30 +44,8 @@ const createComponentFile = async ({
44
44
  <br />
45
45
  <strong>You can edit this slice directly in your code editor.</strong>
46
46
  {/**
47
- * 💡 Use Prismic MCP with your code editor
48
- *
49
- * Get AI-powered help to build your slice components — based on your actual model.
50
- *
51
- * ▶️ Setup:
52
- * 1. Add a new MCP Server in your code editor:
53
- *
54
- * {
55
- * "mcpServers": {
56
- * "Prismic MCP": {
57
- * "command": "npx",
58
- * "args": ["-y", "@prismicio/mcp-server@latest"]
59
- * }
60
- * }
61
- * }
62
- *
63
- * 2. Select a model optimized for coding (e.g. Claude 3.7 Sonnet or similar)
64
- *
65
- * ✅ Then open your slice file and ask your code editor:
66
- * "Code this slice"
67
- *
68
- * Your code editor reads your slice model and helps you code faster ⚡
69
- * 🎙️ Give your feedback: https://community.prismic.io/t/help-us-shape-the-future-of-slice-creation/19505
70
- * 📚 Documentation: https://prismic.io/docs/ai#code-with-prismics-mcp-server
47
+ * 💡 Use the Prismic MCP server with your code editor
48
+ * 📚 Docs: https://prismic.io/docs/ai#code-with-prismics-mcp-server
71
49
  */}`;
72
50
 
73
51
  if (data.componentContents) {