@remotex-labs/xmap 3.0.5 → 4.0.1

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,127 +1,19 @@
1
- import type * as ts from "typescript";
1
+
2
2
  /**
3
- * Defines the color scheme for syntax highlighting different code elements.
4
- *
5
- * @interface HighlightSchemeInterface
6
- *
7
- * @property enumColor - Color code for enum declarations and references
8
- * @property typeColor - Color code for type annotations and primitive types
9
- * @property classColor - Color code for class declarations and references
10
- * @property stringColor - Color code for string literals and template strings
11
- * @property keywordColor - Color code for language keywords
12
- * @property commentColor - Color code for comments (single-line and multi-line)
13
- * @property functionColor - Color code for function declarations and calls
14
- * @property variableColor - Color code for variable declarations and references
15
- * @property interfaceColor - Color code for interface declarations and references
16
- * @property parameterColor - Color code for function and method parameters
17
- * @property getAccessorColor - Color code for getter accessor methods
18
- * @property numericLiteralColor - Color code for numeric literals
19
- * @property methodSignatureColor - Color code for method signatures in interfaces
20
- * @property regularExpressionColor - Color code for regular expression literals
21
- * @property propertyAssignmentColor - Color code for property assignments in object literals
22
- * @property propertyAccessExpressionColor - Color code for property access expressions
23
- * @property expressionWithTypeArgumentsColor - Color code for type arguments in expressions
24
- *
25
- * @example
26
- * ```ts
27
- * const darkTheme: HighlightSchemeInterface = {
28
- * enumColor: Colors.cyan,
29
- * typeColor: Colors.blue,
30
- * classColor: Colors.yellow,
31
- * // ...other color definitions
32
- * };
33
- * ```
34
- *
35
- * @since 1.0.0
3
+ * This file was automatically generated by xBuild.
4
+ * DO NOT EDIT MANUALLY.
36
5
  */
37
- export interface HighlightSchemeInterface {
38
- enumColor: string;
39
- typeColor: string;
40
- classColor: string;
41
- stringColor: string;
42
- keywordColor: string;
43
- commentColor: string;
44
- functionColor: string;
45
- variableColor: string;
46
- interfaceColor: string;
47
- parameterColor: string;
48
- getAccessorColor: string;
49
- numericLiteralColor: string;
50
- methodSignatureColor: string;
51
- regularExpressionColor: string;
52
- propertyAssignmentColor: string;
53
- propertyAccessExpressionColor: string;
54
- expressionWithTypeArgumentsColor: string;
55
- }
6
+ import ts from 'typescript';
7
+
56
8
  /**
57
- * Represents a segment of source code to be highlighted with specific styling.
58
- *
59
- * @interface HighlightNodeSegmentInterface
60
- *
61
- * @property start - The starting character position of the segment in the source text
62
- * @property end - The ending character position of the segment in the source text
63
- * @property color - The color or style code to apply to this segment
64
- * @property reset - The reset code that returns formatting to normal after this segment
65
- *
66
- * @remarks
67
- * Segments are the fundamental units of the highlighting system.
68
- * Each segment represents a portion of text that should receive specific styling.
69
- * When the source code is processed for display,
70
- * these segments are used to insert the appropriate color/style codes at the correct positions.
71
- *
72
- * The highlighter maintains a collection of these segments and applies them
73
- * in position order to create the complete highlighted output.
74
- *
75
- * @example
76
- * ```ts
77
- * const keywordSegment: HighlightNodeSegmentInterface = {
78
- * start: 0,
79
- * end: 6,
80
- * color: '\x1b[34m', // Blue for the keyword "import"
81
- * reset: '\x1b[0m' // Reset to default
82
- * };
83
- * ```
84
- *
85
- * @see HighlightSchemeInterface
86
- * @see addSegment
87
- *
88
- * @since 1.0.0
9
+ * Import will remove at compile time
89
10
  */
90
- export interface HighlightNodeSegmentInterface {
91
- end: number;
92
- start: number;
93
- color: string;
94
- reset: string;
95
- }
96
11
  /**
97
- * An enum containing ANSI escape sequences for various colors
98
- *
99
- * @remarks
100
- * This enum is primarily intended for terminal output and won't work directly in JavaScript for web development.
101
- * It defines color codes for various colors and a reset code to return to the default text color.
102
- *
103
- * @example
104
- * ```ts
105
- * console.log(`${Colors.red}This text will be red in the terminal.${Colors.reset}`);
106
- * ```
107
- *
108
- * @since 1.0.0
12
+ * Imports
13
+ */
14
+ /**
15
+ * Export interfaces
109
16
  */
110
- export declare const enum Colors {
111
- reset = "\u001B[0m",
112
- gray = "\u001B[38;5;243m",
113
- darkGray = "\u001B[38;5;238m",
114
- lightCoral = "\u001B[38;5;203m",
115
- lightOrange = "\u001B[38;5;215m",
116
- oliveGreen = "\u001B[38;5;149m",
117
- burntOrange = "\u001B[38;5;208m",
118
- lightGoldenrodYellow = "\u001B[38;5;221m",
119
- lightYellow = "\u001B[38;5;230m",
120
- canaryYellow = "\u001B[38;5;227m",
121
- deepOrange = "\u001B[38;5;166m",
122
- lightGray = "\u001B[38;5;252m",
123
- brightPink = "\u001B[38;5;197m"
124
- }
125
17
  /**
126
18
  * Class responsible for applying semantic highlighting to a source code string based on a given color scheme
127
19
  *
@@ -188,7 +80,7 @@ export declare class CodeHighlighter {
188
80
  *
189
81
  * @param start - The starting index position in the source text
190
82
  * @param end - The ending index position in the source text (optional)
191
- * @returns The substring of source text between the start and end positions
83
+ * @returns The substring of a source text between the start and end positions
192
84
  *
193
85
  * @remarks
194
86
  * This utility method provides access to specific portions of the source code
@@ -204,7 +96,7 @@ export declare class CodeHighlighter {
204
96
  * // Extract a variable name
205
97
  * const variableName = this.getSegmentSource(10, 15);
206
98
  *
207
- * // Extract from a position to the end of source
99
+ * // Extract from a position to the end of a source
208
100
  * const remaining = this.getSegmentSource(100);
209
101
  * ```
210
102
  *
@@ -219,8 +111,7 @@ export declare class CodeHighlighter {
219
111
  *
220
112
  * @param start - The starting position of the segment in the source text
221
113
  * @param end - The ending position of the segment in the source text
222
- * @param color - The color code to apply to this segment
223
- * @param reset - The color reset code to apply after the segment (defaults to the standard reset code)
114
+ * @param color - The {@link ColorFunctionType} to apply to this segment
224
115
  *
225
116
  * @remarks
226
117
  * This method creates a unique key for each segment based on its position and stores the segment information in a map.
@@ -233,10 +124,10 @@ export declare class CodeHighlighter {
233
124
  * @example
234
125
  * ```ts
235
126
  * // Highlight a variable name in red
236
- * this.addSegment(10, 15, Colors.red);
127
+ * this.addSegment(10, 15, xterm.red);
237
128
  *
238
- * // Highlight a keyword with custom color and reset
239
- * this.addSegment(20, 26, Colors.blue, Colors.customReset);
129
+ * // Highlight a keyword with custom color
130
+ * this.addSegment(20, 26, xterm.blue);
240
131
  * ```
241
132
  *
242
133
  * @see Colors
@@ -292,7 +183,7 @@ export declare class CodeHighlighter {
292
183
  * keyword range (between FirstKeyword and LastKeyword) and highlights it using
293
184
  * the keyword color.
294
185
  *
295
- * Each identified token is added to the segments collection with appropriate position
186
+ * Each identified token is added to the segment collection with the appropriate position
296
187
  * and color information.
297
188
  *
298
189
  * @example
@@ -371,7 +262,7 @@ export declare class CodeHighlighter {
371
262
  *
372
263
  * @remarks
373
264
  * This method identifies the node's kind and applies the appropriate color for highlighting.
374
- * It handles various syntax kinds including literals (string, numeric, regular expressions),
265
+ * It handles various syntax kinds, including literals (string, numeric, regular expressions),
375
266
  * template expressions, identifiers, and type references.
376
267
  * For complex node types like template expressions and identifiers, it delegates to specialized processing methods.
377
268
  *
@@ -382,7 +273,7 @@ export declare class CodeHighlighter {
382
273
  * // Inside the CodeHighlighter class
383
274
  * const node = sourceFile.getChildAt(0);
384
275
  * this.processNode(node);
385
- * // Node is now added to the segments map with appropriate colors
276
+ * // Node is now added to the segment map with appropriate colors
386
277
  * ```
387
278
  *
388
279
  * @see processTemplateExpression
@@ -421,3 +312,153 @@ export declare class CodeHighlighter {
421
312
  * @since 1.0.0
422
313
  */
423
314
  export declare function highlightCode(code: string, schema?: Partial<HighlightSchemeInterface>): string;
315
+
316
+ /**
317
+ * Represents a function that applies coloring or formatting to strings.
318
+ *
319
+ * @param args - Strings to be formatted
320
+ * @returns The formatted string
321
+ *
322
+ * @since 1.0.0
323
+ */
324
+ export type ColorFunctionType = (...args: Array<string>) => string;
325
+ /**
326
+ * Defines a color scheme for syntax highlighting various code elements.
327
+ *
328
+ * @remarks
329
+ * Each property is a {@link ColorFunctionType} that formats a specific type of syntax element,
330
+ * such as enums, classes, keywords, or literals.
331
+ *
332
+ * @see ColorFunctionType
333
+ * @since 1.0.0
334
+ */
335
+ export interface HighlightSchemeInterface {
336
+ /**
337
+ * Color function for enum names.
338
+ * @since 1.0.0
339
+ */
340
+ enumColor: ColorFunctionType;
341
+ /**
342
+ * Color function for type names.
343
+ * @since 1.0.0
344
+ */
345
+ typeColor: ColorFunctionType;
346
+ /**
347
+ * Color function for class names.
348
+ * @since 1.0.0
349
+ */
350
+ classColor: ColorFunctionType;
351
+ /**
352
+ * Color function for string literals.
353
+ * @since 1.0.0
354
+ */
355
+ stringColor: ColorFunctionType;
356
+ /**
357
+ * Color function for language keywords.
358
+ * @since 1.0.0
359
+ */
360
+ keywordColor: ColorFunctionType;
361
+ /**
362
+ * Color function for comments.
363
+ * @since 1.0.0
364
+ */
365
+ commentColor: ColorFunctionType;
366
+ /**
367
+ * Color function for function names.
368
+ * @since 1.0.0
369
+ */
370
+ functionColor: ColorFunctionType;
371
+ /**
372
+ * Color function for variable names.
373
+ * @since 1.0.0
374
+ */
375
+ variableColor: ColorFunctionType;
376
+ /**
377
+ * Color function for interface names.
378
+ * @since 1.0.0
379
+ */
380
+ interfaceColor: ColorFunctionType;
381
+ /**
382
+ * Color function for function/method parameters.
383
+ * @since 1.0.0
384
+ */
385
+ parameterColor: ColorFunctionType;
386
+ /**
387
+ * Color function for getter accessor names.
388
+ * @since 1.0.0
389
+ */
390
+ getAccessorColor: ColorFunctionType;
391
+ /**
392
+ * Color function for numeric literals.
393
+ * @since 1.0.0
394
+ */
395
+ numericLiteralColor: ColorFunctionType;
396
+ /**
397
+ * Color function for method signatures.
398
+ * @since 1.0.0
399
+ */
400
+ methodSignatureColor: ColorFunctionType;
401
+ /**
402
+ * Color function for regular expressions.
403
+ * @since 1.0.0
404
+ */
405
+ regularExpressionColor: ColorFunctionType;
406
+ /**
407
+ * Color function for property assignments.
408
+ * @since 1.0.0
409
+ */
410
+ propertyAssignmentColor: ColorFunctionType;
411
+ /**
412
+ * Color function for property access expressions.
413
+ * @since 1.0.0
414
+ */
415
+ propertyAccessExpressionColor: ColorFunctionType;
416
+ /**
417
+ * Color function for expressions with type arguments.
418
+ * @since 1.0.0
419
+ */
420
+ expressionWithTypeArgumentsColor: ColorFunctionType;
421
+ }
422
+ /**
423
+ * Represents a segment of source code to be highlighted with specific styling.
424
+ *
425
+ * @remarks
426
+ * Segments are the fundamental units of the highlighting system.
427
+ * Each segment represents a portion of text that should receive specific styling.
428
+ * When the source code is processed for display,
429
+ * these segments are used to insert the appropriate color/style codes at the correct positions.
430
+ *
431
+ * The highlighter maintains a collection of these segments and applies them
432
+ * in position order to create the complete highlighted output.
433
+ *
434
+ * @example
435
+ * ```ts
436
+ * const keywordSegment: HighlightNodeSegmentInterface = {
437
+ * start: 0,
438
+ * end: 6,
439
+ * color: xterm.red
440
+ * };
441
+ * ```
442
+ *
443
+ * @see addSegment
444
+ * @see HighlightSchemeInterface
445
+ *
446
+ * @since 1.0.0
447
+ */
448
+ export interface HighlightNodeSegmentInterface {
449
+ /**
450
+ * The starting character position of the segment in the source text.
451
+ * @since 1.0.0
452
+ */
453
+ start: number;
454
+ /**
455
+ * The ending character position of the segment in the source text.
456
+ * @since 1.0.0
457
+ */
458
+ end: number;
459
+ /**
460
+ * The color or style code to apply to this segment.
461
+ * @since 1.0.0
462
+ */
463
+ color: ColorFunctionType;
464
+ }