@imfusion/web-ui 0.5.1-dev.44.g02fbbc52 → 0.5.1-dev.46.gd27f0cfa
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/integrations/code-highlight/highlighter.d.ts +32 -3
- package/dist/integrations/code-highlight/language-patterns.d.ts +7 -0
- package/dist/integrations/code-highlight/languages/cmake.d.ts +1 -0
- package/dist/integrations/code-highlight/languages/cpp.d.ts +1 -0
- package/dist/integrations/code-highlight/languages/python.d.ts +1 -0
- package/dist/integrations/code-highlight.js +188 -48
- package/package.json +1 -1
|
@@ -1,6 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const LANGUAGE_DEFINITIONS: {
|
|
2
|
+
readonly tsx: {
|
|
3
|
+
readonly aliases: readonly ["typescriptreact"];
|
|
4
|
+
};
|
|
5
|
+
readonly ts: {
|
|
6
|
+
readonly aliases: readonly ["typescript"];
|
|
7
|
+
};
|
|
8
|
+
readonly css: {
|
|
9
|
+
readonly aliases: readonly ["scss"];
|
|
10
|
+
};
|
|
11
|
+
readonly shell: {
|
|
12
|
+
readonly aliases: readonly ["bash", "sh", "zsh", "shellscript"];
|
|
13
|
+
};
|
|
14
|
+
readonly json: {
|
|
15
|
+
readonly aliases: readonly [];
|
|
16
|
+
};
|
|
17
|
+
readonly cpp: {
|
|
18
|
+
readonly aliases: readonly ["c++", "cc", "cxx", "hpp"];
|
|
19
|
+
};
|
|
20
|
+
readonly python: {
|
|
21
|
+
readonly aliases: readonly ["py"];
|
|
22
|
+
};
|
|
23
|
+
readonly cmake: {
|
|
24
|
+
readonly aliases: readonly [];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const SUPPORTED_LANGUAGES: string[];
|
|
28
|
+
type CanonicalLanguage = keyof typeof LANGUAGE_DEFINITIONS;
|
|
29
|
+
type LanguageAlias = {
|
|
30
|
+
[Language in CanonicalLanguage]: (typeof LANGUAGE_DEFINITIONS)[Language]["aliases"][number];
|
|
31
|
+
}[CanonicalLanguage];
|
|
32
|
+
export type SupportedLanguage = CanonicalLanguage | LanguageAlias;
|
|
4
33
|
export declare function isSupportedLanguage(value: string): value is SupportedLanguage;
|
|
5
34
|
export declare function highlightToHtml(code: string, language: SupportedLanguage): string;
|
|
6
35
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HighlightTokenClass, TokenRange } from '@tanstack/highlight/core';
|
|
2
|
+
export type LanguagePattern = {
|
|
3
|
+
className: HighlightTokenClass;
|
|
4
|
+
group?: number;
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
};
|
|
7
|
+
export declare function collectPatternRanges(code: string, patterns: readonly LanguagePattern[], initialRanges?: readonly TokenRange[]): TokenRange[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cmake: import('@tanstack/highlight/core').LanguageDefinition<"cmake">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cpp: import('@tanstack/highlight/core').LanguageDefinition<"cpp">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const python: import('@tanstack/highlight/core').LanguageDefinition<"python">;
|
|
@@ -2,63 +2,203 @@ import { a as e, t } from "../meta-B8C51eyL.js";
|
|
|
2
2
|
import { i as n, n as r, r as i } from "../code-qBbqAHK-.js";
|
|
3
3
|
import { useMemo as a } from "react";
|
|
4
4
|
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
-
import { createHighlighter as s,
|
|
6
|
-
import { css as
|
|
7
|
-
import { json as
|
|
8
|
-
import { plaintext as
|
|
9
|
-
import { shell as
|
|
10
|
-
import { ts as
|
|
11
|
-
import { tsx as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
import { createHighlighter as s, defineLanguage as c, renderNodesToHtml as l, renderTokens as u } from "@tanstack/highlight/core";
|
|
6
|
+
import { css as d } from "@tanstack/highlight/languages/css";
|
|
7
|
+
import { json as f } from "@tanstack/highlight/languages/json";
|
|
8
|
+
import { plaintext as p } from "@tanstack/highlight/languages/plaintext";
|
|
9
|
+
import { shell as m } from "@tanstack/highlight/languages/shell";
|
|
10
|
+
import { ts as h } from "@tanstack/highlight/languages/ts";
|
|
11
|
+
import { tsx as g } from "@tanstack/highlight/languages/tsx";
|
|
12
|
+
import { python as _ } from "@tanstack/highlight/languages/python";
|
|
13
|
+
//#region src/integrations/code-highlight/language-patterns.ts
|
|
14
|
+
function v(e, t, n = []) {
|
|
15
|
+
let r = [], i = new Uint8Array(e.length);
|
|
16
|
+
for (let { start: e, end: t } of n) i.fill(1, e, t);
|
|
17
|
+
for (let n of t) {
|
|
18
|
+
let t = new RegExp(n.regex.source, n.regex.flags.includes("g") ? n.regex.flags : `${n.regex.flags}g`), a;
|
|
19
|
+
for (; (a = t.exec(e)) !== null;) {
|
|
20
|
+
let e = n.group == null ? a[0] : a[n.group];
|
|
21
|
+
if (e === "") {
|
|
22
|
+
a[0] === "" && (t.lastIndex += 1);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
let o = n.group == null ? 0 : a[0].indexOf(e), s = a.index + o, c = s + e.length;
|
|
26
|
+
if (s < c) {
|
|
27
|
+
let e = !1;
|
|
28
|
+
for (let t = s; t < c; t += 1) if (i[t]) {
|
|
29
|
+
e = !0;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
e || (r.push({
|
|
33
|
+
start: s,
|
|
34
|
+
end: c,
|
|
35
|
+
className: n.className
|
|
36
|
+
}), i.fill(1, s, c));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return r;
|
|
29
41
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/integrations/code-highlight/languages/cmake.ts
|
|
44
|
+
var y = [
|
|
45
|
+
{
|
|
46
|
+
className: "string",
|
|
47
|
+
regex: /"(?:\\.|[^"\\\n])*"|\[(=*)\[[\s\S]*?\]\1\]/g
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
className: "comment",
|
|
51
|
+
regex: /#[^\n]*/g
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
className: "variable",
|
|
55
|
+
regex: /\$(?:ENV|CACHE)?\{[^}\n]+\}/g
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
className: "keyword",
|
|
59
|
+
regex: /\b(?:break|continue|else|elseif|endforeach|endfunction|endif|endmacro|endwhile|if|include|macro|return|while)\b/gi
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
className: "literal",
|
|
63
|
+
regex: /\b(?:FALSE|IGNORE|NOTFOUND|NO|OFF|ON|TRUE|YES)\b/gi
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
className: "function",
|
|
67
|
+
regex: /\b[A-Za-z_][\w-]*(?=\s*\()/g
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
className: "number",
|
|
71
|
+
regex: /\b\d+(?:\.\d+)?\b/g
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
className: "operator",
|
|
75
|
+
regex: /(?:LESS_EQUAL|GREATER_EQUAL|STREQUAL|IN_LIST|MATCHES|EQUAL|LESS|GREATER|AND|OR|NOT|[=<>+*/!-])/gi
|
|
76
|
+
}
|
|
77
|
+
], b = c({
|
|
78
|
+
name: "cmake",
|
|
79
|
+
tokenize(e) {
|
|
80
|
+
return v(e, y);
|
|
81
|
+
}
|
|
82
|
+
}), x = [
|
|
83
|
+
{
|
|
84
|
+
className: "comment",
|
|
85
|
+
regex: /\/\/[^\n]*|\/\*[\s\S]*?\*\//g
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
className: "string",
|
|
89
|
+
regex: /"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
className: "meta",
|
|
93
|
+
regex: /^[ \t]*#[ \t]*(?:include|define|if|ifdef|ifndef|elif|else|endif|pragma|undef|error|warning)\b/gm
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
className: "keyword",
|
|
97
|
+
regex: /\b(?:alignas|alignof|and|asm|atomic_cancel|atomic_commit|atomic_noexcept|auto|bitand|bitor|break|case|catch|co_await|co_return|co_yield|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|default|delete|do|dynamic_cast|else|enum|explicit|export|extern|for|friend|goto|if|inline|mutable|namespace|new|noexcept|not|operator|or|private|protected|public|reflexpr|register|reinterpret_cast|requires|return|sizeof|static|static_assert|static_cast|struct|switch|synchronized|template|this|thread_local|throw|try|typedef|typeid|typename|union|using|virtual|volatile|while|xor)\b/g
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
className: "type",
|
|
101
|
+
regex: /\b(?:bool|char|char8_t|char16_t|char32_t|double|float|int|long|short|signed|unsigned|void|wchar_t)\b/g
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
className: "literal",
|
|
105
|
+
regex: /\b(?:NULL|nullptr|true|false)\b/g
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
className: "function",
|
|
109
|
+
regex: /\b[A-Za-z_]\w*(?=\s*\()/g
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
className: "number",
|
|
113
|
+
regex: /\b(?:0[xX][\da-fA-F']+|0[bB][01']+|\d[\d']*(?:\.\d[\d']*)?(?:[eE][+-]?\d[\d']*)?[uUlLfF]*)\b/g
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
className: "operator",
|
|
117
|
+
regex: /(?:<<=?|>>=?|->\*|->|\+\+|--|&&|\|\||==|!=|<=|>=|::|\+=|-=|\*=|\/=|%=|&=|\|=|\^=|[-+*/%=&|^!<>?:~])/g
|
|
118
|
+
}
|
|
119
|
+
], S = c({
|
|
120
|
+
name: "cpp",
|
|
121
|
+
aliases: [
|
|
122
|
+
"c++",
|
|
123
|
+
"cc",
|
|
124
|
+
"cxx",
|
|
125
|
+
"hpp"
|
|
126
|
+
],
|
|
127
|
+
tokenize(e) {
|
|
128
|
+
return v(e, x);
|
|
129
|
+
}
|
|
130
|
+
}), C = [{
|
|
131
|
+
className: "function",
|
|
132
|
+
regex: /\b[A-Za-z_]\w*(?=\s*\()/g
|
|
133
|
+
}], w = c({
|
|
134
|
+
name: "python",
|
|
135
|
+
aliases: ["py"],
|
|
136
|
+
tokenize(e, t) {
|
|
137
|
+
let n = _.tokenize(e, t), r = v(e, C, n);
|
|
138
|
+
return [...n, ...r];
|
|
139
|
+
}
|
|
140
|
+
}), T = {
|
|
141
|
+
tsx: { aliases: ["typescriptreact"] },
|
|
142
|
+
ts: { aliases: ["typescript"] },
|
|
143
|
+
css: { aliases: ["scss"] },
|
|
144
|
+
shell: { aliases: [
|
|
145
|
+
"bash",
|
|
146
|
+
"sh",
|
|
147
|
+
"zsh",
|
|
148
|
+
"shellscript"
|
|
149
|
+
] },
|
|
150
|
+
json: { aliases: [] },
|
|
151
|
+
cpp: { aliases: [
|
|
152
|
+
"c++",
|
|
153
|
+
"cc",
|
|
154
|
+
"cxx",
|
|
155
|
+
"hpp"
|
|
156
|
+
] },
|
|
157
|
+
python: { aliases: ["py"] },
|
|
158
|
+
cmake: { aliases: [] }
|
|
159
|
+
}, E = Object.keys(T), D = [...E, ...Object.values(T).flatMap(({ aliases: e }) => e)];
|
|
160
|
+
function O(e) {
|
|
161
|
+
return D.includes(e);
|
|
162
|
+
}
|
|
163
|
+
function k(e, t) {
|
|
164
|
+
return e.aliases.includes(t);
|
|
165
|
+
}
|
|
166
|
+
function A(e) {
|
|
167
|
+
for (let [t, n] of Object.entries(T)) if (k(n, e)) return t;
|
|
168
|
+
return e;
|
|
169
|
+
}
|
|
170
|
+
var j = s({
|
|
34
171
|
languages: [
|
|
172
|
+
g,
|
|
35
173
|
h,
|
|
36
|
-
m,
|
|
37
|
-
u,
|
|
38
|
-
p,
|
|
39
174
|
d,
|
|
40
|
-
|
|
175
|
+
m,
|
|
176
|
+
f,
|
|
177
|
+
S,
|
|
178
|
+
w,
|
|
179
|
+
b,
|
|
180
|
+
p
|
|
41
181
|
],
|
|
42
182
|
fallbackLanguage: "plaintext"
|
|
43
183
|
});
|
|
44
|
-
function
|
|
45
|
-
let n =
|
|
46
|
-
return
|
|
184
|
+
function M(e, t) {
|
|
185
|
+
let n = A(t), { tokens: r } = j.tokenize(e, { lang: n });
|
|
186
|
+
return l(u(r));
|
|
47
187
|
}
|
|
48
188
|
//#endregion
|
|
49
189
|
//#region src/integrations/code-highlight/code-highlight.tsx
|
|
50
|
-
var
|
|
51
|
-
Block: () =>
|
|
52
|
-
Inline: () =>
|
|
190
|
+
var N = /* @__PURE__ */ e({
|
|
191
|
+
Block: () => F,
|
|
192
|
+
Inline: () => I,
|
|
53
193
|
InlineLink: () => n
|
|
54
194
|
});
|
|
55
|
-
function
|
|
195
|
+
function P(e, t) {
|
|
56
196
|
return a(() => {
|
|
57
|
-
if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html:
|
|
197
|
+
if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html: M(e, t) } });
|
|
58
198
|
}, [e, t]);
|
|
59
199
|
}
|
|
60
|
-
function
|
|
61
|
-
let i =
|
|
200
|
+
function F({ language: e, children: t, ...n }) {
|
|
201
|
+
let i = P(t, e);
|
|
62
202
|
return /* @__PURE__ */ o(r, {
|
|
63
203
|
...n,
|
|
64
204
|
language: e,
|
|
@@ -66,19 +206,19 @@ function T({ language: e, children: t, ...n }) {
|
|
|
66
206
|
children: t
|
|
67
207
|
});
|
|
68
208
|
}
|
|
69
|
-
|
|
70
|
-
function
|
|
71
|
-
let r =
|
|
209
|
+
F.displayName = "Code.Block";
|
|
210
|
+
function I({ language: e, children: t, ...n }) {
|
|
211
|
+
let r = P(t, e);
|
|
72
212
|
return /* @__PURE__ */ o(i, {
|
|
73
213
|
...n,
|
|
74
214
|
highlighted: r,
|
|
75
215
|
children: t
|
|
76
216
|
});
|
|
77
217
|
}
|
|
78
|
-
|
|
218
|
+
I.displayName = "Code.Inline";
|
|
79
219
|
//#endregion
|
|
80
220
|
//#region src/integrations/code-highlight/code-highlight.meta.ts
|
|
81
|
-
var
|
|
221
|
+
var L = {
|
|
82
222
|
name: "CodeHighlight",
|
|
83
223
|
category: t.display,
|
|
84
224
|
status: "experimental",
|
|
@@ -94,4 +234,4 @@ var D = {
|
|
|
94
234
|
}
|
|
95
235
|
};
|
|
96
236
|
//#endregion
|
|
97
|
-
export {
|
|
237
|
+
export { N as Code, E as SUPPORTED_LANGUAGES, L as codeHighlightMeta, O as isSupportedLanguage };
|
package/package.json
CHANGED