@intlayer/design-system 6.1.4 → 6.1.5

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 (27) hide show
  1. package/dist/.vite/manifest.json +6 -5
  2. package/dist/components/IDE/MarkDownRender.cjs +2 -2
  3. package/dist/components/IDE/MarkDownRender.cjs.map +1 -1
  4. package/dist/components/IDE/MarkDownRender.d.ts.map +1 -1
  5. package/dist/components/IDE/MarkDownRender.mjs +2 -2
  6. package/dist/components/IDE/MarkDownRender.mjs.map +1 -1
  7. package/dist/components/MarkDownRender/MarkDownRender.cjs +4 -3
  8. package/dist/components/MarkDownRender/MarkDownRender.cjs.map +1 -1
  9. package/dist/components/MarkDownRender/MarkDownRender.d.ts +1 -1
  10. package/dist/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
  11. package/dist/components/MarkDownRender/MarkDownRender.mjs +3 -2
  12. package/dist/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
  13. package/dist/components/MarkDownRender/{processer.cjs → processor.cjs} +307 -107
  14. package/dist/components/MarkDownRender/processor.cjs.map +1 -0
  15. package/dist/components/MarkDownRender/{processer.d.ts → processor.d.ts} +1 -1
  16. package/dist/components/MarkDownRender/processor.d.ts.map +1 -0
  17. package/dist/components/MarkDownRender/{processer.mjs → processor.mjs} +307 -107
  18. package/dist/components/MarkDownRender/processor.mjs.map +1 -0
  19. package/dist/hooks/useHorizontalSwipe.cjs +4 -4
  20. package/dist/hooks/useHorizontalSwipe.cjs.map +1 -1
  21. package/dist/hooks/useHorizontalSwipe.d.ts.map +1 -1
  22. package/dist/hooks/useHorizontalSwipe.mjs +4 -4
  23. package/dist/hooks/useHorizontalSwipe.mjs.map +1 -1
  24. package/package.json +18 -19
  25. package/dist/components/MarkDownRender/processer.cjs.map +0 -1
  26. package/dist/components/MarkDownRender/processer.d.ts.map +0 -1
  27. package/dist/components/MarkDownRender/processer.mjs.map +0 -1
@@ -351,6 +351,7 @@ const parseTableAlignCapture = (alignCapture) => {
351
351
  return "left";
352
352
  };
353
353
  const parseTableRow = (source, parse, state, tableOutput) => {
354
+ const start = performance.now();
354
355
  const prevInTable = state.inTable;
355
356
  state.inTable = true;
356
357
  let cells = [[]];
@@ -375,6 +376,12 @@ const parseTableRow = (source, parse, state, tableOutput) => {
375
376
  });
376
377
  flush();
377
378
  state.inTable = prevInTable;
379
+ const duration = performance.now() - start;
380
+ if (duration > 1) {
381
+ console.log(
382
+ `parseTableRow: ${duration.toFixed(3)}ms, source length: ${source.length}, cells count: ${cells.length}`
383
+ );
384
+ }
378
385
  return cells;
379
386
  };
380
387
  const parseTableAlign = (source) => {
@@ -382,10 +389,18 @@ const parseTableAlign = (source) => {
382
389
  return alignText.map(parseTableAlignCapture);
383
390
  };
384
391
  const parseTableCells = (source, parse, state) => {
392
+ const start = performance.now();
385
393
  const rowsText = source.trim().split("\n");
386
- return rowsText.map((rowText) => {
394
+ const result = rowsText.map((rowText) => {
387
395
  return parseTableRow(rowText, parse, state, true);
388
396
  });
397
+ const duration = performance.now() - start;
398
+ if (duration > 1) {
399
+ console.log(
400
+ `parseTableCells: ${duration.toFixed(3)}ms, source length: ${source.length}, rows count: ${rowsText.length}`
401
+ );
402
+ }
403
+ return result;
389
404
  };
390
405
  const parseTable = (capture, parse, state) => {
391
406
  state.inline = true;
@@ -416,6 +431,7 @@ const normalizeAttributeKey = (key) => {
416
431
  return key;
417
432
  };
418
433
  const parseStyleAttribute = (styleString) => {
434
+ const start = performance.now();
419
435
  const styles = [];
420
436
  let buffer = "";
421
437
  let inUrl = false;
@@ -462,9 +478,16 @@ const parseStyleAttribute = (styleString) => {
462
478
  styles.push([key, value]);
463
479
  }
464
480
  }
481
+ const duration = performance.now() - start;
482
+ if (duration > 1) {
483
+ console.log(
484
+ `parseStyleAttribute: ${duration.toFixed(3)}ms, styleString length: ${styleString.length}, styles count: ${styles.length}`
485
+ );
486
+ }
465
487
  return styles;
466
488
  };
467
489
  const trimLeadingWhitespaceOutsideFences = (text, whitespace) => {
490
+ const start = performance.now();
468
491
  if (!whitespace) return text;
469
492
  const lines = text.split("\n");
470
493
  let inFence = false;
@@ -494,7 +517,14 @@ const trimLeadingWhitespaceOutsideFences = (text, whitespace) => {
494
517
  }
495
518
  return line.startsWith(whitespace) ? line.slice(whitespace.length) : line;
496
519
  });
497
- return out.join("\n");
520
+ const result = out.join("\n");
521
+ const duration = performance.now() - start;
522
+ if (duration > 1) {
523
+ console.log(
524
+ `trimLeadingWhitespaceOutsideFences: ${duration.toFixed(3)}ms, text length: ${text.length}, lines count: ${lines.length}`
525
+ );
526
+ }
527
+ return result;
498
528
  };
499
529
  const attributeValueToJSXPropValue = (tag, key, value, sanitizeUrlFn) => {
500
530
  if (key === "style") {
@@ -526,9 +556,18 @@ const attributeValueToJSXPropValue = (tag, key, value, sanitizeUrlFn) => {
526
556
  return value;
527
557
  };
528
558
  const normalizeWhitespace = (source) => {
529
- return source.replace(CR_NEWLINE_R, "\n").replace(FORMFEED_R, "").replace(TAB_R, " ");
559
+ const start = performance.now();
560
+ const result = source.replace(CR_NEWLINE_R, "\n").replace(FORMFEED_R, "").replace(TAB_R, " ");
561
+ const duration = performance.now() - start;
562
+ if (duration > 1) {
563
+ console.log(
564
+ `normalizeWhitespace: ${duration.toFixed(3)}ms, source length: ${source.length}`
565
+ );
566
+ }
567
+ return result;
530
568
  };
531
569
  const parserFor = (rules) => {
570
+ const start = performance.now();
532
571
  var ruleList = Object.keys(rules);
533
572
  if (define_process_env_default.NODE_ENV !== "production") {
534
573
  ruleList.forEach((type) => {
@@ -544,6 +583,7 @@ const parserFor = (rules) => {
544
583
  return rules[a]._order - rules[b]._order || (a < b ? -1 : 1);
545
584
  });
546
585
  const nestedParse = (source, state = {}) => {
586
+ const parseStart = performance.now();
547
587
  var result = [];
548
588
  state.prevCapture = state.prevCapture || "";
549
589
  if (source.trim()) {
@@ -556,10 +596,24 @@ const parserFor = (rules) => {
556
596
  i++;
557
597
  continue;
558
598
  }
599
+ const matchStart = performance.now();
559
600
  var capture = rule._match(source, state);
601
+ const matchDuration = performance.now() - matchStart;
602
+ if (matchDuration > 1) {
603
+ console.log(
604
+ `${ruleType}._match: ${matchDuration.toFixed(3)}ms, source length: ${source.length}`
605
+ );
606
+ }
560
607
  if (capture && capture[0]) {
561
608
  source = source.substring(capture[0].length);
609
+ const ruleParseStart = performance.now();
562
610
  const parsedAny = rule._parse(capture, nestedParse, state);
611
+ const ruleParseDuration = performance.now() - ruleParseStart;
612
+ if (ruleParseDuration > 1) {
613
+ console.log(
614
+ `${ruleType}._parse: ${ruleParseDuration.toFixed(3)}ms, capture length: ${capture[0].length}`
615
+ );
616
+ }
563
617
  state.prevCapture += capture[0];
564
618
  if (!parsedAny.type)
565
619
  parsedAny.type = ruleType;
@@ -571,8 +625,20 @@ const parserFor = (rules) => {
571
625
  }
572
626
  }
573
627
  state.prevCapture = "";
628
+ const parseDuration = performance.now() - parseStart;
629
+ if (parseDuration > 1) {
630
+ console.log(
631
+ `nestedParse: ${parseDuration.toFixed(3)}ms, source length: ${source.length}, result count: ${result.length}`
632
+ );
633
+ }
574
634
  return result;
575
635
  };
636
+ const duration = performance.now() - start;
637
+ if (duration > 1) {
638
+ console.log(
639
+ `parserFor: ${duration.toFixed(3)}ms, rules count: ${ruleList.length}`
640
+ );
641
+ }
576
642
  return (source, state) => nestedParse(normalizeWhitespace(source), state);
577
643
  };
578
644
  const allowInline = (fn) => {
@@ -629,6 +695,7 @@ const sanitizer = (input) => {
629
695
  };
630
696
  const unescape = (rawString) => rawString ? rawString.replace(UNESCAPE_R, "$1") : rawString;
631
697
  const parseInline = (parse, children, state) => {
698
+ const start = performance.now();
632
699
  const isCurrentlyInline = state.inline ?? false;
633
700
  const isCurrentlySimple = state.simple ?? false;
634
701
  state.inline = true;
@@ -636,9 +703,16 @@ const parseInline = (parse, children, state) => {
636
703
  const result = parse(children, state);
637
704
  state.inline = isCurrentlyInline;
638
705
  state.simple = isCurrentlySimple;
706
+ const duration = performance.now() - start;
707
+ if (duration > 1) {
708
+ console.log(
709
+ `parseInline: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
710
+ );
711
+ }
639
712
  return result;
640
713
  };
641
714
  const parseSimpleInline = (parse, children, state) => {
715
+ const start = performance.now();
642
716
  const isCurrentlyInline = state.inline ?? false;
643
717
  const isCurrentlySimple = state.simple ?? false;
644
718
  state.inline = false;
@@ -646,13 +720,26 @@ const parseSimpleInline = (parse, children, state) => {
646
720
  const result = parse(children, state);
647
721
  state.inline = isCurrentlyInline;
648
722
  state.simple = isCurrentlySimple;
723
+ const duration = performance.now() - start;
724
+ if (duration > 1) {
725
+ console.log(
726
+ `parseSimpleInline: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
727
+ );
728
+ }
649
729
  return result;
650
730
  };
651
731
  const parseBlock = (parse, children, state = {}) => {
732
+ const start = performance.now();
652
733
  const isCurrentlyInline = state.inline || false;
653
734
  state.inline = false;
654
735
  const result = parse(children, state);
655
736
  state.inline = isCurrentlyInline;
737
+ const duration = performance.now() - start;
738
+ if (duration > 1) {
739
+ console.log(
740
+ `parseBlock: ${duration.toFixed(3)}ms, children length: ${children.length}, result count: ${result.length}`
741
+ );
742
+ }
656
743
  return result;
657
744
  };
658
745
  const parseCaptureInline = (capture, parse, state) => {
@@ -663,34 +750,56 @@ const parseCaptureInline = (capture, parse, state) => {
663
750
  const captureNothing = () => ({});
664
751
  const renderNothing = () => null;
665
752
  const reactFor = (render) => (ast, state = {}) => {
753
+ const start = performance.now();
666
754
  const patchedRender = (ast2, state2 = {}) => reactFor(render)(ast2, state2);
667
755
  if (Array.isArray(ast)) {
668
756
  const oldKey = state.key;
669
- const result = [];
757
+ const result2 = [];
670
758
  let lastWasString = false;
671
759
  for (let i = 0; i < ast.length; i++) {
672
760
  state.key = i;
673
761
  const nodeOut = patchedRender(ast[i], state);
674
762
  const isString = typeof nodeOut === "string";
675
763
  if (isString && lastWasString) {
676
- result[result.length - 1] = result[result.length - 1] + nodeOut;
764
+ result2[result2.length - 1] = result2[result2.length - 1] + nodeOut;
677
765
  } else if (nodeOut !== null) {
678
- result.push(nodeOut);
766
+ result2.push(nodeOut);
679
767
  }
680
768
  lastWasString = isString;
681
769
  }
682
770
  state.key = oldKey;
683
- return result;
771
+ const duration2 = performance.now() - start;
772
+ if (duration2 > 1) {
773
+ console.log(
774
+ `reactFor (array): ${duration2.toFixed(3)}ms, ast length: ${ast.length}`
775
+ );
776
+ }
777
+ return result2;
684
778
  }
685
- return render(
779
+ const result = render(
686
780
  ast,
687
781
  patchedRender,
688
782
  state
689
783
  );
784
+ const duration = performance.now() - start;
785
+ if (duration > 1) {
786
+ console.log(
787
+ `reactFor (single): ${duration.toFixed(3)}ms, ast type: ${ast.type}`
788
+ );
789
+ }
790
+ return result;
690
791
  };
691
792
  const createRenderer = (rules, userRender) => (ast, render, state) => {
793
+ const start = performance.now();
692
794
  const renderer = rules[ast.type]._render;
693
- return userRender ? userRender(() => renderer?.(ast, render, state), ast, render, state) : renderer?.(ast, render, state);
795
+ const result = userRender ? userRender(() => renderer?.(ast, render, state), ast, render, state) : renderer?.(ast, render, state);
796
+ const duration = performance.now() - start;
797
+ if (duration > 1) {
798
+ console.log(
799
+ `createRenderer: ${duration.toFixed(3)}ms, ast type: ${ast.type}, hasUserRender: ${!!userRender}`
800
+ );
801
+ }
802
+ return result;
694
803
  };
695
804
  const cx = (...args) => args.filter(Boolean).join(" ");
696
805
  const get = (src, path, fb) => {
@@ -734,7 +843,9 @@ const compiler = (markdown = "", options = {}) => {
734
843
  ];
735
844
  const containsBlockSyntax = (input) => {
736
845
  const cleaned = input.replace(TRIM_STARTING_NEWLINES, "");
737
- return BLOCK_SYNTAXES.some((r) => r.test(cleaned));
846
+ const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;
847
+ const syntaxes = options.disableParsingRawHTML ? [...NON_PARAGRAPH_BLOCK_SYNTAXES, PARAGRAPH_R, CUSTOM_COMPONENT_R] : BLOCK_SYNTAXES;
848
+ return syntaxes.some((r) => r.test(slice));
738
849
  };
739
850
  const matchParagraph = (source, state) => {
740
851
  if (state.inline || state.simple || state.inHTML && source.indexOf("\n\n") === -1 && state.prevCapture?.indexOf("\n\n") === -1) {
@@ -772,90 +883,17 @@ const compiler = (markdown = "", options = {}) => {
772
883
  );
773
884
  };
774
885
  const compile = (input) => {
775
- input = input.replace(FRONT_MATTER_R, "");
776
- const transformFrameworkH5GroupsToTabs = (src) => {
777
- const lines = src.split(/\r?\n/);
778
- const out = [];
779
- let i = 0;
780
- let insideTabsDepth = 0;
781
- while (i < lines.length) {
782
- const line = lines[i];
783
- if (/<\s*Tabs[>\s]/.test(line)) {
784
- insideTabsDepth++;
785
- }
786
- if (/<\s*\/\s*Tabs\s*>/.test(line)) {
787
- insideTabsDepth = Math.max(0, insideTabsDepth - 1);
788
- }
789
- if (!insideTabsDepth) {
790
- const headingMatch = line.match(/^#{5}\s+(.+?)\s*$/);
791
- if (headingMatch) {
792
- const collected = [];
793
- const captureSection = (startIndex) => {
794
- let j2 = startIndex;
795
- const buf = [];
796
- while (j2 < lines.length) {
797
- const l = lines[j2];
798
- if (/^#{1,5}\s+/.test(l)) break;
799
- if (/<\s*Tabs[>\s]/.test(l)) insideTabsDepth++;
800
- if (/<\s*\/\s*Tabs\s*>/.test(l))
801
- insideTabsDepth = Math.max(0, insideTabsDepth - 1);
802
- buf.push(l);
803
- j2++;
804
- }
805
- return {
806
- content: buf.join("\n").replace(/\n+$/, "\n"),
807
- endIndex: j2
808
- };
809
- };
810
- let j = i;
811
- while (j < lines.length) {
812
- const h2 = lines[j].match(/^#{5}\s+(.+?)\s*$/);
813
- if (!h2) break;
814
- const hLabel = h2[1].trim();
815
- const { content, endIndex } = captureSection(j + 1);
816
- collected.push({
817
- label: hLabel,
818
- value: hLabel.toLowerCase(),
819
- content
820
- });
821
- j = endIndex;
822
- if (!lines[j]?.startsWith("#####")) break;
823
- }
824
- if (collected.length >= 2) {
825
- const defaultTab = (collected.find((t) => t.value === "intlayer") ?? collected[0]).value;
826
- out.push(`<Tabs defaultTab="${defaultTab}">`);
827
- const order = ["intlayer", "next-intl", "next-i18next"];
828
- for (const key of order) {
829
- const item = collected.find((c) => c.value === key);
830
- if (!item) continue;
831
- out.push(
832
- ` <TabItem label="${item.label}" value="${item.value}">`
833
- );
834
- const inner = item.content.replace(/^\n+|\n+$/g, "");
835
- out.push(inner);
836
- out.push(" </TabItem>");
837
- }
838
- out.push("</Tabs>");
839
- i = j;
840
- continue;
841
- }
842
- }
843
- }
844
- out.push(line);
845
- i++;
846
- }
847
- return out.join("\n");
848
- };
849
- input = transformFrameworkH5GroupsToTabs(input);
886
+ const start = performance.now();
887
+ const result = input.replace(FRONT_MATTER_R, "");
850
888
  let inline = false;
851
889
  if (options.forceInline) {
852
890
  inline = true;
853
891
  } else if (!options.forceBlock) {
854
- inline = SHOULD_RENDER_AS_BLOCK_R.test(input) === false;
892
+ inline = SHOULD_RENDER_AS_BLOCK_R.test(result) === false;
855
893
  }
856
894
  const arr = emitter(
857
895
  parser(
858
- inline ? input : `${trimEnd(input).replace(TRIM_STARTING_NEWLINES, "")}
896
+ inline ? result : `${trimEnd(result).replace(TRIM_STARTING_NEWLINES, "")}
859
897
 
860
898
  `,
861
899
  {
@@ -867,6 +905,12 @@ const compiler = (markdown = "", options = {}) => {
867
905
  arr.pop();
868
906
  }
869
907
  if (options.wrapper === null) {
908
+ const duration2 = performance.now() - start;
909
+ if (duration2 > 1) {
910
+ console.log(
911
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
912
+ );
913
+ }
870
914
  return arr;
871
915
  }
872
916
  const wrapper = options.wrapper ?? (inline ? "span" : "div");
@@ -876,16 +920,35 @@ const compiler = (markdown = "", options = {}) => {
876
920
  } else if (arr.length === 1) {
877
921
  jsx3 = arr[0];
878
922
  if (typeof jsx3 === "string") {
923
+ const duration2 = performance.now() - start;
924
+ if (duration2 > 1) {
925
+ console.log(
926
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
927
+ );
928
+ }
879
929
  return /* @__PURE__ */ jsx("span", { children: jsx3 }, "outer");
880
930
  } else {
931
+ const duration2 = performance.now() - start;
932
+ if (duration2 > 1) {
933
+ console.log(
934
+ `compile: ${duration2.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
935
+ );
936
+ }
881
937
  return jsx3;
882
938
  }
883
939
  } else {
884
940
  jsx3 = null;
885
941
  }
942
+ const duration = performance.now() - start;
943
+ if (duration > 1) {
944
+ console.log(
945
+ `compile: ${duration.toFixed(3)}ms, input length: ${input.length}, inline: ${inline}`
946
+ );
947
+ }
886
948
  return createElementFn(wrapper, { key: "outer" }, jsx3);
887
949
  };
888
950
  const attrStringToMap = (tag, str) => {
951
+ const start = performance.now();
889
952
  if (!str || !str.trim()) {
890
953
  return null;
891
954
  }
@@ -893,7 +956,7 @@ const compiler = (markdown = "", options = {}) => {
893
956
  if (!attributes) {
894
957
  return null;
895
958
  }
896
- return attributes.reduce((map, raw) => {
959
+ const result = attributes.reduce((map, raw) => {
897
960
  const delimiterIdx = raw.indexOf("=");
898
961
  if (delimiterIdx !== -1) {
899
962
  const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
@@ -914,6 +977,13 @@ const compiler = (markdown = "", options = {}) => {
914
977
  }
915
978
  return map;
916
979
  }, {});
980
+ const duration = performance.now() - start;
981
+ if (duration > 1) {
982
+ console.log(
983
+ `attrStringToMap: ${duration.toFixed(3)}ms, str length: ${str.length}, attributes count: ${attributes.length}`
984
+ );
985
+ }
986
+ return result;
917
987
  };
918
988
  if (define_process_env_default.NODE_ENV !== "production") {
919
989
  if (typeof markdown !== "string") {
@@ -939,15 +1009,24 @@ const compiler = (markdown = "", options = {}) => {
939
1009
  _match: blockRegex(BLOCKQUOTE_R),
940
1010
  _order: Priority.HIGH,
941
1011
  _parse(capture, parse, state) {
1012
+ const start = performance.now();
942
1013
  const matchAlert = capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, "").match(BLOCKQUOTE_ALERT_R);
943
1014
  const alert = matchAlert?.[1];
944
1015
  const content = matchAlert?.[2] ?? "";
945
- return {
1016
+ const result = {
946
1017
  alert,
947
1018
  children: parse(content, state)
948
1019
  };
1020
+ const duration = performance.now() - start;
1021
+ if (duration > 1) {
1022
+ console.log(
1023
+ `blockQuote._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1024
+ );
1025
+ }
1026
+ return result;
949
1027
  },
950
1028
  _render(node, _output, state = {}) {
1029
+ const start = performance.now();
951
1030
  const props = {
952
1031
  key: state?.key
953
1032
  };
@@ -961,7 +1040,18 @@ const compiler = (markdown = "", options = {}) => {
961
1040
  tag: "header"
962
1041
  });
963
1042
  }
964
- return h("blockquote", props, _output(node.children, state));
1043
+ const result = h(
1044
+ "blockquote",
1045
+ props,
1046
+ _output(node.children, state)
1047
+ );
1048
+ const duration = performance.now() - start;
1049
+ if (duration > 1) {
1050
+ console.log(
1051
+ `blockQuote._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}, has alert: ${!!node.alert}`
1052
+ );
1053
+ }
1054
+ return result;
965
1055
  }
966
1056
  },
967
1057
  [RuleType.breakLine]: {
@@ -996,24 +1086,32 @@ const compiler = (markdown = "", options = {}) => {
996
1086
  };
997
1087
  },
998
1088
  _render(node, _output, state = {}) {
1089
+ const start = performance.now();
999
1090
  const attrs = { ...node.attrs ?? {} };
1000
1091
  const langClass = node.lang ? `lang-${node.lang}` : "lang-plaintext";
1001
1092
  attrs.className = attrs.className ? `${attrs.className} ${langClass}` : langClass;
1002
1093
  if (node.lang && !attrs.lang) attrs.lang = node.lang;
1003
- return h(
1094
+ const result = h(
1004
1095
  "pre",
1005
1096
  { key: state.key },
1006
1097
  h("code", attrs, node.text)
1007
1098
  );
1099
+ const duration = performance.now() - start;
1100
+ if (duration > 1) {
1101
+ console.log(
1102
+ `codeBlock._render: ${duration.toFixed(3)}ms, text length: ${node.text.length}, lang: ${node.lang || "none"}`
1103
+ );
1104
+ }
1105
+ return result;
1008
1106
  }
1009
1107
  },
1010
1108
  [RuleType.codeFenced]: {
1011
1109
  _qualify: ["```", "~~~"],
1012
1110
  _match: blockRegex(CODE_BLOCK_FENCED_R),
1013
1111
  _order: Priority.MAX,
1014
- _parse(capture, _parse, state) {
1112
+ _parse(capture) {
1015
1113
  const rawText = capture[4];
1016
- const text = state.inHTML && rawText.indexOf("`") !== -1 ? rawText.replace(/\n/g, "\\n") : rawText;
1114
+ const text = rawText;
1017
1115
  return {
1018
1116
  // if capture[3] it's additional metadata
1019
1117
  attrs: attrStringToMap("code", capture[3] ?? ""),
@@ -1033,7 +1131,15 @@ const compiler = (markdown = "", options = {}) => {
1033
1131
  };
1034
1132
  },
1035
1133
  _render(node, _output, state = {}) {
1036
- return h("code", { key: state.key }, node.text);
1134
+ const start = performance.now();
1135
+ const result = h("code", { key: state.key }, node.text);
1136
+ const duration = performance.now() - start;
1137
+ if (duration > 1) {
1138
+ console.log(
1139
+ `codeInline._render: ${duration.toFixed(3)}ms, text length: ${node.text.length}`
1140
+ );
1141
+ }
1142
+ return result;
1037
1143
  }
1038
1144
  },
1039
1145
  /**
@@ -1101,18 +1207,34 @@ const compiler = (markdown = "", options = {}) => {
1101
1207
  ),
1102
1208
  _order: Priority.HIGH,
1103
1209
  _parse(capture, parse, state) {
1104
- return {
1210
+ const start = performance.now();
1211
+ const result = {
1105
1212
  children: parseInline(parse, capture[2], state),
1106
1213
  id: slug(capture[2], slugify),
1107
1214
  level: capture[1].length
1108
1215
  };
1216
+ const duration = performance.now() - start;
1217
+ if (duration > 1) {
1218
+ console.log(
1219
+ `heading._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}, level: ${capture[1].length}`
1220
+ );
1221
+ }
1222
+ return result;
1109
1223
  },
1110
1224
  _render(node, _output, state = {}) {
1111
- return h(
1225
+ const start = performance.now();
1226
+ const result = h(
1112
1227
  `h${node.level}`,
1113
1228
  { id: node.id, key: state.key },
1114
1229
  _output(node.children, state)
1115
1230
  );
1231
+ const duration = performance.now() - start;
1232
+ if (duration > 1) {
1233
+ console.log(
1234
+ `heading._render: ${duration.toFixed(3)}ms, level: ${node.level}, children count: ${node.children.length}, id: ${node.id}`
1235
+ );
1236
+ }
1237
+ return result;
1116
1238
  }
1117
1239
  },
1118
1240
  [RuleType.headingSetext]: {
@@ -1127,7 +1249,13 @@ const compiler = (markdown = "", options = {}) => {
1127
1249
  }
1128
1250
  },
1129
1251
  [RuleType.htmlBlock]: {
1130
- _qualify: ["<"],
1252
+ _qualify: (source) => {
1253
+ if (options.disableParsingRawHTML) return false;
1254
+ if (source[0] !== "<") return false;
1255
+ if (!/^<([a-z][a-z0-9:-]*)\b/.test(source)) return false;
1256
+ const tag = source.match(/^<([a-z][a-z0-9:-]*)\b/)?.[1];
1257
+ return tag ? source.indexOf(`</${tag}>`) !== -1 : false;
1258
+ },
1131
1259
  /**
1132
1260
  * find the first matching end tag and process the interior
1133
1261
  */
@@ -1164,15 +1292,27 @@ const compiler = (markdown = "", options = {}) => {
1164
1292
  return ast;
1165
1293
  },
1166
1294
  _render(node, _output, state = {}) {
1167
- return h(
1295
+ const start = performance.now();
1296
+ const result = h(
1168
1297
  node.tag,
1169
1298
  { key: state.key, ...node.attrs ?? {} },
1170
1299
  node.text ?? (node.children ? _output(node.children, state) : "")
1171
1300
  );
1301
+ const duration = performance.now() - start;
1302
+ if (duration > 1) {
1303
+ console.log(
1304
+ `htmlBlock._render: ${duration.toFixed(3)}ms, tag: ${node.tag}, has text: ${!!node.text}, has children: ${!!node.children}`
1305
+ );
1306
+ }
1307
+ return result;
1172
1308
  }
1173
1309
  },
1174
1310
  [RuleType.htmlSelfClosing]: {
1175
- _qualify: ["<"],
1311
+ _qualify: (source) => {
1312
+ if (options.disableParsingRawHTML) return false;
1313
+ if (source[0] !== "<") return false;
1314
+ return /^<([a-zA-Z][a-zA-Z0-9:]*)[\s>/]/.test(source);
1315
+ },
1176
1316
  /**
1177
1317
  * find the first matching end tag and process the interior
1178
1318
  */
@@ -1186,10 +1326,18 @@ const compiler = (markdown = "", options = {}) => {
1186
1326
  };
1187
1327
  },
1188
1328
  _render(node, _output, state = {}) {
1189
- return h(node.tag, {
1329
+ const start = performance.now();
1330
+ const result = h(node.tag, {
1190
1331
  key: state.key,
1191
1332
  ...node.attrs ?? {}
1192
1333
  });
1334
+ const duration = performance.now() - start;
1335
+ if (duration > 1) {
1336
+ console.log(
1337
+ `htmlSelfClosing._render: ${duration.toFixed(3)}ms, tag: ${node.tag}`
1338
+ );
1339
+ }
1340
+ return result;
1193
1341
  }
1194
1342
  },
1195
1343
  [RuleType.htmlComment]: {
@@ -1377,9 +1525,27 @@ const compiler = (markdown = "", options = {}) => {
1377
1525
  [RuleType.paragraph]: {
1378
1526
  _match: allowInline(matchParagraph),
1379
1527
  _order: Priority.LOW,
1380
- _parse: parseCaptureInline,
1528
+ _parse(capture, parse, state) {
1529
+ const start = performance.now();
1530
+ const result = parseCaptureInline(capture, parse, state);
1531
+ const duration = performance.now() - start;
1532
+ if (duration > 1) {
1533
+ console.log(
1534
+ `paragraph._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1535
+ );
1536
+ }
1537
+ return result;
1538
+ },
1381
1539
  _render(node, _output, state = {}) {
1382
- return /* @__PURE__ */ jsx("p", { children: _output(node.children, state) }, state.key);
1540
+ const start = performance.now();
1541
+ const result = /* @__PURE__ */ jsx("p", { children: _output(node.children, state) }, state.key);
1542
+ const duration = performance.now() - start;
1543
+ if (duration > 1) {
1544
+ console.log(
1545
+ `paragraph._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1546
+ );
1547
+ }
1548
+ return result;
1383
1549
  }
1384
1550
  },
1385
1551
  [RuleType.ref]: {
@@ -1444,10 +1610,21 @@ const compiler = (markdown = "", options = {}) => {
1444
1610
  _qualify: ["|"],
1445
1611
  _match: blockRegex(NP_TABLE_R),
1446
1612
  _order: Priority.HIGH,
1447
- _parse: parseTable,
1613
+ _parse(capture, parse, state) {
1614
+ const start = performance.now();
1615
+ const result = parseTable(capture, parse, state);
1616
+ const duration = performance.now() - start;
1617
+ if (duration > 1) {
1618
+ console.log(
1619
+ `table._parse: ${duration.toFixed(3)}ms, capture length: ${capture[0].length}`
1620
+ );
1621
+ }
1622
+ return result;
1623
+ },
1448
1624
  _render(node, _output, state = {}) {
1625
+ const start = performance.now();
1449
1626
  const table = node;
1450
- return h(
1627
+ const result = h(
1451
1628
  "table",
1452
1629
  { key: state.key },
1453
1630
  h(
@@ -1483,6 +1660,13 @@ const compiler = (markdown = "", options = {}) => {
1483
1660
  )
1484
1661
  )
1485
1662
  );
1663
+ const duration = performance.now() - start;
1664
+ if (duration > 1) {
1665
+ console.log(
1666
+ `table._render: ${duration.toFixed(3)}ms, header count: ${table.header.length}, rows count: ${table.cells.length}`
1667
+ );
1668
+ }
1669
+ return result;
1486
1670
  }
1487
1671
  },
1488
1672
  [RuleType.text]: {
@@ -1522,7 +1706,15 @@ const compiler = (markdown = "", options = {}) => {
1522
1706
  };
1523
1707
  },
1524
1708
  _render(node, _output, state = {}) {
1525
- return /* @__PURE__ */ jsx("strong", { children: _output(node.children, state) }, state.key);
1709
+ const start = performance.now();
1710
+ const result = /* @__PURE__ */ jsx("strong", { children: _output(node.children, state) }, state.key);
1711
+ const duration = performance.now() - start;
1712
+ if (duration > 1) {
1713
+ console.log(
1714
+ `textBolded._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1715
+ );
1716
+ }
1717
+ return result;
1526
1718
  }
1527
1719
  },
1528
1720
  [RuleType.textEmphasized]: {
@@ -1540,7 +1732,15 @@ const compiler = (markdown = "", options = {}) => {
1540
1732
  };
1541
1733
  },
1542
1734
  _render(node, _output, state = {}) {
1543
- return /* @__PURE__ */ jsx("em", { children: _output(node.children, state) }, state.key);
1735
+ const start = performance.now();
1736
+ const result = /* @__PURE__ */ jsx("em", { children: _output(node.children, state) }, state.key);
1737
+ const duration = performance.now() - start;
1738
+ if (duration > 1) {
1739
+ console.log(
1740
+ `textEmphasized._render: ${duration.toFixed(3)}ms, children count: ${node.children.length}`
1741
+ );
1742
+ }
1743
+ return result;
1544
1744
  }
1545
1745
  },
1546
1746
  [RuleType.textEscaped]: {
@@ -1616,4 +1816,4 @@ export {
1616
1816
  sanitizer,
1617
1817
  slugify
1618
1818
  };
1619
- //# sourceMappingURL=processer.mjs.map
1819
+ //# sourceMappingURL=processor.mjs.map