@opentui/core 0.0.0-20251029-27ffe014 → 0.0.0-20251031-fc297165

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.
@@ -5112,19 +5112,141 @@ var env = new Proxy({}, {
5112
5112
  });
5113
5113
 
5114
5114
  // src/lib/tree-sitter-styled-text.ts
5115
- function treeSitterToTextChunks(content, highlights, syntaxStyle) {
5115
+ registerEnvVar({ name: "OTUI_TS_STYLE_WARN", default: false, description: "Enable warnings for missing syntax styles" });
5116
+ function getSpecificity(group) {
5117
+ return group.split(".").length;
5118
+ }
5119
+ function shouldSuppressInInjection(group, meta) {
5120
+ if (meta?.isInjection) {
5121
+ return false;
5122
+ }
5123
+ return group === "markup.raw.block";
5124
+ }
5125
+ function treeSitterToTextChunks(content, highlights, syntaxStyle, options) {
5116
5126
  const chunks = [];
5117
5127
  const defaultStyle = syntaxStyle.getStyle("default");
5118
- let currentIndex = 0;
5128
+ const concealEnabled = options?.enabled ?? true;
5129
+ const injectionContainerRanges = [];
5130
+ const boundaries = [];
5119
5131
  for (let i = 0;i < highlights.length; i++) {
5120
- const [startIndex, endIndex, group] = highlights[i];
5121
- if (startIndex < currentIndex)
5132
+ const [start, end, , meta] = highlights[i];
5133
+ if (start === end)
5122
5134
  continue;
5123
- if (currentIndex < startIndex) {
5124
- const text2 = content.slice(currentIndex, startIndex);
5135
+ if (meta?.containsInjection) {
5136
+ injectionContainerRanges.push({ start, end });
5137
+ }
5138
+ boundaries.push({ offset: start, type: "start", highlightIndex: i });
5139
+ boundaries.push({ offset: end, type: "end", highlightIndex: i });
5140
+ }
5141
+ boundaries.sort((a, b) => {
5142
+ if (a.offset !== b.offset)
5143
+ return a.offset - b.offset;
5144
+ if (a.type === "end" && b.type === "start")
5145
+ return -1;
5146
+ if (a.type === "start" && b.type === "end")
5147
+ return 1;
5148
+ return 0;
5149
+ });
5150
+ const activeHighlights = new Set;
5151
+ let currentOffset = 0;
5152
+ for (let i = 0;i < boundaries.length; i++) {
5153
+ const boundary = boundaries[i];
5154
+ if (currentOffset < boundary.offset && activeHighlights.size > 0) {
5155
+ const segmentText = content.slice(currentOffset, boundary.offset);
5156
+ const activeGroups = [];
5157
+ for (const idx of activeHighlights) {
5158
+ const [, , group, meta] = highlights[idx];
5159
+ activeGroups.push({ group, meta, index: idx });
5160
+ }
5161
+ const concealHighlight = concealEnabled ? activeGroups.find((h) => h.meta?.conceal !== undefined || h.group === "conceal" || h.group.startsWith("conceal.")) : undefined;
5162
+ if (concealHighlight) {
5163
+ let replacementText = "";
5164
+ if (concealHighlight.meta?.conceal !== undefined) {
5165
+ replacementText = concealHighlight.meta.conceal;
5166
+ } else if (concealHighlight.group === "conceal.with.space") {
5167
+ replacementText = " ";
5168
+ }
5169
+ if (replacementText) {
5170
+ chunks.push({
5171
+ __isChunk: true,
5172
+ text: replacementText,
5173
+ fg: defaultStyle?.fg,
5174
+ bg: defaultStyle?.bg,
5175
+ attributes: defaultStyle ? createTextAttributes({
5176
+ bold: defaultStyle.bold,
5177
+ italic: defaultStyle.italic,
5178
+ underline: defaultStyle.underline,
5179
+ dim: defaultStyle.dim
5180
+ }) : 0
5181
+ });
5182
+ }
5183
+ } else {
5184
+ const insideInjectionContainer = injectionContainerRanges.some((range) => currentOffset >= range.start && currentOffset < range.end);
5185
+ const validGroups = activeGroups.filter((h) => {
5186
+ if (insideInjectionContainer && shouldSuppressInInjection(h.group, h.meta)) {
5187
+ return false;
5188
+ }
5189
+ return true;
5190
+ });
5191
+ const sortedGroups = validGroups.sort((a, b) => {
5192
+ const aSpec = getSpecificity(a.group);
5193
+ const bSpec = getSpecificity(b.group);
5194
+ if (aSpec !== bSpec)
5195
+ return aSpec - bSpec;
5196
+ return a.index - b.index;
5197
+ });
5198
+ const mergedStyle = {};
5199
+ for (const { group } of sortedGroups) {
5200
+ let styleForGroup = syntaxStyle.getStyle(group);
5201
+ if (!styleForGroup && group.includes(".")) {
5202
+ const baseName = group.split(".")[0];
5203
+ styleForGroup = syntaxStyle.getStyle(baseName);
5204
+ }
5205
+ if (styleForGroup) {
5206
+ if (styleForGroup.fg !== undefined)
5207
+ mergedStyle.fg = styleForGroup.fg;
5208
+ if (styleForGroup.bg !== undefined)
5209
+ mergedStyle.bg = styleForGroup.bg;
5210
+ if (styleForGroup.bold !== undefined)
5211
+ mergedStyle.bold = styleForGroup.bold;
5212
+ if (styleForGroup.italic !== undefined)
5213
+ mergedStyle.italic = styleForGroup.italic;
5214
+ if (styleForGroup.underline !== undefined)
5215
+ mergedStyle.underline = styleForGroup.underline;
5216
+ if (styleForGroup.dim !== undefined)
5217
+ mergedStyle.dim = styleForGroup.dim;
5218
+ } else {
5219
+ if (group.includes(".")) {
5220
+ const baseName = group.split(".")[0];
5221
+ if (env.OTUI_TS_STYLE_WARN) {
5222
+ console.warn(`Syntax style not found for group "${group}" or base scope "${baseName}", using default style`);
5223
+ }
5224
+ } else {
5225
+ if (env.OTUI_TS_STYLE_WARN) {
5226
+ console.warn(`Syntax style not found for group "${group}", using default style`);
5227
+ }
5228
+ }
5229
+ }
5230
+ }
5231
+ const finalStyle = Object.keys(mergedStyle).length > 0 ? mergedStyle : defaultStyle;
5232
+ chunks.push({
5233
+ __isChunk: true,
5234
+ text: segmentText,
5235
+ fg: finalStyle?.fg,
5236
+ bg: finalStyle?.bg,
5237
+ attributes: finalStyle ? createTextAttributes({
5238
+ bold: finalStyle.bold,
5239
+ italic: finalStyle.italic,
5240
+ underline: finalStyle.underline,
5241
+ dim: finalStyle.dim
5242
+ }) : 0
5243
+ });
5244
+ }
5245
+ } else if (currentOffset < boundary.offset) {
5246
+ const text = content.slice(currentOffset, boundary.offset);
5125
5247
  chunks.push({
5126
5248
  __isChunk: true,
5127
- text: text2,
5249
+ text,
5128
5250
  fg: defaultStyle?.fg,
5129
5251
  bg: defaultStyle?.bg,
5130
5252
  attributes: defaultStyle ? createTextAttributes({
@@ -5134,37 +5256,39 @@ function treeSitterToTextChunks(content, highlights, syntaxStyle) {
5134
5256
  dim: defaultStyle.dim
5135
5257
  }) : 0
5136
5258
  });
5137
- currentIndex = startIndex;
5138
5259
  }
5139
- let resolvedStyle = syntaxStyle.getStyle(group);
5140
- let j = i + 1;
5141
- while (j < highlights.length && highlights[j][0] === startIndex) {
5142
- const [, , nextGroup] = highlights[j];
5143
- const nextStyle = syntaxStyle.getStyle(nextGroup);
5144
- if (nextStyle) {
5145
- resolvedStyle = nextStyle;
5260
+ if (boundary.type === "start") {
5261
+ activeHighlights.add(boundary.highlightIndex);
5262
+ } else {
5263
+ activeHighlights.delete(boundary.highlightIndex);
5264
+ if (concealEnabled) {
5265
+ const [, , group, meta] = highlights[boundary.highlightIndex];
5266
+ if (meta?.concealLines !== undefined) {
5267
+ if (boundary.offset < content.length && content[boundary.offset] === `
5268
+ `) {
5269
+ currentOffset = boundary.offset + 1;
5270
+ continue;
5271
+ }
5272
+ }
5273
+ if (meta?.conceal !== undefined) {
5274
+ if (meta.conceal === " ") {
5275
+ if (boundary.offset < content.length && content[boundary.offset] === " ") {
5276
+ currentOffset = boundary.offset + 1;
5277
+ continue;
5278
+ }
5279
+ } else if (meta.conceal === "" && group === "conceal" && !meta.isInjection) {
5280
+ if (boundary.offset < content.length && content[boundary.offset] === " ") {
5281
+ currentOffset = boundary.offset + 1;
5282
+ continue;
5283
+ }
5284
+ }
5285
+ }
5146
5286
  }
5147
- j++;
5148
5287
  }
5149
- i = j - 1;
5150
- const text = content.slice(startIndex, endIndex);
5151
- const styleToUse = resolvedStyle || defaultStyle;
5152
- chunks.push({
5153
- __isChunk: true,
5154
- text,
5155
- fg: styleToUse?.fg,
5156
- bg: styleToUse?.bg,
5157
- attributes: styleToUse ? createTextAttributes({
5158
- bold: styleToUse.bold,
5159
- italic: styleToUse.italic,
5160
- underline: styleToUse.underline,
5161
- dim: styleToUse.dim
5162
- }) : 0
5163
- });
5164
- currentIndex = endIndex;
5288
+ currentOffset = boundary.offset;
5165
5289
  }
5166
- if (currentIndex < content.length) {
5167
- const text = content.slice(currentIndex);
5290
+ if (currentOffset < content.length) {
5291
+ const text = content.slice(currentOffset);
5168
5292
  chunks.push({
5169
5293
  __isChunk: true,
5170
5294
  text,
@@ -5180,10 +5304,10 @@ function treeSitterToTextChunks(content, highlights, syntaxStyle) {
5180
5304
  }
5181
5305
  return chunks;
5182
5306
  }
5183
- async function treeSitterToStyledText(content, filetype, syntaxStyle, client) {
5307
+ async function treeSitterToStyledText(content, filetype, syntaxStyle, client, options) {
5184
5308
  const result = await client.highlightOnce(content, filetype);
5185
5309
  if (result.highlights && result.highlights.length > 0) {
5186
- const chunks = treeSitterToTextChunks(content, result.highlights, syntaxStyle);
5310
+ const chunks = treeSitterToTextChunks(content, result.highlights, syntaxStyle, options?.conceal);
5187
5311
  return new StyledText(chunks);
5188
5312
  } else {
5189
5313
  const defaultStyle = syntaxStyle.mergeStyles("default");
@@ -5314,6 +5438,11 @@ import javascript_highlights from "./assets/javascript/highlights.scm" with { ty
5314
5438
  import javascript_language from "./assets/javascript/tree-sitter-javascript.wasm" with { type: "file" };
5315
5439
  import typescript_highlights from "./assets/typescript/highlights.scm" with { type: "file" };
5316
5440
  import typescript_language from "./assets/typescript/tree-sitter-typescript.wasm" with { type: "file" };
5441
+ import markdown_highlights from "./assets/markdown/highlights.scm" with { type: "file" };
5442
+ import markdown_language from "./assets/markdown/tree-sitter-markdown.wasm" with { type: "file" };
5443
+ import markdown_injections from "./assets/markdown/injections.scm" with { type: "file" };
5444
+ import markdown_inline_highlights from "./assets/markdown_inline/highlights.scm" with { type: "file" };
5445
+ import markdown_inline_language from "./assets/markdown_inline/tree-sitter-markdown_inline.wasm" with { type: "file" };
5317
5446
  var _cachedParsers;
5318
5447
  function getParsers() {
5319
5448
  if (!_cachedParsers) {
@@ -5331,6 +5460,35 @@ function getParsers() {
5331
5460
  highlights: [resolve(dirname(fileURLToPath(import.meta.url)), typescript_highlights)]
5332
5461
  },
5333
5462
  wasm: resolve(dirname(fileURLToPath(import.meta.url)), typescript_language)
5463
+ },
5464
+ {
5465
+ filetype: "markdown",
5466
+ queries: {
5467
+ highlights: [resolve(dirname(fileURLToPath(import.meta.url)), markdown_highlights)],
5468
+ injections: [resolve(dirname(fileURLToPath(import.meta.url)), markdown_injections)]
5469
+ },
5470
+ wasm: resolve(dirname(fileURLToPath(import.meta.url)), markdown_language),
5471
+ injectionMapping: {
5472
+ nodeTypes: {
5473
+ inline: "markdown_inline",
5474
+ pipe_table_cell: "markdown_inline"
5475
+ },
5476
+ infoStringMap: {
5477
+ javascript: "javascript",
5478
+ js: "javascript",
5479
+ typescript: "typescript",
5480
+ ts: "typescript",
5481
+ markdown: "markdown",
5482
+ md: "markdown"
5483
+ }
5484
+ }
5485
+ },
5486
+ {
5487
+ filetype: "markdown_inline",
5488
+ queries: {
5489
+ highlights: [resolve(dirname(fileURLToPath(import.meta.url)), markdown_inline_highlights)]
5490
+ },
5491
+ wasm: resolve(dirname(fileURLToPath(import.meta.url)), markdown_inline_language)
5334
5492
  }
5335
5493
  ];
5336
5494
  }
@@ -5475,7 +5633,8 @@ class TreeSitterClient extends EventEmitter2 {
5475
5633
  ...filetypeParser,
5476
5634
  wasm: this.resolvePath(filetypeParser.wasm),
5477
5635
  queries: {
5478
- highlights: filetypeParser.queries.highlights.map((path) => this.resolvePath(path))
5636
+ highlights: filetypeParser.queries.highlights.map((path) => this.resolvePath(path)),
5637
+ injections: filetypeParser.queries.injections?.map((path) => this.resolvePath(path))
5479
5638
  }
5480
5639
  };
5481
5640
  this.worker?.postMessage({ type: "ADD_FILETYPE_PARSER", filetypeParser: resolvedParser });
@@ -5581,6 +5740,14 @@ class TreeSitterClient extends EventEmitter2 {
5581
5740
  }
5582
5741
  return;
5583
5742
  }
5743
+ if (type === "CLEAR_CACHE_RESPONSE") {
5744
+ const callback = this.messageCallbacks.get(messageId);
5745
+ if (callback) {
5746
+ this.messageCallbacks.delete(messageId);
5747
+ callback({ error });
5748
+ }
5749
+ return;
5750
+ }
5584
5751
  if (warning) {
5585
5752
  this.emitWarning(warning, bufferId);
5586
5753
  return;
@@ -5594,9 +5761,11 @@ class TreeSitterClient extends EventEmitter2 {
5594
5761
  const message = data.join(" ");
5595
5762
  this.emit("worker:log", logType, message);
5596
5763
  if (logType === "log") {
5597
- console.log("Worker stdout:", ...data);
5764
+ console.log("TSWorker:", ...data);
5598
5765
  } else if (logType === "error") {
5599
- console.error("Worker stderr:", ...data);
5766
+ console.error("TSWorker:", ...data);
5767
+ } else if (logType === "warn") {
5768
+ console.warn("TSWorker:", ...data);
5600
5769
  }
5601
5770
  return;
5602
5771
  }
@@ -5776,6 +5945,25 @@ class TreeSitterClient extends EventEmitter2 {
5776
5945
  });
5777
5946
  }
5778
5947
  }
5948
+ async clearCache() {
5949
+ if (!this.initialized || !this.worker) {
5950
+ throw new Error("Cannot clear cache: client is not initialized");
5951
+ }
5952
+ const messageId = `clear_cache_${this.messageIdCounter++}`;
5953
+ return new Promise((resolve3, reject) => {
5954
+ this.messageCallbacks.set(messageId, (response) => {
5955
+ if (response.error) {
5956
+ reject(new Error(response.error));
5957
+ } else {
5958
+ resolve3();
5959
+ }
5960
+ });
5961
+ this.worker.postMessage({
5962
+ type: "CLEAR_CACHE",
5963
+ messageId
5964
+ });
5965
+ });
5966
+ }
5779
5967
  }
5780
5968
 
5781
5969
  // src/lib/data-paths.ts
@@ -5929,6 +6117,24 @@ function extToFiletype(extension) {
5929
6117
  ["rs", "rust"],
5930
6118
  ["c", "c"],
5931
6119
  ["cpp", "cpp"],
6120
+ ["c++", "cpp"],
6121
+ ["cs", "csharp"],
6122
+ ["java", "java"],
6123
+ ["kt", "kotlin"],
6124
+ ["swift", "swift"],
6125
+ ["php", "php"],
6126
+ ["sql", "sql"],
6127
+ ["pl", "perl"],
6128
+ ["lua", "lua"],
6129
+ ["erl", "erlang"],
6130
+ ["exs", "elixir"],
6131
+ ["ex", "elixir"],
6132
+ ["elm", "elm"],
6133
+ ["fsharp", "fsharp"],
6134
+ ["fs", "fsharp"],
6135
+ ["fsx", "fsharp"],
6136
+ ["fsscript", "fsharp"],
6137
+ ["fsi", "fsharp"],
5932
6138
  ["h", "c"],
5933
6139
  ["hpp", "cpp"],
5934
6140
  ["html", "html"],
@@ -6071,17 +6277,35 @@ class DownloadUtils {
6071
6277
  }
6072
6278
 
6073
6279
  // src/lib/tree-sitter/assets/update.ts
6280
+ import { readdir } from "fs/promises";
6074
6281
  var __dirname = "/Users/runner/work/opentui/opentui/packages/core/src/lib/tree-sitter/assets";
6075
6282
  function getDefaultOptions() {
6076
6283
  return {
6077
- configPath: path3.resolve(__dirname, "../parsers-config.json"),
6284
+ configPath: path3.resolve(__dirname, "../parsers-config"),
6078
6285
  assetsDir: path3.resolve(__dirname),
6079
6286
  outputPath: path3.resolve(__dirname, "../default-parsers.ts")
6080
6287
  };
6081
6288
  }
6082
6289
  async function loadConfig(configPath) {
6083
- const configContent = await readFile(configPath, "utf-8");
6084
- return JSON.parse(configContent);
6290
+ let ext = path3.extname(configPath);
6291
+ let resolvedConfigPath = configPath;
6292
+ if (ext === "") {
6293
+ const files = await readdir(path3.dirname(configPath));
6294
+ const file = files.find((file2) => file2.startsWith(path3.basename(configPath)) && (file2.endsWith(".json") || file2.endsWith(".ts") || file2.endsWith(".js")));
6295
+ if (!file) {
6296
+ throw new Error(`No config file found for ${configPath}`);
6297
+ }
6298
+ resolvedConfigPath = path3.join(path3.dirname(configPath), file);
6299
+ ext = path3.extname(resolvedConfigPath);
6300
+ }
6301
+ if (ext === ".json") {
6302
+ const configContent = await readFile(resolvedConfigPath, "utf-8");
6303
+ return JSON.parse(configContent);
6304
+ } else if (ext === ".ts" || ext === ".js") {
6305
+ const { default: configContent } = await import(resolvedConfigPath);
6306
+ return configContent;
6307
+ }
6308
+ throw new Error(`Unsupported config file extension: ${ext}`);
6085
6309
  }
6086
6310
  async function downloadLanguage(filetype, languageUrl, assetsDir, outputPath) {
6087
6311
  const languageDir = path3.join(assetsDir, filetype);
@@ -6093,53 +6317,85 @@ async function downloadLanguage(filetype, languageUrl, assetsDir, outputPath) {
6093
6317
  }
6094
6318
  return "./" + path3.relative(path3.dirname(outputPath), languagePath);
6095
6319
  }
6096
- async function downloadAndCombineQueries(filetype, queryUrls, assetsDir, outputPath) {
6320
+ async function downloadAndCombineQueries(filetype, queryUrls, assetsDir, outputPath, queryType, configPath) {
6097
6321
  const queriesDir = path3.join(assetsDir, filetype);
6098
- const highlightsPath = path3.join(queriesDir, "highlights.scm");
6322
+ const queryPath = path3.join(queriesDir, `${queryType}.scm`);
6099
6323
  const queryContents = [];
6100
6324
  for (let i = 0;i < queryUrls.length; i++) {
6101
6325
  const queryUrl = queryUrls[i];
6102
- console.log(` Downloading query ${i + 1}/${queryUrls.length}: ${queryUrl}`);
6103
- try {
6104
- const response = await fetch(queryUrl);
6105
- if (!response.ok) {
6106
- console.warn(`Failed to download query from ${queryUrl}: ${response.statusText}`);
6326
+ if (queryUrl.startsWith("./")) {
6327
+ console.log(` Using local query ${i + 1}/${queryUrls.length}: ${queryUrl}`);
6328
+ try {
6329
+ const localPath = path3.resolve(path3.dirname(configPath), queryUrl);
6330
+ const content = await readFile(localPath, "utf-8");
6331
+ if (content.trim()) {
6332
+ queryContents.push(content);
6333
+ console.log(` \u2713 Loaded ${content.split(`
6334
+ `).length} lines from local file`);
6335
+ }
6336
+ } catch (error) {
6337
+ console.warn(`Failed to read local query from ${queryUrl}: ${error}`);
6107
6338
  continue;
6108
6339
  }
6109
- const content = await response.text();
6110
- if (content.trim()) {
6111
- queryContents.push(`; Query from: ${queryUrl}
6340
+ } else {
6341
+ console.log(` Downloading query ${i + 1}/${queryUrls.length}: ${queryUrl}`);
6342
+ try {
6343
+ const response = await fetch(queryUrl);
6344
+ if (!response.ok) {
6345
+ console.warn(`Failed to download query from ${queryUrl}: ${response.statusText}`);
6346
+ continue;
6347
+ }
6348
+ const content = await response.text();
6349
+ if (content.trim()) {
6350
+ queryContents.push(`; Query from: ${queryUrl}
6112
6351
  ${content}`);
6113
- console.log(` \u2713 Downloaded ${content.split(`
6352
+ console.log(` \u2713 Downloaded ${content.split(`
6114
6353
  `).length} lines`);
6354
+ }
6355
+ } catch (error) {
6356
+ console.warn(`Failed to download query from ${queryUrl}: ${error}`);
6357
+ continue;
6115
6358
  }
6116
- } catch (error) {
6117
- console.warn(`Failed to download query from ${queryUrl}: ${error}`);
6118
- continue;
6119
6359
  }
6120
6360
  }
6121
6361
  const combinedContent = queryContents.join(`
6122
6362
 
6123
6363
  `);
6124
- await writeFile2(highlightsPath, combinedContent, "utf-8");
6125
- console.log(` Combined ${queryContents.length} queries into ${highlightsPath}`);
6126
- return "./" + path3.relative(path3.dirname(outputPath), highlightsPath);
6364
+ await writeFile2(queryPath, combinedContent, "utf-8");
6365
+ console.log(` Combined ${queryContents.length} queries into ${queryPath}`);
6366
+ return "./" + path3.relative(path3.dirname(outputPath), queryPath);
6127
6367
  }
6128
6368
  async function generateDefaultParsersFile(parsers, outputPath) {
6129
6369
  const imports = parsers.map((parser) => {
6130
6370
  const safeFiletype = parser.filetype.replace(/[^a-zA-Z0-9]/g, "_");
6131
- return `import ${safeFiletype}_highlights from "${parser.highlightsPath}" with { type: "file" }
6132
- import ${safeFiletype}_language from "${parser.languagePath}" with { type: "file" }`;
6371
+ const lines = [
6372
+ `import ${safeFiletype}_highlights from "${parser.highlightsPath}" with { type: "file" }`,
6373
+ `import ${safeFiletype}_language from "${parser.languagePath}" with { type: "file" }`
6374
+ ];
6375
+ if (parser.injectionsPath) {
6376
+ lines.push(`import ${safeFiletype}_injections from "${parser.injectionsPath}" with { type: "file" }`);
6377
+ }
6378
+ return lines.join(`
6379
+ `);
6133
6380
  }).join(`
6134
6381
  `);
6135
6382
  const parserDefinitions = parsers.map((parser) => {
6136
6383
  const safeFiletype = parser.filetype.replace(/[^a-zA-Z0-9]/g, "_");
6384
+ const queriesLines = [
6385
+ ` highlights: [resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_highlights)],`
6386
+ ];
6387
+ if (parser.injectionsPath) {
6388
+ queriesLines.push(` injections: [resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_injections)],`);
6389
+ }
6390
+ const injectionMappingLine = parser.injectionMapping ? ` injectionMapping: ${JSON.stringify(parser.injectionMapping, null, 10)},` : "";
6137
6391
  return ` {
6138
6392
  filetype: "${parser.filetype}",
6139
6393
  queries: {
6140
- highlights: [resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_highlights)],
6394
+ ${queriesLines.join(`
6395
+ `)}
6141
6396
  },
6142
- wasm: resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_language),
6397
+ wasm: resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_language),${injectionMappingLine ? `
6398
+ ` + injectionMappingLine : ""}
6143
6399
  }`;
6144
6400
  }).join(`,
6145
6401
  `);
@@ -6184,11 +6440,18 @@ async function main(options) {
6184
6440
  console.log(` Downloading language...`);
6185
6441
  const languagePath = await downloadLanguage(parser.filetype, parser.wasm, opts.assetsDir, opts.outputPath);
6186
6442
  console.log(` Downloading ${parser.queries.highlights.length} highlight queries...`);
6187
- const highlightsPath = await downloadAndCombineQueries(parser.filetype, parser.queries.highlights, opts.assetsDir, opts.outputPath);
6443
+ const highlightsPath = await downloadAndCombineQueries(parser.filetype, parser.queries.highlights, opts.assetsDir, opts.outputPath, "highlights", opts.configPath);
6444
+ let injectionsPath;
6445
+ if (parser.queries.injections && parser.queries.injections.length > 0) {
6446
+ console.log(` Downloading ${parser.queries.injections.length} injection queries...`);
6447
+ injectionsPath = await downloadAndCombineQueries(parser.filetype, parser.queries.injections, opts.assetsDir, opts.outputPath, "injections", opts.configPath);
6448
+ }
6188
6449
  generatedParsers.push({
6189
6450
  filetype: parser.filetype,
6190
6451
  languagePath,
6191
- highlightsPath
6452
+ highlightsPath,
6453
+ injectionsPath,
6454
+ injectionMapping: parser.injectionMapping
6192
6455
  });
6193
6456
  console.log(` \u2713 Completed ${parser.filetype}`);
6194
6457
  }
@@ -8073,6 +8336,10 @@ function getOpenTUILib(libPath) {
8073
8336
  args: ["ptr", "usize"],
8074
8337
  returns: "void"
8075
8338
  },
8339
+ textBufferGetHighlightCount: {
8340
+ args: ["ptr"],
8341
+ returns: "u32"
8342
+ },
8076
8343
  createTextBufferView: {
8077
8344
  args: ["ptr"],
8078
8345
  returns: "ptr"
@@ -9118,6 +9385,9 @@ class FFIRenderLib {
9118
9385
  this.opentui.symbols.textBufferFreeLineHighlights(nativePtr, count);
9119
9386
  return results;
9120
9387
  }
9388
+ textBufferGetHighlightCount(buffer) {
9389
+ return this.opentui.symbols.textBufferGetHighlightCount(buffer);
9390
+ }
9121
9391
  getArenaAllocatedBytes() {
9122
9392
  const result = this.opentui.symbols.getArenaAllocatedBytes();
9123
9393
  return typeof result === "bigint" ? Number(result) : result;
@@ -9657,6 +9927,10 @@ class TextBuffer {
9657
9927
  this.guard();
9658
9928
  return this.lib.textBufferGetLineHighlights(this.bufferPtr, lineIdx);
9659
9929
  }
9930
+ getHighlightCount() {
9931
+ this.guard();
9932
+ return this.lib.textBufferGetHighlightCount(this.bufferPtr);
9933
+ }
9660
9934
  setSyntaxStyle(style) {
9661
9935
  this.guard();
9662
9936
  this._syntaxStyle = style ?? undefined;
@@ -13097,5 +13371,5 @@ Captured output:
13097
13371
 
13098
13372
  export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
13099
13373
 
13100
- //# debugId=33BCB77A44B43F2164756E2164756E21
13101
- //# sourceMappingURL=index-xn9k0wzm.js.map
13374
+ //# debugId=3D6AC881EA3F1FB664756E2164756E21
13375
+ //# sourceMappingURL=index-vr8t68wb.js.map