@imfusion/web-ui 0.5.1-dev.45.gf3889fa8 → 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.
@@ -4,4 +4,4 @@ export type LanguagePattern = {
4
4
  group?: number;
5
5
  regex: RegExp;
6
6
  };
7
- export declare function collectPatternRanges(code: string, patterns: readonly LanguagePattern[]): TokenRange[];
7
+ export declare function collectPatternRanges(code: string, patterns: readonly LanguagePattern[], initialRanges?: readonly TokenRange[]): TokenRange[];
@@ -0,0 +1 @@
1
+ export declare const python: import('@tanstack/highlight/core').LanguageDefinition<"python">;
@@ -6,37 +6,38 @@ import { createHighlighter as s, defineLanguage as c, renderNodesToHtml as l, re
6
6
  import { css as d } from "@tanstack/highlight/languages/css";
7
7
  import { json as f } from "@tanstack/highlight/languages/json";
8
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";
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
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;
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;
18
19
  for (; (a = t.exec(e)) !== null;) {
19
- let e = i.group == null ? a[0] : a[i.group];
20
+ let e = n.group == null ? a[0] : a[n.group];
20
21
  if (e === "") {
21
22
  a[0] === "" && (t.lastIndex += 1);
22
23
  continue;
23
24
  }
24
- let o = i.group == null ? 0 : a[0].indexOf(e), s = a.index + o, c = s + e.length;
25
+ let o = n.group == null ? 0 : a[0].indexOf(e), s = a.index + o, c = s + e.length;
25
26
  if (s < c) {
26
27
  let e = !1;
27
- for (let t = s; t < c; t += 1) if (r[t]) {
28
+ for (let t = s; t < c; t += 1) if (i[t]) {
28
29
  e = !0;
29
30
  break;
30
31
  }
31
- e || (n.push({
32
+ e || (r.push({
32
33
  start: s,
33
34
  end: c,
34
- className: i.className
35
- }), r.fill(1, s, c));
35
+ className: n.className
36
+ }), i.fill(1, s, c));
36
37
  }
37
38
  }
38
39
  }
39
- return n;
40
+ return r;
40
41
  }
41
42
  //#endregion
42
43
  //#region src/integrations/code-highlight/languages/cmake.ts
@@ -126,7 +127,17 @@ var y = [
126
127
  tokenize(e) {
127
128
  return v(e, x);
128
129
  }
129
- }), C = {
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 = {
130
141
  tsx: { aliases: ["typescriptreact"] },
131
142
  ts: { aliases: ["typescript"] },
132
143
  css: { aliases: ["scss"] },
@@ -145,49 +156,49 @@ var y = [
145
156
  ] },
146
157
  python: { aliases: ["py"] },
147
158
  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);
159
+ }, E = Object.keys(T), D = [...E, ...Object.values(T).flatMap(({ aliases: e }) => e)];
160
+ function O(e) {
161
+ return D.includes(e);
151
162
  }
152
- function D(e, t) {
163
+ function k(e, t) {
153
164
  return e.aliases.includes(t);
154
165
  }
155
- function O(e) {
156
- for (let [t, n] of Object.entries(C)) if (D(n, e)) return t;
166
+ function A(e) {
167
+ for (let [t, n] of Object.entries(T)) if (k(n, e)) return t;
157
168
  return e;
158
169
  }
159
- var k = s({
170
+ var j = s({
160
171
  languages: [
161
- _,
162
172
  g,
163
- d,
164
173
  h,
174
+ d,
175
+ m,
165
176
  f,
166
177
  S,
167
- m,
178
+ w,
168
179
  b,
169
180
  p
170
181
  ],
171
182
  fallbackLanguage: "plaintext"
172
183
  });
173
- function A(e, t) {
174
- let n = O(t), { tokens: r } = k.tokenize(e, { lang: n });
184
+ function M(e, t) {
185
+ let n = A(t), { tokens: r } = j.tokenize(e, { lang: n });
175
186
  return l(u(r));
176
187
  }
177
188
  //#endregion
178
189
  //#region src/integrations/code-highlight/code-highlight.tsx
179
- var j = /* @__PURE__ */ e({
180
- Block: () => N,
181
- Inline: () => P,
190
+ var N = /* @__PURE__ */ e({
191
+ Block: () => F,
192
+ Inline: () => I,
182
193
  InlineLink: () => n
183
194
  });
184
- function M(e, t) {
195
+ function P(e, t) {
185
196
  return a(() => {
186
- if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html: A(e, t) } });
197
+ if (!(t == null || e === "")) return /* @__PURE__ */ o("span", { dangerouslySetInnerHTML: { __html: M(e, t) } });
187
198
  }, [e, t]);
188
199
  }
189
- function N({ language: e, children: t, ...n }) {
190
- let i = M(t, e);
200
+ function F({ language: e, children: t, ...n }) {
201
+ let i = P(t, e);
191
202
  return /* @__PURE__ */ o(r, {
192
203
  ...n,
193
204
  language: e,
@@ -195,19 +206,19 @@ function N({ language: e, children: t, ...n }) {
195
206
  children: t
196
207
  });
197
208
  }
198
- N.displayName = "Code.Block";
199
- function P({ language: e, children: t, ...n }) {
200
- let r = M(t, e);
209
+ F.displayName = "Code.Block";
210
+ function I({ language: e, children: t, ...n }) {
211
+ let r = P(t, e);
201
212
  return /* @__PURE__ */ o(i, {
202
213
  ...n,
203
214
  highlighted: r,
204
215
  children: t
205
216
  });
206
217
  }
207
- P.displayName = "Code.Inline";
218
+ I.displayName = "Code.Inline";
208
219
  //#endregion
209
220
  //#region src/integrations/code-highlight/code-highlight.meta.ts
210
- var F = {
221
+ var L = {
211
222
  name: "CodeHighlight",
212
223
  category: t.display,
213
224
  status: "experimental",
@@ -223,4 +234,4 @@ var F = {
223
234
  }
224
235
  };
225
236
  //#endregion
226
- export { j as Code, w as SUPPORTED_LANGUAGES, F as codeHighlightMeta, E as isSupportedLanguage };
237
+ export { N as Code, E as SUPPORTED_LANGUAGES, L as codeHighlightMeta, O as isSupportedLanguage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imfusion/web-ui",
3
- "version": "0.5.1-dev.45.gf3889fa8",
3
+ "version": "0.5.1-dev.46.gd27f0cfa",
4
4
  "description": "The official Web UI component library for ImFusion web apps",
5
5
  "author": "ImFusion GmbH",
6
6
  "license": "UNLICENSED",