vite-plugin-react-deck 1.4.0 → 1.5.2
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.
- package/helpers.d.ts +1 -0
- package/index.cjs +10 -6
- package/index.mjs +10 -6
- package/package.json +1 -1
- package/types.d.ts +10 -0
package/helpers.d.ts
CHANGED
package/index.cjs
CHANGED
|
@@ -413,7 +413,7 @@ const root = ReactDOM.createRoot(
|
|
|
413
413
|
);
|
|
414
414
|
root.render(
|
|
415
415
|
<StrictMode>
|
|
416
|
-
<Deck deck={deck} theme={theme} layouts={layouts} />
|
|
416
|
+
<Deck deck={deck} theme={theme} layouts={layouts}${config.transition ? ` transition="${config.transition}"` : ""} />
|
|
417
417
|
</StrictMode>
|
|
418
418
|
)
|
|
419
419
|
|
|
@@ -435,7 +435,7 @@ var import_unist_util_visit = require("unist-util-visit");
|
|
|
435
435
|
|
|
436
436
|
// src/codegen.ts
|
|
437
437
|
var Patterns = {
|
|
438
|
-
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\)
|
|
438
|
+
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\);$/g,
|
|
439
439
|
FragmentDev: /^\s*<>\s*|\s*<\/>;\s*$/g
|
|
440
440
|
};
|
|
441
441
|
function extractMainCodeAsChildren(source, { isJsx }) {
|
|
@@ -495,10 +495,9 @@ async function transformSlidesMdxToReact(sourceContent, {
|
|
|
495
495
|
);
|
|
496
496
|
const slides = finalContent.split("---\n");
|
|
497
497
|
const enrichedSlides = [];
|
|
498
|
-
const LAYOUT_REGEX = /\S*\nlayout: (.*)/g;
|
|
499
498
|
let frontmatterForNextSlide = null;
|
|
500
499
|
for (const slide of slides) {
|
|
501
|
-
if (
|
|
500
|
+
if (isFrontmatterBlock(slide)) {
|
|
502
501
|
frontmatterForNextSlide = (0, import_gray_matter.default)(`---
|
|
503
502
|
${slide}
|
|
504
503
|
---`).data;
|
|
@@ -587,6 +586,10 @@ ${[...inlineModules.keys()].join("\n")}
|
|
|
587
586
|
${source}
|
|
588
587
|
`;
|
|
589
588
|
}
|
|
589
|
+
function isFrontmatterBlock(text) {
|
|
590
|
+
const lines = text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
591
|
+
return lines.length > 0 && lines.every((l) => /^[\w][\w-]*\s*:/.test(l));
|
|
592
|
+
}
|
|
590
593
|
var CRLF = "\r\n";
|
|
591
594
|
function normalizeNewline(input) {
|
|
592
595
|
return input.replace(new RegExp(CRLF, "g"), "\n");
|
|
@@ -599,7 +602,8 @@ var import_lodash = __toESM(require("lodash"), 1);
|
|
|
599
602
|
var import_zod = require("zod");
|
|
600
603
|
var PestacleConfigSchema = import_zod.z.object({
|
|
601
604
|
theme: import_zod.z.enum(["green", "purple", "solarized-light"]).default("green"),
|
|
602
|
-
startupPage: import_zod.z.boolean().optional()
|
|
605
|
+
startupPage: import_zod.z.boolean().optional(),
|
|
606
|
+
transition: import_zod.z.enum(["fade", "slide", "drop", "none"]).optional()
|
|
603
607
|
});
|
|
604
608
|
|
|
605
609
|
// src/index.ts
|
|
@@ -771,7 +775,7 @@ var src_default = async (options) => {
|
|
|
771
775
|
slidePath: `${directory}/deck.mdx`,
|
|
772
776
|
theme: options.theme,
|
|
773
777
|
deckTheme,
|
|
774
|
-
config
|
|
778
|
+
config: { ...config, transition: options.transition }
|
|
775
779
|
});
|
|
776
780
|
return contentIndex;
|
|
777
781
|
}
|
package/index.mjs
CHANGED
|
@@ -392,7 +392,7 @@ const root = ReactDOM.createRoot(
|
|
|
392
392
|
);
|
|
393
393
|
root.render(
|
|
394
394
|
<StrictMode>
|
|
395
|
-
<Deck deck={deck} theme={theme} layouts={layouts} />
|
|
395
|
+
<Deck deck={deck} theme={theme} layouts={layouts}${config.transition ? ` transition="${config.transition}"` : ""} />
|
|
396
396
|
</StrictMode>
|
|
397
397
|
)
|
|
398
398
|
|
|
@@ -414,7 +414,7 @@ import { visit } from "unist-util-visit";
|
|
|
414
414
|
|
|
415
415
|
// src/codegen.ts
|
|
416
416
|
var Patterns = {
|
|
417
|
-
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\)
|
|
417
|
+
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\);$/g,
|
|
418
418
|
FragmentDev: /^\s*<>\s*|\s*<\/>;\s*$/g
|
|
419
419
|
};
|
|
420
420
|
function extractMainCodeAsChildren(source, { isJsx }) {
|
|
@@ -474,10 +474,9 @@ async function transformSlidesMdxToReact(sourceContent, {
|
|
|
474
474
|
);
|
|
475
475
|
const slides = finalContent.split("---\n");
|
|
476
476
|
const enrichedSlides = [];
|
|
477
|
-
const LAYOUT_REGEX = /\S*\nlayout: (.*)/g;
|
|
478
477
|
let frontmatterForNextSlide = null;
|
|
479
478
|
for (const slide of slides) {
|
|
480
|
-
if (
|
|
479
|
+
if (isFrontmatterBlock(slide)) {
|
|
481
480
|
frontmatterForNextSlide = matter(`---
|
|
482
481
|
${slide}
|
|
483
482
|
---`).data;
|
|
@@ -566,6 +565,10 @@ ${[...inlineModules.keys()].join("\n")}
|
|
|
566
565
|
${source}
|
|
567
566
|
`;
|
|
568
567
|
}
|
|
568
|
+
function isFrontmatterBlock(text) {
|
|
569
|
+
const lines = text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
570
|
+
return lines.length > 0 && lines.every((l) => /^[\w][\w-]*\s*:/.test(l));
|
|
571
|
+
}
|
|
569
572
|
var CRLF = "\r\n";
|
|
570
573
|
function normalizeNewline(input) {
|
|
571
574
|
return input.replace(new RegExp(CRLF, "g"), "\n");
|
|
@@ -578,7 +581,8 @@ import _ from "lodash";
|
|
|
578
581
|
import { z } from "zod";
|
|
579
582
|
var PestacleConfigSchema = z.object({
|
|
580
583
|
theme: z.enum(["green", "purple", "solarized-light"]).default("green"),
|
|
581
|
-
startupPage: z.boolean().optional()
|
|
584
|
+
startupPage: z.boolean().optional(),
|
|
585
|
+
transition: z.enum(["fade", "slide", "drop", "none"]).optional()
|
|
582
586
|
});
|
|
583
587
|
|
|
584
588
|
// src/config.ts
|
|
@@ -755,7 +759,7 @@ var index_default = async (options) => {
|
|
|
755
759
|
slidePath: `${directory}/deck.mdx`,
|
|
756
760
|
theme: options.theme,
|
|
757
761
|
deckTheme,
|
|
758
|
-
config
|
|
762
|
+
config: { ...config, transition: options.transition }
|
|
759
763
|
});
|
|
760
764
|
return contentIndex;
|
|
761
765
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export declare const TransitionNames: readonly ["fade", "slide", "drop", "none"];
|
|
3
|
+
export type TransitionName = (typeof TransitionNames)[number];
|
|
2
4
|
export interface ReactDeckOptions {
|
|
3
5
|
rehypePlugins: any[];
|
|
4
6
|
remarkPlugins: any[];
|
|
5
7
|
theme: "green" | "purple" | "solarized-light";
|
|
6
8
|
/** Show the talks listing page. Defaults to true in dev, false in production. */
|
|
7
9
|
startupPage?: boolean;
|
|
10
|
+
/** Default slide transition. */
|
|
11
|
+
transition?: TransitionName;
|
|
8
12
|
}
|
|
9
13
|
export declare const PestacleConfigSchema: z.ZodObject<{
|
|
10
14
|
theme: z.ZodDefault<z.ZodEnum<{
|
|
@@ -13,5 +17,11 @@ export declare const PestacleConfigSchema: z.ZodObject<{
|
|
|
13
17
|
"solarized-light": "solarized-light";
|
|
14
18
|
}>>;
|
|
15
19
|
startupPage: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
transition: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
fade: "fade";
|
|
22
|
+
slide: "slide";
|
|
23
|
+
drop: "drop";
|
|
24
|
+
none: "none";
|
|
25
|
+
}>>;
|
|
16
26
|
}, z.core.$strip>;
|
|
17
27
|
export type PestacleConfig = z.infer<typeof PestacleConfigSchema>;
|