vite-plugin-react-deck 1.10.0 → 1.11.0

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/index.cjs CHANGED
@@ -478,7 +478,7 @@ var import_mdx = require("@mdx-js/mdx");
478
478
  var import_gray_matter = __toESM(require("gray-matter"), 1);
479
479
  var import_remark_directive = __toESM(require("remark-directive"), 1);
480
480
  var import_remark_gfm = __toESM(require("remark-gfm"), 1);
481
- var import_unist_util_visit = require("unist-util-visit");
481
+ var import_unist_util_visit2 = require("unist-util-visit");
482
482
 
483
483
  // src/codegen.ts
484
484
  var Patterns = {
@@ -515,6 +515,35 @@ ${header}
515
515
  `.trim();
516
516
  }
517
517
 
518
+ // src/remark-morph.ts
519
+ var import_unist_util_visit = require("unist-util-visit");
520
+ var MORPH_EXPR_RE = /^morph\s*=\s*"([^"]+)"$/;
521
+ function remarkMorph() {
522
+ return (tree) => {
523
+ (0, import_unist_util_visit.visit)(tree, "mdxTextExpression", (node, index, parent) => {
524
+ if (!parent || index == null) return;
525
+ const match = node.value.match(MORPH_EXPR_RE);
526
+ if (!match) return;
527
+ const morphName = match[1];
528
+ parent.children.splice(index, 1);
529
+ if (index > 0) {
530
+ const prev = parent.children[index - 1];
531
+ if (prev.type === "text") {
532
+ prev.value = prev.value.replace(/\s+$/, "");
533
+ }
534
+ }
535
+ if (!parent.data) {
536
+ parent.data = {};
537
+ }
538
+ if (!parent.data.hProperties) {
539
+ parent.data.hProperties = {};
540
+ }
541
+ parent.data.hProperties.morph = morphName;
542
+ return [import_unist_util_visit.SKIP, index];
543
+ });
544
+ };
545
+ }
546
+
518
547
  // src/slides.ts
519
548
  var INCLUDE_RE = /^::include\{file=(.+?)\}\s*$/gm;
520
549
  function resolveIncludes(content, filePath, { maxDepth = 10, _depth = 0 } = {}) {
@@ -551,7 +580,7 @@ function resolveIncludes(content, filePath, { maxDepth = 10, _depth = 0 } = {})
551
580
  }
552
581
  function myRemarkPlugin() {
553
582
  return (tree) => {
554
- (0, import_unist_util_visit.visit)(tree, (node) => {
583
+ (0, import_unist_util_visit2.visit)(tree, (node) => {
555
584
  if (node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective") {
556
585
  if (!node.data) {
557
586
  node.data = {};
@@ -609,6 +638,7 @@ ${slide}
609
638
  import_remark_gfm.default,
610
639
  import_remark_directive.default,
611
640
  myRemarkPlugin,
641
+ remarkMorph,
612
642
  ...options.remarkPlugins
613
643
  ]
614
644
  });
package/index.mjs CHANGED
@@ -457,7 +457,7 @@ import { compile } from "@mdx-js/mdx";
457
457
  import matter from "gray-matter";
458
458
  import remarkDirective from "remark-directive";
459
459
  import remarkGfm from "remark-gfm";
460
- import { visit } from "unist-util-visit";
460
+ import { visit as visit2 } from "unist-util-visit";
461
461
 
462
462
  // src/codegen.ts
463
463
  var Patterns = {
@@ -494,6 +494,35 @@ ${header}
494
494
  `.trim();
495
495
  }
496
496
 
497
+ // src/remark-morph.ts
498
+ import { SKIP, visit } from "unist-util-visit";
499
+ var MORPH_EXPR_RE = /^morph\s*=\s*"([^"]+)"$/;
500
+ function remarkMorph() {
501
+ return (tree) => {
502
+ visit(tree, "mdxTextExpression", (node, index, parent) => {
503
+ if (!parent || index == null) return;
504
+ const match = node.value.match(MORPH_EXPR_RE);
505
+ if (!match) return;
506
+ const morphName = match[1];
507
+ parent.children.splice(index, 1);
508
+ if (index > 0) {
509
+ const prev = parent.children[index - 1];
510
+ if (prev.type === "text") {
511
+ prev.value = prev.value.replace(/\s+$/, "");
512
+ }
513
+ }
514
+ if (!parent.data) {
515
+ parent.data = {};
516
+ }
517
+ if (!parent.data.hProperties) {
518
+ parent.data.hProperties = {};
519
+ }
520
+ parent.data.hProperties.morph = morphName;
521
+ return [SKIP, index];
522
+ });
523
+ };
524
+ }
525
+
497
526
  // src/slides.ts
498
527
  var INCLUDE_RE = /^::include\{file=(.+?)\}\s*$/gm;
499
528
  function resolveIncludes(content, filePath, { maxDepth = 10, _depth = 0 } = {}) {
@@ -530,7 +559,7 @@ function resolveIncludes(content, filePath, { maxDepth = 10, _depth = 0 } = {})
530
559
  }
531
560
  function myRemarkPlugin() {
532
561
  return (tree) => {
533
- visit(tree, (node) => {
562
+ visit2(tree, (node) => {
534
563
  if (node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective") {
535
564
  if (!node.data) {
536
565
  node.data = {};
@@ -588,6 +617,7 @@ ${slide}
588
617
  remarkGfm,
589
618
  remarkDirective,
590
619
  myRemarkPlugin,
620
+ remarkMorph,
591
621
  ...options.remarkPlugins
592
622
  ]
593
623
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-deck",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.cjs",
@@ -0,0 +1 @@
1
+ export declare function remarkMorph(): (tree: any) => void;