@haklex/rich-renderer-codeblock 0.0.82 → 0.0.84

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.
@@ -1,230 +0,0 @@
1
- import { useMemo } from "react";
2
- import { getIconData, iconToHTML, iconToSVG } from "@iconify/utils";
3
- import { icons } from "@iconify-json/material-icon-theme";
4
- import { jsx } from "react/jsx-runtime";
5
- //#region src/icons/material-icon.ts
6
- /** Get SVG markup for a material-icon-theme icon by name. Returns null if not found. */
7
- function getMaterialIconSvg(iconName) {
8
- const data = getIconData(icons, iconName);
9
- if (!data) return null;
10
- const svg = iconToSVG(data);
11
- return iconToHTML(svg.body, svg.attributes);
12
- }
13
- //#endregion
14
- //#region src/icons/file.tsx
15
- /** Maps file extension to material-icon-theme icon name. */
16
- var EXT_TO_ICON = {
17
- ts: "typescript",
18
- tsx: "react-ts",
19
- mts: "typescript",
20
- cts: "typescript",
21
- js: "javascript",
22
- jsx: "react",
23
- mjs: "javascript",
24
- cjs: "javascript",
25
- py: "python",
26
- rs: "rust",
27
- go: "go",
28
- java: "java",
29
- html: "html",
30
- htm: "html",
31
- css: "css",
32
- scss: "sass",
33
- sass: "sass",
34
- less: "sass",
35
- json: "json",
36
- jsonc: "json",
37
- json5: "json",
38
- md: "markdown",
39
- mdx: "markdown",
40
- sh: "console",
41
- bash: "console",
42
- zsh: "console",
43
- yml: "yaml",
44
- yaml: "yaml",
45
- sql: "database",
46
- c: "c",
47
- h: "c",
48
- cpp: "cpp",
49
- cc: "cpp",
50
- cxx: "cpp",
51
- hpp: "cpp",
52
- swift: "swift",
53
- kt: "kotlin",
54
- kts: "kotlin",
55
- rb: "ruby",
56
- php: "php",
57
- vue: "vue",
58
- svelte: "svelte",
59
- toml: "toml",
60
- xml: "xml",
61
- graphql: "graphql",
62
- gql: "graphql",
63
- dockerfile: "docker",
64
- lua: "lua",
65
- zig: "zig"
66
- };
67
- function getFileIconSvg(filename) {
68
- return getMaterialIconSvg(EXT_TO_ICON[filename.split(".").pop()?.toLowerCase() ?? ""] ?? "file");
69
- }
70
- var FileIcon = ({ filename, size = 16, className, fallback = "F" }) => {
71
- const html = useMemo(() => getFileIconSvg(filename), [filename]);
72
- const wrapperStyle = {
73
- width: size,
74
- height: size,
75
- display: "inline-flex",
76
- alignItems: "center",
77
- justifyContent: "center",
78
- opacity: html ? 1 : .5,
79
- fontSize: size * .6
80
- };
81
- if (!html) return /* @__PURE__ */ jsx("span", {
82
- className,
83
- style: wrapperStyle,
84
- children: fallback
85
- });
86
- return /* @__PURE__ */ jsx("span", {
87
- className,
88
- dangerouslySetInnerHTML: { __html: html },
89
- style: {
90
- width: size,
91
- height: size
92
- }
93
- });
94
- };
95
- //#endregion
96
- //#region src/styles.css.ts
97
- var semanticClassNames = {
98
- card: "rr-code-card",
99
- lang: "rr-code-lang",
100
- langIcon: "rr-code-lang-icon",
101
- copyButton: "rr-code-copy",
102
- bodyBackground: "rr-code-bg",
103
- scroll: "rr-code-scroll",
104
- scrollCollapsed: "rr-code-scroll-collapsed",
105
- body: "rr-code-body",
106
- bodyReadonly: "rr-code-readonly",
107
- expandWrap: "rr-code-expand-wrap",
108
- expandButton: "rr-code-expand",
109
- lined: "rr-code-lined",
110
- linedWithNumbers: "rr-code-lined-ln"
111
- };
112
- var card = "_1pn9r4q0";
113
- var langInput = "_1pn9r4q1";
114
- var lang = "_1pn9r4q2";
115
- var langIcon = "_1pn9r4q3";
116
- var copyButton = "_1pn9r4q4";
117
- var bodyBackground = "_1pn9r4q5";
118
- var scroll = "_1pn9r4q6";
119
- var scrollCollapsed = "_1pn9r4q7";
120
- var body = "_1pn9r4q8";
121
- var bodyReadonly = "_1pn9r4q9";
122
- var expandWrap = "_1pn9r4qa";
123
- var expandButton = "_1pn9r4qb";
124
- var lined = "_1pn9r4qc";
125
- var linedWithNumbers = "_1pn9r4qd";
126
- //#endregion
127
- //#region src/icons/language.tsx
128
- /** Maps normalized language to material-icon-theme icon name. */
129
- var LANG_TO_ICON = {
130
- "javascript": "javascript",
131
- "js": "javascript",
132
- "typescript": "typescript",
133
- "ts": "typescript",
134
- "angular-ts": "angular",
135
- "angular-html": "angular",
136
- "jsx": "react",
137
- "tsx": "react",
138
- "html": "html",
139
- "html-derivative": "html",
140
- "css": "css",
141
- "scss": "sass",
142
- "sass": "sass",
143
- "less": "sass",
144
- "postcss": "postcss",
145
- "stylus": "stylus",
146
- "json": "json",
147
- "json5": "json",
148
- "jsonc": "json",
149
- "jsonl": "json",
150
- "markdown": "markdown",
151
- "md": "markdown",
152
- "mdx": "markdown",
153
- "mdc": "markdown",
154
- "bash": "console",
155
- "sh": "console",
156
- "shell": "console",
157
- "shellscript": "console",
158
- "zsh": "console",
159
- "python": "python",
160
- "py": "python",
161
- "rust": "rust",
162
- "go": "go",
163
- "java": "java",
164
- "c": "c",
165
- "cpp": "cpp",
166
- "c++": "cpp",
167
- "swift": "swift",
168
- "kotlin": "kotlin",
169
- "kt": "kotlin",
170
- "yaml": "yaml",
171
- "yml": "yaml",
172
- "sql": "database",
173
- "xml": "xml",
174
- "vue": "vue",
175
- "vue-html": "vue",
176
- "vue-vine": "vue",
177
- "svelte": "svelte",
178
- "astro": "astro",
179
- "php": "php",
180
- "rb": "ruby",
181
- "r": "r",
182
- "julia": "julia",
183
- "lua": "lua",
184
- "zig": "zig",
185
- "toml": "toml",
186
- "graphql": "graphql",
187
- "gql": "graphql",
188
- "dockerfile": "docker",
189
- "coffee": "coffee",
190
- "pug": "pug",
191
- "haml": "haml",
192
- "handlebars": "handlebars",
193
- "marko": "markojs",
194
- "imba": "imba",
195
- "hurl": "hurl",
196
- "http": "http"
197
- };
198
- function getLanguageIconSvg(lang) {
199
- return getMaterialIconSvg(LANG_TO_ICON[lang] ?? "code");
200
- }
201
- /** Returns whether a Material icon is available for the given language. */
202
- function hasLanguageIcon(lang) {
203
- return getLanguageIconSvg(lang) !== null;
204
- }
205
- var LanguageIcon = ({ language, size = 14, className = `${langIcon} ${semanticClassNames.langIcon}` }) => {
206
- const html = useMemo(() => getLanguageIconSvg(language), [language]);
207
- if (!html) return /* @__PURE__ */ jsx("span", {
208
- className,
209
- style: {
210
- width: size,
211
- height: size,
212
- display: "inline-flex",
213
- alignItems: "center",
214
- justifyContent: "center",
215
- opacity: .6,
216
- fontSize: size * .6
217
- },
218
- children: "•"
219
- });
220
- return /* @__PURE__ */ jsx("span", {
221
- className,
222
- dangerouslySetInnerHTML: { __html: html },
223
- style: {
224
- width: size,
225
- height: size
226
- }
227
- });
228
- };
229
- //#endregion
230
- export { semanticClassNames as _, bodyBackground as a, copyButton as c, lang as d, langInput as f, scrollCollapsed as g, scroll as h, body as i, expandButton as l, linedWithNumbers as m, LanguageIcon as n, bodyReadonly as o, lined as p, hasLanguageIcon as r, card as s, LANG_TO_ICON as t, expandWrap as u, FileIcon as v, getMaterialIconSvg as y };