@slicemachine/adapter-next 0.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/lib/pascalCase.ts","../src/lib/buildSliceLibraryIndexFileContents.ts","../src/lib/getJSOrTSXFileExtension.ts","../src/hooks/slice-create.ts","../src/hooks/slice-update.ts","../src/hooks/slice-delete.ts","../src/lib/readJSONFile.ts","../src/hooks/slice-read.ts","../node_modules/@prismicio/types/dist/index.js","../src/hooks/slice-library-read.ts","../src/hooks/customType-create.ts","../src/hooks/customType-update.ts","../src/hooks/customType-delete.ts","../src/hooks/customType-read.ts","../src/hooks/customType-library-read.ts","../src/hooks/snippet-read.ts","../src/hooks/sliceSimulator-setup-read.ts","../src/plugin.ts","../src/SliceSimulator.tsx"],"sourcesContent":["import { pascalCase as basePascalCase } from \"pascal-case\";\n\n/**\n * Converts a string to a Pascal cased string.\n *\n * @param input - String to convert into a Pascal cased string.\n *\n * @returns Pascal cased string version of `input`.\n */\nexport const pascalCase = (...input: (string | undefined)[]): string => {\n\treturn basePascalCase(input.filter(Boolean).join(\" \"));\n};\n","import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { pascalCase } from \"./pascalCase\";\n\ntype BuildSliceLibraryIndexFileContentsArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const buildSliceLibraryIndexFileContents = async (\n\targs: BuildSliceLibraryIndexFileContentsArgs,\n): Promise<{ filePath: string; contents: string }> => {\n\tconst filePath = args.helpers.joinPathFromRoot(\n\t\targs.libraryID,\n\t\targs.options.typescript ? \"index.ts\" : \"index.js\",\n\t);\n\tconst sliceLibrary = await args.actions.readSliceLibrary({\n\t\tlibraryID: args.libraryID,\n\t});\n\n\tlet contents = stripIndent`\n\t\timport dynamic from 'next/dynamic'\n\n\t\texport const components = {\n\t\t\t${sliceLibrary.sliceIDs.map(\n\t\t\t\t(id) => `${id}: dynamic(() => import('./${pascalCase(id)}')),`,\n\t\t\t)}\n\t\t}\n\t`;\n\n\tif (args.options.format) {\n\t\tcontents = await args.helpers.format(contents, filePath);\n\t}\n\n\treturn { filePath, contents };\n};\n","import type { PluginOptions } from \"../types\";\n\nexport const getJSOrTSXFileExtension = (\n\tpluginOptions: PluginOptions,\n): string => {\n\tif (pluginOptions.typescript) {\n\t\treturn \"tsx\";\n\t} else if (pluginOptions.jsxExtension) {\n\t\treturn \"jsx\";\n\t} else {\n\t\treturn \"js\";\n\t}\n};\n","import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { generateTypes } from \"prismic-ts-codegen\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryIndexFileContents } from \"../lib/buildSliceLibraryIndexFileContents\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"model.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, `index.${getJSOrTSXFileExtension(options)}`);\n\tconst model = data.model;\n\tconst pascalID = pascalCase(model.id);\n\n\tlet contents: string;\n\n\tif (options.typescript) {\n\t\tcontents = stripIndent`\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\t\t\timport { ${pascalID}Slice } from \"./types\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalID}\\`.\n\t\t\t */\n\t\t\texport type ${pascalID}Props = SliceComponentProps<${pascalID}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalID} = ({ slice }: ${pascalID}Props): React.Element => {\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\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalID}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"./types\").${pascalID}Slice} ${pascalID}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalID}Slice>} ${pascalID}Props\n\t\t\t * @param {${pascalID}Props}\n\t\t\t */\n\t\t\tconst ${pascalID} = ({ 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\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalID};\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst createTypesFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"types.ts\");\n\n\tlet contents = generateTypes({\n\t\tsharedSliceModels: [data.model],\n\t});\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst upsertSliceLibraryIndexFile = async ({\n\tdata,\n\tactions,\n\thelpers,\n\tproject,\n\toptions,\n}: Omit<Args, \"dir\">) => {\n\tconst { filePath, contents } = await buildSliceLibraryIndexFileContents({\n\t\tlibraryID: data.libraryID,\n\t\tactions,\n\t\thelpers,\n\t\tproject,\n\t\toptions,\n\t});\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.id),\n\t);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait Promise.allSettled([\n\t\tcreateModelFile({ dir, data, ...context }),\n\t\tcreateComponentFile({ dir, data, ...context }),\n\t\tcreateTypesFile({ dir, data, ...context }),\n\t]);\n\n\tawait upsertSliceLibraryIndexFile({ data, ...context });\n};\n","import type {\n\tSliceMachineContext,\n\tSliceUpdateHook,\n\tSliceUpdateHookData,\n} from \"@slicemachine/plugin-kit\";\nimport { generateTypes } from \"prismic-ts-codegen\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceUpdateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst updateModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"model.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst updateTypesFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"types.ts\");\n\n\tlet contents = generateTypes({\n\t\tsharedSliceModels: [data.model],\n\t});\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const sliceUpdate: SliceUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.id),\n\t);\n\n\tawait Promise.allSettled([\n\t\tupdateModelFile({ dir, data, ...context }),\n\t\tupdateTypesFile({ dir, data, ...context }),\n\t]);\n};\n","import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceLibraryIndexFileContents } from \"../lib/buildSliceLibraryIndexFileContents\";\nimport { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.id),\n\t);\n\n\tawait fs.rm(dir, { recursive: true });\n};\n\nconst updateSliceLibraryIndexFile = async ({\n\tdata,\n\tactions,\n\thelpers,\n\tproject,\n\toptions,\n}: Args) => {\n\tconst { filePath, contents } = await buildSliceLibraryIndexFileContents({\n\t\tlibraryID: data.libraryID,\n\t\tactions,\n\t\thelpers,\n\t\tproject,\n\t\toptions,\n\t});\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const sliceDelete: SliceDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait deleteSliceDir({ data, ...context });\n\tawait updateSliceLibraryIndexFile({ data, ...context });\n};\n","import * as fs from \"node:fs/promises\";\n\nexport const readJSONFile = async <T = unknown>(path: string): Promise<T> => {\n\tconst contents = await fs.readFile(path, \"utf8\");\n\n\treturn JSON.parse(contents);\n};\n","import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\nimport { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\t\"model.json\",\n\t);\n\n\treturn await readJSONFile<prismicT.SharedSliceModel>(filePath);\n};\n","const RichTextNodeType = {\n heading1: \"heading1\",\n heading2: \"heading2\",\n heading3: \"heading3\",\n heading4: \"heading4\",\n heading5: \"heading5\",\n heading6: \"heading6\",\n paragraph: \"paragraph\",\n preformatted: \"preformatted\",\n strong: \"strong\",\n em: \"em\",\n listItem: \"list-item\",\n oListItem: \"o-list-item\",\n list: \"group-list-item\",\n oList: \"group-o-list-item\",\n image: \"image\",\n embed: \"embed\",\n hyperlink: \"hyperlink\",\n label: \"label\",\n span: \"span\"\n};\nconst LinkType = {\n Any: \"Any\",\n Document: \"Document\",\n Media: \"Media\",\n Web: \"Web\"\n};\nconst OEmbedType = {\n Photo: \"photo\",\n Video: \"video\",\n Link: \"link\",\n Rich: \"rich\"\n};\n\nconst CustomTypeModelFieldType = {\n Boolean: \"Boolean\",\n Color: \"Color\",\n Date: \"Date\",\n Embed: \"Embed\",\n GeoPoint: \"GeoPoint\",\n Group: \"Group\",\n Image: \"Image\",\n IntegrationFields: \"IntegrationFields\",\n Link: \"Link\",\n Number: \"Number\",\n Select: \"Select\",\n Slices: \"Slices\",\n StructuredText: \"StructuredText\",\n Text: \"Text\",\n Timestamp: \"Timestamp\",\n UID: \"UID\",\n Range: \"Range\",\n Separator: \"Separator\",\n LegacySlices: \"Choice\"\n};\nconst CustomTypeModelLinkSelectType = {\n Document: \"document\",\n Media: \"media\",\n Web: \"web\"\n};\nconst CustomTypeModelSliceDisplay = {\n List: \"list\",\n Grid: \"grid\"\n};\nconst CustomTypeModelSliceType = {\n Slice: \"Slice\",\n SharedSlice: \"SharedSlice\"\n};\n\nconst WebhookType = {\n APIUpdate: \"api-update\",\n TestTrigger: \"test-trigger\"\n};\n\nconst EmbedType = OEmbedType;\n\nexport { CustomTypeModelFieldType, CustomTypeModelLinkSelectType, CustomTypeModelSliceDisplay, CustomTypeModelSliceType, EmbedType, LinkType, OEmbedType, RichTextNodeType, WebhookType };\n//# sourceMappingURL=index.js.map\n","import type { SliceLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isSharedSliceModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is prismicT.SharedSliceModel => {\n\treturn (\n\t\ttypeof input === \"object\" &&\n\t\tinput !== null &&\n\t\t\"type\" in input &&\n\t\tinput.type === prismicT.CustomTypeModelSliceType.SharedSlice\n\t);\n};\n\nexport const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dirPath = helpers.joinPathFromRoot(data.libraryID);\n\n\tconst childDirs = await fs.readdir(dirPath);\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tconst modelPath = path.join(dirPath, childDir, \"model.json\");\n\n\t\t\ttry {\n\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tid: data.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n","import type {\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { generateTypes } from \"prismic-ts-codegen\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: CustomTypeCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst createTypesFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"types.ts\");\n\n\t// TODO: Figure out how to import Shared Slice types\n\tlet contents = generateTypes({\n\t\tcustomTypeModels: [data.model],\n\t});\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = context.helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait Promise.allSettled([\n\t\tcreateModelFile({ dir, data, ...context }),\n\t\tcreateTypesFile({ dir, data, ...context }),\n\t]);\n};\n","import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeUpdate = customTypeCreate;\n","import type { CustomTypeDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dir = helpers.joinPathFromRoot(\"customtypes\", data.model.id);\n\n\tawait fs.rm(dir, { recursive: true });\n};\n","import type { CustomTypeReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeRead: CustomTypeReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = helpers.joinPathFromRoot(\n\t\t\"customtypes\",\n\t\tdata.id,\n\t\t\"index.json\",\n\t);\n\n\treturn await readJSONFile<prismicT.CustomTypeModel>(filePath);\n};\n","import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is prismicT.CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dirPath = helpers.joinPathFromRoot(\"customtypes\");\n\n\tconst childDirs = await fs.readdir(dirPath);\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tconst modelPath = path.join(dirPath, childDir, \"index.json\");\n\n\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\tids.push(modelContents.id);\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n","import type { SnippetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\nimport { stripIndent } from \"common-tags\";\nimport type { Config as PrettierConfig } from \"prettier\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst prettierOptions: PrettierConfig = { parser: \"typescript\" };\n\nconst dotPath = (segments: string[]): string => {\n\treturn segments.join(\".\");\n};\n\nexport const snippetRead: SnippetReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst { fieldPath } = data;\n\n\tconst label = \"React\";\n\n\tswitch (data.model.type) {\n\t\tcase prismicT.CustomTypeModelFieldType.Link: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"tsx\",\n\t\t\t\tcode: await helpers.format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<PrismicLink field={${dotPath(fieldPath)}}>Link</PrismicLink>\n\t\t\t\t\t`,\n\t\t\t\t\tundefined,\n\t\t\t\t\t{ prettier: prettierOptions },\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\n\t\tcase prismicT.CustomTypeModelFieldType.Image: {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tlabel: `${label} (next/image)`,\n\t\t\t\t\tlanguage: \"tsx\",\n\t\t\t\t\tcode: await helpers.format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicNextImage field={${dotPath(fieldPath)}} />\n\t\t\t\t\t\t`,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{ prettier: prettierOptions },\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel,\n\t\t\t\t\tlanguage: \"tsx\",\n\t\t\t\t\tcode: await helpers.format(\n\t\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t\t<PrismicImage field={${dotPath(fieldPath)}} />\n\t\t\t\t\t\t`,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{ prettier: prettierOptions },\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tcase prismicT.CustomTypeModelFieldType.Group: {\n\t\t\tconst code = await helpers.format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<>{${dotPath(fieldPath)}.map(item => (\n\t\t\t\t\t <>{/* Render content for item */}</>\n\t\t\t\t\t))}</>\n\t\t\t\t`,\n\t\t\t\tundefined,\n\t\t\t\t{ prettier: prettierOptions },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"tsx\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tcase prismicT.CustomTypeModelFieldType.Slices: {\n\t\t\tconst code = await helpers.format(\n\t\t\t\tstripIndent`\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t slices={${dotPath(fieldPath)}}\n\t\t\t\t\t components={components}\n\t\t\t\t\t/>\n\t\t\t\t`,\n\t\t\t\tundefined,\n\t\t\t\t{ prettier: prettierOptions },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"tsx\",\n\t\t\t\tcode,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\tlanguage: \"tsx\",\n\t\t\t\tcode: await helpers.format(\n\t\t\t\t\tstripIndent`\n\t\t\t\t\t\t<>{${dotPath(fieldPath)}}</>\n\t\t\t\t\t`,\n\t\t\t\t\tundefined,\n\t\t\t\t\t{ prettier: prettierOptions },\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n};\n","import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { SliceSimulatorSetupStepValidationMessageType } from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport * as http from \"node:http\";\n\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\n\t\"@prismicio/react\",\n\t\"@prismicio/slice-simulator-react\",\n\t\"@prismicio/client@latest\",\n\t\"@prismicio/helpers\",\n];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tbody: stripIndent`\n\t\t\tThe simulator requires extra dependencies. Run the following command to install them.\n\n\t\t\t~~~sh\n\t\t\tnpm install --save @prismicio/react @prismicio/slice-simulator-react @prismicio/client@latest @prismicio/helpers\n\t\t\t~~~\n\t\t`,\n\t\tvalidate: async () => {\n\t\t\tconst missingDependencies: string[] = [];\n\n\t\t\tfor (const dependency of REQUIRED_DEPENDENCIES) {\n\t\t\t\ttry {\n\t\t\t\t\t// `require.resolve()` is preferred\n\t\t\t\t\t// over `import()` because we don't\n\t\t\t\t\t// want to load the module. Loading a\n\t\t\t\t\t// module could introduce side-effects.\n\t\t\t\t\trequire.resolve(dependency);\n\t\t\t\t} catch {\n\t\t\t\t\tmissingDependencies.push(dependency);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingDependencies.length >= REQUIRED_DEPENDENCIES.length) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: SliceSimulatorSetupStepValidationMessageType.Error,\n\t\t\t\t\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: stripIndent`\n\t\t\t\t\t\tInstall the required dependencies to continue.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (missingDependencies.length > 0) {\n\t\t\t\tconst formattedMissingDependencies = missingDependencies\n\t\t\t\t\t.map((missingDependency) => `\\`${missingDependency}\\``)\n\t\t\t\t\t.join(\", \");\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: SliceSimulatorSetupStepValidationMessageType.Warning,\n\t\t\t\t\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: stripIndent`\n\t\t\t\t\t\tThe following dependencies are missing: ${formattedMissingDependencies}\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n};\n\nconst createStep2 = async ({\n\thelpers,\n\toptions,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst fileName = `slice-simulator.${getJSOrTSXFileExtension}`;\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tlet fileContents: string;\n\n\tif (options.typescript) {\n\t\tfileContents = stripIndent`\n\t\t\timport { GetStaticProps } from \"next/types\";\n\t\t\timport { SliceSimulator } from \"@prismicio/slice-simulator-react\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport state from \"../.slicemachine/libraries-state.json\";\n\t\t\timport { components } from \"../slices\";\n\n\t\t\tconst SliceSimulatorPage = () => {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t\tstate={state}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default SliceSimulatorPage;\n\n\t\t\texport const getStaticProps: GetStaticProps = () => {\n\t\t\t\treturn {\n\t\t\t\t\t// Exclude this page from production builds.\n\t\t\t\t\tnotFound: process.env.NODE_ENV === \"production\",\n\t\t\t\t};\n\t\t\t};\n\t\t`;\n\t} else {\n\t\tfileContents = stripIndent`\n\t\t\timport { SliceSimulator } from \"@prismicio/slice-simulator-react\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport state from \"../.slicemachine/libraries-state.json\";\n\t\t\timport { components } from \"../slices\";\n\n\t\t\tconst SliceSimulatorPage = () => {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t\tstate={state}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default SliceSimulatorPage;\n\n\t\t\texport const getStaticProps= () => {\n\t\t\t\treturn {\n\t\t\t\t\t// Exclude this page from production builds.\n\t\t\t\t\tnotFound: process.env.NODE_ENV === \"production\",\n\t\t\t\t};\n\t\t\t};\n\t\t`;\n\t}\n\n\tfileContents = await helpers.format(fileContents, filePath);\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tbody: stripIndent`\n\t\t\tIn your \\`pages\\` directory, create a file called \\`${fileName}\\` and add the following code. This route will be used to simulate and develop your components.\n\n\t\t\t~~~tsx\n\t\t\t${fileContents}\n\t\t\t~~~\n\t\t`,\n\t};\n};\n\nconst createStep3 = async ({\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst filePath = helpers.joinPathFromRoot(\"sm.json\");\n\tconst fileContents = await helpers.format(\n\t\t`\n\t\t\t{\n\t\t\t\t\"localSliceSimulatorURL\": \"http://localhost:3000/slice-simulator\"\n\t\t\t}\n\t\t`,\n\t\tfilePath,\n\t);\n\n\treturn {\n\t\ttitle: \"Update `sm.json`\",\n\t\tbody: stripIndent`\n\t\t\tUpdate your \\`sm.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`slice-simulator\\` page.\n\n\t\t\t~~~json\n\t\t\t${fileContents}\n\t\t\t~~~\n\t\t`,\n\t\tvalidate: async () => {\n\t\t\tconst project = await helpers.getProject();\n\n\t\t\tif (!(\"localSliceSimulatorURL\" in project.config)) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: SliceSimulatorSetupStepValidationMessageType.Error,\n\t\t\t\t\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: stripIndent`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`sm.json\\` file.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Test if the URL is valid.\n\t\t\ttry {\n\t\t\t\tif (project.config.localSliceSimulatorURL) {\n\t\t\t\t\tnew URL(project.config.localSliceSimulatorURL);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Undefined Slice Simulator URL\");\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn {\n\t\t\t\t\ttype: SliceSimulatorSetupStepValidationMessageType.Warning,\n\t\t\t\t\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: stripIndent`\n\t\t\t\t\t\tThe \\`localSliceSimulatorURL\\` property should be of the shape \\`http://localhost:PORT/PATH\\`. See the codeblock for an example.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check if the URL is accessible.\n\t\t\tconst ok = await new Promise<boolean>((resolve) => {\n\t\t\t\tif (project.config.localSliceSimulatorURL) {\n\t\t\t\t\thttp.get(project.config.localSliceSimulatorURL, (res) => {\n\t\t\t\t\t\tif (res.statusCode) {\n\t\t\t\t\t\t\tresolve(res.statusCode >= 200 && res.statusCode < 300);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tresolve(false);\n\t\t\t});\n\n\t\t\tif (!ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: SliceSimulatorSetupStepValidationMessageType.Warning,\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: stripIndent`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`sm.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/technologies/setup-slice-simulator-nextjs) for more details.\n\t\t\t\t\t`,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n};\n\nexport const sliceSimulatorSetupRead: SliceSimulatorSetupReadHook<\n\tPluginOptions\n> = async (_data, context) => {\n\treturn Promise.all([\n\t\tcreateStep1(context),\n\t\tcreateStep2(context),\n\t\tcreateStep3(context),\n\t]);\n};\n","import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceLibraryRead } from \"./hooks/slice-library-read\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeLibraryRead } from \"./hooks/customType-library-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n","import * as React from \"react\";\nimport {\n\tCoreManager,\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSliceSimulatorState,\n\tStateManagerEventType,\n\tStateManagerStatus,\n\tdisableEventHandler,\n\tgetDefaultManagedState,\n\tgetDefaultMessage,\n\tgetDefaultProps,\n\tgetDefaultSlices,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/slice-simulator-core\";\n\nconst coreManager = new CoreManager();\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"];\n};\n\nexport type SliceSimulatorProps = {\n\t/**\n\t * React component to render simulated Slices.\n\t *\n\t * @example\n\t *\n\t * ```tsx\n\t * import { SliceSimulator } from \"@slicemachine/adapter-next\";\n\t * import { SliceZone } from \"@prismicio/react\";\n\t *\n\t * import { components } from \"../slices\";\n\t * import state from \"../.slicemachine/libraries-state.json\";\n\t *\n\t * <SliceSimulator\n\t * \tsliceZone={({ slices }) => (\n\t * \t\t<SliceZone slices={slices} components={components} />\n\t * \t)}\n\t * \tstate={state}\n\t * />;\n\t * ```\n\t */\n\tsliceZone: (props: SliceSimulatorSliceZoneProps) => JSX.Element;\n\tclassName?: string;\n} & BaseSliceSimulatorProps;\n\nexport const SliceSimulator = ({\n\tsliceZone: SliceZoneComp,\n\tstate,\n\tbackground,\n\tzIndex,\n\tclassName,\n}: SliceSimulatorProps): JSX.Element => {\n\tconst defaultProps = getDefaultProps();\n\n\tconst [managedState, setManagedState] = React.useState(() =>\n\t\tgetDefaultManagedState(),\n\t);\n\tconst [slices, setSlices] = React.useState(() => getDefaultSlices());\n\tconst [message, setMessage] = React.useState(() => getDefaultMessage());\n\n\tReact.useEffect(() => {\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.ManagedState,\n\t\t\t(_managedState) => {\n\t\t\t\tsetManagedState(_managedState);\n\t\t\t},\n\t\t\t\"simulator-managed-state\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tcoreManager.stateManager.on(\n\t\t\tStateManagerEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message);\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tcoreManager.init(state);\n\n\t\treturn () => {\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.ManagedState,\n\t\t\t\t\"simulator-managed-state\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Slices,\n\t\t\t\t\"simulator-slices\",\n\t\t\t);\n\n\t\t\tcoreManager.stateManager.off(\n\t\t\t\tStateManagerEventType.Message,\n\t\t\t\t\"simulator-message\",\n\t\t\t);\n\t\t};\n\t}, []);\n\n\t// Update state on HMR\n\tconst didMount = React.useRef(false);\n\tReact.useEffect(() => {\n\t\tif (didMount.current) {\n\t\t\tcoreManager.stateManager.reload(state);\n\t\t} else {\n\t\t\tdidMount.current = true;\n\t\t}\n\t}, [state]);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: zIndex ?? undefined,\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: background ?? undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : slices.length ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\tmanagedState.status !== StateManagerStatus.Loaded\n\t\t\t\t\t\t\t? { display: \"none\" }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<SliceZoneComp slices={slices} />\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"names":["basePascalCase","createModelFile","createTypesFile","prismicT.CustomTypeModelSliceType","prismicT.CustomTypeModelFieldType","pkgName"],"mappings":";;;;;;;;;;;;;AASa,MAAA,UAAA,GAAa,IAAI,KAA0C,KAAA;AACvE,EAAA,OAAOA,YAAe,CAA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AAS,IAAK,CAAA,GAAA,CAAA;AAAA,IAC5D,KAAO,EAAA;AAAA,MACN,QACC,OAAO,MAAA,KAAW,WACf,GAAA,YAAA,CAAa,SACb,MAAU,IAAA,IAAA,GAAA,MAAA,GAAA,KAAA,CAAA;AAAA,MACd,QAAU,EAAA,OAAA;AAAA,MACV,GAAK,EAAA,CAAA;AAAA,MACL,IAAM,EAAA,CAAA;AAAA,MACN,KAAO,EAAA,MAAA;AAAA,MACP,MAAQ,EAAA,OAAA;AAAA,MACR,QAAU,EAAA,MAAA;AAAA,MACV,YACC,OAAO,UAAA,KAAe,WACnB,GAAA,YAAA,CAAa,aACb,UAAc,IAAA,IAAA,GAAA,UAAA,GAAA,KAAA,CAAA;AAAA,KAAA;AAAA,GAGlB,EAAA,OAAA,uCACC,SAAD,EAAA;AAAA,IAAS,uBAAA,EAAyB,EAAE,MAAQ,EAAA,OAAA,EAAA;AAAA,GACzC,CAAA,GAAA,MAAA,CAAO,MACV,mBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IACC,EAAG,EAAA,MAAA;AAAA,IACH,SAAW,EAAA,kBAAA;AAAA,IACX,OACC,YAAa,CAAA,MAAA,KAAW,mBAAmB,MACxC,GAAA,EAAE,SAAS,MACX,EAAA,GAAA,KAAA,CAAA;AAAA,IAEJ,cAAgB,EAAA,cAAA;AAAA,IAChB,eACC,EAAA,mBAAA;AAAA,GAAA,sCAGA,aAAD,EAAA;AAAA,IAAe,MAAA;AAAA,GAEb,CAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAAA;;;;"}
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@slicemachine/adapter-next",
3
+ "version": "0.0.1",
4
+ "description": "Slice Machine adapter for Next.js.",
5
+ "keywords": [
6
+ "typescript",
7
+ "prismic"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "ssh://git@github.com/prismicio/slicemachine-adapter-next.git"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "author": "Prismic <contact@prismic.io> (https://prismic.io)",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "require": "./dist/index.cjs",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "main": "dist/index.cjs",
24
+ "module": "dist/index.js",
25
+ "types": "dist/index.d.ts",
26
+ "files": [
27
+ "dist",
28
+ "src"
29
+ ],
30
+ "scripts": {
31
+ "build": "siroc build",
32
+ "dev": "siroc build --watch",
33
+ "format": "prettier --write .",
34
+ "lint": "eslint --ext .js,.ts .",
35
+ "prepare": "npm run build",
36
+ "release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
37
+ "release:alpha": "npm run test && standard-version --release-as major --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
38
+ "release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run",
39
+ "release:dry": "standard-version --dry-run",
40
+ "size": "size-limit",
41
+ "test": "npm run lint && npm run unit && npm run build && npm run size",
42
+ "unit": "vitest run --coverage",
43
+ "unit:watch": "vitest watch"
44
+ },
45
+ "dependencies": {
46
+ "@prismicio/slice-simulator-core": "^0.2.2",
47
+ "@slicemachine/plugin-kit": "^0.0.2",
48
+ "common-tags": "^1.8.2",
49
+ "pascal-case": "^3.1.2",
50
+ "prismic-ts-codegen": "^0.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "@prismicio/mock": "^0.1.0",
54
+ "@prismicio/types": "^0.2.0",
55
+ "@size-limit/preset-small-lib": "^7.0.8",
56
+ "@types/common-tags": "^1.8.1",
57
+ "@types/react": "^18.0.15",
58
+ "@types/semver": "^7.3.10",
59
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
60
+ "@typescript-eslint/parser": "^5.30.5",
61
+ "c8": "^7.11.3",
62
+ "eslint": "^8.19.0",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-plugin-prettier": "^4.2.1",
65
+ "eslint-plugin-tsdoc": "^0.2.16",
66
+ "npm-run-all": "^4.1.5",
67
+ "prettier": "^2.7.1",
68
+ "prettier-plugin-jsdoc": "^0.3.38",
69
+ "react": "^18.2.0",
70
+ "siroc": "^0.16.0",
71
+ "size-limit": "^7.0.8",
72
+ "standard-version": "^9.5.0",
73
+ "ts-morph": "^15.1.0",
74
+ "typescript": "^4.7.4",
75
+ "vitest": "^0.18.0"
76
+ },
77
+ "peerDependencies": {
78
+ "next": "^11 || ^12",
79
+ "react": "^17 || ^18"
80
+ },
81
+ "engines": {
82
+ "node": ">=14.15.0"
83
+ },
84
+ "publishConfig": {
85
+ "access": "public"
86
+ }
87
+ }
@@ -0,0 +1,158 @@
1
+ import * as React from "react";
2
+ import {
3
+ CoreManager,
4
+ SliceSimulatorProps as BaseSliceSimulatorProps,
5
+ SliceSimulatorState,
6
+ StateManagerEventType,
7
+ StateManagerStatus,
8
+ disableEventHandler,
9
+ getDefaultManagedState,
10
+ getDefaultMessage,
11
+ getDefaultProps,
12
+ getDefaultSlices,
13
+ onClickHandler,
14
+ simulatorClass,
15
+ simulatorRootClass,
16
+ } from "@prismicio/slice-simulator-core";
17
+
18
+ const coreManager = new CoreManager();
19
+
20
+ export type SliceSimulatorSliceZoneProps = {
21
+ slices: SliceSimulatorState["slices"];
22
+ };
23
+
24
+ export type SliceSimulatorProps = {
25
+ /**
26
+ * React component to render simulated Slices.
27
+ *
28
+ * @example
29
+ *
30
+ * ```tsx
31
+ * import { SliceSimulator } from "@slicemachine/adapter-next";
32
+ * import { SliceZone } from "@prismicio/react";
33
+ *
34
+ * import { components } from "../slices";
35
+ * import state from "../.slicemachine/libraries-state.json";
36
+ *
37
+ * <SliceSimulator
38
+ * sliceZone={({ slices }) => (
39
+ * <SliceZone slices={slices} components={components} />
40
+ * )}
41
+ * state={state}
42
+ * />;
43
+ * ```
44
+ */
45
+ sliceZone: (props: SliceSimulatorSliceZoneProps) => JSX.Element;
46
+ className?: string;
47
+ } & BaseSliceSimulatorProps;
48
+
49
+ export const SliceSimulator = ({
50
+ sliceZone: SliceZoneComp,
51
+ state,
52
+ background,
53
+ zIndex,
54
+ className,
55
+ }: SliceSimulatorProps): JSX.Element => {
56
+ const defaultProps = getDefaultProps();
57
+
58
+ const [managedState, setManagedState] = React.useState(() =>
59
+ getDefaultManagedState(),
60
+ );
61
+ const [slices, setSlices] = React.useState(() => getDefaultSlices());
62
+ const [message, setMessage] = React.useState(() => getDefaultMessage());
63
+
64
+ React.useEffect(() => {
65
+ coreManager.stateManager.on(
66
+ StateManagerEventType.ManagedState,
67
+ (_managedState) => {
68
+ setManagedState(_managedState);
69
+ },
70
+ "simulator-managed-state",
71
+ );
72
+ coreManager.stateManager.on(
73
+ StateManagerEventType.Slices,
74
+ (_slices) => {
75
+ setSlices(_slices);
76
+ },
77
+ "simulator-slices",
78
+ );
79
+ coreManager.stateManager.on(
80
+ StateManagerEventType.Message,
81
+ (_message) => {
82
+ setMessage(_message);
83
+ },
84
+ "simulator-message",
85
+ );
86
+
87
+ coreManager.init(state);
88
+
89
+ return () => {
90
+ coreManager.stateManager.off(
91
+ StateManagerEventType.ManagedState,
92
+ "simulator-managed-state",
93
+ );
94
+
95
+ coreManager.stateManager.off(
96
+ StateManagerEventType.Slices,
97
+ "simulator-slices",
98
+ );
99
+
100
+ coreManager.stateManager.off(
101
+ StateManagerEventType.Message,
102
+ "simulator-message",
103
+ );
104
+ };
105
+ }, []);
106
+
107
+ // Update state on HMR
108
+ const didMount = React.useRef(false);
109
+ React.useEffect(() => {
110
+ if (didMount.current) {
111
+ coreManager.stateManager.reload(state);
112
+ } else {
113
+ didMount.current = true;
114
+ }
115
+ }, [state]);
116
+
117
+ return (
118
+ <div
119
+ className={[simulatorClass, className].filter(Boolean).join(" ")}
120
+ style={{
121
+ zIndex:
122
+ typeof zIndex === "undefined"
123
+ ? defaultProps.zIndex
124
+ : zIndex ?? undefined,
125
+ position: "fixed",
126
+ top: 0,
127
+ left: 0,
128
+ width: "100%",
129
+ height: "100vh",
130
+ overflow: "auto",
131
+ background:
132
+ typeof background === "undefined"
133
+ ? defaultProps.background
134
+ : background ?? undefined,
135
+ }}
136
+ >
137
+ {message ? (
138
+ <article dangerouslySetInnerHTML={{ __html: message }} />
139
+ ) : slices.length ? (
140
+ <div
141
+ id="root"
142
+ className={simulatorRootClass}
143
+ style={
144
+ managedState.status !== StateManagerStatus.Loaded
145
+ ? { display: "none" }
146
+ : undefined
147
+ }
148
+ onClickCapture={onClickHandler as unknown as React.MouseEventHandler}
149
+ onSubmitCapture={
150
+ disableEventHandler as unknown as React.FormEventHandler
151
+ }
152
+ >
153
+ <SliceZoneComp slices={slices} />
154
+ </div>
155
+ ) : null}
156
+ </div>
157
+ );
158
+ };
@@ -0,0 +1,56 @@
1
+ import type {
2
+ CustomTypeCreateHook,
3
+ CustomTypeCreateHookData,
4
+ SliceMachineContext,
5
+ } from "@slicemachine/plugin-kit";
6
+ import { generateTypes } from "prismic-ts-codegen";
7
+ import * as fs from "node:fs/promises";
8
+ import * as path from "node:path";
9
+
10
+ import type { PluginOptions } from "../types";
11
+
12
+ type Args = {
13
+ dir: string;
14
+ data: CustomTypeCreateHookData;
15
+ } & SliceMachineContext<PluginOptions>;
16
+
17
+ const createModelFile = async ({ dir, data, helpers, options }: Args) => {
18
+ const filePath = path.join(dir, "index.json");
19
+
20
+ let contents = JSON.stringify(data.model);
21
+
22
+ if (options.format) {
23
+ contents = await helpers.format(contents, filePath);
24
+ }
25
+
26
+ await fs.writeFile(filePath, contents);
27
+ };
28
+
29
+ const createTypesFile = async ({ dir, data, helpers, options }: Args) => {
30
+ const filePath = path.join(dir, "types.ts");
31
+
32
+ // TODO: Figure out how to import Shared Slice types
33
+ let contents = generateTypes({
34
+ customTypeModels: [data.model],
35
+ });
36
+
37
+ if (options.format) {
38
+ contents = await helpers.format(contents, filePath);
39
+ }
40
+
41
+ await fs.writeFile(filePath, contents);
42
+ };
43
+
44
+ export const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (
45
+ data,
46
+ context,
47
+ ) => {
48
+ const dir = context.helpers.joinPathFromRoot("customtypes", data.model.id);
49
+
50
+ await fs.mkdir(dir, { recursive: true });
51
+
52
+ await Promise.allSettled([
53
+ createModelFile({ dir, data, ...context }),
54
+ createTypesFile({ dir, data, ...context }),
55
+ ]);
56
+ };
@@ -0,0 +1,13 @@
1
+ import type { CustomTypeDeleteHook } from "@slicemachine/plugin-kit";
2
+ import * as fs from "node:fs/promises";
3
+
4
+ import type { PluginOptions } from "../types";
5
+
6
+ export const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (
7
+ data,
8
+ { helpers },
9
+ ) => {
10
+ const dir = helpers.joinPathFromRoot("customtypes", data.model.id);
11
+
12
+ await fs.rm(dir, { recursive: true });
13
+ };
@@ -0,0 +1,40 @@
1
+ import type { CustomTypeLibraryReadHook } from "@slicemachine/plugin-kit";
2
+ import * as prismicT from "@prismicio/types";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+
6
+ import { readJSONFile } from "../lib/readJSONFile";
7
+
8
+ import type { PluginOptions } from "../types";
9
+
10
+ const isCustomTypeModel = (
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ input: any,
13
+ ): input is prismicT.CustomTypeModel => {
14
+ return typeof input === "object" && input !== null && "json" in input;
15
+ };
16
+
17
+ export const customTypeLibraryRead: CustomTypeLibraryReadHook<
18
+ PluginOptions
19
+ > = async (_data, { helpers }) => {
20
+ const dirPath = helpers.joinPathFromRoot("customtypes");
21
+
22
+ const childDirs = await fs.readdir(dirPath);
23
+
24
+ const ids: string[] = [];
25
+ await Promise.all(
26
+ childDirs.map(async (childDir) => {
27
+ const modelPath = path.join(dirPath, childDir, "index.json");
28
+
29
+ const modelContents = await readJSONFile(modelPath);
30
+
31
+ if (isCustomTypeModel(modelContents)) {
32
+ ids.push(modelContents.id);
33
+ }
34
+ }),
35
+ );
36
+
37
+ return {
38
+ ids: ids.sort(),
39
+ };
40
+ };
@@ -0,0 +1,19 @@
1
+ import type { CustomTypeReadHook } from "@slicemachine/plugin-kit";
2
+ import * as prismicT from "@prismicio/types";
3
+
4
+ import { readJSONFile } from "../lib/readJSONFile";
5
+
6
+ import type { PluginOptions } from "../types";
7
+
8
+ export const customTypeRead: CustomTypeReadHook<PluginOptions> = async (
9
+ data,
10
+ { helpers },
11
+ ) => {
12
+ const filePath = helpers.joinPathFromRoot(
13
+ "customtypes",
14
+ data.id,
15
+ "index.json",
16
+ );
17
+
18
+ return await readJSONFile<prismicT.CustomTypeModel>(filePath);
19
+ };
@@ -0,0 +1,3 @@
1
+ import { customTypeCreate } from "./customType-create";
2
+
3
+ export const customTypeUpdate = customTypeCreate;
@@ -0,0 +1,146 @@
1
+ import type {
2
+ SliceCreateHook,
3
+ SliceCreateHookData,
4
+ SliceMachineContext,
5
+ } from "@slicemachine/plugin-kit";
6
+ import { generateTypes } from "prismic-ts-codegen";
7
+ import { stripIndent } from "common-tags";
8
+ import * as fs from "node:fs/promises";
9
+ import * as path from "node:path";
10
+
11
+ import { buildSliceLibraryIndexFileContents } from "../lib/buildSliceLibraryIndexFileContents";
12
+ import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension";
13
+ import { pascalCase } from "../lib/pascalCase";
14
+
15
+ import type { PluginOptions } from "../types";
16
+
17
+ type Args = {
18
+ dir: string;
19
+ data: SliceCreateHookData;
20
+ } & SliceMachineContext<PluginOptions>;
21
+
22
+ const createModelFile = async ({ dir, data, helpers, options }: Args) => {
23
+ const filePath = path.join(dir, "model.json");
24
+
25
+ let contents = JSON.stringify(data.model);
26
+
27
+ if (options.format) {
28
+ contents = await helpers.format(contents, filePath);
29
+ }
30
+
31
+ await fs.writeFile(filePath, contents);
32
+ };
33
+
34
+ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
35
+ const filePath = path.join(dir, `index.${getJSOrTSXFileExtension(options)}`);
36
+ const model = data.model;
37
+ const pascalID = pascalCase(model.id);
38
+
39
+ let contents: string;
40
+
41
+ if (options.typescript) {
42
+ contents = stripIndent`
43
+ import { SliceComponentProps } from "@prismicio/react";
44
+ import { ${pascalID}Slice } from "./types";
45
+
46
+ /**
47
+ * Props for \`${pascalID}\`.
48
+ */
49
+ export type ${pascalID}Props = SliceComponentProps<${pascalID}Slice>;
50
+
51
+ /**
52
+ * Component for "${model.name}" Slices.
53
+ */
54
+ const ${pascalID} = ({ slice }: ${pascalID}Props): React.Element => {
55
+ return (
56
+ <section
57
+ data-slice-type={slice.slice_type}
58
+ data-slice-variation={slice.variation}
59
+ >
60
+ Placeholder component for ${model.id} (variation: {slice.variation}) Slices
61
+ </section>
62
+ );
63
+ };
64
+
65
+ export default ${pascalID}
66
+ `;
67
+ } else {
68
+ contents = stripIndent`
69
+ /**
70
+ * @typedef {import("./types").${pascalID}Slice} ${pascalID}Slice
71
+ * @typedef {import("@prismicio/react").SliceComponentProps<${pascalID}Slice>} ${pascalID}Props
72
+ * @param {${pascalID}Props}
73
+ */
74
+ const ${pascalID} = ({ slice }) => {
75
+ return (
76
+ <section
77
+ data-slice-type={slice.slice_type}
78
+ data-slice-variation={slice.variation}
79
+ >
80
+ Placeholder component for ${model.id} (variation: {slice.variation}) Slices
81
+ </section>
82
+ );
83
+ };
84
+
85
+ export default ${pascalID};
86
+ `;
87
+ }
88
+
89
+ if (options.format) {
90
+ contents = await helpers.format(contents, filePath);
91
+ }
92
+
93
+ await fs.writeFile(filePath, contents);
94
+ };
95
+
96
+ const createTypesFile = async ({ dir, data, helpers, options }: Args) => {
97
+ const filePath = path.join(dir, "types.ts");
98
+
99
+ let contents = generateTypes({
100
+ sharedSliceModels: [data.model],
101
+ });
102
+
103
+ if (options.format) {
104
+ contents = await helpers.format(contents, filePath);
105
+ }
106
+
107
+ await fs.writeFile(filePath, contents);
108
+ };
109
+
110
+ const upsertSliceLibraryIndexFile = async ({
111
+ data,
112
+ actions,
113
+ helpers,
114
+ project,
115
+ options,
116
+ }: Omit<Args, "dir">) => {
117
+ const { filePath, contents } = await buildSliceLibraryIndexFileContents({
118
+ libraryID: data.libraryID,
119
+ actions,
120
+ helpers,
121
+ project,
122
+ options,
123
+ });
124
+
125
+ await fs.writeFile(filePath, contents);
126
+ };
127
+
128
+ export const sliceCreate: SliceCreateHook<PluginOptions> = async (
129
+ data,
130
+ context,
131
+ ) => {
132
+ const dir = context.helpers.joinPathFromRoot(
133
+ data.libraryID,
134
+ pascalCase(data.model.id),
135
+ );
136
+
137
+ await fs.mkdir(dir, { recursive: true });
138
+
139
+ await Promise.allSettled([
140
+ createModelFile({ dir, data, ...context }),
141
+ createComponentFile({ dir, data, ...context }),
142
+ createTypesFile({ dir, data, ...context }),
143
+ ]);
144
+
145
+ await upsertSliceLibraryIndexFile({ data, ...context });
146
+ };