@gofreego/tsutils 0.1.10 → 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 +88 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ var reactRouterDom = require('react-router-dom');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var ReactMarkdown = require('react-markdown');
|
|
9
9
|
var remarkGfm = require('remark-gfm');
|
|
10
|
+
var remarkMath = require('remark-math');
|
|
11
|
+
var rehypeKatex = require('rehype-katex');
|
|
12
|
+
require('katex/dist/katex.min.css');
|
|
10
13
|
var ContentCopyIcon = require('@mui/icons-material/ContentCopy');
|
|
11
14
|
var CheckIcon = require('@mui/icons-material/Check');
|
|
12
15
|
var shiki = require('shiki');
|
|
@@ -16,6 +19,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
16
19
|
|
|
17
20
|
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
18
21
|
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
22
|
+
var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
|
|
23
|
+
var rehypeKatex__default = /*#__PURE__*/_interopDefault(rehypeKatex);
|
|
19
24
|
var ContentCopyIcon__default = /*#__PURE__*/_interopDefault(ContentCopyIcon);
|
|
20
25
|
var CheckIcon__default = /*#__PURE__*/_interopDefault(CheckIcon);
|
|
21
26
|
var WarningAmberIcon__default = /*#__PURE__*/_interopDefault(WarningAmberIcon);
|
|
@@ -400,7 +405,7 @@ var getHighlighter = async () => {
|
|
|
400
405
|
}
|
|
401
406
|
highlighterPromise = shiki.createHighlighter({
|
|
402
407
|
themes: ["github-light", "github-dark"],
|
|
403
|
-
langs: ["js", "ts", "go", "json", "bash", "yaml", "md", "python", "java", "cpp", "c", "html", "css", "sql"]
|
|
408
|
+
langs: ["js", "ts", "go", "json", "bash", "yaml", "md", "python", "java", "cpp", "c", "html", "css", "sql", "http", "text"]
|
|
404
409
|
}).then((highlighter) => {
|
|
405
410
|
highlighterInstance = highlighter;
|
|
406
411
|
return highlighter;
|
|
@@ -410,8 +415,10 @@ var getHighlighter = async () => {
|
|
|
410
415
|
var ReadmeViewer = ({
|
|
411
416
|
content,
|
|
412
417
|
className = "",
|
|
413
|
-
isDark
|
|
418
|
+
isDark: propIsDark,
|
|
419
|
+
muiTheme
|
|
414
420
|
}) => {
|
|
421
|
+
const isDark = propIsDark !== void 0 ? propIsDark : muiTheme?.palette?.mode === "dark";
|
|
415
422
|
const [highlighter, setHighlighter] = react.useState(null);
|
|
416
423
|
const [copiedBlocks, setCopiedBlocks] = react.useState(/* @__PURE__ */ new Set());
|
|
417
424
|
react.useEffect(() => {
|
|
@@ -432,70 +439,85 @@ var ReadmeViewer = ({
|
|
|
432
439
|
console.error("Failed to copy text: ", err);
|
|
433
440
|
}
|
|
434
441
|
};
|
|
435
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
borderRadius: "4px",
|
|
471
|
-
padding: "6px",
|
|
472
|
-
fontSize: "14px",
|
|
473
|
-
cursor: "pointer",
|
|
474
|
-
color: "var(--md-sys-color-on-surface-variant)",
|
|
475
|
-
alignItems: "center",
|
|
476
|
-
justifyContent: "center",
|
|
477
|
-
transition: "all 0.2s ease",
|
|
478
|
-
width: "32px",
|
|
479
|
-
height: "32px"
|
|
480
|
-
},
|
|
481
|
-
onMouseEnter: (e) => {
|
|
482
|
-
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-highest)" : "var(--md-sys-color-surface-container-high)";
|
|
483
|
-
},
|
|
484
|
-
onMouseLeave: (e) => {
|
|
485
|
-
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-high)" : "var(--md-sys-color-surface-container-highest)";
|
|
486
|
-
},
|
|
487
|
-
title: copiedBlocks.has(blockId) ? "Copied!" : "Copy code",
|
|
488
|
-
children: copiedBlocks.has(blockId) ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon__default.default, { style: { fontSize: "16px" } }) : /* @__PURE__ */ jsxRuntime.jsx(ContentCopyIcon__default.default, { style: { fontSize: "16px" } })
|
|
442
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `readme-viewer markdown-body ${className}`, children: [
|
|
443
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
444
|
+
.shiki-wrapper pre.shiki {
|
|
445
|
+
padding: 16px !important;
|
|
446
|
+
border-radius: 8px !important;
|
|
447
|
+
overflow-x: auto;
|
|
448
|
+
margin-bottom: 16px;
|
|
449
|
+
border: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
|
|
450
|
+
}
|
|
451
|
+
` }),
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
453
|
+
ReactMarkdown__default.default,
|
|
454
|
+
{
|
|
455
|
+
remarkPlugins: [remarkGfm__default.default, remarkMath__default.default],
|
|
456
|
+
rehypePlugins: [rehypeKatex__default.default],
|
|
457
|
+
components: {
|
|
458
|
+
code({ className: className2, children, ...props }) {
|
|
459
|
+
const match = /language-(\w+)/.exec(className2 || "");
|
|
460
|
+
if (match && highlighter) {
|
|
461
|
+
const codeText = String(children).replace(/\n$/, "");
|
|
462
|
+
const blockId = `code-${Math.random().toString(36).substr(2, 9)}`;
|
|
463
|
+
let highlightedHtml = "";
|
|
464
|
+
try {
|
|
465
|
+
highlightedHtml = highlighter.codeToHtml(codeText, {
|
|
466
|
+
lang: match[1],
|
|
467
|
+
theme: isDark ? "github-dark" : "github-light"
|
|
468
|
+
});
|
|
469
|
+
} catch (e) {
|
|
470
|
+
try {
|
|
471
|
+
highlightedHtml = highlighter.codeToHtml(codeText, {
|
|
472
|
+
lang: "text",
|
|
473
|
+
theme: isDark ? "github-dark" : "github-light"
|
|
474
|
+
});
|
|
475
|
+
} catch (fallbackError) {
|
|
476
|
+
highlightedHtml = `<pre><code>${codeText}</code></pre>`;
|
|
489
477
|
}
|
|
490
|
-
|
|
491
|
-
|
|
478
|
+
}
|
|
479
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
480
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "shiki-wrapper", dangerouslySetInnerHTML: { __html: highlightedHtml } }),
|
|
481
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
482
|
+
"button",
|
|
483
|
+
{
|
|
484
|
+
onClick: () => copyToClipboard(codeText, blockId),
|
|
485
|
+
style: {
|
|
486
|
+
position: "absolute",
|
|
487
|
+
top: "8px",
|
|
488
|
+
right: "8px",
|
|
489
|
+
backgroundColor: "var(--md-sys-color-surface-container-high)",
|
|
490
|
+
border: "1px solid var(--md-sys-color-outline-variant)",
|
|
491
|
+
borderRadius: "4px",
|
|
492
|
+
padding: "6px",
|
|
493
|
+
fontSize: "14px",
|
|
494
|
+
cursor: "pointer",
|
|
495
|
+
color: "var(--md-sys-color-on-surface-variant)",
|
|
496
|
+
alignItems: "center",
|
|
497
|
+
justifyContent: "center",
|
|
498
|
+
transition: "all 0.2s ease",
|
|
499
|
+
width: "32px",
|
|
500
|
+
height: "32px"
|
|
501
|
+
},
|
|
502
|
+
onMouseEnter: (e) => {
|
|
503
|
+
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-highest)" : "var(--md-sys-color-surface-container-high)";
|
|
504
|
+
},
|
|
505
|
+
onMouseLeave: (e) => {
|
|
506
|
+
e.currentTarget.style.backgroundColor = isDark ? "var(--md-sys-color-surface-container-high)" : "var(--md-sys-color-surface-container-highest)";
|
|
507
|
+
},
|
|
508
|
+
title: copiedBlocks.has(blockId) ? "Copied!" : "Copy code",
|
|
509
|
+
children: copiedBlocks.has(blockId) ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon__default.default, { style: { fontSize: "16px" } }) : /* @__PURE__ */ jsxRuntime.jsx(ContentCopyIcon__default.default, { style: { fontSize: "16px" } })
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
] });
|
|
513
|
+
}
|
|
514
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", { className: className2, ...props, children });
|
|
492
515
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
) });
|
|
516
|
+
},
|
|
517
|
+
children: content
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
] });
|
|
499
521
|
};
|
|
500
522
|
var ReadmeViewer_default = ReadmeViewer;
|
|
501
523
|
var NotificationContext = react.createContext(void 0);
|
|
@@ -584,13 +606,13 @@ var ConfirmDialog = ({
|
|
|
584
606
|
onConfirm,
|
|
585
607
|
onCancel
|
|
586
608
|
}) => {
|
|
587
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(material.Dialog, { open, onClose: onCancel, maxWidth: "xs", fullWidth: true, children: [
|
|
609
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Dialog, { open, onClose: onCancel, maxWidth: "xs", fullWidth: true, slotProps: { paper: { sx: { borderRadius: 4 } } }, children: [
|
|
588
610
|
/* @__PURE__ */ jsxRuntime.jsx(material.DialogTitle, { children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
589
611
|
/* @__PURE__ */ jsxRuntime.jsx(WarningAmberIcon__default.default, { color: confirmColor }),
|
|
590
612
|
title
|
|
591
613
|
] }) }),
|
|
592
614
|
/* @__PURE__ */ jsxRuntime.jsx(material.DialogContent, { children: /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", children: message }) }),
|
|
593
|
-
/* @__PURE__ */ jsxRuntime.jsxs(material.DialogActions, { children: [
|
|
615
|
+
/* @__PURE__ */ jsxRuntime.jsxs(material.DialogActions, { sx: { px: 3, pb: 2 }, children: [
|
|
594
616
|
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: onCancel, variant: "outlined", children: cancelText }),
|
|
595
617
|
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: onConfirm, variant: "contained", color: confirmColor, autoFocus: true, children: confirmText })
|
|
596
618
|
] })
|