@imfusion/web-ui 0.5.1-dev.44.g02fbbc52 → 0.5.1-dev.45.gf3889fa8

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,6 +1,35 @@
1
- export declare const SUPPORTED_LANGUAGES: readonly ["tsx", "ts", "css", "shell", "json"];
2
- declare const LANGUAGE_ALIASES: readonly ["typescript", "bash", "sh", "zsh", "shellscript", "scss"];
3
- export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number] | (typeof LANGUAGE_ALIASES)[number];
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[]): 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">;
@@ -2,63 +2,192 @@ 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, renderNodesToHtml as c, renderTokens as l } from "@tanstack/highlight/core";
6
- import { css as u } from "@tanstack/highlight/languages/css";
7
- import { json as d } from "@tanstack/highlight/languages/json";
8
- import { plaintext as f } from "@tanstack/highlight/languages/plaintext";
9
- import { shell as p } from "@tanstack/highlight/languages/shell";
10
- import { ts as m } from "@tanstack/highlight/languages/ts";
11
- import { tsx as h } from "@tanstack/highlight/languages/tsx";
12
- //#region src/integrations/code-highlight/highlighter.ts
13
- var g = [
14
- "tsx",
15
- "ts",
16
- "css",
17
- "shell",
18
- "json"
19
- ], _ = [
20
- "typescript",
21
- "bash",
22
- "sh",
23
- "zsh",
24
- "shellscript",
25
- "scss"
26
- ], v = [...g, ..._];
27
- function y(e) {
28
- return v.includes(e);
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 { python as m } from "@tanstack/highlight/languages/python";
10
+ import { shell as h } from "@tanstack/highlight/languages/shell";
11
+ import { ts as g } from "@tanstack/highlight/languages/ts";
12
+ import { tsx as _ } from "@tanstack/highlight/languages/tsx";
13
+ //#region src/integrations/code-highlight/language-patterns.ts
14
+ function v(e, t) {
15
+ let n = [], r = new Uint8Array(e.length);
16
+ for (let i of t) {
17
+ let t = new RegExp(i.regex.source, i.regex.flags.includes("g") ? i.regex.flags : `${i.regex.flags}g`), a;
18
+ for (; (a = t.exec(e)) !== null;) {
19
+ let e = i.group == null ? a[0] : a[i.group];
20
+ if (e === "") {
21
+ a[0] === "" && (t.lastIndex += 1);
22
+ continue;
23
+ }
24
+ let o = i.group == null ? 0 : a[0].indexOf(e), s = a.index + o, c = s + e.length;
25
+ if (s < c) {
26
+ let e = !1;
27
+ for (let t = s; t < c; t += 1) if (r[t]) {
28
+ e = !0;
29
+ break;
30
+ }
31
+ e || (n.push({
32
+ start: s,
33
+ end: c,
34
+ className: i.className
35
+ }), r.fill(1, s, c));
36
+ }
37
+ }
38
+ }
39
+ return n;
40
+ }
41
+ //#endregion
42
+ //#region src/integrations/code-highlight/languages/cmake.ts
43
+ var y = [
44
+ {
45
+ className: "string",
46
+ regex: /"(?:\\.|[^"\\\n])*"|\[(=*)\[[\s\S]*?\]\1\]/g
47
+ },
48
+ {
49
+ className: "comment",
50
+ regex: /#[^\n]*/g
51
+ },
52
+ {
53
+ className: "variable",
54
+ regex: /\$(?:ENV|CACHE)?\{[^}\n]+\}/g
55
+ },
56
+ {
57
+ className: "keyword",
58
+ regex: /\b(?:break|continue|else|elseif|endforeach|endfunction|endif|endmacro|endwhile|if|include|macro|return|while)\b/gi
59
+ },
60
+ {
61
+ className: "literal",
62
+ regex: /\b(?:FALSE|IGNORE|NOTFOUND|NO|OFF|ON|TRUE|YES)\b/gi
63
+ },
64
+ {
65
+ className: "function",
66
+ regex: /\b[A-Za-z_][\w-]*(?=\s*\()/g
67
+ },
68
+ {
69
+ className: "number",
70
+ regex: /\b\d+(?:\.\d+)?\b/g
71
+ },
72
+ {
73
+ className: "operator",
74
+ regex: /(?:LESS_EQUAL|GREATER_EQUAL|STREQUAL|IN_LIST|MATCHES|EQUAL|LESS|GREATER|AND|OR|NOT|[=<>+*/!-])/gi
75
+ }
76
+ ], b = c({
77
+ name: "cmake",
78
+ tokenize(e) {
79
+ return v(e, y);
80
+ }
81
+ }), x = [
82
+ {
83
+ className: "comment",
84
+ regex: /\/\/[^\n]*|\/\*[\s\S]*?\*\//g
85
+ },
86
+ {
87
+ className: "string",
88
+ regex: /"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g
89
+ },
90
+ {
91
+ className: "meta",
92
+ regex: /^[ \t]*#[ \t]*(?:include|define|if|ifdef|ifndef|elif|else|endif|pragma|undef|error|warning)\b/gm
93
+ },
94
+ {
95
+ className: "keyword",
96
+ 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
97
+ },
98
+ {
99
+ className: "type",
100
+ regex: /\b(?:bool|char|char8_t|char16_t|char32_t|double|float|int|long|short|signed|unsigned|void|wchar_t)\b/g
101
+ },
102
+ {
103
+ className: "literal",
104
+ regex: /\b(?:NULL|nullptr|true|false)\b/g
105
+ },
106
+ {
107
+ className: "function",
108
+ regex: /\b[A-Za-z_]\w*(?=\s*\()/g
109
+ },
110
+ {
111
+ className: "number",
112
+ regex: /\b(?:0[xX][\da-fA-F']+|0[bB][01']+|\d[\d']*(?:\.\d[\d']*)?(?:[eE][+-]?\d[\d']*)?[uUlLfF]*)\b/g
113
+ },
114
+ {
115
+ className: "operator",
116
+ regex: /(?:<<=?|>>=?|->\*|->|\+\+|--|&&|\|\||==|!=|<=|>=|::|\+=|-=|\*=|\/=|%=|&=|\|=|\^=|[-+*/%=&|^!<>?:~])/g
117
+ }
118
+ ], S = c({
119
+ name: "cpp",
120
+ aliases: [
121
+ "c++",
122
+ "cc",
123
+ "cxx",
124
+ "hpp"
125
+ ],
126
+ tokenize(e) {
127
+ return v(e, x);
128
+ }
129
+ }), C = {
130
+ tsx: { aliases: ["typescriptreact"] },
131
+ ts: { aliases: ["typescript"] },
132
+ css: { aliases: ["scss"] },
133
+ shell: { aliases: [
134
+ "bash",
135
+ "sh",
136
+ "zsh",
137
+ "shellscript"
138
+ ] },
139
+ json: { aliases: [] },
140
+ cpp: { aliases: [
141
+ "c++",
142
+ "cc",
143
+ "cxx",
144
+ "hpp"
145
+ ] },
146
+ python: { aliases: ["py"] },
147
+ cmake: { aliases: [] }
148
+ }, w = Object.keys(C), T = [...w, ...Object.values(C).flatMap(({ aliases: e }) => e)];
149
+ function E(e) {
150
+ return T.includes(e);
151
+ }
152
+ function D(e, t) {
153
+ return e.aliases.includes(t);
29
154
  }
30
- var b = {
31
- shellscript: "shell",
32
- scss: "css"
33
- }, x = s({
155
+ function O(e) {
156
+ for (let [t, n] of Object.entries(C)) if (D(n, e)) return t;
157
+ return e;
158
+ }
159
+ var k = s({
34
160
  languages: [
161
+ _,
162
+ g,
163
+ d,
35
164
  h,
165
+ f,
166
+ S,
36
167
  m,
37
- u,
38
- p,
39
- d,
40
- f
168
+ b,
169
+ p
41
170
  ],
42
171
  fallbackLanguage: "plaintext"
43
172
  });
44
- function S(e, t) {
45
- let n = b[t] ?? t, { tokens: r } = x.tokenize(e, { lang: n });
46
- return c(l(r));
173
+ function A(e, t) {
174
+ let n = O(t), { tokens: r } = k.tokenize(e, { lang: n });
175
+ return l(u(r));
47
176
  }
48
177
  //#endregion
49
178
  //#region src/integrations/code-highlight/code-highlight.tsx
50
- var C = /* @__PURE__ */ e({
51
- Block: () => T,
52
- Inline: () => E,
179
+ var j = /* @__PURE__ */ e({
180
+ Block: () => N,
181
+ Inline: () => P,
53
182
  InlineLink: () => n
54
183
  });
55
- function w(e, t) {
184
+ function M(e, t) {
56
185
  return a(() => {
57
- if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html: S(e, t) } });
186
+ if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html: A(e, t) } });
58
187
  }, [e, t]);
59
188
  }
60
- function T({ language: e, children: t, ...n }) {
61
- let i = w(t, e);
189
+ function N({ language: e, children: t, ...n }) {
190
+ let i = M(t, e);
62
191
  return /* @__PURE__ */ o(r, {
63
192
  ...n,
64
193
  language: e,
@@ -66,19 +195,19 @@ function T({ language: e, children: t, ...n }) {
66
195
  children: t
67
196
  });
68
197
  }
69
- T.displayName = "Code.Block";
70
- function E({ language: e, children: t, ...n }) {
71
- let r = w(t, e);
198
+ N.displayName = "Code.Block";
199
+ function P({ language: e, children: t, ...n }) {
200
+ let r = M(t, e);
72
201
  return /* @__PURE__ */ o(i, {
73
202
  ...n,
74
203
  highlighted: r,
75
204
  children: t
76
205
  });
77
206
  }
78
- E.displayName = "Code.Inline";
207
+ P.displayName = "Code.Inline";
79
208
  //#endregion
80
209
  //#region src/integrations/code-highlight/code-highlight.meta.ts
81
- var D = {
210
+ var F = {
82
211
  name: "CodeHighlight",
83
212
  category: t.display,
84
213
  status: "experimental",
@@ -94,4 +223,4 @@ var D = {
94
223
  }
95
224
  };
96
225
  //#endregion
97
- export { C as Code, g as SUPPORTED_LANGUAGES, D as codeHighlightMeta, y as isSupportedLanguage };
226
+ export { j as Code, w as SUPPORTED_LANGUAGES, F as codeHighlightMeta, E as isSupportedLanguage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imfusion/web-ui",
3
- "version": "0.5.1-dev.44.g02fbbc52",
3
+ "version": "0.5.1-dev.45.gf3889fa8",
4
4
  "description": "The official Web UI component library for ImFusion web apps",
5
5
  "author": "ImFusion GmbH",
6
6
  "license": "UNLICENSED",