@gofreego/tsutils 0.1.11 → 0.1.12
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +75 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -403,8 +403,10 @@ var getHighlighter = async () => {
|
|
|
403
403
|
var ReadmeViewer = ({
|
|
404
404
|
content,
|
|
405
405
|
className = "",
|
|
406
|
-
isDark
|
|
406
|
+
isDark: propIsDark,
|
|
407
|
+
muiTheme
|
|
407
408
|
}) => {
|
|
409
|
+
const isDark = propIsDark !== void 0 ? propIsDark : muiTheme?.palette?.mode === "dark";
|
|
408
410
|
const [highlighter, setHighlighter] = useState(null);
|
|
409
411
|
const [copiedBlocks, setCopiedBlocks] = useState(/* @__PURE__ */ new Set());
|
|
410
412
|
useEffect(() => {
|
|
@@ -425,74 +427,85 @@ var ReadmeViewer = ({
|
|
|
425
427
|
console.error("Failed to copy text: ", err);
|
|
426
428
|
}
|
|
427
429
|
};
|
|
428
|
-
return /* @__PURE__ */
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
430
|
+
return /* @__PURE__ */ jsxs("div", { className: `readme-viewer markdown-body ${className}`, children: [
|
|
431
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
432
|
+
.shiki-wrapper pre.shiki {
|
|
433
|
+
padding: 16px !important;
|
|
434
|
+
border-radius: 8px !important;
|
|
435
|
+
overflow-x: auto;
|
|
436
|
+
margin-bottom: 16px;
|
|
437
|
+
border: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
|
|
438
|
+
}
|
|
439
|
+
` }),
|
|
440
|
+
/* @__PURE__ */ jsx(
|
|
441
|
+
ReactMarkdown,
|
|
442
|
+
{
|
|
443
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
444
|
+
rehypePlugins: [rehypeKatex],
|
|
445
|
+
components: {
|
|
446
|
+
code({ className: className2, children, ...props }) {
|
|
447
|
+
const match = /language-(\w+)/.exec(className2 || "");
|
|
448
|
+
if (match && highlighter) {
|
|
449
|
+
const codeText = String(children).replace(/\n$/, "");
|
|
450
|
+
const blockId = `code-${Math.random().toString(36).substr(2, 9)}`;
|
|
451
|
+
let highlightedHtml = "";
|
|
446
452
|
try {
|
|
447
453
|
highlightedHtml = highlighter.codeToHtml(codeText, {
|
|
448
|
-
lang:
|
|
454
|
+
lang: match[1],
|
|
449
455
|
theme: isDark ? "github-dark" : "github-light"
|
|
450
456
|
});
|
|
451
|
-
} catch (
|
|
452
|
-
|
|
457
|
+
} catch (e) {
|
|
458
|
+
try {
|
|
459
|
+
highlightedHtml = highlighter.codeToHtml(codeText, {
|
|
460
|
+
lang: "text",
|
|
461
|
+
theme: isDark ? "github-dark" : "github-light"
|
|
462
|
+
});
|
|
463
|
+
} catch (fallbackError) {
|
|
464
|
+
highlightedHtml = `<pre><code>${codeText}</code></pre>`;
|
|
465
|
+
}
|
|
453
466
|
}
|
|
467
|
+
return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
468
|
+
/* @__PURE__ */ jsx("div", { className: "shiki-wrapper", dangerouslySetInnerHTML: { __html: highlightedHtml } }),
|
|
469
|
+
/* @__PURE__ */ jsx(
|
|
470
|
+
"button",
|
|
471
|
+
{
|
|
472
|
+
onClick: () => copyToClipboard(codeText, blockId),
|
|
473
|
+
style: {
|
|
474
|
+
position: "absolute",
|
|
475
|
+
top: "8px",
|
|
476
|
+
right: "8px",
|
|
477
|
+
backgroundColor: "var(--md-sys-color-surface-container-high)",
|
|
478
|
+
border: "1px solid var(--md-sys-color-outline-variant)",
|
|
479
|
+
borderRadius: "4px",
|
|
480
|
+
padding: "6px",
|
|
481
|
+
fontSize: "14px",
|
|
482
|
+
cursor: "pointer",
|
|
483
|
+
color: "var(--md-sys-color-on-surface-variant)",
|
|
484
|
+
alignItems: "center",
|
|
485
|
+
justifyContent: "center",
|
|
486
|
+
transition: "all 0.2s ease",
|
|
487
|
+
width: "32px",
|
|
488
|
+
height: "32px"
|
|
489
|
+
},
|
|
490
|
+
onMouseEnter: (e) => {
|
|
491
|
+
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-highest)" : "var(--md-sys-color-surface-container-high)";
|
|
492
|
+
},
|
|
493
|
+
onMouseLeave: (e) => {
|
|
494
|
+
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-high)" : "var(--md-sys-color-surface-container-highest)";
|
|
495
|
+
},
|
|
496
|
+
title: copiedBlocks.has(blockId) ? "Copied!" : "Copy code",
|
|
497
|
+
children: copiedBlocks.has(blockId) ? /* @__PURE__ */ jsx(CheckIcon, { style: { fontSize: "16px" } }) : /* @__PURE__ */ jsx(ContentCopyIcon, { style: { fontSize: "16px" } })
|
|
498
|
+
}
|
|
499
|
+
)
|
|
500
|
+
] });
|
|
454
501
|
}
|
|
455
|
-
return /* @__PURE__ */
|
|
456
|
-
/* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: highlightedHtml } }),
|
|
457
|
-
/* @__PURE__ */ jsx(
|
|
458
|
-
"button",
|
|
459
|
-
{
|
|
460
|
-
onClick: () => copyToClipboard(codeText, blockId),
|
|
461
|
-
style: {
|
|
462
|
-
position: "absolute",
|
|
463
|
-
top: "8px",
|
|
464
|
-
right: "8px",
|
|
465
|
-
backgroundColor: "var(--md-sys-color-surface-container-high)",
|
|
466
|
-
border: "1px solid var(--md-sys-color-outline-variant)",
|
|
467
|
-
borderRadius: "4px",
|
|
468
|
-
padding: "6px",
|
|
469
|
-
fontSize: "14px",
|
|
470
|
-
cursor: "pointer",
|
|
471
|
-
color: "var(--md-sys-color-on-surface-variant)",
|
|
472
|
-
alignItems: "center",
|
|
473
|
-
justifyContent: "center",
|
|
474
|
-
transition: "all 0.2s ease",
|
|
475
|
-
width: "32px",
|
|
476
|
-
height: "32px"
|
|
477
|
-
},
|
|
478
|
-
onMouseEnter: (e) => {
|
|
479
|
-
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-highest)" : "var(--md-sys-color-surface-container-high)";
|
|
480
|
-
},
|
|
481
|
-
onMouseLeave: (e) => {
|
|
482
|
-
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-high)" : "var(--md-sys-color-surface-container-highest)";
|
|
483
|
-
},
|
|
484
|
-
title: copiedBlocks.has(blockId) ? "Copied!" : "Copy code",
|
|
485
|
-
children: copiedBlocks.has(blockId) ? /* @__PURE__ */ jsx(CheckIcon, { style: { fontSize: "16px" } }) : /* @__PURE__ */ jsx(ContentCopyIcon, { style: { fontSize: "16px" } })
|
|
486
|
-
}
|
|
487
|
-
)
|
|
488
|
-
] });
|
|
502
|
+
return /* @__PURE__ */ jsx("code", { className: className2, ...props, children });
|
|
489
503
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
) });
|
|
504
|
+
},
|
|
505
|
+
children: content
|
|
506
|
+
}
|
|
507
|
+
)
|
|
508
|
+
] });
|
|
496
509
|
};
|
|
497
510
|
var ReadmeViewer_default = ReadmeViewer;
|
|
498
511
|
var NotificationContext = createContext(void 0);
|