@hackersheet/next-document-content-components 0.1.0-alpha.1

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 (61) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/components/code-block/code-block-copy-button.d.ts +8 -0
  3. package/dist/cjs/components/code-block/code-block-copy-button.js +47 -0
  4. package/dist/cjs/components/code-block/code-block-icon.d.ts +8 -0
  5. package/dist/cjs/components/code-block/code-block-icon.js +66 -0
  6. package/dist/cjs/components/code-block/code-block-kifu.d.ts +9 -0
  7. package/dist/cjs/components/code-block/code-block-kifu.js +66 -0
  8. package/dist/cjs/components/code-block/code-block-mermaid.d.ts +8 -0
  9. package/dist/cjs/components/code-block/code-block-mermaid.js +71 -0
  10. package/dist/cjs/components/code-block/code-block.d.ts +6 -0
  11. package/dist/cjs/components/code-block/code-block.js +48 -0
  12. package/dist/cjs/components/code-block/shiki.d.ts +3 -0
  13. package/dist/cjs/components/code-block/shiki.js +52 -0
  14. package/dist/cjs/components/image/image.d.ts +6 -0
  15. package/dist/cjs/components/image/image.js +38 -0
  16. package/dist/cjs/components/index.d.ts +9 -0
  17. package/dist/cjs/components/index.js +56 -0
  18. package/dist/cjs/components/kifu-to/kifu-to.d.ts +6 -0
  19. package/dist/cjs/components/kifu-to/kifu-to.js +41 -0
  20. package/dist/cjs/components/link/link.d.ts +6 -0
  21. package/dist/cjs/components/link/link.js +38 -0
  22. package/dist/cjs/components/link-card/link-card.d.ts +6 -0
  23. package/dist/cjs/components/link-card/link-card.js +47 -0
  24. package/dist/cjs/components/x-post/x-post.d.ts +6 -0
  25. package/dist/cjs/components/x-post/x-post.js +49 -0
  26. package/dist/cjs/components/youtube/youtube.d.ts +6 -0
  27. package/dist/cjs/components/youtube/youtube.js +39 -0
  28. package/dist/cjs/index.d.ts +9 -0
  29. package/dist/cjs/index.js +22 -0
  30. package/dist/esm/components/code-block/code-block-copy-button.d.mts +8 -0
  31. package/dist/esm/components/code-block/code-block-copy-button.mjs +17 -0
  32. package/dist/esm/components/code-block/code-block-icon.d.mts +8 -0
  33. package/dist/esm/components/code-block/code-block-icon.mjs +36 -0
  34. package/dist/esm/components/code-block/code-block-kifu.d.mts +9 -0
  35. package/dist/esm/components/code-block/code-block-kifu.mjs +36 -0
  36. package/dist/esm/components/code-block/code-block-mermaid.d.mts +8 -0
  37. package/dist/esm/components/code-block/code-block-mermaid.mjs +41 -0
  38. package/dist/esm/components/code-block/code-block.d.mts +6 -0
  39. package/dist/esm/components/code-block/code-block.mjs +18 -0
  40. package/dist/esm/components/code-block/shiki.d.mts +3 -0
  41. package/dist/esm/components/code-block/shiki.mjs +28 -0
  42. package/dist/esm/components/image/image.d.mts +6 -0
  43. package/dist/esm/components/image/image.mjs +8 -0
  44. package/dist/esm/components/index.d.mts +9 -0
  45. package/dist/esm/components/index.mjs +16 -0
  46. package/dist/esm/components/kifu-to/kifu-to.d.mts +6 -0
  47. package/dist/esm/components/kifu-to/kifu-to.mjs +11 -0
  48. package/dist/esm/components/link/link.d.mts +6 -0
  49. package/dist/esm/components/link/link.mjs +8 -0
  50. package/dist/esm/components/link-card/link-card.d.mts +6 -0
  51. package/dist/esm/components/link-card/link-card.mjs +17 -0
  52. package/dist/esm/components/x-post/x-post.d.mts +6 -0
  53. package/dist/esm/components/x-post/x-post.mjs +19 -0
  54. package/dist/esm/components/youtube/youtube.d.mts +6 -0
  55. package/dist/esm/components/youtube/youtube.mjs +9 -0
  56. package/dist/esm/index.d.mts +9 -0
  57. package/dist/esm/index.mjs +1 -0
  58. package/dist/style.module.css +279 -0
  59. package/dist/style.module.scss.d.ts +9 -0
  60. package/license.md +21 -0
  61. package/package.json +73 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var link_card_exports = {};
30
+ __export(link_card_exports, {
31
+ default: () => LinkCard
32
+ });
33
+ module.exports = __toCommonJS(link_card_exports);
34
+ var import_image = __toESM(require("next/image"));
35
+ var import_react = __toESM(require("react"));
36
+ function LinkCard({
37
+ domain,
38
+ url,
39
+ title,
40
+ description,
41
+ imageUrl,
42
+ imageHeight,
43
+ imageWidth
44
+ }) {
45
+ const faviconUrl = `https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://${domain}&size=16`;
46
+ return /* @__PURE__ */ import_react.default.createElement("a", { href: url, className: "link-card" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "link-card-main" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "link-card-title" }, title), /* @__PURE__ */ import_react.default.createElement("div", { className: "link-card-description" }, description), /* @__PURE__ */ import_react.default.createElement("div", { className: "link-card-domain" }, /* @__PURE__ */ import_react.default.createElement("picture", null, /* @__PURE__ */ import_react.default.createElement("img", { src: faviconUrl, alt: `${domain} favicon`, width: 16, height: 16 })), /* @__PURE__ */ import_react.default.createElement("div", null, domain))), imageUrl && /* @__PURE__ */ import_react.default.createElement("div", { className: "link-card-image" }, /* @__PURE__ */ import_react.default.createElement(import_image.default, { alt: title, src: imageUrl, height: imageHeight, width: imageWidth })));
47
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { XPostComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function XPost({ id }: XPostComponentProps): Promise<React.JSX.Element>;
5
+
6
+ export { XPost as default };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var x_post_exports = {};
30
+ __export(x_post_exports, {
31
+ default: () => XPost
32
+ });
33
+ module.exports = __toCommonJS(x_post_exports);
34
+ var import_cache = require("next/cache");
35
+ var import_react = __toESM(require("react"));
36
+ var import_react_tweet = require("react-tweet");
37
+ var import_api = require("react-tweet/api");
38
+ const getTweet = (0, import_cache.unstable_cache)(async (id) => (0, import_api.getTweet)(id), ["tweet"], {
39
+ revalidate: 3600 * 24
40
+ });
41
+ async function XPost({ id }) {
42
+ try {
43
+ const tweet = await getTweet(id);
44
+ return tweet ? /* @__PURE__ */ import_react.default.createElement(import_react_tweet.EmbeddedTweet, { tweet }) : /* @__PURE__ */ import_react.default.createElement(import_react_tweet.TweetNotFound, null);
45
+ } catch (error) {
46
+ console.error(error);
47
+ return /* @__PURE__ */ import_react.default.createElement(import_react_tweet.TweetNotFound, { error });
48
+ }
49
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { YoutubeComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function Youtube({ videoId, params, playLabel, ...props }: YoutubeComponentProps): Promise<React.JSX.Element>;
5
+
6
+ export { Youtube as default };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var youtube_exports = {};
30
+ __export(youtube_exports, {
31
+ default: () => Youtube
32
+ });
33
+ module.exports = __toCommonJS(youtube_exports);
34
+ var import_google = require("@next/third-parties/google");
35
+ var import_react = __toESM(require("react"));
36
+ async function Youtube({ videoId, params, playLabel, ...props }) {
37
+ const paramsString = params ? Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&") : void 0;
38
+ return /* @__PURE__ */ import_react.default.createElement(import_google.YouTubeEmbed, { ...props, videoid: videoId, params: paramsString, playlabel: playLabel });
39
+ }
@@ -0,0 +1,9 @@
1
+ export { default as CodeBlock } from './components/code-block/code-block.js';
2
+ export { default as Image } from './components/image/image.js';
3
+ export { default as KifuTo } from './components/kifu-to/kifu-to.js';
4
+ export { default as Link } from './components/link/link.js';
5
+ export { default as LinkCard } from './components/link-card/link-card.js';
6
+ export { default as XPost } from './components/x-post/x-post.js';
7
+ export { default as Youtube } from './components/youtube/youtube.js';
8
+ import 'react';
9
+ import '@hackersheet/react-document-content';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./components"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./components")
22
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+
3
+ interface CodeBlockCopyButtonProps {
4
+ code: string;
5
+ }
6
+ declare function CodeBlockCopyButton({ code }: CodeBlockCopyButtonProps): React.JSX.Element;
7
+
8
+ export { type CodeBlockCopyButtonProps, CodeBlockCopyButton as default };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import React, { useState } from "react";
3
+ import { HiOutlineClipboardDocumentList, HiCheck } from "react-icons/hi2";
4
+ function CodeBlockCopyButton({ code }) {
5
+ const [copied, setCopied] = useState(false);
6
+ const removeShikiCode = (code2) => code2.replace(/ *\/\/.*\[!code[^\]]+\]/gm, "").trim();
7
+ const handleClick = () => {
8
+ navigator.clipboard.writeText(removeShikiCode(code)).then(() => {
9
+ setCopied(true);
10
+ setTimeout(() => setCopied(false), 1e3);
11
+ });
12
+ };
13
+ return /* @__PURE__ */ React.createElement("button", { onClick: handleClick }, copied ? /* @__PURE__ */ React.createElement(HiCheck, { size: 18 }) : /* @__PURE__ */ React.createElement(HiOutlineClipboardDocumentList, { size: 18 }));
14
+ }
15
+ export {
16
+ CodeBlockCopyButton as default
17
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+
3
+ interface CodeBlockIconProps {
4
+ language: string;
5
+ }
6
+ declare function CodeBlockIcon({ language }: CodeBlockIconProps): React.JSX.Element;
7
+
8
+ export { type CodeBlockIconProps, CodeBlockIcon as default };
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { FaTerminal, FaReact } from "react-icons/fa6";
3
+ import { HiCodeBracket } from "react-icons/hi2";
4
+ import { SiTypescript, SiTerraform, SiMarkdown, SiPhp, SiRuby, SiYaml } from "react-icons/si";
5
+ import { TbTxt } from "react-icons/tb";
6
+ import { VscJson } from "react-icons/vsc";
7
+ function CodeBlockIcon({ language }) {
8
+ switch (language) {
9
+ case "sh":
10
+ case "bash":
11
+ return /* @__PURE__ */ React.createElement(FaTerminal, null);
12
+ case "hcl":
13
+ return /* @__PURE__ */ React.createElement(SiTerraform, null);
14
+ case "typescript":
15
+ return /* @__PURE__ */ React.createElement(SiTypescript, null);
16
+ case "tsx":
17
+ return /* @__PURE__ */ React.createElement(FaReact, null);
18
+ case "markdown":
19
+ return /* @__PURE__ */ React.createElement(SiMarkdown, null);
20
+ case "php":
21
+ return /* @__PURE__ */ React.createElement(SiPhp, null);
22
+ case "ruby":
23
+ return /* @__PURE__ */ React.createElement(SiRuby, null);
24
+ case "yaml":
25
+ return /* @__PURE__ */ React.createElement(SiYaml, null);
26
+ case "json":
27
+ return /* @__PURE__ */ React.createElement(VscJson, null);
28
+ case "text":
29
+ return /* @__PURE__ */ React.createElement(TbTxt, null);
30
+ default:
31
+ return /* @__PURE__ */ React.createElement(HiCodeBracket, null);
32
+ }
33
+ }
34
+ export {
35
+ CodeBlockIcon as default
36
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ interface KifuProps {
4
+ kifu: string;
5
+ filename?: string;
6
+ }
7
+ declare function CodeBlockKifu({ kifu, filename }: KifuProps): React.JSX.Element | null;
8
+
9
+ export { type KifuProps, CodeBlockKifu as default };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { KifuLite, KifuStore } from "kifu-for-js";
3
+ import { useSearchParams } from "next/navigation";
4
+ import React, { useEffect, useState } from "react";
5
+ function CodeBlockKifu({ kifu, filename }) {
6
+ const searchParams = useSearchParams();
7
+ const id = filename ? `user-content-${filename}` : void 0;
8
+ const [kifuStore] = useState(() => new KifuStore({ kifu }));
9
+ useEffect(() => {
10
+ initKifuUserSettings();
11
+ }, []);
12
+ useEffect(() => {
13
+ const newPly = Number(searchParams.get("ply") ?? 0);
14
+ const hash = typeof window !== "undefined" ? window.location.hash.replace(/^#!?/, "") : "";
15
+ if (hash === id) {
16
+ kifuStore.player.goto(newPly);
17
+ }
18
+ }, [searchParams, kifuStore, id]);
19
+ if (!kifuStore) {
20
+ return null;
21
+ }
22
+ return /* @__PURE__ */ React.createElement("div", { className: "my-4 flex justify-center", id }, /* @__PURE__ */ React.createElement(KifuLite, { style: { width: "100%" }, kifuStore }));
23
+ }
24
+ function initKifuUserSettings() {
25
+ const LOCALSTORAGE_KEY = "kifuforjs";
26
+ const defaultSettings = {
27
+ hapticFeedback: false
28
+ };
29
+ const settings = localStorage.getItem(LOCALSTORAGE_KEY);
30
+ if (!settings) {
31
+ localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(defaultSettings));
32
+ }
33
+ }
34
+ export {
35
+ CodeBlockKifu as default
36
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+
3
+ interface CodeBlockMermaidProps {
4
+ code: string;
5
+ }
6
+ declare function CodeBlockMermaid({ code }: CodeBlockMermaidProps): React.JSX.Element;
7
+
8
+ export { type CodeBlockMermaidProps, CodeBlockMermaid as default };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { createHash } from "crypto";
3
+ import mermaid from "mermaid";
4
+ import { useTheme } from "next-themes";
5
+ import React, { useEffect, useRef, useState } from "react";
6
+ function createId(code) {
7
+ const hash = createHash("sha256");
8
+ hash.update(code);
9
+ return "id-" + hash.digest("hex");
10
+ }
11
+ function CodeBlockMermaid({ code }) {
12
+ const ref = useRef(null);
13
+ const [mounted, setMounted] = useState(false);
14
+ const [svg, setSvg] = useState("");
15
+ const { theme, systemTheme } = useTheme();
16
+ const id = createId(code);
17
+ useEffect(() => {
18
+ const renderMermaid = async () => {
19
+ if (!mounted) {
20
+ setMounted(true);
21
+ }
22
+ const currentTheme = theme === "system" ? systemTheme : theme;
23
+ if (mounted && ref.current) {
24
+ mermaid.initialize({ theme: currentTheme });
25
+ try {
26
+ const result = await mermaid.render(id, code, ref.current);
27
+ setSvg(result.svg);
28
+ } catch {
29
+ setSvg("Mermaid Syntax Error");
30
+ }
31
+ }
32
+ };
33
+ renderMermaid();
34
+ }, [mounted, code, id, theme, systemTheme, setSvg, setMounted]);
35
+ if (!mounted)
36
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, "Loading..."));
37
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { dangerouslySetInnerHTML: { __html: svg }, ref }));
38
+ }
39
+ export {
40
+ CodeBlockMermaid as default
41
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { CodeBlockComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function CodeBlock({ code, language }: CodeBlockComponentProps): Promise<React.JSX.Element>;
5
+
6
+ export { CodeBlock as default };
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import CodeBlockCopyButton from "./code-block-copy-button";
3
+ import CodeBlockIcon from "./code-block-icon";
4
+ import CodeBlockKifu from "./code-block-kifu";
5
+ import CodeBlockMermaid from "./code-block-mermaid";
6
+ import { highlighteCode } from "./shiki";
7
+ async function CodeBlock({ code, language }) {
8
+ const [lang, filename] = language.split(":");
9
+ const isMermaid = lang === "mermaid";
10
+ const isKifu = lang === "kifu";
11
+ if (isMermaid) return /* @__PURE__ */ React.createElement(CodeBlockMermaid, { code });
12
+ if (isKifu) return /* @__PURE__ */ React.createElement(CodeBlockKifu, { kifu: code, filename });
13
+ const html = await highlighteCode(code, lang);
14
+ return /* @__PURE__ */ React.createElement("div", { className: "code-block" }, /* @__PURE__ */ React.createElement("div", { className: "code-block-header" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(CodeBlockIcon, { language })), /* @__PURE__ */ React.createElement("div", { className: "code-block-filename" }, filename), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(CodeBlockCopyButton, { code }))), html && /* @__PURE__ */ React.createElement("div", { dangerouslySetInnerHTML: { __html: html } }), !html && /* @__PURE__ */ React.createElement("pre", null, code));
15
+ }
16
+ export {
17
+ CodeBlock as default
18
+ };
@@ -0,0 +1,3 @@
1
+ declare function highlighteCode(code: string, language: string): Promise<string | null>;
2
+
3
+ export { highlighteCode };
@@ -0,0 +1,28 @@
1
+ import { transformerNotationDiff, transformerNotationWordHighlight } from "@shikijs/transformers";
2
+ import { cache } from "react";
3
+ import { bundledLanguages, bundledThemes, getSingletonHighlighter } from "shiki";
4
+ async function highlighteCode(code, language) {
5
+ const highlighter = await getShikiHighlighter();
6
+ const shikiLang = Object.keys(bundledLanguages).find((lang) => lang === language);
7
+ if (shikiLang === void 0 && language !== "text") {
8
+ return null;
9
+ }
10
+ const html = highlighter.codeToHtml(code, {
11
+ lang: shikiLang || "text",
12
+ themes: {
13
+ light: "github-light",
14
+ dark: "github-dark-dimmed"
15
+ },
16
+ transformers: [transformerNotationDiff(), transformerNotationWordHighlight()]
17
+ });
18
+ return html;
19
+ }
20
+ const getShikiHighlighter = cache(async () => {
21
+ return getSingletonHighlighter({
22
+ themes: Object.keys(bundledThemes),
23
+ langs: Object.keys(bundledLanguages)
24
+ });
25
+ });
26
+ export {
27
+ highlighteCode
28
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ImageComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function Image({ src, width, height, alt }: ImageComponentProps): React.JSX.Element;
5
+
6
+ export { Image as default };
@@ -0,0 +1,8 @@
1
+ import NextImage from "next/image";
2
+ import React from "react";
3
+ function Image({ src, width, height, alt }) {
4
+ return /* @__PURE__ */ React.createElement(NextImage, { src, width, height, alt });
5
+ }
6
+ export {
7
+ Image as default
8
+ };
@@ -0,0 +1,9 @@
1
+ export { default as CodeBlock } from './code-block/code-block.mjs';
2
+ export { default as Image } from './image/image.mjs';
3
+ export { default as KifuTo } from './kifu-to/kifu-to.mjs';
4
+ export { default as Link } from './link/link.mjs';
5
+ export { default as LinkCard } from './link-card/link-card.mjs';
6
+ export { default as XPost } from './x-post/x-post.mjs';
7
+ export { default as Youtube } from './youtube/youtube.mjs';
8
+ import 'react';
9
+ import '@hackersheet/react-document-content';
@@ -0,0 +1,16 @@
1
+ import CodeBlock from "./code-block/code-block";
2
+ import Image from "./image/image";
3
+ import KifuTo from "./kifu-to/kifu-to";
4
+ import Link from "./link/link";
5
+ import LinkCard from "./link-card/link-card";
6
+ import XPost from "./x-post/x-post";
7
+ import Youtube from "./youtube/youtube";
8
+ export {
9
+ CodeBlock,
10
+ Image,
11
+ KifuTo,
12
+ Link,
13
+ LinkCard,
14
+ XPost,
15
+ Youtube
16
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { KifuToComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function KifuTo({ id, ply, label: defaultLabel }: KifuToComponentProps): React.JSX.Element;
5
+
6
+ export { KifuTo as default };
@@ -0,0 +1,11 @@
1
+ import Link from "next/link";
2
+ import React from "react";
3
+ function KifuTo({ id, ply, label: defaultLabel }) {
4
+ const fullId = `user-content-${id}`;
5
+ const href = `?ply=${ply}#${fullId}`;
6
+ const label = defaultLabel ?? `${ply}\u624B\u76EE`;
7
+ return /* @__PURE__ */ React.createElement(Link, { href }, label);
8
+ }
9
+ export {
10
+ KifuTo as default
11
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { LinkComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function Link({ href, id, children }: LinkComponentProps): React.JSX.Element;
5
+
6
+ export { Link as default };
@@ -0,0 +1,8 @@
1
+ import NextLink from "next/link";
2
+ import React from "react";
3
+ function Link({ href, id, children }) {
4
+ return /* @__PURE__ */ React.createElement(NextLink, { href, id }, children);
5
+ }
6
+ export {
7
+ Link as default
8
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { LinkCardComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function LinkCard({ domain, url, title, description, imageUrl, imageHeight, imageWidth, }: LinkCardComponentProps): React.JSX.Element;
5
+
6
+ export { LinkCard as default };
@@ -0,0 +1,17 @@
1
+ import Image from "next/image";
2
+ import React from "react";
3
+ function LinkCard({
4
+ domain,
5
+ url,
6
+ title,
7
+ description,
8
+ imageUrl,
9
+ imageHeight,
10
+ imageWidth
11
+ }) {
12
+ const faviconUrl = `https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://${domain}&size=16`;
13
+ return /* @__PURE__ */ React.createElement("a", { href: url, className: "link-card" }, /* @__PURE__ */ React.createElement("div", { className: "link-card-main" }, /* @__PURE__ */ React.createElement("div", { className: "link-card-title" }, title), /* @__PURE__ */ React.createElement("div", { className: "link-card-description" }, description), /* @__PURE__ */ React.createElement("div", { className: "link-card-domain" }, /* @__PURE__ */ React.createElement("picture", null, /* @__PURE__ */ React.createElement("img", { src: faviconUrl, alt: `${domain} favicon`, width: 16, height: 16 })), /* @__PURE__ */ React.createElement("div", null, domain))), imageUrl && /* @__PURE__ */ React.createElement("div", { className: "link-card-image" }, /* @__PURE__ */ React.createElement(Image, { alt: title, src: imageUrl, height: imageHeight, width: imageWidth })));
14
+ }
15
+ export {
16
+ LinkCard as default
17
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { XPostComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function XPost({ id }: XPostComponentProps): Promise<React.JSX.Element>;
5
+
6
+ export { XPost as default };
@@ -0,0 +1,19 @@
1
+ import { unstable_cache } from "next/cache";
2
+ import React from "react";
3
+ import { EmbeddedTweet, TweetNotFound } from "react-tweet";
4
+ import { getTweet as _getTweet } from "react-tweet/api";
5
+ const getTweet = unstable_cache(async (id) => _getTweet(id), ["tweet"], {
6
+ revalidate: 3600 * 24
7
+ });
8
+ async function XPost({ id }) {
9
+ try {
10
+ const tweet = await getTweet(id);
11
+ return tweet ? /* @__PURE__ */ React.createElement(EmbeddedTweet, { tweet }) : /* @__PURE__ */ React.createElement(TweetNotFound, null);
12
+ } catch (error) {
13
+ console.error(error);
14
+ return /* @__PURE__ */ React.createElement(TweetNotFound, { error });
15
+ }
16
+ }
17
+ export {
18
+ XPost as default
19
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { YoutubeComponentProps } from '@hackersheet/react-document-content';
3
+
4
+ declare function Youtube({ videoId, params, playLabel, ...props }: YoutubeComponentProps): Promise<React.JSX.Element>;
5
+
6
+ export { Youtube as default };
@@ -0,0 +1,9 @@
1
+ import { YouTubeEmbed } from "@next/third-parties/google";
2
+ import React from "react";
3
+ async function Youtube({ videoId, params, playLabel, ...props }) {
4
+ const paramsString = params ? Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&") : void 0;
5
+ return /* @__PURE__ */ React.createElement(YouTubeEmbed, { ...props, videoid: videoId, params: paramsString, playlabel: playLabel });
6
+ }
7
+ export {
8
+ Youtube as default
9
+ };
@@ -0,0 +1,9 @@
1
+ export { default as CodeBlock } from './components/code-block/code-block.mjs';
2
+ export { default as Image } from './components/image/image.mjs';
3
+ export { default as KifuTo } from './components/kifu-to/kifu-to.mjs';
4
+ export { default as Link } from './components/link/link.mjs';
5
+ export { default as LinkCard } from './components/link-card/link-card.mjs';
6
+ export { default as XPost } from './components/x-post/x-post.mjs';
7
+ export { default as Youtube } from './components/youtube/youtube.mjs';
8
+ import 'react';
9
+ import '@hackersheet/react-document-content';
@@ -0,0 +1 @@
1
+ export * from "./components";