@slicemachine/adapter-sveltekit 0.3.14-dev-slices-templates-feature.0 → 0.3.14-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.
@@ -12,27 +12,25 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
12
12
  var _a, _b;
13
13
  const createComponentFile = async ({ data, helpers, actions, options }) => {
14
14
  const pascalName = pascalCase.pascalCase(data.model.name);
15
- let componentContents;
15
+ let contents;
16
16
  const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
17
17
  helpers,
18
18
  options
19
19
  });
20
- if (data.componentContents) {
21
- componentContents = data.componentContents;
22
- } else if (isTypeScriptProject) {
23
- componentContents = commonTags.source(_a || (_a = __template([`
20
+ if (isTypeScriptProject) {
21
+ contents = commonTags.source(_a || (_a = __template([`
24
22
  <script lang="ts">
25
23
  import type { Content } from '@prismicio/client';
26
24
 
27
25
  export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
28
26
  } else {
29
- componentContents = commonTags.source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
27
+ contents = commonTags.source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
30
28
  }
31
29
  await fs.writeSliceFile({
32
30
  libraryID: data.libraryID,
33
31
  model: data.model,
34
32
  filename: "index.svelte",
35
- contents: componentContents,
33
+ contents,
36
34
  format: options.format,
37
35
  actions,
38
36
  helpers,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet componentContents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcomponentContents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcomponentContents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcomponentContents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents: componentContents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["pascalCase","checkIsTypeScriptProject","source","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,aAAaA,WAAA,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MA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liceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["pascalCase","checkIsTypeScriptProject","source","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,aAAaA,WAAA,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,qBAAqB;AACxB,eAAWC,WAAAA,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIuB,4NAAV,CAAA,IAAA,UAAA;AAAA,EAAA,OAOxB;AACK,eAAAA,WAAA,OAAA,OAAA,KAAM,kFAE4C,sPAAV,CAAA,IAAA,UAAA;AAAA,EAQnD;AAED,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
@@ -10,27 +10,25 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
10
10
  var _a, _b;
11
11
  const createComponentFile = async ({ data, helpers, actions, options }) => {
12
12
  const pascalName = pascalCase(data.model.name);
13
- let componentContents;
13
+ let contents;
14
14
  const isTypeScriptProject = await checkIsTypeScriptProject({
15
15
  helpers,
16
16
  options
17
17
  });
18
- if (data.componentContents) {
19
- componentContents = data.componentContents;
20
- } else if (isTypeScriptProject) {
21
- componentContents = source(_a || (_a = __template([`
18
+ if (isTypeScriptProject) {
19
+ contents = source(_a || (_a = __template([`
22
20
  <script lang="ts">
23
21
  import type { Content } from '@prismicio/client';
24
22
 
25
23
  export let slice: Content.`, "Slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
26
24
  } else {
27
- componentContents = source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
25
+ contents = source(_b || (_b = __template(['\n <script>\n /** @type {import("@prismicio/client").Content.', "Slice} */\n export let slice;\n <\/script>\n\n <section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n Placeholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n </section>\n "])), pascalName);
28
26
  }
29
27
  await writeSliceFile({
30
28
  libraryID: data.libraryID,
31
29
  model: data.model,
32
30
  filename: "index.svelte",
33
- contents: componentContents,
31
+ contents,
34
32
  format: options.format,
35
33
  actions,
36
34
  helpers,
@@ -1 +1 @@
1
- {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet componentContents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcomponentContents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcomponentContents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcomponentContents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents: componentContents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAA,IAAA;AAkBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACV,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,mBAAmB;AAC3B,wBAAoB,KAAK;AAAA,aACf,qBAAqB;AAC/B,wBAAoB,OAAM,OAAA,KAAA,WAAA,CAAA;AAAA;AAAA;AAAA;AAAA,iCAIc,4NAAV,CAAA,IAAA,UAAA;AAAA,EAAA,OAOxB;AACc,wBAAA,OAAA,OAAA,KAAM,kFAEmC,sPAAV,CAAA,IAAA,UAAA;AAAA,EAQnD;AAED,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,QACT,SAAS,CAAC,wBAAwB;AAAA,QAClC,QAAQ;AAAA,MACR;AAAA,IACD;AAAA,EAAA,CACD;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;"}
1
+ {"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t<script lang=\"ts\">\n\t\t\t\timport type { Content } from '@prismicio/client';\n\n\t\t\t\texport let slice: Content.${pascalName}Slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t<script>\n\t\t\t\t/** @type {import(\"@prismicio/client\").Content.${pascalName}Slice} */\n\t\t\t\texport let slice;\n\t\t\t</script>\n\n\t\t\t<section data-slice-type={slice.slice_type} data-slice-variation={slice.variation}>\n\t\t\t\tPlaceholder component for {slice.slice_type} (variation: {slice.variation}) Slices\n\t\t\t</section>\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename: \"index.svelte\",\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t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jB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/adapter-sveltekit",
3
- "version": "0.3.14-dev-slices-templates-feature.0",
3
+ "version": "0.3.14-dev-next-release.4",
4
4
  "description": "Slice Machine adapter for SvelteKit.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -64,7 +64,7 @@
64
64
  "dependencies": {
65
65
  "@prismicio/simulator": "^0.1.4",
66
66
  "@prismicio/types-internal": "^2.0.0",
67
- "@slicemachine/plugin-kit": "^0.4.14-dev-slices-templates-feature.0",
67
+ "@slicemachine/plugin-kit": "^0.4.14-dev-next-release.4",
68
68
  "common-tags": "^1.8.2",
69
69
  "fp-ts": "^2.13.1",
70
70
  "io-ts": "^2.2.20",
@@ -109,5 +109,5 @@
109
109
  "engines": {
110
110
  "node": ">=14.15.0"
111
111
  },
112
- "gitHead": "c75b90c9630901ddfaf552e479a4253a7b35ffd8"
112
+ "gitHead": "3d3654dd6a15d9b16e65dc662550ba3bee9b095a"
113
113
  }
@@ -29,17 +29,15 @@ const createComponentFile = async ({
29
29
  }: Args) => {
30
30
  const pascalName = pascalCase(data.model.name);
31
31
 
32
- let componentContents: string;
32
+ let contents: string;
33
33
 
34
34
  const isTypeScriptProject = await checkIsTypeScriptProject({
35
35
  helpers,
36
36
  options,
37
37
  });
38
38
 
39
- if (data.componentContents) {
40
- componentContents = data.componentContents;
41
- } else if (isTypeScriptProject) {
42
- componentContents = source`
39
+ if (isTypeScriptProject) {
40
+ contents = source`
43
41
  <script lang="ts">
44
42
  import type { Content } from '@prismicio/client';
45
43
 
@@ -51,7 +49,7 @@ const createComponentFile = async ({
51
49
  </section>
52
50
  `;
53
51
  } else {
54
- componentContents = source`
52
+ contents = source`
55
53
  <script>
56
54
  /** @type {import("@prismicio/client").Content.${pascalName}Slice} */
57
55
  export let slice;
@@ -67,7 +65,7 @@ const createComponentFile = async ({
67
65
  libraryID: data.libraryID,
68
66
  model: data.model,
69
67
  filename: "index.svelte",
70
- contents: componentContents,
68
+ contents,
71
69
  format: options.format,
72
70
  actions,
73
71
  helpers,