@slicemachine/adapter-nuxt 0.3.3-dev-next-release.2 → 0.3.3-dev-next-release.4

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,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const commonTags = require("common-tags");
4
+ const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
5
+ var __freeze = Object.freeze;
6
+ var __defProp = Object.defineProperty;
7
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
8
+ var _a, _b;
9
+ const documentationRead = async (data, { options, helpers }) => {
10
+ const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
11
+ helpers,
12
+ options
13
+ });
14
+ if (data.kind === "PageSnippet") {
15
+ const { model } = data.data;
16
+ const filePath = `${model.repeatable ? "[uid]" : model.id}.vue`;
17
+ const scriptAttributes = ["setup"];
18
+ if (isTypeScriptProject) {
19
+ scriptAttributes.push('lang="ts"');
20
+ }
21
+ let fileContent;
22
+ if (model.repeatable) {
23
+ fileContent = commonTags.stripIndent(_a || (_a = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = useAsyncData("[', '-uid]", () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useHead({\n title: page.value?.data.meta_title,\n meta: [{\n name: "description",\n content: page.value?.data.meta_description,\n }],\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
24
+ } else {
25
+ fileContent = commonTags.stripIndent(_b || (_b = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const { data: page } = useAsyncData("[', ']", () =>\n prismic.client.getSingle("', '")\n );\n\n useHead({\n title: page.value?.data.meta_title,\n meta: [{\n name: "description",\n content: page.value?.data.meta_description,\n }],\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
26
+ }
27
+ if (options.format) {
28
+ fileContent = await helpers.format(fileContent, helpers.joinPathFromRoot("index.vue"), {
29
+ prettier: { parser: "vue" },
30
+ includeNewlineAtEnd: false
31
+ });
32
+ }
33
+ return [
34
+ {
35
+ label: "Composition API",
36
+ content: commonTags.source`
37
+ ## Create your ${model.label}'s page component
38
+
39
+ Add a new route by creating an \`~/pages/${filePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`~/pages/marketing/${filePath}\`.)
40
+
41
+ Paste in this code:
42
+
43
+ ${`~~~vue [~/pages/${filePath}]
44
+ ${fileContent}
45
+ ~~~`}
46
+
47
+ Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-3-setup) for more information.
48
+ `
49
+ }
50
+ ];
51
+ }
52
+ return [];
53
+ };
54
+ exports.documentationRead = documentationRead;
55
+ //# sourceMappingURL=documentation-read.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentation-read.cjs","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { data: page } = useAsyncData(\"[${model.id}-uid]\", () =>\n\t\t\t\t\tprismic.client.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseHead({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\tmeta: [{\n\t\t\t\t\t\tname: \"description\",\n\t\t\t\t\t\tcontent: page.value?.data.meta_description,\n\t\t\t\t\t}],\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\t\tconst prismic = usePrismic();\n\t\t\t\t\tconst { data: page } = useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\t\tprismic.client.getSingle(\"${model.id}\")\n\t\t\t\t\t);\n\n\t\t\t\t\tuseHead({\n\t\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\t\tmeta: [{\n\t\t\t\t\t\t\tname: \"description\",\n\t\t\t\t\t\t\tcontent: page.value?.data.meta_description,\n\t\t\t\t\t\t}],\n\t\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-3-setup) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":["checkIsTypeScriptProject","stripIndent","source"],"mappings":";;;;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACG,QAAA,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAEG,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM;AACjD,UAAA,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IACjC;AAEG,QAAA;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAcC,WAAW,YAAA,OAAA,KAAA,WAAA,CAAA,kBACY,iKAKY,iDACZ,uBAErC,wWARW,CAAA,IAAA,iBAAiB,KAAK,GAAG,GAKK,MAAM,IAClB,MAAM,IAClC,sBAAsB,eAAe,EAAA;AAAA,IAAA,OAqBhC;AACQ,oBAAAA,WAAAA,YAAA,OAAA,KAAW,WACY,CAAA,kBAAA,qIAIa,+CACX,iXAAA,CAAA,IAL5B,iBAAiB,KAAK,GAAG,GAIM,MAAM,IACjB,MAAM,EAAA;AAAA,IAoBrC;AAED,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAO;AAAA,QAC3B,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEF;AAEM,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAASC,WAAAA;AAAAA,sBACS,MAAM;AAAA;AAAA,gDAEoB,0IAA0I;AAAA;AAAA;AAAA;AAAA,OAInL,mBAAmB;AAAA,EAAc;AAAA;AAAA;AAAA;AAAA;AAAA,MAIpC;AAAA,IAAA;AAAA,EAEF;AAED,SAAO;AACR;;"}
@@ -0,0 +1,3 @@
1
+ import type { DocumentationReadHook } from "@slicemachine/plugin-kit";
2
+ import type { PluginOptions } from "../types";
3
+ export declare const documentationRead: DocumentationReadHook<PluginOptions>;
@@ -0,0 +1,55 @@
1
+ import { stripIndent, source } from "common-tags";
2
+ import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
3
+ var __freeze = Object.freeze;
4
+ var __defProp = Object.defineProperty;
5
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
6
+ var _a, _b;
7
+ const documentationRead = async (data, { options, helpers }) => {
8
+ const isTypeScriptProject = await checkIsTypeScriptProject({
9
+ helpers,
10
+ options
11
+ });
12
+ if (data.kind === "PageSnippet") {
13
+ const { model } = data.data;
14
+ const filePath = `${model.repeatable ? "[uid]" : model.id}.vue`;
15
+ const scriptAttributes = ["setup"];
16
+ if (isTypeScriptProject) {
17
+ scriptAttributes.push('lang="ts"');
18
+ }
19
+ let fileContent;
20
+ if (model.repeatable) {
21
+ fileContent = stripIndent(_a || (_a = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const route = useRoute();\n const { data: page } = useAsyncData("[', '-uid]", () =>\n prismic.client.getByUID("', '", route.params.uid', ')\n );\n\n useHead({\n title: page.value?.data.meta_title,\n meta: [{\n name: "description",\n content: page.value?.data.meta_description,\n }],\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id, isTypeScriptProject ? " as string" : "");
22
+ } else {
23
+ fileContent = stripIndent(_b || (_b = __template(["\n <script ", '>\n import { components } from "~/slices";\n\n const prismic = usePrismic();\n const { data: page } = useAsyncData("[', ']", () =>\n prismic.client.getSingle("', '")\n );\n\n useHead({\n title: page.value?.data.meta_title,\n meta: [{\n name: "description",\n content: page.value?.data.meta_description,\n }],\n });\n <\/script>\n\n <template>\n <SliceZone\n wrapper="main"\n :slices="page?.data.slices ?? []"\n :components="components"\n />\n </template>\n '])), scriptAttributes.join(" "), model.id, model.id);
24
+ }
25
+ if (options.format) {
26
+ fileContent = await helpers.format(fileContent, helpers.joinPathFromRoot("index.vue"), {
27
+ prettier: { parser: "vue" },
28
+ includeNewlineAtEnd: false
29
+ });
30
+ }
31
+ return [
32
+ {
33
+ label: "Composition API",
34
+ content: source`
35
+ ## Create your ${model.label}'s page component
36
+
37
+ Add a new route by creating an \`~/pages/${filePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`~/pages/marketing/${filePath}\`.)
38
+
39
+ Paste in this code:
40
+
41
+ ${`~~~vue [~/pages/${filePath}]
42
+ ${fileContent}
43
+ ~~~`}
44
+
45
+ Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-3-setup) for more information.
46
+ `
47
+ }
48
+ ];
49
+ }
50
+ return [];
51
+ };
52
+ export {
53
+ documentationRead
54
+ };
55
+ //# sourceMappingURL=documentation-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentation-read.js","sources":["../../../src/hooks/documentation-read.ts"],"sourcesContent":["import { source, stripIndent } from \"common-tags\";\n\nimport type { DocumentationReadHook } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nexport const documentationRead: DocumentationReadHook<PluginOptions> = async (\n\tdata,\n\t{ options, helpers },\n) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.kind === \"PageSnippet\") {\n\t\tconst { model } = data.data;\n\t\tconst filePath = `${model.repeatable ? \"[uid]\" : model.id}.vue`;\n\t\tconst scriptAttributes = [\"setup\"];\n\t\tif (isTypeScriptProject) {\n\t\t\tscriptAttributes.push('lang=\"ts\"');\n\t\t}\n\n\t\tlet fileContent: string;\n\n\t\tif (model.repeatable) {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\tconst prismic = usePrismic();\n\t\t\t\tconst route = useRoute();\n\t\t\t\tconst { data: page } = useAsyncData(\"[${model.id}-uid]\", () =>\n\t\t\t\t\tprismic.client.getByUID(\"${model.id}\", route.params.uid${\n\t\t\t\tisTypeScriptProject ? \" as string\" : \"\"\n\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tuseHead({\n\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\tmeta: [{\n\t\t\t\t\t\tname: \"description\",\n\t\t\t\t\t\tcontent: page.value?.data.meta_description,\n\t\t\t\t\t}],\n\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t} else {\n\t\t\tfileContent = stripIndent`\n\t\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\t\t\timport { components } from \"~/slices\";\n\n\t\t\t\t\tconst prismic = usePrismic();\n\t\t\t\t\tconst { data: page } = useAsyncData(\"[${model.id}]\", () =>\n\t\t\t\t\t\tprismic.client.getSingle(\"${model.id}\")\n\t\t\t\t\t);\n\n\t\t\t\t\tuseHead({\n\t\t\t\t\t\ttitle: page.value?.data.meta_title,\n\t\t\t\t\t\tmeta: [{\n\t\t\t\t\t\t\tname: \"description\",\n\t\t\t\t\t\t\tcontent: page.value?.data.meta_description,\n\t\t\t\t\t\t}],\n\t\t\t\t\t});\n\t\t\t\t</script>\n\n\t\t\t\t<template>\n\t\t\t\t\t<SliceZone\n\t\t\t\t\t\twrapper=\"main\"\n\t\t\t\t\t\t:slices=\"page?.data.slices ?? []\"\n\t\t\t\t\t\t:components=\"components\"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t`;\n\t\t}\n\n\t\tif (options.format) {\n\t\t\tfileContent = await helpers.format(\n\t\t\t\tfileContent,\n\t\t\t\thelpers.joinPathFromRoot(\"index.vue\"),\n\t\t\t\t{\n\t\t\t\t\tprettier: { parser: \"vue\" },\n\t\t\t\t\tincludeNewlineAtEnd: false,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: \"Composition API\",\n\t\t\t\tcontent: source`\n\t\t\t\t\t## Create your ${model.label}'s page component\n\n\t\t\t\t\tAdd a new route by creating an \\`~/pages/${filePath}\\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \\`~/pages/marketing/${filePath}\\`.)\n\n\t\t\t\t\tPaste in this code:\n\n\t\t\t\t\t${`~~~vue [~/pages/${filePath}]\\n${fileContent}\\n~~~`}\n\n\t\t\t\t\tMake sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-3-setup) for more information.\n\t\t\t\t`,\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n"],"names":[],"mappings":";;;;;AAAA,IAAA,IAAA;AAOO,MAAM,oBAA0D,OACtE,MACA,EAAE,SAAS,cACR;AACG,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAEG,MAAA,KAAK,SAAS,eAAe;AAC1B,UAAA,EAAE,MAAK,IAAK,KAAK;AACvB,UAAM,WAAW,GAAG,MAAM,aAAa,UAAU,MAAM;AACjD,UAAA,mBAAmB,CAAC,OAAO;AACjC,QAAI,qBAAqB;AACxB,uBAAiB,KAAK,WAAW;AAAA,IACjC;AAEG,QAAA;AAEJ,QAAI,MAAM,YAAY;AACrB,oBAAc,YAAW,OAAA,KAAA,WAAA,CAAA,kBACY,iKAKY,iDACZ,uBAErC,wWARW,CAAA,IAAA,iBAAiB,KAAK,GAAG,GAKK,MAAM,IAClB,MAAM,IAClC,sBAAsB,eAAe,EAAA;AAAA,IAAA,OAqBhC;AACQ,oBAAA,YAAA,OAAA,KAAW,WACY,CAAA,kBAAA,qIAIa,+CACX,iXAAA,CAAA,IAL5B,iBAAiB,KAAK,GAAG,GAIM,MAAM,IACjB,MAAM,EAAA;AAAA,IAoBrC;AAED,QAAI,QAAQ,QAAQ;AACnB,oBAAc,MAAM,QAAQ,OAC3B,aACA,QAAQ,iBAAiB,WAAW,GACpC;AAAA,QACC,UAAU,EAAE,QAAQ,MAAO;AAAA,QAC3B,qBAAqB;AAAA,MAAA,CACrB;AAAA,IAEF;AAEM,WAAA;AAAA,MACN;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,sBACS,MAAM;AAAA;AAAA,gDAEoB,0IAA0I;AAAA;AAAA;AAAA;AAAA,OAInL,mBAAmB;AAAA,EAAc;AAAA;AAAA;AAAA;AAAA;AAAA,MAIpC;AAAA,IAAA;AAAA,EAEF;AAED,SAAO;AACR;"}
@@ -42,9 +42,9 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
42
42
  options
43
43
  });
44
44
  if (isTypeScriptProject) {
45
- contents = commonTags.stripIndent(_a || (_a = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '])), model.id, pascalName);
45
+ contents = commonTags.stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n "], ['\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n "])), pascalName, model.id);
46
46
  } else {
47
- contents = commonTags.stripIndent(_b || (_b = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '])));
47
+ contents = commonTags.stripIndent(_b || (_b = __template(['\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n '], ['\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n '])));
48
48
  }
49
49
  if (options.format) {
50
50
  contents = await helpers.format(contents, filePath, {
@@ -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 { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\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 createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.vue\");\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${model.id} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath, {\n\t\t\tprettier: { parser: \"vue\" },\n\t\t});\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 = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["path","pascalCase","checkIsTypeScriptProject","stripIndent","fs","buildSliceDirectoryPath","rejectIfNecessary","updateSliceModelFile","upsertGlobalContentTypes","upsertSliceLibraryIndex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AA,IACxBE,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,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 { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\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 createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.vue\");\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${model.id} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath, {\n\t\t\tprettier: { parser: \"vue\" },\n\t\t});\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 = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["path","pascalCase","checkIsTypeScriptProject","stripIndent","fs","buildSliceDirectoryPath","rejectIfNecessary","updateSliceModelFile","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAA,IAAA;AAmBA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AAC3E,QAAM,WAAWA,gBAAK,KAAK,KAAK,WAAW;AAC3C,QAAM,QAAQ,KAAK;AACb,QAAA,aAAaC,WAAAA,WAAW,MAAM,IAAI;AAEpC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,qBAAqB;AACb,eAAAC,WAAA,YAAA,OAAA,KAAW,gSAMkC,8OAUjB,gFAAA,GAhBjB,yRAMkC,8OAUjB,gFAAA,CAAA,IAVO,YAUf,MAAM,EAAA;AAAA,EAAA,OAI/B;AACN,eAAWA,WAAW,YAAA,OAAA,KAAA,WAAA,CAAA,igBAAA,GAAA,CAAA,qgBAAA,CAAA,EAAA;AAAA,EAgBtB;AAED,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,UAAU;AAAA,MACnD,UAAU,EAAE,QAAQ,MAAO;AAAA,IAAA,CAC3B;AAAA,EACD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,MAAMC,wBAAAA,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAMD,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAGtCE,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,0CAAqB;AAAA,MACpB,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,GAAG;AAAA,IAAA,CACH;AAAA,IACD,oBAAoB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,EAC7C,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
@@ -22,9 +22,9 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
22
22
  options
23
23
  });
24
24
  if (isTypeScriptProject) {
25
- contents = stripIndent(_a || (_a = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '])), model.id, pascalName);
25
+ contents = stripIndent(_a || (_a = __template(['\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n "], ['\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', " (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n "])), pascalName, model.id);
26
26
  } else {
27
- contents = stripIndent(_b || (_b = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '])));
27
+ contents = stripIndent(_b || (_b = __template(['\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n '], ['\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n '])));
28
28
  }
29
29
  if (options.format) {
30
30
  contents = await helpers.format(contents, filePath, {
@@ -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 { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\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 createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.vue\");\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${model.id} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath, {\n\t\t\tprettier: { parser: \"vue\" },\n\t\t});\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 = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n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,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,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 { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\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 createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.vue\");\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${model.id} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath, {\n\t\t\tprettier: { parser: \"vue\" },\n\t\t});\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 = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAKA,IAAA,IAAA;AAmBA,MA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
@@ -65,7 +65,7 @@ const createStep2 = async ({ helpers, options }) => {
65
65
  if (isTypeScriptProject) {
66
66
  scriptAttributes.push('lang="ts"');
67
67
  }
68
- const fileContents = await helpers.format(commonTags.source(_a || (_a = __template(['\n <template>\n <SliceSimulator #default="{ slices }">\n <SliceZone :slices="slices" :components="components" />\n </SliceSimulator>\n </template>\n\n <script ', '>\n import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";\n import { components } from "~/slices";\n <\/script>\n '])), scriptAttributes.join(" ")), filePath, {
68
+ const fileContents = await helpers.format(commonTags.source(_a || (_a = __template(["\n <script ", '>\n import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";\n import { components } from "~/slices";\n <\/script>\n\n <template>\n <SliceSimulator #default="{ slices }">\n <SliceZone :slices="slices" :components="components" />\n </SliceSimulator>\n </template>\n '])), scriptAttributes.join(" ")), filePath, {
69
69
  includeNewlineAtEnd: false
70
70
  });
71
71
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"sliceSimulator-setup-read.cjs","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch, { Response } from \"node-fetch\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\"@nuxtjs/prismic\"];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\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 ${REQUIRED_DEPENDENCIES.join(\" \")}\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\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\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\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\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\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\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 isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst fileName = \"slice-simulator.vue\";\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst fileContents = await helpers.format(\n\t\tsource`\n\t\t\t<template>\n\t\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t\t</SliceSimulator>\n\t\t\t</template>\n\n\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\t\timport { components } from \"~/slices\";\n\t\t\t</script>\n\t\t`,\n\t\tfilePath,\n\t\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tdescription: `In your \\`pages\\` directory, create a file called \\`${fileName}\\` containing this code.`,\n\t\tbody: source`\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~~~vue\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(\"slicemachine.config.json\");\n\tconst fileContents = await helpers.format(\n\t\tsource`\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\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Update `slicemachine.config.json`\",\n\t\tdescription: `Update your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.`,\n\t\tbody: source`\n\t\t\tUpdate your \\`slicemachine.config.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\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`slicemachine.config.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\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: source`\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\tlet res: Response | undefined = undefined;\n\t\t\ttry {\n\t\t\t\tres = await fetch(project.config.localSliceSimulatorURL);\n\t\t\t} catch (error) {\n\t\t\t\t// Noop, we return if `res` is not defined\n\t\t\t}\n\n\t\t\tif (!res || !res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`slicemachine.config.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/nuxt-setup) 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),\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O,sBAAsB;AAAA,eAC/C;MAER;AAED,UAAI,CAAC,OAAO,CAAC,IAAI,IAAI;AACb,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAASF,WAAAA;AAAAA;AAAAA;AAAAA,QAAA;AAAA,MAIV;AAAA,IACF;AAAA,EAAA;AAEF;AAEa,MAAA,0BAET,OAAO,OAAO,YAAW;AAC5B,SAAO,QAAQ,IAAI;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,EAAA,CACnB;AACF;;"}
1
+ {"version":3,"file":"sliceSimulator-setup-read.cjs","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch, { Response } from \"node-fetch\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\"@nuxtjs/prismic\"];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\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 ${REQUIRED_DEPENDENCIES.join(\" \")}\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\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\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\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\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\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\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 isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst fileName = \"slice-simulator.vue\";\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst fileContents = await helpers.format(\n\t\tsource`\n\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\t\timport { components } from \"~/slices\";\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t\t</SliceSimulator>\n\t\t\t</template>\n\t\t`,\n\t\tfilePath,\n\t\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tdescription: `In your \\`pages\\` directory, create a file called \\`${fileName}\\` containing this code.`,\n\t\tbody: source`\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~~~vue\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(\"slicemachine.config.json\");\n\tconst fileContents = await helpers.format(\n\t\tsource`\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\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Update `slicemachine.config.json`\",\n\t\tdescription: `Update your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.`,\n\t\tbody: source`\n\t\t\tUpdate your \\`slicemachine.config.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\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`slicemachine.config.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\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: source`\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\tlet res: Response | undefined = undefined;\n\t\t\ttry {\n\t\t\t\tres = await fetch(project.config.localSliceSimulatorURL);\n\t\t\t} catch (error) {\n\t\t\t\t// Noop, we return if `res` is not defined\n\t\t\t}\n\n\t\t\tif (!res || !res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`slicemachine.config.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/nuxt-setup) 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"],"names":["require","createRequire","source","checkIsTypeScriptProject","fetch"],"mappings":";;;;;;;;;AAKA,IAAA;AAQA,MAAM,wBAAwB,CAAC,iBAAiB;AAIhD,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtCA,QAAAA,WAAUC,YAAAA,cAAc,QAAQ,IAAI;AAEnC,SAAA;AAAA,IACN,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I;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,EAAA,CACnB;AACF;;"}
@@ -63,7 +63,7 @@ const createStep2 = async ({ helpers, options }) => {
63
63
  if (isTypeScriptProject) {
64
64
  scriptAttributes.push('lang="ts"');
65
65
  }
66
- const fileContents = await helpers.format(source(_a || (_a = __template(['\n <template>\n <SliceSimulator #default="{ slices }">\n <SliceZone :slices="slices" :components="components" />\n </SliceSimulator>\n </template>\n\n <script ', '>\n import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";\n import { components } from "~/slices";\n <\/script>\n '])), scriptAttributes.join(" ")), filePath, {
66
+ const fileContents = await helpers.format(source(_a || (_a = __template(["\n <script ", '>\n import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";\n import { components } from "~/slices";\n <\/script>\n\n <template>\n <SliceSimulator #default="{ slices }">\n <SliceZone :slices="slices" :components="components" />\n </SliceSimulator>\n </template>\n '])), scriptAttributes.join(" ")), filePath, {
67
67
  includeNewlineAtEnd: false
68
68
  });
69
69
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"sliceSimulator-setup-read.js","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch, { Response } from \"node-fetch\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\"@nuxtjs/prismic\"];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\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 ${REQUIRED_DEPENDENCIES.join(\" \")}\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\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\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\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\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\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\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 isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst fileName = \"slice-simulator.vue\";\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst fileContents = await helpers.format(\n\t\tsource`\n\t\t\t<template>\n\t\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t\t</SliceSimulator>\n\t\t\t</template>\n\n\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\t\timport { components } from \"~/slices\";\n\t\t\t</script>\n\t\t`,\n\t\tfilePath,\n\t\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tdescription: `In your \\`pages\\` directory, create a file called \\`${fileName}\\` containing this code.`,\n\t\tbody: source`\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~~~vue\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(\"slicemachine.config.json\");\n\tconst fileContents = await helpers.format(\n\t\tsource`\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\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Update `slicemachine.config.json`\",\n\t\tdescription: `Update your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.`,\n\t\tbody: source`\n\t\t\tUpdate your \\`slicemachine.config.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\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`slicemachine.config.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\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: source`\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\tlet res: Response | undefined = undefined;\n\t\t\ttry {\n\t\t\t\tres = await fetch(project.config.localSliceSimulatorURL);\n\t\t\t} catch (error) {\n\t\t\t\t// Noop, we return if `res` is not defined\n\t\t\t}\n\n\t\t\tif (!res || !res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`slicemachine.config.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/nuxt-setup) 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"],"names":["require"],"mappings":";;;;;;;AAKA,IAAA;AAQA,MAAM,wBAAwB,CAAC,iBAAiB;AAIhD,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtCA,QAAAA,WAAU,cAAc,QAAQ,IAAI;AAEnC,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA;AAAA;AAAA,IAGb,MAAM;AAAA;AAAA;AAAA;AAAA,wBAIgB,sBAAsB,KAAK,GAAG;AAAA;AAAA;AAAA,IAGpD,UAAU,YAAW;AACpB,YAAM,sBAAgC,CAAA;AAEtC,iBAAW,cAAc,uBAAuB;AAC3C,YAAA;AAKHA,mBAAQ,QAAQ,YAAY;AAAA,YAC3B,OAAO,CAAC,QAAQ,iBAAiB,cAAc,CAAC;AAAA,UAAA,CAChD;AAAA,QAAA,QACA;AACD,8BAAoB,KAAK,UAAU;AAAA,QACnC;AAAA,MACD;AAEG,UAAA,oBAAoB,UAAU,sBAAsB,QAAQ;AACxD,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAEG,UAAA,oBAAoB,SAAS,GAAG;AAC7B,cAAA,+BAA+B,oBACnC,IAAI,CAAC,sBAAsB,KAAK,qBAAqB,EACrD,KAAK,IAAI;AAEJ,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA,gDACkC;AAAA;AAAA,QAAA;AAAA,MAG5C;AAAA,IACF;AAAA,EAAA;AAEF;AAEA,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtC,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,WAAW;AACjB,QAAM,WAAW,QAAQ,iBAAiB,SAAS,QAAQ;AAErD,QAAA,mBAA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AAI,IAAI;AACb,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAAA,IACF;AAAA,EAAA;AAEF;AAEa,MAAA,0BAET,OAAO,OAAO,YAAW;AAC5B,SAAO,QAAQ,IAAI;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,EAAA,CACnB;AACF;"}
1
+ {"version":3,"file":"sliceSimulator-setup-read.js","sources":["../../../src/hooks/sliceSimulator-setup-read.ts"],"sourcesContent":["import type {\n\tSliceMachineContext,\n\tSliceSimulatorSetupReadHook,\n\tSliceSimulatorSetupStep,\n} from \"@slicemachine/plugin-kit\";\nimport { source } from \"common-tags\";\nimport { createRequire } from \"node:module\";\nimport fetch, { Response } from \"node-fetch\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst REQUIRED_DEPENDENCIES = [\"@nuxtjs/prismic\"];\n\ntype Args = SliceMachineContext<PluginOptions>;\n\nconst createStep1 = async ({\n\tproject,\n\thelpers,\n}: Args): Promise<SliceSimulatorSetupStep> => {\n\tconst require = createRequire(project.root);\n\n\treturn {\n\t\ttitle: \"Install packages\",\n\t\tdescription: \"The simulator requires some dependencies.\",\n\t\t// TODO: Create a plugin runner helper to provide the correct\n\t\t// package manager\n\t\tbody: source`\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 ${REQUIRED_DEPENDENCIES.join(\" \")}\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\t\tpaths: [helpers.joinPathFromRoot(\"node_modules\")],\n\t\t\t\t\t});\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\ttitle: \"Missing all dependencies\",\n\t\t\t\t\tmessage: source`\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\ttitle: \"Missing some dependencies\",\n\t\t\t\t\tmessage: source`\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 isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst fileName = \"slice-simulator.vue\";\n\tconst filePath = helpers.joinPathFromRoot(\"pages\", fileName);\n\n\tconst scriptAttributes = [\"setup\"];\n\tif (isTypeScriptProject) {\n\t\tscriptAttributes.push('lang=\"ts\"');\n\t}\n\n\tconst fileContents = await helpers.format(\n\t\tsource`\n\t\t\t<script ${scriptAttributes.join(\" \")}>\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-nuxt/simulator\";\n\t\t\timport { components } from \"~/slices\";\n\t\t\t</script>\n\n\t\t\t<template>\n\t\t\t\t<SliceSimulator #default=\"{ slices }\">\n\t\t\t\t\t<SliceZone :slices=\"slices\" :components=\"components\" />\n\t\t\t\t</SliceSimulator>\n\t\t\t</template>\n\t\t`,\n\t\tfilePath,\n\t\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Create a page for the simulator\",\n\t\tdescription: `In your \\`pages\\` directory, create a file called \\`${fileName}\\` containing this code.`,\n\t\tbody: source`\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~~~vue\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(\"slicemachine.config.json\");\n\tconst fileContents = await helpers.format(\n\t\tsource`\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\t{\n\t\t\tincludeNewlineAtEnd: false,\n\t\t},\n\t);\n\n\treturn {\n\t\ttitle: \"Update `slicemachine.config.json`\",\n\t\tdescription: `Update your \\`slicemachine.config.json\\` file with a \\`localSliceSimulatorURL\\` property pointing to your \\`/slice-simulator\\` page.`,\n\t\tbody: source`\n\t\t\tUpdate your \\`slicemachine.config.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\ttitle: \"Missing `localSliceSimulatorURL` property\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tA \\`localSliceSimulatorURL\\` property was not found in your \\`slicemachine.config.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\ttitle: \"An invalid URL was provided\",\n\t\t\t\t\tmessage: source`\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\tlet res: Response | undefined = undefined;\n\t\t\ttry {\n\t\t\t\tres = await fetch(project.config.localSliceSimulatorURL);\n\t\t\t} catch (error) {\n\t\t\t\t// Noop, we return if `res` is not defined\n\t\t\t}\n\n\t\t\tif (!res || !res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\ttitle: \"Unable to connect to simulator page\",\n\t\t\t\t\tmessage: source`\n\t\t\t\t\t\tCheck that the \\`localSliceSimulatorURL\\` property in \\`slicemachine.config.json\\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/nuxt-setup) 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"],"names":["require"],"mappings":";;;;;;;AAKA,IAAA;AAQA,MAAM,wBAAwB,CAAC,iBAAiB;AAIhD,MAAM,cAAc,OAAO,EAC1B,SACA,cAC4C;AACtCA,QAAAA,WAAU,cAAc,QAAQ,IAAI;AAEnC,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA;AAAA;AAAA,IAGb,MAAM;AAAA;AAAA;AAAA;AAAA,wBAIgB,sBAAsB,KAAK,GAAG;AAAA;A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,EAC1B,cAC4C;AACtC,QAAA,WAAW,QAAQ,iBAAiB,0BAA0B;AAC9D,QAAA,eAAe,MAAM,QAAQ,OAClC;AAAA;AAAA;AAAA;AAAA,KAKA,UACA;AAAA,IACC,qBAAqB;AAAA,EAAA,CACrB;AAGK,SAAA;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA;AAAA;AAAA;AAAA,KAIH;AAAA;AAAA;AAAA,IAGH,UAAU,YAAW;AACd,YAAA,UAAU,MAAM,QAAQ;AAE1B,UAAA,EAAE,4BAA4B,QAAQ,SAAS;AAC3C,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAGG,UAAA;AACC,YAAA,QAAQ,OAAO,wBAAwB;AACtC,cAAA,IAAI,QAAQ,OAAO,sBAAsB;AAAA,QAAA,OACvC;AACA,gBAAA,IAAI,MAAM,+BAA+B;AAAA,QAC/C;AAAA,MAAA,QACA;AACM,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAGD,UAAI,MAA4B;AAC5B,UAAA;AACH,cAAM,MAAM,MAAM,QAAQ,OAAO,sBAAsB;AAAA,eAC/C;MAER;AAED,UAAI,CAAC,OAAO,CAAC,IAAI,IAAI;AACb,eAAA;AAAA,UACN,OAAO;AAAA,UACP,SAAS;AAAA;AAAA;AAAA,QAAA;AAAA,MAIV;AAAA,IACF;AAAA,EAAA;AAEF;AAEa,MAAA,0BAET,OAAO,OAAO,YAAW;AAC5B,SAAO,QAAQ,IAAI;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,IACnB,YAAY,OAAO;AAAA,EAAA,CACnB;AACF;"}
package/dist/plugin.cjs CHANGED
@@ -20,9 +20,10 @@ const sliceDelete = require("./hooks/slice-delete.cjs");
20
20
  const sliceLibraryRead = require("./hooks/sliceLibrary-read.cjs");
21
21
  const sliceRead = require("./hooks/slice-read.cjs");
22
22
  const sliceRename = require("./hooks/slice-rename.cjs");
23
- const sliceSimulatorSetupRead = require("./hooks/sliceSimulator-setup-read.cjs");
24
23
  const sliceUpdate = require("./hooks/slice-update.cjs");
25
24
  const snippetRead = require("./hooks/snippet-read.cjs");
25
+ const documentationRead = require("./hooks/documentation-read.cjs");
26
+ const sliceSimulatorSetupRead = require("./hooks/sliceSimulator-setup-read.cjs");
26
27
  const plugin = pluginKit.defineSliceMachinePlugin({
27
28
  meta: {
28
29
  name: _package.name
@@ -52,6 +53,7 @@ const plugin = pluginKit.defineSliceMachinePlugin({
52
53
  hook("custom-type:asset:read", customTypeAssetRead.customTypeAssetRead);
53
54
  hook("custom-type-library:read", customTypeLibraryRead.customTypeLibraryRead);
54
55
  hook("snippet:read", snippetRead.snippetRead);
56
+ hook("documentation:read", documentationRead.documentationRead);
55
57
  hook("slice-simulator:setup:read", sliceSimulatorSetupRead.sliceSimulatorSetupRead);
56
58
  }
57
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\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:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\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"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","sliceUpdate","sliceRename","sliceDelete","sliceRead","sliceAssetUpdate","sliceAssetDelete","sliceAssetRead","sliceLibraryRead","customTypeCreate","customTypeUpdate","customTypeRename","customTypeDelete","customTypeRead","customTypeAssetUpdate","customTypeAssetDelete","customTypeAssetRead","customTypeLibraryRead","snippetRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,cAAcC,UAAAA,SAAS;AAC5B,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAE3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,0BAA0BC,oBAAAA,mBAAmB;AAClD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AAEtD,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
1
+ {"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { documentationRead } from \"./hooks/documentation-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\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\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:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\t\thook(\"documentation:read\", documentationRead);\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","sliceUpdate","sliceRename","sliceDelete","sliceRead","sliceAssetUpdate","sliceAssetDelete","sliceAssetRead","sliceLibraryRead","customTypeCreate","customTypeUpdate","customTypeRename","customTypeDelete","customTypeRead","customTypeAssetUpdate","customTypeAssetDelete","customTypeAssetRead","customTypeLibraryRead","snippetRead","documentationRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,cAAcC,UAAAA,SAAS;AAC5B,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAE3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,0BAA0BC,oBAAAA,mBAAmB;AAClD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AAEtD,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,sBAAsBC,kBAAAA,iBAAiB;AAC5C,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
package/dist/plugin.js CHANGED
@@ -18,9 +18,10 @@ import { sliceDelete } from "./hooks/slice-delete.js";
18
18
  import { sliceLibraryRead } from "./hooks/sliceLibrary-read.js";
19
19
  import { sliceRead } from "./hooks/slice-read.js";
20
20
  import { sliceRename } from "./hooks/slice-rename.js";
21
- import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read.js";
22
21
  import { sliceUpdate } from "./hooks/slice-update.js";
23
22
  import { snippetRead } from "./hooks/snippet-read.js";
23
+ import { documentationRead } from "./hooks/documentation-read.js";
24
+ import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read.js";
24
25
  const plugin = defineSliceMachinePlugin({
25
26
  meta: {
26
27
  name
@@ -50,6 +51,7 @@ const plugin = defineSliceMachinePlugin({
50
51
  hook("custom-type:asset:read", customTypeAssetRead);
51
52
  hook("custom-type-library:read", customTypeLibraryRead);
52
53
  hook("snippet:read", snippetRead);
54
+ hook("documentation:read", documentationRead);
53
55
  hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
54
56
  }
55
57
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\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:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAEhC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAEhC,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
1
+ {"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { documentationRead } from \"./hooks/documentation-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\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\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:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\t\thook(\"documentation:read\", documentationRead);\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAEhC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAChC,SAAK,sBAAsB,iBAAiB;AAC5C,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-nuxt",
3
- "version": "0.3.3-dev-next-release.2",
3
+ "version": "0.3.3-dev-next-release.4",
4
4
  "description": "Slice Machine adapter for Nuxt 3.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -59,7 +59,7 @@
59
59
  "dependencies": {
60
60
  "@prismicio/simulator": "^0.1.4",
61
61
  "@prismicio/types-internal": "^2.0.0",
62
- "@slicemachine/plugin-kit": "^0.4.3-dev-next-release.2",
62
+ "@slicemachine/plugin-kit": "^0.4.3-dev-next-release.4",
63
63
  "common-tags": "^1.8.2",
64
64
  "fp-ts": "^2.13.1",
65
65
  "fs-extra": "^11.1.0",
@@ -103,5 +103,5 @@
103
103
  "engines": {
104
104
  "node": ">=14.15.0"
105
105
  },
106
- "gitHead": "72c72e209cda174dfe40bcdcf5c0ab17cc3e121c"
106
+ "gitHead": "570b595ff63a1d3d6ad2604942b7343d6b0b65eb"
107
107
  }
@@ -0,0 +1,116 @@
1
+ import { source, stripIndent } from "common-tags";
2
+
3
+ import type { DocumentationReadHook } from "@slicemachine/plugin-kit";
4
+
5
+ import type { PluginOptions } from "../types";
6
+ import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
7
+
8
+ export const documentationRead: DocumentationReadHook<PluginOptions> = async (
9
+ data,
10
+ { options, helpers },
11
+ ) => {
12
+ const isTypeScriptProject = await checkIsTypeScriptProject({
13
+ helpers,
14
+ options,
15
+ });
16
+
17
+ if (data.kind === "PageSnippet") {
18
+ const { model } = data.data;
19
+ const filePath = `${model.repeatable ? "[uid]" : model.id}.vue`;
20
+ const scriptAttributes = ["setup"];
21
+ if (isTypeScriptProject) {
22
+ scriptAttributes.push('lang="ts"');
23
+ }
24
+
25
+ let fileContent: string;
26
+
27
+ if (model.repeatable) {
28
+ fileContent = stripIndent`
29
+ <script ${scriptAttributes.join(" ")}>
30
+ import { components } from "~/slices";
31
+
32
+ const prismic = usePrismic();
33
+ const route = useRoute();
34
+ const { data: page } = useAsyncData("[${model.id}-uid]", () =>
35
+ prismic.client.getByUID("${model.id}", route.params.uid${
36
+ isTypeScriptProject ? " as string" : ""
37
+ })
38
+ );
39
+
40
+ useHead({
41
+ title: page.value?.data.meta_title,
42
+ meta: [{
43
+ name: "description",
44
+ content: page.value?.data.meta_description,
45
+ }],
46
+ });
47
+ </script>
48
+
49
+ <template>
50
+ <SliceZone
51
+ wrapper="main"
52
+ :slices="page?.data.slices ?? []"
53
+ :components="components"
54
+ />
55
+ </template>
56
+ `;
57
+ } else {
58
+ fileContent = stripIndent`
59
+ <script ${scriptAttributes.join(" ")}>
60
+ import { components } from "~/slices";
61
+
62
+ const prismic = usePrismic();
63
+ const { data: page } = useAsyncData("[${model.id}]", () =>
64
+ prismic.client.getSingle("${model.id}")
65
+ );
66
+
67
+ useHead({
68
+ title: page.value?.data.meta_title,
69
+ meta: [{
70
+ name: "description",
71
+ content: page.value?.data.meta_description,
72
+ }],
73
+ });
74
+ </script>
75
+
76
+ <template>
77
+ <SliceZone
78
+ wrapper="main"
79
+ :slices="page?.data.slices ?? []"
80
+ :components="components"
81
+ />
82
+ </template>
83
+ `;
84
+ }
85
+
86
+ if (options.format) {
87
+ fileContent = await helpers.format(
88
+ fileContent,
89
+ helpers.joinPathFromRoot("index.vue"),
90
+ {
91
+ prettier: { parser: "vue" },
92
+ includeNewlineAtEnd: false,
93
+ },
94
+ );
95
+ }
96
+
97
+ return [
98
+ {
99
+ label: "Composition API",
100
+ content: source`
101
+ ## Create your ${model.label}'s page component
102
+
103
+ Add a new route by creating an \`~/pages/${filePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`~/pages/marketing/${filePath}\`.)
104
+
105
+ Paste in this code:
106
+
107
+ ${`~~~vue [~/pages/${filePath}]\n${fileContent}\n~~~`}
108
+
109
+ Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-3-setup) for more information.
110
+ `,
111
+ },
112
+ ];
113
+ }
114
+
115
+ return [];
116
+ };
@@ -36,15 +36,6 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
36
36
 
37
37
  if (isTypeScriptProject) {
38
38
  contents = stripIndent`
39
- <template>
40
- <section
41
- :data-slice-type="slice.slice_type"
42
- :data-slice-variation="slice.variation"
43
- >
44
- Placeholder component for ${model.id} (variation: {{ slice.variation }}) Slices
45
- </section>
46
- </template>
47
-
48
39
  <script setup lang="ts">
49
40
  import { Content } from "@prismicio/client";
50
41
 
@@ -54,23 +45,32 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
54
45
  ["slice", "index", "slices", "context"]
55
46
  ));
56
47
  </script>
57
- `;
58
- } else {
59
- contents = stripIndent`
48
+
60
49
  <template>
61
50
  <section
62
51
  :data-slice-type="slice.slice_type"
63
52
  :data-slice-variation="slice.variation"
64
53
  >
65
- Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices
54
+ Placeholder component for ${model.id} (variation: {{ slice.variation }}) Slices
66
55
  </section>
67
56
  </template>
68
-
57
+ `;
58
+ } else {
59
+ contents = stripIndent`
69
60
  <script setup>
70
61
  // The array passed to \`getSliceComponentProps\` is purely optional.
71
62
  // Consider it as a visual hint for you when templating your slice.
72
63
  defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));
73
64
  </script>
65
+
66
+ <template>
67
+ <section
68
+ :data-slice-type="slice.slice_type"
69
+ :data-slice-variation="slice.variation"
70
+ >
71
+ Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices
72
+ </section>
73
+ </template>
74
74
  `;
75
75
  }
76
76
 
@@ -94,16 +94,16 @@ const createStep2 = async ({
94
94
 
95
95
  const fileContents = await helpers.format(
96
96
  source`
97
+ <script ${scriptAttributes.join(" ")}>
98
+ import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";
99
+ import { components } from "~/slices";
100
+ </script>
101
+
97
102
  <template>
98
103
  <SliceSimulator #default="{ slices }">
99
104
  <SliceZone :slices="slices" :components="components" />
100
105
  </SliceSimulator>
101
106
  </template>
102
-
103
- <script ${scriptAttributes.join(" ")}>
104
- import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";
105
- import { components } from "~/slices";
106
- </script>
107
107
  `,
108
108
  filePath,
109
109
  {
package/src/plugin.ts CHANGED
@@ -21,9 +21,10 @@ import { sliceDelete } from "./hooks/slice-delete";
21
21
  import { sliceLibraryRead } from "./hooks/sliceLibrary-read";
22
22
  import { sliceRead } from "./hooks/slice-read";
23
23
  import { sliceRename } from "./hooks/slice-rename";
24
- import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
25
24
  import { sliceUpdate } from "./hooks/slice-update";
26
25
  import { snippetRead } from "./hooks/snippet-read";
26
+ import { documentationRead } from "./hooks/documentation-read";
27
+ import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
27
28
 
28
29
  export const plugin = defineSliceMachinePlugin<PluginOptions>({
29
30
  meta: {
@@ -57,7 +58,7 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
57
58
  hook("custom-type-library:read", customTypeLibraryRead);
58
59
 
59
60
  hook("snippet:read", snippetRead);
60
-
61
+ hook("documentation:read", documentationRead);
61
62
  hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
62
63
  },
63
64
  });