@opentui/core 0.1.88 → 0.1.89

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.
@@ -0,0 +1,188 @@
1
+ // @bun
2
+ import {
3
+ exports_src
4
+ } from "./index-rs5zwr4j.js";
5
+ import {
6
+ __require
7
+ } from "./index-e89anq5x.js";
8
+
9
+ // src/runtime-plugin.ts
10
+ var CORE_RUNTIME_SPECIFIER = "@opentui/core";
11
+ var CORE_TESTING_RUNTIME_SPECIFIER = "@opentui/core/testing";
12
+ var RUNTIME_MODULE_PREFIX = "opentui:runtime-module:";
13
+ var MAX_RUNTIME_RESOLVE_PARENTS = 64;
14
+ var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER];
15
+ var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS);
16
+ var isCoreRuntimeModuleSpecifier = (specifier) => {
17
+ return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier);
18
+ };
19
+ var loadCoreTestingRuntimeModule = async () => {
20
+ return await import("./testing.js");
21
+ };
22
+ var escapeRegExp = (value) => {
23
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24
+ };
25
+ var exactSpecifierFilter = (specifier) => {
26
+ return new RegExp(`^${escapeRegExp(specifier)}$`);
27
+ };
28
+ var runtimeModuleIdForSpecifier = (specifier) => {
29
+ return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`;
30
+ };
31
+ var resolveRuntimeModuleExports = async (moduleEntry) => {
32
+ if (typeof moduleEntry === "function") {
33
+ return await moduleEntry();
34
+ }
35
+ return moduleEntry;
36
+ };
37
+ var sourcePath = (path) => {
38
+ const searchIndex = path.indexOf("?");
39
+ const hashIndex = path.indexOf("#");
40
+ const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
41
+ return end === undefined ? path : path.slice(0, end);
42
+ };
43
+ var runtimeLoaderForPath = (path) => {
44
+ const cleanPath = sourcePath(path);
45
+ if (cleanPath.endsWith(".tsx")) {
46
+ return "tsx";
47
+ }
48
+ if (cleanPath.endsWith(".jsx")) {
49
+ return "jsx";
50
+ }
51
+ if (cleanPath.endsWith(".ts") || cleanPath.endsWith(".mts") || cleanPath.endsWith(".cts")) {
52
+ return "ts";
53
+ }
54
+ if (cleanPath.endsWith(".js") || cleanPath.endsWith(".mjs") || cleanPath.endsWith(".cjs")) {
55
+ return "js";
56
+ }
57
+ return null;
58
+ };
59
+ var runtimeSourceFilter = /^(?!.*(?:\/|\\)node_modules(?:\/|\\)).*\.(?:[cm]?js|[cm]?ts|jsx|tsx)(?:[?#].*)?$/;
60
+ var resolveImportSpecifierPatterns = [
61
+ /(from\s+["'])([^"']+)(["'])/g,
62
+ /(import\s+["'])([^"']+)(["'])/g,
63
+ /(import\s*\(\s*["'])([^"']+)(["']\s*\))/g,
64
+ /(require\s*\(\s*["'])([^"']+)(["']\s*\))/g
65
+ ];
66
+ var isBareSpecifier = (specifier) => {
67
+ if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("\\")) {
68
+ return false;
69
+ }
70
+ if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("file:") || specifier.startsWith("data:")) {
71
+ return false;
72
+ }
73
+ if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
74
+ return false;
75
+ }
76
+ return true;
77
+ };
78
+ var registerResolveParent = (resolveParentsByRecency, resolveParent) => {
79
+ const existingIndex = resolveParentsByRecency.indexOf(resolveParent);
80
+ if (existingIndex >= 0) {
81
+ resolveParentsByRecency.splice(existingIndex, 1);
82
+ }
83
+ resolveParentsByRecency.push(resolveParent);
84
+ if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {
85
+ resolveParentsByRecency.shift();
86
+ }
87
+ };
88
+ var rewriteImportSpecifiers = (code, resolveReplacement) => {
89
+ let transformedCode = code;
90
+ for (const pattern of resolveImportSpecifierPatterns) {
91
+ transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {
92
+ const replacement = resolveReplacement(specifier);
93
+ if (!replacement || replacement === specifier) {
94
+ return fullMatch;
95
+ }
96
+ return `${prefix}${replacement}${suffix}`;
97
+ });
98
+ }
99
+ return transformedCode;
100
+ };
101
+ var resolveFromParent = (specifier, parent) => {
102
+ try {
103
+ const resolvedSpecifier = import.meta.resolve(specifier, parent);
104
+ if (resolvedSpecifier === specifier || resolvedSpecifier.startsWith("node:") || resolvedSpecifier.startsWith("bun:")) {
105
+ return null;
106
+ }
107
+ return resolvedSpecifier;
108
+ } catch {
109
+ return null;
110
+ }
111
+ };
112
+ var rewriteImportsFromResolveParents = (code, resolveParentsByRecency) => {
113
+ if (resolveParentsByRecency.length === 0) {
114
+ return code;
115
+ }
116
+ const resolveFromParents = (specifier) => {
117
+ if (!isBareSpecifier(specifier)) {
118
+ return null;
119
+ }
120
+ for (let index = resolveParentsByRecency.length - 1;index >= 0; index -= 1) {
121
+ const resolveParent = resolveParentsByRecency[index];
122
+ const resolvedSpecifier = resolveFromParent(specifier, resolveParent);
123
+ if (resolvedSpecifier) {
124
+ return resolvedSpecifier;
125
+ }
126
+ }
127
+ return null;
128
+ };
129
+ return rewriteImportSpecifiers(code, resolveFromParents);
130
+ };
131
+ var rewriteRuntimeSpecifiers = (code, runtimeModuleIdsBySpecifier) => {
132
+ return rewriteImportSpecifiers(code, (specifier) => {
133
+ const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier);
134
+ return runtimeModuleId ?? null;
135
+ });
136
+ };
137
+ function createRuntimePlugin(input = {}) {
138
+ const runtimeModules = new Map;
139
+ runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? exports_src);
140
+ runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule);
141
+ for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {
142
+ runtimeModules.set(specifier, moduleEntry);
143
+ }
144
+ const runtimeModuleIdsBySpecifier = new Map;
145
+ for (const specifier of runtimeModules.keys()) {
146
+ runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier));
147
+ }
148
+ return {
149
+ name: "bun-plugin-opentui-runtime-modules",
150
+ setup: (build) => {
151
+ const resolveParentsByRecency = [];
152
+ for (const [specifier, moduleEntry] of runtimeModules.entries()) {
153
+ const moduleId = runtimeModuleIdsBySpecifier.get(specifier);
154
+ if (!moduleId) {
155
+ continue;
156
+ }
157
+ build.module(moduleId, async () => ({
158
+ exports: await resolveRuntimeModuleExports(moduleEntry),
159
+ loader: "object"
160
+ }));
161
+ build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }));
162
+ }
163
+ build.onLoad({ filter: runtimeSourceFilter }, async (args) => {
164
+ const path = sourcePath(args.path);
165
+ const loader = runtimeLoaderForPath(args.path);
166
+ if (!loader) {
167
+ throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
168
+ }
169
+ const file = Bun.file(path);
170
+ const contents = await file.text();
171
+ const runtimeRewrittenContents = rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier);
172
+ if (runtimeRewrittenContents !== contents) {
173
+ registerResolveParent(resolveParentsByRecency, path);
174
+ }
175
+ const transformedContents = rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency);
176
+ return {
177
+ contents: transformedContents,
178
+ loader
179
+ };
180
+ });
181
+ }
182
+ };
183
+ }
184
+
185
+ export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
186
+
187
+ //# debugId=320B34A5E2C7118F64756E2164756E21
188
+ //# sourceMappingURL=index-tae5jwnc.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/runtime-plugin.ts"],
4
+ "sourcesContent": [
5
+ "import { type BunPlugin } from \"bun\"\nimport * as coreRuntime from \"./index\"\n\nexport type RuntimeModuleExports = Record<string, unknown>\nexport type RuntimeModuleLoader = () => RuntimeModuleExports | Promise<RuntimeModuleExports>\nexport type RuntimeModuleEntry = RuntimeModuleExports | RuntimeModuleLoader\n\nexport interface CreateRuntimePluginOptions {\n core?: RuntimeModuleEntry\n additional?: Record<string, RuntimeModuleEntry>\n}\n\nconst CORE_RUNTIME_SPECIFIER = \"@opentui/core\"\nconst CORE_TESTING_RUNTIME_SPECIFIER = \"@opentui/core/testing\"\nconst RUNTIME_MODULE_PREFIX = \"opentui:runtime-module:\"\nconst MAX_RUNTIME_RESOLVE_PARENTS = 64\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER] as const\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set<string>(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS)\n\nexport const isCoreRuntimeModuleSpecifier = (specifier: string): boolean => {\n return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier)\n}\n\nconst loadCoreTestingRuntimeModule = async (): Promise<RuntimeModuleExports> => {\n return (await import(\"./testing\")) as RuntimeModuleExports\n}\n\nconst escapeRegExp = (value: string): string => {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\nconst exactSpecifierFilter = (specifier: string): RegExp => {\n return new RegExp(`^${escapeRegExp(specifier)}$`)\n}\n\nexport const runtimeModuleIdForSpecifier = (specifier: string): string => {\n return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`\n}\n\nconst resolveRuntimeModuleExports = async (moduleEntry: RuntimeModuleEntry): Promise<RuntimeModuleExports> => {\n if (typeof moduleEntry === \"function\") {\n return await moduleEntry()\n }\n\n return moduleEntry\n}\n\nconst sourcePath = (path: string): string => {\n const searchIndex = path.indexOf(\"?\")\n const hashIndex = path.indexOf(\"#\")\n const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0]\n return end === undefined ? path : path.slice(0, end)\n}\n\nconst runtimeLoaderForPath = (path: string): \"js\" | \"ts\" | \"jsx\" | \"tsx\" | null => {\n const cleanPath = sourcePath(path)\n\n if (cleanPath.endsWith(\".tsx\")) {\n return \"tsx\"\n }\n\n if (cleanPath.endsWith(\".jsx\")) {\n return \"jsx\"\n }\n\n if (cleanPath.endsWith(\".ts\") || cleanPath.endsWith(\".mts\") || cleanPath.endsWith(\".cts\")) {\n return \"ts\"\n }\n\n if (cleanPath.endsWith(\".js\") || cleanPath.endsWith(\".mjs\") || cleanPath.endsWith(\".cjs\")) {\n return \"js\"\n }\n\n return null\n}\n\nconst runtimeSourceFilter = /^(?!.*(?:\\/|\\\\)node_modules(?:\\/|\\\\)).*\\.(?:[cm]?js|[cm]?ts|jsx|tsx)(?:[?#].*)?$/\n\nconst resolveImportSpecifierPatterns = [\n /(from\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n /(require\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n] as const\n\nconst isBareSpecifier = (specifier: string): boolean => {\n if (specifier.startsWith(\".\") || specifier.startsWith(\"/\") || specifier.startsWith(\"\\\\\")) {\n return false\n }\n\n if (\n specifier.startsWith(\"node:\") ||\n specifier.startsWith(\"bun:\") ||\n specifier.startsWith(\"http:\") ||\n specifier.startsWith(\"https:\") ||\n specifier.startsWith(\"file:\") ||\n specifier.startsWith(\"data:\")\n ) {\n return false\n }\n\n if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {\n return false\n }\n\n return true\n}\n\nconst registerResolveParent = (resolveParentsByRecency: string[], resolveParent: string): void => {\n const existingIndex = resolveParentsByRecency.indexOf(resolveParent)\n if (existingIndex >= 0) {\n resolveParentsByRecency.splice(existingIndex, 1)\n }\n\n resolveParentsByRecency.push(resolveParent)\n\n if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {\n resolveParentsByRecency.shift()\n }\n}\n\nconst rewriteImportSpecifiers = (code: string, resolveReplacement: (specifier: string) => string | null): string => {\n let transformedCode = code\n\n for (const pattern of resolveImportSpecifierPatterns) {\n transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {\n const replacement = resolveReplacement(specifier)\n if (!replacement || replacement === specifier) {\n return fullMatch\n }\n\n return `${prefix}${replacement}${suffix}`\n })\n }\n\n return transformedCode\n}\n\nconst resolveFromParent = (specifier: string, parent: string): string | null => {\n try {\n const resolvedSpecifier = import.meta.resolve(specifier, parent)\n if (\n resolvedSpecifier === specifier ||\n resolvedSpecifier.startsWith(\"node:\") ||\n resolvedSpecifier.startsWith(\"bun:\")\n ) {\n return null\n }\n\n return resolvedSpecifier\n } catch {\n return null\n }\n}\n\nconst rewriteImportsFromResolveParents = (code: string, resolveParentsByRecency: string[]): string => {\n if (resolveParentsByRecency.length === 0) {\n return code\n }\n\n const resolveFromParents = (specifier: string): string | null => {\n if (!isBareSpecifier(specifier)) {\n return null\n }\n\n for (let index = resolveParentsByRecency.length - 1; index >= 0; index -= 1) {\n const resolveParent = resolveParentsByRecency[index]\n const resolvedSpecifier = resolveFromParent(specifier, resolveParent)\n if (resolvedSpecifier) {\n return resolvedSpecifier\n }\n }\n\n return null\n }\n\n return rewriteImportSpecifiers(code, resolveFromParents)\n}\n\nconst rewriteRuntimeSpecifiers = (code: string, runtimeModuleIdsBySpecifier: Map<string, string>): string => {\n return rewriteImportSpecifiers(code, (specifier) => {\n const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier)\n return runtimeModuleId ?? null\n })\n}\n\nexport function createRuntimePlugin(input: CreateRuntimePluginOptions = {}): BunPlugin {\n const runtimeModules = new Map<string, RuntimeModuleEntry>()\n runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? (coreRuntime as RuntimeModuleExports))\n runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule)\n\n for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {\n runtimeModules.set(specifier, moduleEntry)\n }\n\n const runtimeModuleIdsBySpecifier = new Map<string, string>()\n for (const specifier of runtimeModules.keys()) {\n runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier))\n }\n\n return {\n name: \"bun-plugin-opentui-runtime-modules\",\n setup: (build) => {\n const resolveParentsByRecency: string[] = []\n\n for (const [specifier, moduleEntry] of runtimeModules.entries()) {\n const moduleId = runtimeModuleIdsBySpecifier.get(specifier)\n\n if (!moduleId) {\n continue\n }\n\n build.module(moduleId, async () => ({\n exports: await resolveRuntimeModuleExports(moduleEntry),\n loader: \"object\",\n }))\n\n build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }))\n }\n\n build.onLoad({ filter: runtimeSourceFilter }, async (args) => {\n const path = sourcePath(args.path)\n const loader = runtimeLoaderForPath(args.path)\n if (!loader) {\n throw new Error(`Unable to determine runtime loader for path: ${args.path}`)\n }\n\n const file = Bun.file(path)\n const contents = await file.text()\n const runtimeRewrittenContents = rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)\n\n if (runtimeRewrittenContents !== contents) {\n registerResolveParent(resolveParentsByRecency, path)\n }\n\n const transformedContents = rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency)\n\n return {\n contents: transformedContents,\n loader,\n }\n })\n },\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;AAYA,IAAM,yBAAyB;AAC/B,IAAM,iCAAiC;AACvC,IAAM,wBAAwB;AAC9B,IAAM,8BAA8B;AAEpC,IAAM,yCAAyC,CAAC,wBAAwB,8BAA8B;AAEtG,IAAM,4CAA4C,IAAI,IAAY,sCAAsC;AAEjG,IAAM,+BAA+B,CAAC,cAA+B;AA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G,OAAO;AAAA,UACL,UAAU;AAAA,UACV;AAAA,QACF;AAAA,OACD;AAAA;AAAA,EAEL;AAAA;",
8
+ "debugId": "320B34A5E2C7118F64756E2164756E21",
9
+ "names": []
10
+ }
package/index.js CHANGED
@@ -4,14 +4,11 @@ import {
4
4
  ASCIIFontRenderable,
5
5
  ArrowRenderable,
6
6
  BloomEffect,
7
- BlurEffect,
8
7
  Box,
9
8
  BoxRenderable,
10
- BrightnessEffect,
11
9
  Code,
12
10
  CodeRenderable,
13
11
  DiffRenderable,
14
- DistortionEffect,
15
12
  EditBuffer,
16
13
  EditorView,
17
14
  FrameBuffer,
@@ -47,14 +44,14 @@ import {
47
44
  TimeToFirstDrawRenderable,
48
45
  Timeline,
49
46
  VRenderable,
50
- VignetteEffect,
51
47
  applyAsciiArt,
48
+ applyBrightness,
52
49
  applyChromaticAberration,
53
- applyGrayscale,
50
+ applyGain,
54
51
  applyInvert,
55
52
  applyNoise,
53
+ applySaturation,
56
54
  applyScanlines,
57
- applySepia,
58
55
  convertThemeToStyles,
59
56
  createCoreSlotRegistry,
60
57
  createSlotRegistry,
@@ -64,7 +61,7 @@ import {
64
61
  registerCorePlugin,
65
62
  resolveCoreSlot,
66
63
  vstyles
67
- } from "./index-nyw5p3ep.js";
64
+ } from "./index-rs5zwr4j.js";
68
65
  import {
69
66
  ASCIIFontSelectionHelper,
70
67
  ATTRIBUTE_BASE_BITS,
@@ -99,6 +96,7 @@ import {
99
96
  StdinParser,
100
97
  StyledText,
101
98
  SystemClock,
99
+ TargetChannel,
102
100
  TerminalConsole,
103
101
  TerminalPalette,
104
102
  TextAttributes,
@@ -106,6 +104,7 @@ import {
106
104
  TreeSitterClient,
107
105
  addDefaultParsers,
108
106
  attributesWithLink,
107
+ basenameToFiletype,
109
108
  bg,
110
109
  bgBlack,
111
110
  bgBlue,
@@ -146,6 +145,7 @@ import {
146
145
  envRegistry,
147
146
  exports_src,
148
147
  extToFiletype,
148
+ extensionToFiletype,
149
149
  fg,
150
150
  fonts,
151
151
  generateEnvColored,
@@ -162,6 +162,7 @@ import {
162
162
  hastToStyledText,
163
163
  hexToRgb,
164
164
  hsvToRgb,
165
+ infoStringToFiletype,
165
166
  instantiate,
166
167
  isRenderable,
167
168
  isStyledText,
@@ -212,7 +213,7 @@ import {
212
213
  white,
213
214
  wrapWithDelegates,
214
215
  yellow
215
- } from "./index-nkrr8a4c.js";
216
+ } from "./index-e89anq5x.js";
216
217
  export {
217
218
  yellow,
218
219
  wrapWithDelegates,
@@ -268,6 +269,7 @@ export {
268
269
  isStyledText,
269
270
  isRenderable,
270
271
  instantiate,
272
+ infoStringToFiletype,
271
273
  hsvToRgb,
272
274
  hexToRgb,
273
275
  hastToStyledText,
@@ -284,6 +286,7 @@ export {
284
286
  generateEnvColored,
285
287
  fonts,
286
288
  fg,
289
+ extensionToFiletype,
287
290
  extToFiletype,
288
291
  envRegistry,
289
292
  env,
@@ -328,17 +331,18 @@ export {
328
331
  bgBlue,
329
332
  bgBlack,
330
333
  bg,
334
+ basenameToFiletype,
331
335
  attributesWithLink,
332
- applySepia,
333
336
  applyScanlines,
337
+ applySaturation,
334
338
  applyNoise,
335
339
  applyInvert,
336
- applyGrayscale,
340
+ applyGain,
337
341
  applyChromaticAberration,
342
+ applyBrightness,
338
343
  applyAsciiArt,
339
344
  addDefaultParsers,
340
345
  exports_src as Yoga,
341
- VignetteEffect,
342
346
  VRenderable,
343
347
  TreeSitterClient,
344
348
  Timeline,
@@ -354,6 +358,7 @@ export {
354
358
  Text,
355
359
  TerminalPalette,
356
360
  TerminalConsole,
361
+ TargetChannel,
357
362
  TabSelectRenderableEvents,
358
363
  TabSelectRenderable,
359
364
  TabSelect,
@@ -401,7 +406,6 @@ export {
401
406
  ExtmarksController,
402
407
  EditorView,
403
408
  EditBuffer,
404
- DistortionEffect,
405
409
  DiffRenderable,
406
410
  DebugOverlayCorner,
407
411
  DataPathsManager,
@@ -410,12 +414,10 @@ export {
410
414
  Code,
411
415
  CliRenderer,
412
416
  CliRenderEvents,
413
- BrightnessEffect,
414
417
  BoxRenderable,
415
418
  Box,
416
419
  BorderChars,
417
420
  BorderCharArrays,
418
- BlurEffect,
419
421
  BloomEffect,
420
422
  BaseRenderable,
421
423
  ArrowRenderable,
@@ -426,5 +428,5 @@ export {
426
428
  ASCIIFont
427
429
  };
428
430
 
429
- //# debugId=E879501EEAF15E7064756E2164756E21
431
+ //# debugId=53A36A9E1B38F8E764756E2164756E21
430
432
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "E879501EEAF15E7064756E2164756E21",
7
+ "debugId": "53A36A9E1B38F8E764756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -22,12 +22,19 @@ export type StdinEvent = {
22
22
  protocol: StdinResponseProtocol;
23
23
  sequence: string;
24
24
  };
25
+ export interface StdinParserProtocolContext {
26
+ kittyKeyboardEnabled: boolean;
27
+ privateCapabilityRepliesActive: boolean;
28
+ pixelResolutionQueryActive: boolean;
29
+ explicitWidthCprActive: boolean;
30
+ }
25
31
  export interface StdinParserOptions {
26
32
  timeoutMs?: number;
27
33
  maxPendingBytes?: number;
28
34
  armTimeouts?: boolean;
29
35
  onTimeoutFlush?: () => void;
30
36
  useKittyKeyboard?: boolean;
37
+ protocolContext?: Partial<StdinParserProtocolContext>;
31
38
  clock?: Clock;
32
39
  }
33
40
  export declare class StdinParser {
@@ -40,6 +47,7 @@ export declare class StdinParser {
40
47
  private readonly useKittyKeyboard;
41
48
  private readonly mouseParser;
42
49
  private readonly clock;
50
+ private protocolContext;
43
51
  private timeoutId;
44
52
  private destroyed;
45
53
  private pendingSinceMs;
@@ -51,6 +59,7 @@ export declare class StdinParser {
51
59
  private paste;
52
60
  constructor(options?: StdinParserOptions);
53
61
  get bufferCapacity(): number;
62
+ updateProtocolContext(patch: Partial<StdinParserProtocolContext>): void;
54
63
  push(data: Uint8Array): void;
55
64
  read(): StdinEvent | null;
56
65
  drain(onEvent: (event: StdinEvent) => void): void;
@@ -70,6 +79,7 @@ export declare class StdinParser {
70
79
  private markPending;
71
80
  private consumePasteBytes;
72
81
  private pushPasteBytes;
82
+ private reconcileDeferredStateWithProtocolContext;
73
83
  private reconcileTimeoutState;
74
84
  private clearTimeout;
75
85
  private resetState;
@@ -1,2 +1,2 @@
1
- import type { FiletypeParserOptions } from "./types.js";
1
+ import type { FiletypeParserOptions } from "./types";
2
2
  export declare function getParsers(): FiletypeParserOptions[];
@@ -6,6 +6,7 @@
6
6
  declare const _default: {
7
7
  parsers: ({
8
8
  filetype: string;
9
+ aliases: string[];
9
10
  wasm: string;
10
11
  queries: {
11
12
  highlights: string[];
@@ -27,12 +28,26 @@ declare const _default: {
27
28
  infoStringMap: {
28
29
  javascript: string;
29
30
  js: string;
31
+ jsx: string;
32
+ javascriptreact: string;
30
33
  typescript: string;
31
34
  ts: string;
35
+ tsx: string;
36
+ typescriptreact: string;
32
37
  markdown: string;
33
38
  md: string;
34
39
  };
35
40
  };
41
+ aliases?: undefined;
42
+ } | {
43
+ filetype: string;
44
+ wasm: string;
45
+ queries: {
46
+ highlights: string[];
47
+ injections?: undefined;
48
+ };
49
+ aliases?: undefined;
50
+ injectionMapping?: undefined;
36
51
  })[];
37
52
  };
38
53
  export default _default;
@@ -1,2 +1,5 @@
1
+ export declare const extensionToFiletype: Map<string, string>;
2
+ export declare const basenameToFiletype: Map<string, string>;
1
3
  export declare function extToFiletype(extension: string): string | undefined;
2
4
  export declare function pathToFiletype(path: string): string | undefined;
5
+ export declare function infoStringToFiletype(infoString: string): string | undefined;
@@ -26,6 +26,7 @@ export interface InjectionMapping {
26
26
  }
27
27
  export interface FiletypeParserOptions {
28
28
  filetype: string;
29
+ aliases?: string[];
29
30
  queries: {
30
31
  highlights: string[];
31
32
  injections?: string[];
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
- "version": "0.1.88",
7
+ "version": "0.1.89",
8
8
  "description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -67,11 +67,11 @@
67
67
  "bun-webgpu": "0.1.5",
68
68
  "planck": "^1.4.2",
69
69
  "three": "0.177.0",
70
- "@opentui/core-darwin-x64": "0.1.88",
71
- "@opentui/core-darwin-arm64": "0.1.88",
72
- "@opentui/core-linux-x64": "0.1.88",
73
- "@opentui/core-linux-arm64": "0.1.88",
74
- "@opentui/core-win32-x64": "0.1.88",
75
- "@opentui/core-win32-arm64": "0.1.88"
70
+ "@opentui/core-darwin-x64": "0.1.89",
71
+ "@opentui/core-darwin-arm64": "0.1.89",
72
+ "@opentui/core-linux-x64": "0.1.89",
73
+ "@opentui/core-linux-arm64": "0.1.89",
74
+ "@opentui/core-win32-x64": "0.1.89",
75
+ "@opentui/core-win32-arm64": "0.1.89"
76
76
  }
77
77
  }
package/parser.worker.js CHANGED
@@ -135,6 +135,7 @@ var self = globalThis;
135
135
  class ParserWorker {
136
136
  bufferParsers = new Map;
137
137
  filetypeParserOptions = new Map;
138
+ filetypeAliases = new Map;
138
139
  filetypeParsers = new Map;
139
140
  filetypeParserPromises = new Map;
140
141
  reusableParsers = new Map;
@@ -188,7 +189,38 @@ class ParserWorker {
188
189
  return this.initializePromise;
189
190
  }
190
191
  addFiletypeParser(filetypeParser) {
191
- this.filetypeParserOptions.set(filetypeParser.filetype, filetypeParser);
192
+ const previousAliases = this.filetypeParserOptions.get(filetypeParser.filetype)?.aliases ?? [];
193
+ for (const alias of previousAliases) {
194
+ if (this.filetypeAliases.get(alias) === filetypeParser.filetype) {
195
+ this.filetypeAliases.delete(alias);
196
+ }
197
+ }
198
+ const aliases = [...new Set((filetypeParser.aliases ?? []).filter((alias) => alias !== filetypeParser.filetype))];
199
+ this.filetypeAliases.delete(filetypeParser.filetype);
200
+ this.filetypeParserOptions.set(filetypeParser.filetype, {
201
+ ...filetypeParser,
202
+ aliases
203
+ });
204
+ for (const alias of aliases) {
205
+ this.filetypeAliases.set(alias, filetypeParser.filetype);
206
+ }
207
+ this.invalidateParserCaches(filetypeParser.filetype);
208
+ }
209
+ resolveCanonicalFiletype(filetype) {
210
+ if (this.filetypeParserOptions.has(filetype)) {
211
+ return filetype;
212
+ }
213
+ return this.filetypeAliases.get(filetype) ?? filetype;
214
+ }
215
+ invalidateParserCaches(filetype) {
216
+ this.filetypeParsers.delete(filetype);
217
+ this.filetypeParserPromises.delete(filetype);
218
+ const reusableParser = this.reusableParsers.get(filetype);
219
+ if (reusableParser) {
220
+ reusableParser.parser.delete();
221
+ this.reusableParsers.delete(filetype);
222
+ }
223
+ this.reusableParserPromises.delete(filetype);
192
224
  }
193
225
  async createQueries(filetypeParser, language) {
194
226
  try {
@@ -236,22 +268,23 @@ class ParserWorker {
236
268
  }
237
269
  }
238
270
  async resolveFiletypeParser(filetype) {
239
- if (this.filetypeParsers.has(filetype)) {
240
- return this.filetypeParsers.get(filetype);
271
+ const canonicalFiletype = this.resolveCanonicalFiletype(filetype);
272
+ if (this.filetypeParsers.has(canonicalFiletype)) {
273
+ return this.filetypeParsers.get(canonicalFiletype);
241
274
  }
242
- if (this.filetypeParserPromises.has(filetype)) {
243
- return this.filetypeParserPromises.get(filetype);
275
+ if (this.filetypeParserPromises.has(canonicalFiletype)) {
276
+ return this.filetypeParserPromises.get(canonicalFiletype);
244
277
  }
245
- const loadingPromise = this.loadFiletypeParser(filetype);
246
- this.filetypeParserPromises.set(filetype, loadingPromise);
278
+ const loadingPromise = this.loadFiletypeParser(canonicalFiletype);
279
+ this.filetypeParserPromises.set(canonicalFiletype, loadingPromise);
247
280
  try {
248
281
  const result = await loadingPromise;
249
282
  if (result) {
250
- this.filetypeParsers.set(filetype, result);
283
+ this.filetypeParsers.set(canonicalFiletype, result);
251
284
  }
252
285
  return result;
253
286
  } finally {
254
- this.filetypeParserPromises.delete(filetype);
287
+ this.filetypeParserPromises.delete(canonicalFiletype);
255
288
  }
256
289
  }
257
290
  async loadFiletypeParser(filetype) {
@@ -279,22 +312,23 @@ class ParserWorker {
279
312
  return this.resolveFiletypeParser(filetype);
280
313
  }
281
314
  async getReusableParser(filetype) {
282
- if (this.reusableParsers.has(filetype)) {
283
- return this.reusableParsers.get(filetype);
315
+ const canonicalFiletype = this.resolveCanonicalFiletype(filetype);
316
+ if (this.reusableParsers.has(canonicalFiletype)) {
317
+ return this.reusableParsers.get(canonicalFiletype);
284
318
  }
285
- if (this.reusableParserPromises.has(filetype)) {
286
- return this.reusableParserPromises.get(filetype);
319
+ if (this.reusableParserPromises.has(canonicalFiletype)) {
320
+ return this.reusableParserPromises.get(canonicalFiletype);
287
321
  }
288
- const creationPromise = this.createReusableParser(filetype);
289
- this.reusableParserPromises.set(filetype, creationPromise);
322
+ const creationPromise = this.createReusableParser(canonicalFiletype);
323
+ this.reusableParserPromises.set(canonicalFiletype, creationPromise);
290
324
  try {
291
325
  const result = await creationPromise;
292
326
  if (result) {
293
- this.reusableParsers.set(filetype, result);
327
+ this.reusableParsers.set(canonicalFiletype, result);
294
328
  }
295
329
  return result;
296
330
  } finally {
297
- this.reusableParserPromises.delete(filetype);
331
+ this.reusableParserPromises.delete(canonicalFiletype);
298
332
  }
299
333
  }
300
334
  async createReusableParser(filetype) {
@@ -858,5 +892,5 @@ if (!isMainThread) {
858
892
  };
859
893
  }
860
894
 
861
- //# debugId=9C8F94938CC7697764756E2164756E21
895
+ //# debugId=181702D6D7C45F4964756E2164756E21
862
896
  //# sourceMappingURL=parser.worker.js.map