@slicemachine/adapter-next 0.3.18-dev-next-release.2 → 0.3.18-dev-next-release.3

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.
Files changed (44) hide show
  1. package/dist/AlternateGrid/javascript.jsx +247 -0
  2. package/dist/AlternateGrid/typescript.tsx +244 -0
  3. package/dist/CallToAction/javascript.jsx +135 -0
  4. package/dist/CallToAction/typescript.tsx +137 -0
  5. package/dist/CustomerLogos/javascript.jsx +129 -0
  6. package/dist/CustomerLogos/typescript.tsx +128 -0
  7. package/dist/Hero/javascript.jsx +207 -0
  8. package/dist/Hero/typescript.tsx +204 -0
  9. package/dist/plugin.cjs +18 -2
  10. package/dist/plugin.cjs.map +1 -1
  11. package/dist/plugin.js +19 -3
  12. package/dist/plugin.js.map +1 -1
  13. package/dist/sliceTemplates/AlternateGrid/index.cjs +4 -505
  14. package/dist/sliceTemplates/AlternateGrid/index.cjs.map +1 -1
  15. package/dist/sliceTemplates/AlternateGrid/index.d.ts +2 -3
  16. package/dist/sliceTemplates/AlternateGrid/index.js +4 -505
  17. package/dist/sliceTemplates/AlternateGrid/index.js.map +1 -1
  18. package/dist/sliceTemplates/CallToAction/index.cjs +4 -291
  19. package/dist/sliceTemplates/CallToAction/index.cjs.map +1 -1
  20. package/dist/sliceTemplates/CallToAction/index.d.ts +2 -3
  21. package/dist/sliceTemplates/CallToAction/index.js +4 -291
  22. package/dist/sliceTemplates/CallToAction/index.js.map +1 -1
  23. package/dist/sliceTemplates/CustomerLogos/index.cjs +3 -275
  24. package/dist/sliceTemplates/CustomerLogos/index.cjs.map +1 -1
  25. package/dist/sliceTemplates/CustomerLogos/index.d.ts +2 -3
  26. package/dist/sliceTemplates/CustomerLogos/index.js +3 -275
  27. package/dist/sliceTemplates/CustomerLogos/index.js.map +1 -1
  28. package/dist/sliceTemplates/Hero/index.cjs +4 -517
  29. package/dist/sliceTemplates/Hero/index.cjs.map +1 -1
  30. package/dist/sliceTemplates/Hero/index.d.ts +2 -3
  31. package/dist/sliceTemplates/Hero/index.js +4 -517
  32. package/dist/sliceTemplates/Hero/index.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/plugin.ts +22 -2
  35. package/src/sliceTemplates/AlternateGrid/index.ts +5 -510
  36. package/src/sliceTemplates/CallToAction/index.ts +4 -298
  37. package/src/sliceTemplates/CustomerLogos/index.ts +3 -282
  38. package/src/sliceTemplates/Hero/index.ts +4 -524
  39. package/dist/hooks/sliceTemplateLibrary-read.cjs +0 -39
  40. package/dist/hooks/sliceTemplateLibrary-read.cjs.map +0 -1
  41. package/dist/hooks/sliceTemplateLibrary-read.d.ts +0 -3
  42. package/dist/hooks/sliceTemplateLibrary-read.js +0 -39
  43. package/dist/hooks/sliceTemplateLibrary-read.js.map +0 -1
  44. package/src/hooks/sliceTemplateLibrary-read.ts +0 -59
@@ -1,9 +1,10 @@
1
1
  import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
2
  import { SharedSliceContent } from "@prismicio/types-internal/lib/content";
3
3
 
4
- import { pascalCase } from "../../lib/pascalCase";
5
-
6
- import { stripIndent } from "common-tags";
4
+ export const screenshotPaths = {
5
+ default: "Hero/screenshot-default.png",
6
+ imageRight: "Hero/screenshot-imageRight.png",
7
+ };
7
8
 
8
9
  export const mocks: SharedSliceContent[] = [
9
10
  {
@@ -169,522 +170,6 @@ export const mocks: SharedSliceContent[] = [
169
170
  },
170
171
  ];
171
172
 
172
- export const createComponentContents = (
173
- model: SharedSlice,
174
- isTypeScriptProject: boolean,
175
- ): string => {
176
- const pascalName = pascalCase(model.name);
177
-
178
- if (isTypeScriptProject) {
179
- return stripIndent`
180
- import { Content, isFilled } from "@prismicio/client";
181
- import { PrismicNextLink, PrismicNextImage } from "@prismicio/next";
182
- import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
183
-
184
- /**
185
- * Props for \`${pascalName}\`.
186
- */
187
- export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
188
-
189
- /**
190
- * Component for "${model.name}" Slices.
191
- */
192
- const ${pascalName} = ({ slice }: ${pascalName}Props): JSX.Element => {
193
- return (
194
- <section
195
- data-slice-type={slice.slice_type}
196
- data-slice-variation={slice.variation}
197
- className="es-bounded es-fullpage-hero"
198
- >
199
- <div
200
- className={\`
201
- es-bounded__content
202
- es-fullpage-hero__content
203
- \${slice.variation === "imageRight"
204
- ? "es-fullpage-hero__image--right"
205
- : "es-fullpage-hero__image--left"
206
- }
207
- \`}
208
- >
209
- <div>
210
- {isFilled.image(slice.primary.image) && (
211
- <PrismicNextImage
212
- field={slice.primary.image}
213
- className="es-fullpage-hero__image"
214
- />
215
- )}
216
- </div>
217
-
218
- <div className="es-fullpage-hero__content-right">
219
- <div className="es-fullpage-hero__content__intro">
220
- {isFilled.keyText(slice.primary.eyebrowHeadline) && (
221
- <p className="es-fullpage-hero__content__intro__eyebrow">
222
- {slice.primary.eyebrowHeadline}
223
- </p>
224
- )}
225
- {isFilled.richText(slice.primary.title) && (
226
- <div className="es-fullpage-hero__content__intro__headline">
227
- <PrismicRichText field={slice.primary.title} />
228
- </div>
229
- )}
230
- {isFilled.richText(slice.primary.description) && (
231
- <div className="es-fullpage-hero__content__intro__description">
232
- <PrismicRichText field={slice.primary.description} />
233
- </div>
234
- )}
235
- {isFilled.link(slice.primary.callToActionLink) && (
236
- <PrismicNextLink
237
- className="es-call-to-action__link"
238
- field={slice.primary.callToActionLink}
239
- >
240
- {slice.primary.callToActionLabel || "Learn more…"}
241
- </PrismicNextLink>
242
- )}
243
- </div>
244
- </div>
245
- </div>
246
- <style>
247
- {\`
248
- .es-bounded {
249
- margin: 0px;
250
- min-width: 0px;
251
- position: relative;
252
- }
253
-
254
- .es-bounded-content {
255
- min-width: 0px;
256
- max-width: 90%;
257
- margin: 0px auto;
258
- }
259
-
260
- .es-fullpage-hero {
261
- font-family: system-ui, sans-serif;
262
- background-color: #fff;
263
- color: #333;
264
- }
265
-
266
- .es-fullpage-hero__image {
267
- max-width: 100%;
268
- height: auto;
269
- align-self: center;
270
- }
271
-
272
- .es-fullpage-hero__image--left > div:first-child {
273
- order: 1;
274
- }
275
-
276
- .es-fullpage-hero__image--left > div:nth-child(2) {
277
- order: 2;
278
- }
279
-
280
- .es-fullpage-hero__image--right > div:first-child {
281
- order: 2;
282
- }
283
-
284
- .es-fullpage-hero__image--right > div:nth-child(2) {
285
- order: 1;
286
- }
287
-
288
- .es-fullpage-hero__content {
289
- display: flex;
290
- flex-direction: column;
291
- gap: 2rem;
292
- }
293
-
294
- .es-fullpage-hero__content-right {
295
- display: flex;
296
- flex-direction: column;
297
- justify-content: space-around;
298
- padding: 1.5rem;
299
- }
300
-
301
- @media (min-width: 1080px) {
302
- .es-fullpage-hero__content {
303
- flex-direction: row;
304
- }
305
-
306
- .es-fullpage-hero__content > div {
307
- width: 50%;
308
- }
309
- }
310
-
311
- .es-fullpage-hero__content-right__intro {
312
- margin-top: -2rem;
313
- display: grid;
314
- gap: 0.5rem;
315
- }
316
-
317
- .es-fullpage-hero__content__intro {
318
- display: grid;
319
- gap: 1rem;
320
- }
321
-
322
- .es-fullpage-hero__content__intro__eyebrow {
323
- color: #47C1AF;
324
- font-size: 1.15rem;
325
- font-weight: 500;
326
- margin: 0;
327
- }
328
-
329
- .es-fullpage-hero__content__intro__headline {
330
- font-size: 1.625rem;
331
- font-weight: 700;
332
- }
333
-
334
- .es-fullpage-hero__content__intro__headline > * {
335
- margin: 0;
336
- }
337
-
338
- @media (min-width: 640px) {
339
- .es-fullpage-hero__content__intro__headline {
340
- font-size: 2rem;
341
- }
342
- }
343
-
344
- @media (min-width: 1024px) {
345
- .es-fullpage-hero__content__intro__headline {
346
- font-size: 2.5rem;
347
- }
348
- }
349
-
350
- @media (min-width: 1200px) {
351
- .es-fullpage-hero__content__intro__headline {
352
- font-size: 2.75rem;
353
- }
354
- }
355
-
356
- .es-fullpage-hero__content__intro__description {
357
- font-size: 1.15rem;
358
- max-width: 38rem;
359
- }
360
-
361
- .es-fullpage-hero__content__intro__description > p {
362
- margin: 0;
363
- }
364
-
365
- @media (min-width: 1200px) {
366
- .es-fullpage-hero__content__intro__description {
367
- font-size: 1.4rem;
368
- }
369
- }
370
-
371
- .es-fullpage-hero__content__items {
372
- display: grid;
373
- gap: 2rem;
374
- }
375
-
376
- @media (min-width: 640px) {
377
- .es-fullpage-hero__content__items {
378
- grid-template-columns: repeat(2, 1fr);
379
- }
380
- }
381
-
382
- .es-fullpage-hero__item {
383
- display: grid;
384
- align-content: start;
385
- }
386
-
387
- .es-fullpage-hero__item__icon {
388
- max-height: 3rem;
389
- }
390
-
391
- .es-fullpage-hero__item__heading {
392
- font-weight: 700;
393
- font-size: 1.17rem;
394
- margin-top: 0;
395
- margin-bottom: .5rem;
396
- }
397
-
398
- .es-fullpage-hero__item__heading > * {
399
- margin: 0;
400
- }
401
-
402
- .es-fullpage-hero__item__description {
403
- font-size: 0.9rem;
404
- }
405
-
406
- .es-fullpage-hero__item__description > * {
407
- margin: 0;
408
- }
409
-
410
- .es-call-to-action__link {
411
- justify-self: flex-start;
412
- border-radius: 0.25rem;
413
- font-size: 0.875rem;
414
- line-height: 1.3;
415
- padding: 1rem 2.625rem;
416
- transition: background-color 100ms linear;
417
- background-color: #16745f;
418
- color: #fff;
419
- }
420
-
421
- .es-call-to-action__link:hover {
422
- background-color: #0d5e4c;
423
- }
424
- \`}
425
- </style>
426
- </section>
427
- );
428
- };
429
-
430
- export default ${pascalName};
431
-
432
- `;
433
- }
434
-
435
- return stripIndent`
436
- import { isFilled } from "@prismicio/client";
437
- import { PrismicNextLink, PrismicNextImage } from "@prismicio/next";
438
- import { PrismicRichText } from "@prismicio/react";
439
-
440
- /**
441
- * @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
442
- * @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
443
- * @param {${pascalName}Props}
444
- */
445
- const ${pascalName} = ({ slice }) => {
446
- return (
447
- <section
448
- data-slice-type={slice.slice_type}
449
- data-slice-variation={slice.variation}
450
- className="es-bounded es-fullpage-hero"
451
- >
452
- <div
453
- className={\`
454
- es-bounded__content
455
- es-fullpage-hero__content
456
- \${slice.variation === "imageRight"
457
- ? "es-fullpage-hero__image--right"
458
- : "es-fullpage-hero__image--left"
459
- }
460
- \`}
461
- >
462
- <div>
463
- {isFilled.image(slice.primary.image) && (
464
- <PrismicNextImage
465
- field={slice.primary.image}
466
- className="es-fullpage-hero__image"
467
- />
468
- )}
469
- </div>
470
-
471
- <div className="es-fullpage-hero__content-right">
472
- <div className="es-fullpage-hero__content__intro">
473
- {isFilled.keyText(slice.primary.eyebrowHeadline) && (
474
- <p className="es-fullpage-hero__content__intro__eyebrow">
475
- {slice.primary.eyebrowHeadline}
476
- </p>
477
- )}
478
- {isFilled.richText(slice.primary.title) && (
479
- <div className="es-fullpage-hero__content__intro__headline">
480
- <PrismicRichText field={slice.primary.title} />
481
- </div>
482
- )}
483
- {isFilled.richText(slice.primary.description) && (
484
- <div className="es-fullpage-hero__content__intro__description">
485
- <PrismicRichText field={slice.primary.description} />
486
- </div>
487
- )}
488
- {isFilled.link(slice.primary.callToActionLink) && (
489
- <PrismicNextLink
490
- className="es-call-to-action__link"
491
- field={slice.primary.callToActionLink}
492
- >
493
- {slice.primary.callToActionLabel || "Learn more…"}
494
- </PrismicNextLink>
495
- )}
496
- </div>
497
- </div>
498
- </div>
499
- <style>
500
- {\`
501
- .es-bounded {
502
- margin: 0px;
503
- min-width: 0px;
504
- position: relative;
505
- }
506
-
507
- .es-bounded-content {
508
- min-width: 0px;
509
- max-width: 90%;
510
- margin: 0px auto;
511
- }
512
-
513
- .es-fullpage-hero {
514
- font-family: system-ui, sans-serif;
515
- background-color: #fff;
516
- color: #333;
517
- }
518
-
519
- .es-fullpage-hero__image {
520
- max-width: 100%;
521
- height: auto;
522
- align-self: center;
523
- }
524
-
525
- .es-fullpage-hero__image--left > div:first-child {
526
- order: 1;
527
- }
528
-
529
- .es-fullpage-hero__image--left > div:nth-child(2) {
530
- order: 2;
531
- }
532
-
533
- .es-fullpage-hero__image--right > div:first-child {
534
- order: 2;
535
- }
536
-
537
- .es-fullpage-hero__image--right > div:nth-child(2) {
538
- order: 1;
539
- }
540
-
541
- .es-fullpage-hero__content {
542
- display: flex;
543
- flex-direction: column;
544
- gap: 2rem;
545
- }
546
-
547
- .es-fullpage-hero__content-right {
548
- display: flex;
549
- flex-direction: column;
550
- justify-content: space-around;
551
- padding: 1.5rem;
552
- }
553
-
554
- @media (min-width: 1080px) {
555
- .es-fullpage-hero__content {
556
- flex-direction: row;
557
- }
558
-
559
- .es-fullpage-hero__content > div {
560
- width: 50%;
561
- }
562
- }
563
-
564
- .es-fullpage-hero__content-right__intro {
565
- margin-top: -2rem;
566
- display: grid;
567
- gap: 0.5rem;
568
- }
569
-
570
- .es-fullpage-hero__content__intro {
571
- display: grid;
572
- gap: 1rem;
573
- }
574
-
575
- .es-fullpage-hero__content__intro__eyebrow {
576
- color: #47C1AF;
577
- font-size: 1.15rem;
578
- font-weight: 500;
579
- margin: 0;
580
- }
581
-
582
- .es-fullpage-hero__content__intro__headline {
583
- font-size: 1.625rem;
584
- font-weight: 700;
585
- }
586
-
587
- .es-fullpage-hero__content__intro__headline > * {
588
- margin: 0;
589
- }
590
-
591
- @media (min-width: 640px) {
592
- .es-fullpage-hero__content__intro__headline {
593
- font-size: 2rem;
594
- }
595
- }
596
-
597
- @media (min-width: 1024px) {
598
- .es-fullpage-hero__content__intro__headline {
599
- font-size: 2.5rem;
600
- }
601
- }
602
-
603
- @media (min-width: 1200px) {
604
- .es-fullpage-hero__content__intro__headline {
605
- font-size: 2.75rem;
606
- }
607
- }
608
-
609
- .es-fullpage-hero__content__intro__description {
610
- font-size: 1.15rem;
611
- max-width: 38rem;
612
- }
613
-
614
- .es-fullpage-hero__content__intro__description > p {
615
- margin: 0;
616
- }
617
-
618
- @media (min-width: 1200px) {
619
- .es-fullpage-hero__content__intro__description {
620
- font-size: 1.4rem;
621
- }
622
- }
623
-
624
- .es-fullpage-hero__content__items {
625
- display: grid;
626
- gap: 2rem;
627
- }
628
-
629
- @media (min-width: 640px) {
630
- .es-fullpage-hero__content__items {
631
- grid-template-columns: repeat(2, 1fr);
632
- }
633
- }
634
-
635
- .es-fullpage-hero__item {
636
- display: grid;
637
- align-content: start;
638
- }
639
-
640
- .es-fullpage-hero__item__icon {
641
- max-height: 3rem;
642
- }
643
-
644
- .es-fullpage-hero__item__heading {
645
- font-weight: 700;
646
- font-size: 1.17rem;
647
- margin-top: 0;
648
- margin-bottom: .5rem;
649
- }
650
-
651
- .es-fullpage-hero__item__heading > * {
652
- margin: 0;
653
- }
654
-
655
- .es-fullpage-hero__item__description {
656
- font-size: 0.9rem;
657
- }
658
-
659
- .es-fullpage-hero__item__description > * {
660
- margin: 0;
661
- }
662
-
663
- .es-call-to-action__link {
664
- justify-self: flex-start;
665
- border-radius: 0.25rem;
666
- font-size: 0.875rem;
667
- line-height: 1.3;
668
- padding: 1rem 2.625rem;
669
- transition: background-color 100ms linear;
670
- background-color: #16745f;
671
- color: #fff;
672
- }
673
-
674
- .es-call-to-action__link:hover {
675
- background-color: #0d5e4c;
676
- }
677
- \`}
678
- </style>
679
- </section>
680
- );
681
- };
682
-
683
- export default ${pascalName};
684
-
685
- `;
686
- };
687
-
688
173
  export const model: SharedSlice = {
689
174
  id: "hero",
690
175
  type: "SharedSlice",
@@ -815,8 +300,3 @@ export const model: SharedSlice = {
815
300
  },
816
301
  ],
817
302
  };
818
-
819
- export const screenshotPaths = {
820
- default: "Hero/screenshot-default.png",
821
- imageRight: "Hero/screenshot-imageRight.png",
822
- };
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const path = require("node:path");
5
- const node_url = require("node:url");
6
- const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
7
- const index = require("../sliceTemplates/Hero/index.cjs");
8
- const index$1 = require("../sliceTemplates/CallToAction/index.cjs");
9
- const index$2 = require("../sliceTemplates/AlternateGrid/index.cjs");
10
- const index$3 = require("../sliceTemplates/CustomerLogos/index.cjs");
11
- const initialTemplates = [index, index$1, index$2, index$3];
12
- const sliceTemplateLibraryRead = async ({ templateIDs }, { helpers, options }) => {
13
- const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
14
- helpers,
15
- options
16
- });
17
- const templates = templateIDs && templateIDs.length ? initialTemplates.filter((t) => templateIDs == null ? void 0 : templateIDs.includes(t.model.id)) : initialTemplates;
18
- const templatesPromises = templates.map(async (t) => {
19
- const { mocks, model, createComponentContents, screenshotPaths } = t;
20
- const screenshotEntries = Object.entries(screenshotPaths);
21
- const screenshotPromises = screenshotEntries.map(([key, filePath]) => {
22
- return fs.readFile(node_url.fileURLToPath(new URL(path.join("..", filePath), typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : document.currentScript && document.currentScript.src || new URL("hooks/sliceTemplateLibrary-read.cjs", document.baseURI).href))).then((data) => [key, data]);
23
- });
24
- const readScreenshots = await Promise.all(screenshotPromises);
25
- const screenshots = Object.fromEntries(readScreenshots);
26
- return {
27
- mocks,
28
- model,
29
- createComponentContents: (model2) => createComponentContents(model2, isTypeScriptProject),
30
- screenshots
31
- };
32
- });
33
- const resolvedTemplates = await Promise.all(templatesPromises);
34
- return {
35
- templates: resolvedTemplates
36
- };
37
- };
38
- exports.sliceTemplateLibraryRead = sliceTemplateLibraryRead;
39
- //# sourceMappingURL=sliceTemplateLibrary-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sliceTemplateLibrary-read.cjs","sources":["../../../src/hooks/sliceTemplateLibrary-read.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport type { SliceTemplateLibraryReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport * as Hero from \"../sliceTemplates/Hero\";\nimport * as CallToAction from \"../sliceTemplates/CallToAction\";\nimport * as AlternateGrid from \"../sliceTemplates/AlternateGrid\";\nimport * as CustomerLogos from \"../sliceTemplates/CustomerLogos\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst initialTemplates = [Hero, CallToAction, AlternateGrid, CustomerLogos];\n\nexport const sliceTemplateLibraryRead: SliceTemplateLibraryReadHook<\n\tPluginOptions\n> = async ({ templateIDs }, { helpers, options }) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst templates =\n\t\ttemplateIDs && templateIDs.length\n\t\t\t? initialTemplates.filter((t) => templateIDs?.includes(t.model.id))\n\t\t\t: initialTemplates;\n\n\tconst templatesPromises = templates.map(async (t) => {\n\t\tconst { mocks, model, createComponentContents, screenshotPaths } = t;\n\n\t\tconst screenshotEntries = Object.entries(screenshotPaths);\n\t\tconst screenshotPromises = screenshotEntries.map(([key, filePath]) => {\n\t\t\treturn fs\n\t\t\t\t.readFile(\n\t\t\t\t\tfileURLToPath(new URL(path.join(\"..\", filePath), import.meta.url)),\n\t\t\t\t)\n\t\t\t\t.then((data) => [key, data]);\n\t\t});\n\t\tconst readScreenshots = await Promise.all(screenshotPromises);\n\t\tconst screenshots = Object.fromEntries(readScreenshots);\n\n\t\treturn {\n\t\t\tmocks,\n\t\t\tmodel,\n\t\t\tcreateComponentContents: (model: SharedSlice) =>\n\t\t\t\tcreateComponentContents(model, isTypeScriptProject),\n\t\t\tscreenshots,\n\t\t};\n\t});\n\n\tconst resolvedTemplates = await Promise.all(templatesPromises);\n\n\treturn {\n\t\ttemplates: resolvedTemplates,\n\t};\n};\n"],"names":["Hero","CallToAction","AlternateGrid","CustomerLogos","checkIsTypeScriptProject","fileURLToPath","model"],"mappings":";;;;;;;;;;AAgBA,MAAM,mBAAmB,CAACA,OAAMC,SAAcC,SAAeC,OAAa;AAE7D,MAAA,2BAET,OAAO,EAAE,YAAA,GAAe,EAAE,SAAS,cAAa;AAC7C,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,YACL,eAAe,YAAY,SACxB,iBAAiB,OAAO,CAAC,MAAM,2CAAa,SAAS,EAAE,MAAM,GAAG,IAChE;AAEJ,QAAM,oBAAoB,UAAU,IAAI,OAAO,MAAK;AACnD,UAAM,EAAE,OAAO,OAAO,yBAAyB,oBAAoB;AAE7D,UAAA,oBAAoB,OAAO,QAAQ,eAAe;AACxD,UAAM,qBAAqB,kBAAkB,IAAI,CAAC,CAAC,KAAK,QAAQ,MAAK;AAC7D,aAAA,GACL,SACAC,SAAc,cAAA,IAAI,IAAI,KAAK,KAAK,MAAM,QAAQ,kNAAkB,CAAC,CAAC,EAElE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AAAA,IAAA,CAC5B;AACD,UAAM,kBAAkB,MAAM,QAAQ,IAAI,kBAAkB;AACtD,UAAA,cAAc,OAAO,YAAY,eAAe;AAE/C,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,yBAAyB,CAACC,WACzB,wBAAwBA,QAAO,mBAAmB;AAAA,MACnD;AAAA,IAAA;AAAA,GAED;AAED,QAAM,oBAAoB,MAAM,QAAQ,IAAI,iBAAiB;AAEtD,SAAA;AAAA,IACN,WAAW;AAAA,EAAA;AAEb;;"}
@@ -1,3 +0,0 @@
1
- import type { SliceTemplateLibraryReadHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const sliceTemplateLibraryRead: SliceTemplateLibraryReadHook<PluginOptions>;
@@ -1,39 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path__default from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
5
- import * as index from "../sliceTemplates/Hero/index.js";
6
- import * as index$1 from "../sliceTemplates/CallToAction/index.js";
7
- import * as index$2 from "../sliceTemplates/AlternateGrid/index.js";
8
- import * as index$3 from "../sliceTemplates/CustomerLogos/index.js";
9
- const initialTemplates = [index, index$1, index$2, index$3];
10
- const sliceTemplateLibraryRead = async ({ templateIDs }, { helpers, options }) => {
11
- const isTypeScriptProject = await checkIsTypeScriptProject({
12
- helpers,
13
- options
14
- });
15
- const templates = templateIDs && templateIDs.length ? initialTemplates.filter((t) => templateIDs == null ? void 0 : templateIDs.includes(t.model.id)) : initialTemplates;
16
- const templatesPromises = templates.map(async (t) => {
17
- const { mocks, model, createComponentContents, screenshotPaths } = t;
18
- const screenshotEntries = Object.entries(screenshotPaths);
19
- const screenshotPromises = screenshotEntries.map(([key, filePath]) => {
20
- return fs.readFile(fileURLToPath(new URL(path__default.join("..", filePath), import.meta.url))).then((data) => [key, data]);
21
- });
22
- const readScreenshots = await Promise.all(screenshotPromises);
23
- const screenshots = Object.fromEntries(readScreenshots);
24
- return {
25
- mocks,
26
- model,
27
- createComponentContents: (model2) => createComponentContents(model2, isTypeScriptProject),
28
- screenshots
29
- };
30
- });
31
- const resolvedTemplates = await Promise.all(templatesPromises);
32
- return {
33
- templates: resolvedTemplates
34
- };
35
- };
36
- export {
37
- sliceTemplateLibraryRead
38
- };
39
- //# sourceMappingURL=sliceTemplateLibrary-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sliceTemplateLibrary-read.js","sources":["../../../src/hooks/sliceTemplateLibrary-read.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { SharedSlice } from \"@prismicio/types-internal/lib/customtypes\";\nimport type { SliceTemplateLibraryReadHook } from \"@slicemachine/plugin-kit\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\n\nimport * as Hero from \"../sliceTemplates/Hero\";\nimport * as CallToAction from \"../sliceTemplates/CallToAction\";\nimport * as AlternateGrid from \"../sliceTemplates/AlternateGrid\";\nimport * as CustomerLogos from \"../sliceTemplates/CustomerLogos\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst initialTemplates = [Hero, CallToAction, AlternateGrid, CustomerLogos];\n\nexport const sliceTemplateLibraryRead: SliceTemplateLibraryReadHook<\n\tPluginOptions\n> = async ({ templateIDs }, { helpers, options }) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst templates =\n\t\ttemplateIDs && templateIDs.length\n\t\t\t? initialTemplates.filter((t) => templateIDs?.includes(t.model.id))\n\t\t\t: initialTemplates;\n\n\tconst templatesPromises = templates.map(async (t) => {\n\t\tconst { mocks, model, createComponentContents, screenshotPaths } = t;\n\n\t\tconst screenshotEntries = Object.entries(screenshotPaths);\n\t\tconst screenshotPromises = screenshotEntries.map(([key, filePath]) => {\n\t\t\treturn fs\n\t\t\t\t.readFile(\n\t\t\t\t\tfileURLToPath(new URL(path.join(\"..\", filePath), import.meta.url)),\n\t\t\t\t)\n\t\t\t\t.then((data) => [key, data]);\n\t\t});\n\t\tconst readScreenshots = await Promise.all(screenshotPromises);\n\t\tconst screenshots = Object.fromEntries(readScreenshots);\n\n\t\treturn {\n\t\t\tmocks,\n\t\t\tmodel,\n\t\t\tcreateComponentContents: (model: SharedSlice) =>\n\t\t\t\tcreateComponentContents(model, isTypeScriptProject),\n\t\t\tscreenshots,\n\t\t};\n\t});\n\n\tconst resolvedTemplates = await Promise.all(templatesPromises);\n\n\treturn {\n\t\ttemplates: resolvedTemplates,\n\t};\n};\n"],"names":["Hero","CallToAction","AlternateGrid","CustomerLogos","path","model"],"mappings":";;;;;;;;AAgBA,MAAM,mBAAmB,CAACA,OAAMC,SAAcC,SAAeC,OAAa;AAE7D,MAAA,2BAET,OAAO,EAAE,YAAA,GAAe,EAAE,SAAS,cAAa;AAC7C,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,YACL,eAAe,YAAY,SACxB,iBAAiB,OAAO,CAAC,MAAM,2CAAa,SAAS,EAAE,MAAM,GAAG,IAChE;AAEJ,QAAM,oBAAoB,UAAU,IAAI,OAAO,MAAK;AACnD,UAAM,EAAE,OAAO,OAAO,yBAAyB,oBAAoB;AAE7D,UAAA,oBAAoB,OAAO,QAAQ,eAAe;AACxD,UAAM,qBAAqB,kBAAkB,IAAI,CAAC,CAAC,KAAK,QAAQ,MAAK;AAC7D,aAAA,GACL,SACA,cAAc,IAAI,IAAIC,cAAK,KAAK,MAAM,QAAQ,GAAG,YAAY,GAAG,CAAC,CAAC,EAElE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AAAA,IAAA,CAC5B;AACD,UAAM,kBAAkB,MAAM,QAAQ,IAAI,kBAAkB;AACtD,UAAA,cAAc,OAAO,YAAY,eAAe;AAE/C,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA,yBAAyB,CAACC,WACzB,wBAAwBA,QAAO,mBAAmB;AAAA,MACnD;AAAA,IAAA;AAAA,GAED;AAED,QAAM,oBAAoB,MAAM,QAAQ,IAAI,iBAAiB;AAEtD,SAAA;AAAA,IACN,WAAW;AAAA,EAAA;AAEb;"}
@@ -1,59 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
6
- import type { SliceTemplateLibraryReadHook } from "@slicemachine/plugin-kit";
7
-
8
- import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
9
-
10
- import * as Hero from "../sliceTemplates/Hero";
11
- import * as CallToAction from "../sliceTemplates/CallToAction";
12
- import * as AlternateGrid from "../sliceTemplates/AlternateGrid";
13
- import * as CustomerLogos from "../sliceTemplates/CustomerLogos";
14
-
15
- import type { PluginOptions } from "../types";
16
-
17
- const initialTemplates = [Hero, CallToAction, AlternateGrid, CustomerLogos];
18
-
19
- export const sliceTemplateLibraryRead: SliceTemplateLibraryReadHook<
20
- PluginOptions
21
- > = async ({ templateIDs }, { helpers, options }) => {
22
- const isTypeScriptProject = await checkIsTypeScriptProject({
23
- helpers,
24
- options,
25
- });
26
- const templates =
27
- templateIDs && templateIDs.length
28
- ? initialTemplates.filter((t) => templateIDs?.includes(t.model.id))
29
- : initialTemplates;
30
-
31
- const templatesPromises = templates.map(async (t) => {
32
- const { mocks, model, createComponentContents, screenshotPaths } = t;
33
-
34
- const screenshotEntries = Object.entries(screenshotPaths);
35
- const screenshotPromises = screenshotEntries.map(([key, filePath]) => {
36
- return fs
37
- .readFile(
38
- fileURLToPath(new URL(path.join("..", filePath), import.meta.url)),
39
- )
40
- .then((data) => [key, data]);
41
- });
42
- const readScreenshots = await Promise.all(screenshotPromises);
43
- const screenshots = Object.fromEntries(readScreenshots);
44
-
45
- return {
46
- mocks,
47
- model,
48
- createComponentContents: (model: SharedSlice) =>
49
- createComponentContents(model, isTypeScriptProject),
50
- screenshots,
51
- };
52
- });
53
-
54
- const resolvedTemplates = await Promise.all(templatesPromises);
55
-
56
- return {
57
- templates: resolvedTemplates,
58
- };
59
- };