@let-value/translate-extract-static 1.1.0 → 1.1.1-beta.2

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,2 +1,1474 @@
1
- export * from "@let-value/translate-extract/core";
2
- export * from "@let-value/translate-extract/static";
1
+ //#region ../translate/dist/index.d.ts
2
+
3
+ //#region src/locales.d.ts
4
+ type PluralFormsLocale = "ach" | "af" | "ak" | "am" | "an" | "ar" | "arn" | "ast" | "ay" | "az" | "be" | "bg" | "bn" | "bo" | "br" | "brx" | "bs" | "ca" | "cgg" | "cs" | "csb" | "cy" | "da" | "de" | "doi" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "ff" | "fi" | "fil" | "fo" | "fr" | "fur" | "fy" | "ga" | "gd" | "gl" | "gu" | "gun" | "ha" | "he" | "hi" | "hne" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "jbo" | "jv" | "ka" | "kab" | "kk" | "km" | "kn" | "ko" | "ku" | "kw" | "ky" | "lb" | "ln" | "lo" | "lt" | "lv" | "mai" | "mfe" | "mg" | "mi" | "mk" | "ml" | "mn" | "mni" | "mnk" | "mr" | "ms" | "mt" | "my" | "nah" | "nap" | "nb" | "ne" | "nl" | "nn" | "no" | "nso" | "oc" | "or" | "pa" | "pap" | "pl" | "pms" | "ps" | "pt" | "rm" | "ro" | "ru" | "rw" | "sah" | "sat" | "sco" | "sd" | "se" | "si" | "sk" | "sl" | "so" | "son" | "sq" | "sr" | "su" | "sv" | "sw" | "ta" | "te" | "tg" | "th" | "ti" | "tk" | "tr" | "tt" | "ug" | "uk" | "ur" | "uz" | "vi" | "wa" | "wo" | "yo" | "zh";
5
+ //#endregion
6
+ //#region src/config.d.ts
7
+ //#endregion
8
+ //#region ../node_modules/loglevel/index.d.ts
9
+ // Originally from Definitely Typed, see:
10
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b4683d7/types/loglevel/index.d.ts
11
+ // Original definitions by: Stefan Profanter <https://github.com/Pro>
12
+ // Gabor Szmetanko <https://github.com/szmeti>
13
+ // Christian Rackerseder <https://github.com/screendriver>
14
+
15
+ declare const log: log.RootLogger;
16
+ declare namespace log {
17
+ /**
18
+ * Log levels
19
+ */
20
+ interface LogLevel {
21
+ TRACE: 0;
22
+ DEBUG: 1;
23
+ INFO: 2;
24
+ WARN: 3;
25
+ ERROR: 4;
26
+ SILENT: 5;
27
+ }
28
+
29
+ /**
30
+ * Possible log level numbers.
31
+ */
32
+ type LogLevelNumbers = LogLevel[keyof LogLevel];
33
+
34
+ /**
35
+ * Possible log level descriptors, may be string, lower or upper case, or number.
36
+ */
37
+ type LogLevelDesc = LogLevelNumbers | LogLevelNames | 'silent' | keyof LogLevel;
38
+ type LogLevelNames = 'trace' | 'debug' | 'info' | 'warn' | 'error';
39
+ type LoggingMethod = (...message: any[]) => void;
40
+ type MethodFactory = (methodName: LogLevelNames, level: LogLevelNumbers, loggerName: string | symbol) => LoggingMethod;
41
+ interface RootLogger extends Logger {
42
+ /**
43
+ * If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
44
+ * Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
45
+ * onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
46
+ * returns the loglevel object, which you can then bind to another name yourself.
47
+ */
48
+ noConflict(): any;
49
+
50
+ /**
51
+ * This gets you a new logger object that works exactly like the root log object, but can have its level and
52
+ * logging methods set independently. All loggers must have a name (which is a non-empty string or a symbol)
53
+ * Calling * getLogger() multiple times with the same name will return an identical logger object.
54
+ * In large applications, it can be incredibly useful to turn logging on and off for particular modules as you are
55
+ * working with them. Using the getLogger() method lets you create a separate logger for each part of your
56
+ * application with its own logging level. Likewise, for small, independent modules, using a named logger instead
57
+ * of the default root logger allows developers using your module to selectively turn on deep, trace-level logging
58
+ * when trying to debug problems, while logging only errors or silencing logging altogether under normal
59
+ * circumstances.
60
+ * @param name The name of the produced logger
61
+ */
62
+ getLogger(name: string | symbol): Logger;
63
+
64
+ /**
65
+ * This will return you the dictionary of all loggers created with getLogger, keyed off of their names.
66
+ */
67
+ getLoggers(): {
68
+ [name: string]: Logger;
69
+ };
70
+
71
+ /**
72
+ * A .default property for ES6 default import compatibility
73
+ */
74
+ default: RootLogger;
75
+ }
76
+ interface Logger {
77
+ /**
78
+ * Available log levels.
79
+ */
80
+ readonly levels: LogLevel;
81
+
82
+ /**
83
+ * Plugin API entry point. This will be called for each enabled method each time the level is set
84
+ * (including initially), and should return a MethodFactory to be used for the given log method, at the given level,
85
+ * for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's
86
+ * recommended that this wraps the initially provided value of log.methodFactory
87
+ */
88
+ methodFactory: MethodFactory;
89
+
90
+ /**
91
+ * Output trace message to console.
92
+ * This will also include a full stack trace
93
+ *
94
+ * @param msg any data to log to the console
95
+ */
96
+ trace(...msg: any[]): void;
97
+
98
+ /**
99
+ * Output debug message to console including appropriate icons
100
+ *
101
+ * @param msg any data to log to the console
102
+ */
103
+ debug(...msg: any[]): void;
104
+
105
+ /**
106
+ * Output debug message to console including appropriate icons
107
+ *
108
+ * @param msg any data to log to the console
109
+ */
110
+ log(...msg: any[]): void;
111
+
112
+ /**
113
+ * Output info message to console including appropriate icons
114
+ *
115
+ * @param msg any data to log to the console
116
+ */
117
+ info(...msg: any[]): void;
118
+
119
+ /**
120
+ * Output warn message to console including appropriate icons
121
+ *
122
+ * @param msg any data to log to the console
123
+ */
124
+ warn(...msg: any[]): void;
125
+
126
+ /**
127
+ * Output error message to console including appropriate icons
128
+ *
129
+ * @param msg any data to log to the console
130
+ */
131
+ error(...msg: any[]): void;
132
+
133
+ /**
134
+ * This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
135
+ * or log.error("something") will output messages, but log.info("something") will not.
136
+ *
137
+ * @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
138
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
139
+ * back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
140
+ * false as the optional 'persist' second argument, persistence will be skipped.
141
+ */
142
+ setLevel(level: LogLevelDesc, persist?: boolean): void;
143
+
144
+ /**
145
+ * Returns the current logging level, as a value from LogLevel.
146
+ * It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin
147
+ * development, and partly to let you optimize logging code as below, where debug data is only generated if the
148
+ * level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling
149
+ * on your code and you have hard numbers telling you that your log data generation is a real performance problem.
150
+ */
151
+ getLevel(): LogLevel[keyof LogLevel];
152
+
153
+ /**
154
+ * This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when
155
+ * initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings.
156
+ * For example, your application might set the log level to error in a production environment, but when debugging
157
+ * an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set
158
+ * using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting
159
+ * to error.
160
+ *
161
+ * The level argument takes is the same values that you might pass to setLevel(). Levels set using
162
+ * setDefaultLevel() never persist to subsequent page loads.
163
+ *
164
+ * @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
165
+ */
166
+ setDefaultLevel(level: LogLevelDesc): void;
167
+
168
+ /**
169
+ * This resets the current log level to the default level (or `warn` if no explicit default was set) and clears
170
+ * the persisted level if one was previously persisted.
171
+ */
172
+ resetLevel(): void;
173
+
174
+ /**
175
+ * This enables all log messages, and is equivalent to log.setLevel("trace").
176
+ *
177
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
178
+ * back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
179
+ * false as the optional 'persist' second argument, persistence will be skipped.
180
+ */
181
+ enableAll(persist?: boolean): void;
182
+
183
+ /**
184
+ * This disables all log messages, and is equivalent to log.setLevel("silent").
185
+ *
186
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
187
+ * back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
188
+ * false as the optional 'persist' second argument, persistence will be skipped.
189
+ */
190
+ disableAll(persist?: boolean): void;
191
+
192
+ /**
193
+ * Rebuild the logging methods on this logger and its child loggers.
194
+ *
195
+ * This is mostly intended for plugin developers, but can be useful if you update a logger's `methodFactory` or
196
+ * if you want to apply the root logger’s level to any *pre-existing* child loggers (this updates the level on
197
+ * any child logger that hasn't used `setLevel()` or `setDefaultLevel()`).
198
+ */
199
+ rebuild(): void;
200
+ }
201
+ }
202
+ //#endregion
203
+ //#region ../extract/src/logger.d.ts
204
+ type Logger$1 = log.Logger;
205
+ type LogLevelNames$1 = log.LogLevelNames;
206
+ type LogLevel$1 = LogLevelNames$1;
207
+ //#endregion
208
+ //#region ../extract/src/plugins/cleanup/cleanup.d.ts
209
+ declare function cleanup$1(): Plugin;
210
+ //#endregion
211
+ //#region ../node_modules/@keqingmoe/tree-sitter/tree-sitter.d.ts
212
+ /** @module */
213
+ declare module "@keqingmoe/tree-sitter" {
214
+ class Parser {
215
+ /**
216
+ * Parse UTF8 text into a syntax tree.
217
+ *
218
+ * @param input - The text to parse, either as a string or a custom input function
219
+ * that provides text chunks. If providing a function, it should return text chunks
220
+ * based on byte index and position.
221
+ *
222
+ * @param oldTree - An optional previous syntax tree from the same document.
223
+ * If provided and the document has changed, you must first edit this tree using
224
+ * {@link Parser.Tree.edit} to match the new text.
225
+ *
226
+ * @param options - Optional parsing settings:
227
+ * - bufferSize: Size of internal parsing buffer
228
+ * - includedRanges: Array of ranges to parse within the input
229
+ *
230
+ * @returns A syntax tree representing the parsed text
231
+ *
232
+ * @throws May return null or fail if:
233
+ * - No language has been set via {@link Parser.setLanguage}
234
+ * - The parsing timeout (set via {@link Parser.setTimeoutMicros}) was reached
235
+ * - Parsing was cancelled via cancellation flag
236
+ */
237
+ parse(input: string | Parser.Input, oldTree?: Parser.Tree | null, options?: Parser.Options): Parser.Tree;
238
+
239
+ /**
240
+ * Get the ranges of text that the parser will include when parsing.
241
+ *
242
+ * @returns An array of ranges that will be included in parsing
243
+ */
244
+ getIncludedRanges(): Parser.Range[];
245
+
246
+ /**
247
+ * Get the duration in microseconds that parsing is allowed to take.
248
+ *
249
+ * This timeout can be set via {@link Parser.setTimeoutMicros}.
250
+ *
251
+ * @returns The parsing timeout in microseconds
252
+ */
253
+ getTimeoutMicros(): number;
254
+
255
+ /**
256
+ * Set the maximum duration that parsing is allowed to take before halting.
257
+ *
258
+ * If parsing takes longer than this, it will halt early, returning null.
259
+ *
260
+ * @param timeout - The maximum parsing duration in microseconds
261
+ */
262
+ setTimeoutMicros(timeout: number): void;
263
+
264
+ /**
265
+ * Instruct the parser to start the next parse from the beginning.
266
+ *
267
+ * If the parser previously failed because of a timeout or cancellation,
268
+ * it will resume where it left off on the next parse by default.
269
+ * Call this method if you want to parse a different document instead
270
+ * of resuming.
271
+ */
272
+ reset(): void;
273
+
274
+ /**
275
+ * Get the parser's current language
276
+ */
277
+ getLanguage(): Parser.Language;
278
+
279
+ /**
280
+ * Set the language that the parser should use for parsing.
281
+ *
282
+ * The language must be compatible with the version of tree-sitter
283
+ * being used. A version mismatch will prevent the language from
284
+ * being assigned successfully.
285
+ *
286
+ * @param language - The language to use for parsing
287
+ */
288
+ setLanguage(language?: Parser.Language): void;
289
+
290
+ /**
291
+ * Get the parser's current logger
292
+ *
293
+ * @returns The current logging callback
294
+ */
295
+ getLogger(): Parser.Logger;
296
+
297
+ /**
298
+ * Set the logging callback that the parser should use during parsing.
299
+ *
300
+ * @param logFunc - The logging callback to use, or null/false to disable logging
301
+ */
302
+ setLogger(logFunc?: Parser.Logger | string | false | null): void;
303
+
304
+ /**
305
+ * Set the destination to which the parser should write debugging graphs during parsing.
306
+ *
307
+ * The graphs are formatted in the DOT language. You may want to pipe these graphs
308
+ * directly to a 'dot' process to generate SVG output.
309
+ *
310
+ * @param enabled - Whether to enable or disable graph output
311
+ * @param fd - Optional file descriptor for the output
312
+ */
313
+ printDotGraphs(enabled?: boolean, fd?: number): void;
314
+ }
315
+ namespace Parser {
316
+ /** Configuration options for parsing */
317
+ export type Options = {
318
+ /** Size of the internal parsing buffer */
319
+ bufferSize?: number;
320
+
321
+ /** Array of ranges to include when parsing the input */
322
+ includedRanges?: Range[];
323
+ };
324
+
325
+ /**
326
+ * A position in a multi-line text document, in terms of rows and columns.
327
+ * Both values are zero-based.
328
+ */
329
+ export type Point = {
330
+ /** Zero-based row number */
331
+ row: number;
332
+
333
+ /** Zero-based column number */
334
+ column: number;
335
+ };
336
+
337
+ /**
338
+ * A range of positions in a multi-line text document, specified both in
339
+ * terms of byte offsets and row/column positions.
340
+ */
341
+ export type Range = {
342
+ /** The byte offset of the start of the range */
343
+ startIndex: number;
344
+
345
+ /** The byte offset of the end of the range */
346
+ endIndex: number;
347
+
348
+ /** The row and column where the range starts */
349
+ startPosition: Point;
350
+
351
+ /** The row and column where the range ends */
352
+ endPosition: Point;
353
+ };
354
+
355
+ /**
356
+ * A summary of a change to a text document
357
+ */
358
+ export type Edit = {
359
+ /** The byte offset where the edit starts */
360
+ startIndex: number;
361
+
362
+ /** The byte offset where the edit ends in the old document */
363
+ oldEndIndex: number;
364
+
365
+ /** The byte offset where the edit ends in the new document */
366
+ newEndIndex: number;
367
+
368
+ /** The row and column where the edit starts */
369
+ startPosition: Point;
370
+
371
+ /** The row and column where the edit ends in the old document */
372
+ oldEndPosition: Point;
373
+
374
+ /** The row and column where the edit ends in the new document */
375
+ newEndPosition: Point;
376
+ };
377
+
378
+ /**
379
+ * A callback that receives log messages during parser.
380
+ *
381
+ * @param message - The log message
382
+ * @param params - Parameters associated with the log message
383
+ * @param type - The type of log message
384
+ */
385
+ export type Logger = (message: string, params: {
386
+ [param: string]: string;
387
+ }, type: "parse" | "lex") => void;
388
+
389
+ /** A function that provides text content for parsing based on byte index and position */
390
+ export interface Input {
391
+ /**
392
+ * Get a chunk of text at the given byte offset.
393
+ *
394
+ * @param index - The byte index into the text
395
+ * @param position - Optional position in the text as {row, column}
396
+ * @returns A string chunk, or null/undefined if no text at this index
397
+ */
398
+ (index: number, position?: Point): string | null | undefined | {};
399
+ }
400
+
401
+ /** The syntax tree that contains this node */
402
+ export interface SyntaxNode {
403
+ /** The syntax tree that contains this node */
404
+ tree: Tree;
405
+
406
+ /**
407
+ * A unique numeric identifier for this node.
408
+ * Within a given syntax tree, no two nodes have the same id.
409
+ * If a new tree is created based on an older tree and reuses
410
+ * a node, that node will have the same id in both trees.
411
+ */
412
+ id: number;
413
+
414
+ /**
415
+ * This node's type as a numeric id
416
+ */
417
+ typeId: number;
418
+
419
+ /**
420
+ * This node's type as a numeric id as it appears in the grammar,
421
+ * ignoring aliases
422
+ */
423
+ grammarId: number;
424
+
425
+ /**
426
+ * This node's type as a string
427
+ */
428
+ type: string;
429
+
430
+ /**
431
+ * This node's symbol name as it appears in the grammar,
432
+ * ignoring aliases
433
+ */
434
+ grammarType: string;
435
+
436
+ /**
437
+ * Whether this node is named.
438
+ * Named nodes correspond to named rules in the grammar,
439
+ * whereas anonymous nodes correspond to string literals in the grammar.
440
+ */
441
+ isNamed: boolean;
442
+
443
+ /**
444
+ * Whether this node is missing.
445
+ * Missing nodes are inserted by the parser in order to
446
+ * recover from certain kinds of syntax errors.
447
+ */
448
+ isMissing: boolean;
449
+
450
+ /**
451
+ * Whether this node is extra.
452
+ * Extra nodes represent things like comments, which are not
453
+ * required by the grammar but can appear anywhere.
454
+ */
455
+ isExtra: boolean;
456
+
457
+ /**
458
+ * Whether this node has been edited
459
+ */
460
+ hasChanges: boolean;
461
+
462
+ /**
463
+ * Whether this node represents a syntax error or contains
464
+ * any syntax errors within it
465
+ */
466
+ hasError: boolean;
467
+
468
+ /**
469
+ * Whether this node represents a syntax error.
470
+ * Syntax errors represent parts of the code that could not
471
+ * be incorporated into a valid syntax tree.
472
+ */
473
+ isError: boolean;
474
+
475
+ /** The text content for this node from the source code */
476
+ text: string;
477
+
478
+ /** The parse state of this node */
479
+ parseState: number;
480
+
481
+ /** The parse state that follows this node */
482
+ nextParseState: number;
483
+
484
+ /** The position where this node starts in terms of rows and columns */
485
+ startPosition: Point;
486
+
487
+ /** The position where this node ends in terms of rows and columns */
488
+ endPosition: Point;
489
+
490
+ /** The byte offset where this node starts */
491
+ startIndex: number;
492
+
493
+ /** The byte offset where this node ends */
494
+ endIndex: number;
495
+
496
+ /**
497
+ * This node's immediate parent.
498
+ * For iterating over ancestors, prefer using {@link childWithDescendant}
499
+ */
500
+ parent: SyntaxNode | null;
501
+
502
+ /** Array of all child nodes */
503
+ children: Array<SyntaxNode>;
504
+
505
+ /** Array of all named child nodes */
506
+ namedChildren: Array<SyntaxNode>;
507
+
508
+ /** The number of children this node has */
509
+ childCount: number;
510
+
511
+ /**
512
+ * The number of named children this node has.
513
+ * @see {@link isNamed}
514
+ */
515
+ namedChildCount: number;
516
+
517
+ /** The first child of this node */
518
+ firstChild: SyntaxNode | null;
519
+
520
+ /** The first named child of this node */
521
+ firstNamedChild: SyntaxNode | null;
522
+
523
+ /** The last child of this node */
524
+ lastChild: SyntaxNode | null;
525
+
526
+ /** The last child of this node */
527
+ lastNamedChild: SyntaxNode | null;
528
+
529
+ /** This node's next sibling */
530
+ nextSibling: SyntaxNode | null;
531
+
532
+ /** This node's next named sibling */
533
+ nextNamedSibling: SyntaxNode | null;
534
+
535
+ /** This node's previous sibling */
536
+ previousSibling: SyntaxNode | null;
537
+
538
+ /** This node's previous named sibling */
539
+ previousNamedSibling: SyntaxNode | null;
540
+
541
+ /**
542
+ * The number of descendants this node has, including itself
543
+ */
544
+ descendantCount: number;
545
+
546
+ /**
547
+ * Convert this node to its string representation
548
+ */
549
+ toString(): string;
550
+
551
+ /**
552
+ * Get the node's child at the given index, where zero represents the first child.
553
+ *
554
+ * Note: While fairly fast, this method's cost is technically log(i).
555
+ * For iterating over many children, prefer using the children array.
556
+ *
557
+ * @param index - Zero-based index of the child to retrieve
558
+ * @returns The child node, or null if none exists at the given index
559
+ */
560
+ child(index: number): SyntaxNode | null;
561
+
562
+ /**
563
+ * Get this node's named child at the given index.
564
+ *
565
+ * Note: While fairly fast, this method's cost is technically log(i).
566
+ * For iterating over many children, prefer using the namedChildren array.
567
+ *
568
+ * @param index - Zero-based index of the named child to retrieve
569
+ * @returns The named child node, or null if none exists at the given index
570
+ */
571
+ namedChild(index: number): SyntaxNode | null;
572
+
573
+ /**
574
+ * Get the first child with the given field name.
575
+ *
576
+ * For fields that may have multiple children, use childrenForFieldName instead.
577
+ *
578
+ * @param fieldName - The field name to search for
579
+ * @returns The child node, or null if no child has the given field name
580
+ */
581
+ childForFieldName(fieldName: string): SyntaxNode | null;
582
+
583
+ /**
584
+ * Get this node's child with the given numerical field id.
585
+ *
586
+ * Field IDs can be obtained from field names using the parser's language object.
587
+ *
588
+ * @param fieldId - The field ID to search for
589
+ * @returns The child node, or null if no child has the given field ID
590
+ */
591
+ childForFieldId(fieldId: number): SyntaxNode | null;
592
+
593
+ /**
594
+ * Get the field name of the child at the given index
595
+ *
596
+ * @param childIndex - Zero-based index of the child
597
+ * @returns The field name, or null if the child has no field name
598
+ */
599
+ fieldNameForChild(childIndex: number): string | null;
600
+
601
+ /**
602
+ * Get the field name of the named child at the given index
603
+ *
604
+ * @param namedChildIndex - Zero-based index of the named child
605
+ * @returns The field name, or null if the named child has no field name
606
+ */
607
+ fieldNameForNamedChild(namedChildIndex: number): string | null;
608
+
609
+ /**
610
+ * Get all children that have the given field name
611
+ *
612
+ * @param fieldName - The field name to search for
613
+ * @returns Array of child nodes with the given field name
614
+ */
615
+ childrenForFieldName(fieldName: string): Array<SyntaxNode>;
616
+
617
+ /**
618
+ * Get all children that have the given field ID
619
+ *
620
+ * @param fieldId - The field ID to search for
621
+ * @returns Array of child nodes with the given field ID
622
+ */
623
+ childrenForFieldId(fieldId: number): Array<SyntaxNode>;
624
+
625
+ /**
626
+ * Get the node's first child that extends beyond the given byte offset
627
+ *
628
+ * @param index - The byte offset to search from
629
+ * @returns The first child extending beyond the offset, or null if none found
630
+ */
631
+ firstChildForIndex(index: number): SyntaxNode | null;
632
+
633
+ /**
634
+ * Get the node's first named child that extends beyond the given byte offset
635
+ *
636
+ * @param index - The byte offset to search from
637
+ * @returns The first named child extending beyond the offset, or null if none found
638
+ */
639
+ firstNamedChildForIndex(index: number): SyntaxNode | null;
640
+
641
+ /**
642
+ * Get the immediate child that contains the given descendant node.
643
+ * Note that this can return the descendant itself if it is an immediate child.
644
+ *
645
+ * @param descendant - The descendant node to find the parent of
646
+ * @returns The child containing the descendant, or null if not found
647
+ */
648
+ childWithDescendant(descendant: SyntaxNode): SyntaxNode | null;
649
+
650
+ /**
651
+ * Get the smallest node within this node that spans the given byte offset.
652
+ *
653
+ * @param index - The byte offset to search for
654
+ * @returns The smallest node spanning the offset
655
+ */
656
+ descendantForIndex(index: number): SyntaxNode;
657
+
658
+ /**
659
+ * Get the smallest node within this node that spans the given byte range.
660
+ *
661
+ * @param startIndex - The starting byte offset
662
+ * @param endIndex - The ending byte offset
663
+ * @returns The smallest node spanning the range
664
+ */
665
+ descendantForIndex(startIndex: number, endIndex: number): SyntaxNode;
666
+
667
+ /**
668
+ * Get the smallest named node within this node that spans the given byte offset.
669
+ *
670
+ * @param index - The byte offset to search for
671
+ * @returns The smallest named node spanning the offset
672
+ */
673
+ namedDescendantForIndex(index: number): SyntaxNode;
674
+
675
+ /**
676
+ * Get the smallest named node within this node that spans the given byte range.
677
+ *
678
+ * @param startIndex - The starting byte offset
679
+ * @param endIndex - The ending byte offset
680
+ * @returns The smallest named node spanning the range
681
+ */
682
+ namedDescendantForIndex(startIndex: number, endIndex: number): SyntaxNode;
683
+
684
+ /**
685
+ * Get the smallest node within this node that spans the given position.
686
+ * When only one position is provided, it's used as both start and end.
687
+ *
688
+ * @param position - The point to search for
689
+ * @returns The smallest node spanning the position
690
+ */
691
+ descendantForPosition(position: Point): SyntaxNode;
692
+
693
+ /**
694
+ * Get the smallest node within this node that spans the given position range.
695
+ *
696
+ * @param startPosition - The starting position
697
+ * @param endPosition - The ending position
698
+ * @returns The smallest node spanning the range
699
+ */
700
+ descendantForPosition(startPosition: Point, endPosition: Point): SyntaxNode;
701
+
702
+ /**
703
+ * Get the smallest named node within this node that spans the given position.
704
+ * When only one position is provided, it's used as both start and end.
705
+ *
706
+ * @param position - The point to search for
707
+ * @returns The smallest named node spanning the position
708
+ */
709
+ namedDescendantForPosition(position: Point): SyntaxNode;
710
+
711
+ /**
712
+ * Get the smallest named node within this node that spans the given position range.
713
+ *
714
+ * @param startPosition - The starting position
715
+ * @param endPosition - The ending position
716
+ * @returns The smallest named node spanning the range
717
+ */
718
+ namedDescendantForPosition(startPosition: Point, endPosition: Point): SyntaxNode;
719
+
720
+ /**
721
+ * Get all descendants of this node that have the given type(s)
722
+ *
723
+ * @param types - A string or array of strings of node types to find
724
+ * @param startPosition - Optional starting position to search from
725
+ * @param endPosition - Optional ending position to search to
726
+ * @returns Array of descendant nodes matching the given types
727
+ */
728
+ descendantsOfType(types: String | Array<String>, startPosition?: Point, endPosition?: Point): Array<SyntaxNode>;
729
+
730
+ /**
731
+ * Find the closest ancestor of the current node that matches the given type(s).
732
+ *
733
+ * Starting from the node's parent, walks up the tree until it finds a node
734
+ * whose type matches any of the given types.
735
+ *
736
+ * @example
737
+ * const property = tree.rootNode.descendantForIndex(5);
738
+ * // Find closest unary expression ancestor
739
+ * const unary = property.closest('unary_expression');
740
+ * // Find closest binary or call expression ancestor
741
+ * const expr = property.closest(['binary_expression', 'call_expression']);
742
+ *
743
+ * @param types - A string or array of strings representing the node types to search for
744
+ * @returns The closest matching ancestor node, or null if none found
745
+ * @throws If the argument is not a string or array of strings
746
+ */
747
+ closest(types: String | Array<String>): SyntaxNode | null;
748
+
749
+ /**
750
+ * Create a new TreeCursor starting from this node.
751
+ *
752
+ * @returns A new cursor positioned at this node
753
+ */
754
+ walk(): TreeCursor;
755
+ }
756
+
757
+ /** A stateful object for walking a syntax {@link Tree} efficiently */
758
+ export interface TreeCursor {
759
+ /** The type of the current node as a string */
760
+ nodeType: string;
761
+
762
+ /** The type of the current node as a numeric ID */
763
+ nodeTypeId: number;
764
+
765
+ /** The parse state of the current node */
766
+ nodeStateId: number;
767
+
768
+ /** The text of the current node */
769
+ nodeText: string;
770
+
771
+ /** Whether the current node is named */
772
+ nodeIsNamed: boolean;
773
+
774
+ /** Whether the current node is missing from the source code */
775
+ nodeIsMissing: boolean;
776
+
777
+ /** The start position of the current node */
778
+ startPosition: Point;
779
+
780
+ /** The end position of the current node */
781
+ endPosition: Point;
782
+
783
+ /** The start byte index of the current node */
784
+ startIndex: number;
785
+
786
+ /** The end byte index of the current node */
787
+ endIndex: number;
788
+
789
+ /** The current node that the cursor is pointing to */
790
+ readonly currentNode: SyntaxNode;
791
+
792
+ /** The field name of the current node */
793
+ readonly currentFieldName: string;
794
+
795
+ /** The numerical field ID of the current node */
796
+ readonly currentFieldId: number;
797
+
798
+ /** The depth of the current node relative to the node where the cursor was created */
799
+ readonly currentDepth: number;
800
+
801
+ /** The index of the current node among all descendants of the original node */
802
+ readonly currentDescendantIndex: number;
803
+
804
+ /**
805
+ * Re-initialize this cursor to start at a new node
806
+ *
807
+ * @param node - The node to start from
808
+ */
809
+ reset(node: SyntaxNode): void;
810
+
811
+ /**
812
+ * Re-initialize this cursor to the same position as another cursor.
813
+ * Unlike reset(), this will not lose parent information and allows
814
+ * reusing already created cursors.
815
+ *
816
+ * @param cursor - The cursor to copy the position from
817
+ */
818
+ resetTo(cursor: TreeCursor): void;
819
+
820
+ /**
821
+ * Move this cursor to the parent of its current node.
822
+ *
823
+ * @returns true if cursor successfully moved, false if there was no parent
824
+ * (cursor was already at the root node)
825
+ */
826
+ gotoParent(): boolean;
827
+
828
+ /**
829
+ * Move this cursor to the first child of its current node.
830
+ *
831
+ * @returns true if cursor successfully moved, false if there were no children
832
+ */
833
+ gotoFirstChild(): boolean;
834
+
835
+ /**
836
+ * Move this cursor to the last child of its current node.
837
+ * Note: This may be slower than gotoFirstChild() as it needs to iterate
838
+ * through all children to compute the position.
839
+ *
840
+ * @returns true if cursor successfully moved, false if there were no children
841
+ */
842
+ gotoLastChild(): boolean;
843
+
844
+ /**
845
+ * Move this cursor to the first child that extends beyond the given byte offset
846
+ *
847
+ * @param goalIndex - The byte offset to search for
848
+ * @returns true if a child was found and cursor moved, false otherwise
849
+ */
850
+ gotoFirstChildForIndex(goalIndex: number): boolean;
851
+
852
+ /**
853
+ * Move this cursor to the first child that extends beyond the given position
854
+ *
855
+ * @param goalPosition - The position to search for
856
+ * @returns true if a child was found and cursor moved, false otherwise
857
+ */
858
+ gotoFirstChildForPosition(goalPosition: Point): boolean;
859
+
860
+ /**
861
+ * Move this cursor to the next sibling of its current node
862
+ *
863
+ * @returns true if cursor successfully moved, false if there was no next sibling
864
+ */
865
+ gotoNextSibling(): boolean;
866
+
867
+ /**
868
+ * Move this cursor to the previous sibling of its current node.
869
+ * Note: This may be slower than gotoNextSibling() due to how node positions
870
+ * are stored. In the worst case, it will need to iterate through all previous
871
+ * siblings to recalculate positions.
872
+ *
873
+ * @returns true if cursor successfully moved, false if there was no previous sibling
874
+ */
875
+ gotoPreviousSibling(): boolean;
876
+
877
+ /**
878
+ * Move the cursor to the descendant node at the given index, where zero
879
+ * represents the original node the cursor was created with.
880
+ *
881
+ * @param goalDescendantIndex - The index of the descendant to move to
882
+ */
883
+ gotoDescendant(goalDescendantIndex: number): void;
884
+ }
885
+
886
+ /**
887
+ * A tree that represents the syntactic structure of a source code file.
888
+ */
889
+ export interface Tree {
890
+ /**
891
+ * The root node of the syntax tree
892
+ */
893
+ readonly rootNode: SyntaxNode;
894
+
895
+ /**
896
+ * Get the root node of the syntax tree, but with its position shifted
897
+ * forward by the given offset.
898
+ *
899
+ * @param offsetBytes - The number of bytes to shift by
900
+ * @param offsetExtent - The number of rows/columns to shift by
901
+ * @returns The root node with its position offset
902
+ */
903
+ rootNodeWithOffset(offsetBytes: number, offsetExtent: Point): SyntaxNode;
904
+
905
+ /**
906
+ * Edit the syntax tree to keep it in sync with source code that has been edited.
907
+ * The edit must be described both in terms of byte offsets and in terms of
908
+ * row/column coordinates.
909
+ *
910
+ * @param edit - The edit to apply to the tree
911
+ * @returns The edited tree
912
+ */
913
+ edit(edit: Edit): Tree;
914
+
915
+ /**
916
+ * Create a new TreeCursor starting from the root of the tree.
917
+ *
918
+ * @returns A new cursor positioned at the root node
919
+ */
920
+ walk(): TreeCursor;
921
+
922
+ /**
923
+ * Get the text for a node within this tree
924
+ *
925
+ * @param node - The syntax node to get text for
926
+ * @returns The source text for the node
927
+ */
928
+ getText(node: SyntaxNode): string;
929
+
930
+ /**
931
+ * Compare this edited syntax tree to a new syntax tree representing the
932
+ * same document, returning ranges whose syntactic structure has changed.
933
+ *
934
+ * For this to work correctly, this tree must have been edited to match
935
+ * the new tree's ranges. Generally, you'll want to call this right after
936
+ * parsing, using the old tree that was passed to parse and the new tree
937
+ * that was returned.
938
+ *
939
+ * @param other - The new tree to compare against
940
+ * @returns Array of ranges that have changed
941
+ */
942
+ getChangedRanges(other: Tree): Range[];
943
+
944
+ /**
945
+ * Get the ranges that were included when parsing this syntax tree
946
+ *
947
+ * @returns Array of included ranges
948
+ */
949
+ getIncludedRanges(): Range[];
950
+
951
+ /**
952
+ * Get the range that was edited in this tree
953
+ *
954
+ * @returns The edited range
955
+ */
956
+ getEditedRange(): Range;
957
+
958
+ /**
959
+ * Print a graph of the tree in the DOT language.
960
+ * You may want to pipe this to a 'dot' process to generate SVG output.
961
+ *
962
+ * @param fd - Optional file descriptor for the output
963
+ */
964
+ printDotGraph(fd?: number): void;
965
+ }
966
+
967
+ /**
968
+ * A particular syntax node that was captured by a named pattern in a query.
969
+ */
970
+ export interface QueryCapture {
971
+ /** The name that was used to capture the node in the query */
972
+ name: string;
973
+
974
+ /** The captured syntax node */
975
+ node: SyntaxNode;
976
+ }
977
+
978
+ /**
979
+ * A match of a {@link Query} to a particular set of {@link SyntaxNode}s.
980
+ */
981
+ export interface QueryMatch {
982
+ /**
983
+ * The index of the pattern that was matched.
984
+ * Each pattern in a query is assigned a numeric index in sequence.
985
+ */
986
+ pattern: number;
987
+
988
+ /** Array of nodes that were captured in the pattern match */
989
+ captures: QueryCapture[];
990
+ }
991
+ export type QueryOptions = {
992
+ /** The starting row/column position in which the query will be executed. */
993
+ startPosition?: Point;
994
+
995
+ /** The ending row/column position in which the query will be executed. */
996
+ endPosition?: Point;
997
+
998
+ /** The starting byte offset in which the query will be executed. */
999
+ startIndex?: number;
1000
+
1001
+ /** The ending byte offset in which the query will be executed. */
1002
+ endIndex?: number;
1003
+
1004
+ /** The maximum number of in-progress matches for this cursor. The limit must be > 0 and <= 65536. */
1005
+ matchLimit?: number;
1006
+
1007
+ /**
1008
+ * The maximum start depth for a query cursor.
1009
+ *
1010
+ * This prevents cursors from exploring children nodes at a certain depth.
1011
+ * Note if a pattern includes many children, then they will still be
1012
+ * checked.
1013
+ *
1014
+ * The zero max start depth value can be used as a special behavior and
1015
+ * it helps to destructure a subtree by staying on a node and using
1016
+ * captures for interested parts. Note that the zero max start depth
1017
+ * only limit a search depth for a pattern's root node but other nodes
1018
+ * that are parts of the pattern may be searched at any depth what
1019
+ * defined by the pattern structure.
1020
+ */
1021
+ maxStartDepth?: number;
1022
+
1023
+ /**
1024
+ * The maximum duration in microseconds that query execution should be allowed to
1025
+ * take before halting.
1026
+ *
1027
+ * If query execution takes longer than this, it will halt early, returning None.
1028
+ */
1029
+ timeoutMicros?: number;
1030
+ };
1031
+ export class Query {
1032
+ /** The maximum number of in-progress matches for this cursor. */
1033
+ readonly matchLimit: number;
1034
+
1035
+ /**
1036
+ * Create a new query from a string containing one or more S-expression
1037
+ * patterns.
1038
+ *
1039
+ * The query is associated with a particular language, and can only be run
1040
+ * on syntax nodes parsed with that language. References to Queries can be
1041
+ * shared between multiple threads.
1042
+ */
1043
+ constructor(language: Language, source: string | Buffer);
1044
+
1045
+ /**
1046
+ * Iterate over all of the individual captures in the order that they
1047
+ * appear.
1048
+ *
1049
+ * This is useful if you don't care about which pattern matched, and just
1050
+ * want a single, ordered sequence of captures.
1051
+ *
1052
+ * @param node - The syntax node to query
1053
+ * @param options - Optional query options
1054
+ *
1055
+ * @returns An array of captures
1056
+ */
1057
+ captures(node: SyntaxNode, options?: QueryOptions): QueryCapture[];
1058
+
1059
+ /**
1060
+ * Iterate over all of the matches in the order that they were found.
1061
+ *
1062
+ * Each match contains the index of the pattern that matched, and a list of
1063
+ * captures. Because multiple patterns can match the same set of nodes,
1064
+ * one match may contain captures that appear *before* some of the
1065
+ * captures from a previous match.
1066
+ *
1067
+ * @param node - The syntax node to query
1068
+ * @param options - Optional query options
1069
+ *
1070
+ * @returns An array of matches
1071
+ */
1072
+ matches(node: SyntaxNode, options?: QueryOptions): QueryMatch[];
1073
+
1074
+ /**
1075
+ * Disable a certain capture within a query.
1076
+ *
1077
+ * This prevents the capture from being returned in matches, and also
1078
+ * avoids any resource usage associated with recording the capture.
1079
+ *
1080
+ * @param captureName - The name of the capture to disable
1081
+ */
1082
+ disableCapture(captureName: string): void;
1083
+
1084
+ /**
1085
+ * Disable a certain pattern within a query.
1086
+ *
1087
+ * This prevents the pattern from matching, and also avoids any resource
1088
+ * usage associated with the pattern.
1089
+ *
1090
+ * @param patternIndex - The index of the pattern to disable
1091
+ */
1092
+ disablePattern(patternIndex: number): void;
1093
+
1094
+ /**
1095
+ * Check if a given step in a query is 'definite'.
1096
+ *
1097
+ * A query step is 'definite' if its parent pattern will be guaranteed to
1098
+ * match successfully once it reaches the step.
1099
+ *
1100
+ * @param byteOffset - The byte offset of the step to check
1101
+ */
1102
+ isPatternGuaranteedAtStep(byteOffset: number): boolean;
1103
+
1104
+ /**
1105
+ * Check if a given pattern within a query has a single root node.
1106
+ *
1107
+ * @param patternIndex - The index of the pattern to check
1108
+ */
1109
+ isPatternRooted(patternIndex: number): boolean;
1110
+
1111
+ /**
1112
+ * Check if a given pattern within a query has a single root node.
1113
+ *
1114
+ * @param patternIndex - The index of the pattern to check
1115
+ */
1116
+ isPatternNonLocal(patternIndex: number): boolean;
1117
+
1118
+ /**
1119
+ * Get the byte offset where the given pattern starts in the query's
1120
+ * source.
1121
+ *
1122
+ * @param patternIndex - The index of the pattern to check
1123
+ *
1124
+ * @returns The byte offset where the pattern starts
1125
+ */
1126
+ startIndexForPattern(patternIndex: number): number;
1127
+
1128
+ /**
1129
+ * Get the byte offset where the given pattern ends in the query's
1130
+ * source.
1131
+ *
1132
+ * @param patternIndex - The index of the pattern to check
1133
+ *
1134
+ * @returns The byte offset where the pattern ends
1135
+ */
1136
+ endIndexForPattern(patternIndex: number): number;
1137
+
1138
+ /**
1139
+ * Check if, on its last execution, this cursor exceeded its maximum number
1140
+ * of in-progress matches.
1141
+ *
1142
+ * @returns true if the cursor exceeded its match limit
1143
+ */
1144
+ didExceedMatchLimit(): boolean;
1145
+ }
1146
+ export class LookaheadIterator {
1147
+ /** The current symbol of the lookahead iterator. */
1148
+ readonly currentTypeId: number;
1149
+ /** The current symbol name of the lookahead iterator. */
1150
+ readonly currentType: string;
1151
+
1152
+ /**
1153
+ * Create a new lookahead iterator for this language and parse state.
1154
+ *
1155
+ * This returns `null` if the state is invalid for this language.
1156
+ *
1157
+ * Iterating {@link LookaheadIterator} will yield valid symbols in the given
1158
+ * parse state. Newly created lookahead iterators will have {@link currentType}
1159
+ * populated with the `ERROR` symbol.
1160
+ *
1161
+ * Lookahead iterators can be useful to generate suggestions and improve
1162
+ * syntax error diagnostics. To get symbols valid in an ERROR node, use the
1163
+ * lookahead iterator on its first leaf node state. For `MISSING` nodes, a
1164
+ * lookahead iterator created on the previous non-extra leaf node may be
1165
+ * appropriate.
1166
+ *
1167
+ * @param language - The language to use for the lookahead iterator
1168
+ * @param state - The parse state to use for the lookahead iterator
1169
+ */
1170
+ constructor(language: Language, state: number);
1171
+
1172
+ /**
1173
+ * Reset the lookahead iterator.
1174
+ *
1175
+ * This returns `true` if the language was set successfully and `false`
1176
+ * otherwise.
1177
+ *
1178
+ * @param language - The language to use for the lookahead iterator
1179
+ * @param stateId - The parse state to use for the lookahead iterator
1180
+ */
1181
+ reset(language: Language, stateId: number): boolean;
1182
+
1183
+ /**
1184
+ * Reset the lookahead iterator to another state.
1185
+ *
1186
+ * This returns `true` if the iterator was reset to the given state and
1187
+ * `false` otherwise.
1188
+ *
1189
+ * @param stateId - The parse state to reset the lookahead iterator to
1190
+ */
1191
+ resetState(stateId: number): boolean;
1192
+
1193
+ /**
1194
+ * Get an iterator for the lookahead iterator.
1195
+ *
1196
+ * This allows the lookahead iterator to be used in a for-of loop,
1197
+ * iterating over the valid symbols in the current parse state.
1198
+ *
1199
+ * @returns An iterator over the symbol names
1200
+ */
1201
+ [Symbol.iterator](): Iterator<string>;
1202
+ }
1203
+
1204
+ /** The base node type */
1205
+ type BaseNode = {
1206
+ /** The node's type */
1207
+ type: string;
1208
+ /** Whether the node is named */
1209
+ named: boolean;
1210
+ };
1211
+
1212
+ /** A child within a node */
1213
+ type ChildNode = {
1214
+ /** Whether the child is repeated */
1215
+ multiple: boolean;
1216
+ /** Whether the child is required */
1217
+ required: boolean;
1218
+ /** The child's type */
1219
+ types: BaseNode[];
1220
+ };
1221
+
1222
+ /** Information about a language's node types */
1223
+ type NodeInfo = (BaseNode & {
1224
+ /** The subtypes of this node if it's a supertype */
1225
+ subtypes: BaseNode[];
1226
+ }) | (BaseNode & {
1227
+ /** The fields within this node */
1228
+ fields: {
1229
+ [name: string]: ChildNode;
1230
+ };
1231
+ /** The child nodes of this node */
1232
+ children: ChildNode[];
1233
+ });
1234
+
1235
+ /** Information about a language */
1236
+ interface Language {
1237
+ /** The inner language object */
1238
+ language: unknown;
1239
+ /** The node type information of the language */
1240
+ nodeTypeInfo: NodeInfo[];
1241
+ }
1242
+ }
1243
+ export = Parser;
1244
+ }
1245
+ //#endregion
1246
+ //#region ../extract/src/plugins/core/queries/types.d.ts
1247
+ interface Comments {
1248
+ translator?: string;
1249
+ reference?: string;
1250
+ extracted?: string;
1251
+ flag?: string;
1252
+ previous?: string;
1253
+ }
1254
+ interface Translation {
1255
+ context?: string;
1256
+ id: string;
1257
+ plural?: string;
1258
+ message: string[];
1259
+ comments?: Comments;
1260
+ obsolete?: boolean;
1261
+ }
1262
+ //#endregion
1263
+ //#region ../extract/src/plugins/core/core.d.ts
1264
+ declare function core$1(): Plugin<string, Translation[]>;
1265
+ //#endregion
1266
+ //#region ../extract/src/plugins/po/po.d.ts
1267
+ declare function po$1(): Plugin;
1268
+ //#endregion
1269
+ //#region ../extract/src/plugins/react/react.d.ts
1270
+ declare function react$1(): Plugin<string, Translation[]>;
1271
+ //#endregion
1272
+ //#region ../extract/src/static.d.ts
1273
+ declare function core(...props: Parameters<typeof core$1>): {
1274
+ readonly static: {
1275
+ readonly name: "core";
1276
+ readonly props: [];
1277
+ };
1278
+ };
1279
+ declare function react(...props: Parameters<typeof react$1>): {
1280
+ readonly static: {
1281
+ readonly name: "react";
1282
+ readonly props: [];
1283
+ };
1284
+ };
1285
+ declare function po(...props: Parameters<typeof po$1>): {
1286
+ readonly static: {
1287
+ readonly name: "po";
1288
+ readonly props: [];
1289
+ };
1290
+ };
1291
+ declare function cleanup(...props: Parameters<typeof cleanup$1>): {
1292
+ readonly static: {
1293
+ readonly name: "cleanup";
1294
+ readonly props: [];
1295
+ };
1296
+ };
1297
+ type StaticPlugin = ReturnType<typeof core> | ReturnType<typeof react> | ReturnType<typeof po> | ReturnType<typeof cleanup>;
1298
+ //#endregion
1299
+ //#region ../extract/src/plugin.d.ts
1300
+ type MaybePromise<T> = T | Promise<T>;
1301
+ interface Context {
1302
+ config: ResolvedConfig;
1303
+ generatedAt: Date;
1304
+ logger?: Logger$1;
1305
+ }
1306
+ interface ResolveArgs<TInput = unknown> {
1307
+ entrypoint: string;
1308
+ path: string;
1309
+ namespace: string;
1310
+ data?: TInput;
1311
+ }
1312
+ interface ResolveResult<TInput = unknown> {
1313
+ entrypoint: string;
1314
+ path: string;
1315
+ namespace: string;
1316
+ data?: TInput;
1317
+ }
1318
+ interface LoadArgs<TInput = unknown> {
1319
+ entrypoint: string;
1320
+ path: string;
1321
+ namespace: string;
1322
+ data?: TInput;
1323
+ }
1324
+ interface LoadResult<TInput = unknown> {
1325
+ entrypoint: string;
1326
+ path: string;
1327
+ namespace: string;
1328
+ data: TInput;
1329
+ }
1330
+ interface ProcessArgs<TInput = unknown> {
1331
+ entrypoint: string;
1332
+ path: string;
1333
+ namespace: string;
1334
+ data: TInput;
1335
+ }
1336
+ interface ProcessResult<TOutput = unknown> {
1337
+ entrypoint: string;
1338
+ path: string;
1339
+ namespace: string;
1340
+ data: TOutput;
1341
+ }
1342
+ type Filter = {
1343
+ filter: RegExp;
1344
+ namespace?: string;
1345
+ };
1346
+ type ResolveHook<TInput = unknown> = (args: ResolveArgs<TInput>) => MaybePromise<ResolveResult<TInput> | undefined>;
1347
+ type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadResult<TInput> | undefined>;
1348
+ type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
1349
+ interface Build<TInput = unknown, TOutput = unknown> {
1350
+ context: Context;
1351
+ resolve(args: ResolveArgs<unknown>): void;
1352
+ load(args: LoadArgs<unknown>): void;
1353
+ process(args: ProcessArgs<unknown>): void;
1354
+ defer(namespace: string): Promise<void>;
1355
+ onResolve(options: Filter, hook: ResolveHook<TInput>): void;
1356
+ onLoad(options: Filter, hook: LoadHook<TInput>): void;
1357
+ onProcess(options: Filter, hook: ProcessHook<TInput, TOutput>): void;
1358
+ }
1359
+ interface Plugin<TInput = unknown, TOutput = unknown> {
1360
+ name: string;
1361
+ setup(build: Build<TInput, TOutput>): void;
1362
+ }
1363
+ type UniversalPlugin = Plugin | StaticPlugin;
1364
+ //#endregion
1365
+ //#region ../extract/src/configuration.d.ts
1366
+ type DestinationFn = (args: {
1367
+ locale: string;
1368
+ entrypoint: string;
1369
+ path: string;
1370
+ }) => string;
1371
+ type ExcludeFn = (args: {
1372
+ entrypoint: string;
1373
+ path: string;
1374
+ }) => boolean;
1375
+ type Exclude = RegExp | ExcludeFn;
1376
+ declare const defaultPlugins: {
1377
+ core: typeof core;
1378
+ po: typeof po;
1379
+ cleanup: typeof cleanup;
1380
+ };
1381
+ type DefaultPlugins = typeof defaultPlugins;
1382
+ /**
1383
+ * Strategy to handle obsolete translations in existing locale files:
1384
+ * - "mark": keep obsolete entries in the locale file but mark them as obsolete
1385
+ * - "remove": remove obsolete entries from the locale file
1386
+ */
1387
+ type ObsoleteStrategy = "mark" | "remove";
1388
+ interface EntrypointConfig {
1389
+ entrypoint: string;
1390
+ destination?: DestinationFn;
1391
+ obsolete?: ObsoleteStrategy;
1392
+ walk?: boolean;
1393
+ exclude?: Exclude | Exclude[];
1394
+ }
1395
+ interface UserConfig {
1396
+ /**
1397
+ * Default locale to use as the base for extraction
1398
+ * @default "en"
1399
+ * @see {@link PluralFormsLocale} for available locales
1400
+ */
1401
+ defaultLocale?: PluralFormsLocale;
1402
+ /**
1403
+ * Array of locales to extract translations for
1404
+ * @default [defaultLocale]
1405
+ * @see {@link PluralFormsLocale} for available locales
1406
+ */
1407
+ locales?: PluralFormsLocale[];
1408
+ /**
1409
+ * Array of plugins to use or a function to override the default plugins
1410
+ * @default DefaultPlugins
1411
+ * @see {@link DefaultPlugins} for available plugins
1412
+ */
1413
+ plugins?: UniversalPlugin[] | ((defaultPlugins: DefaultPlugins) => UniversalPlugin[]);
1414
+ /**
1415
+ * One or more entrypoints to extract translations from, could be:
1416
+ * - file path, will be treated as a single file entrypoint
1417
+ * - glob pattern will be expanded to match files, each treated as a separate entrypoint
1418
+ * - configuration object with options for the entrypoint
1419
+ * @see {@link EntrypointConfig} for configuration options
1420
+ */
1421
+ entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;
1422
+ /**
1423
+ * Function to determine the destination path for each extracted locale file
1424
+ * @default `./translations/entrypoint.locale.po`
1425
+ * @see {@link DestinationFn}
1426
+ * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig
1427
+ */
1428
+ destination?: DestinationFn;
1429
+ /**
1430
+ * Strategy to handle obsolete translations in existing locale files
1431
+ * @default "mark"
1432
+ * @see {@link ObsoleteStrategy} for available strategies
1433
+ * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig
1434
+ */
1435
+ obsolete?: ObsoleteStrategy;
1436
+ /**
1437
+ * Whether to recursively walk dependencies of the entrypoints
1438
+ * @default true
1439
+ * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.
1440
+ */
1441
+ walk?: boolean;
1442
+ /**
1443
+ * Paths or patterns to exclude from extraction, applied to all entrypoints
1444
+ * @default [/node_modules/, /dist/, /build/]
1445
+ * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.
1446
+ */
1447
+ exclude?: Exclude | Exclude[];
1448
+ /**
1449
+ * Log level for the extraction process
1450
+ * @default "info"
1451
+ */
1452
+ logLevel?: LogLevel$1;
1453
+ }
1454
+ interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
1455
+ exclude?: Exclude[];
1456
+ }
1457
+ interface ResolvedConfig {
1458
+ plugins: UniversalPlugin[];
1459
+ entrypoints: ResolvedEntrypoint[];
1460
+ defaultLocale: string;
1461
+ locales: string[];
1462
+ destination: DestinationFn;
1463
+ obsolete: ObsoleteStrategy;
1464
+ walk: boolean;
1465
+ logLevel: LogLevel$1;
1466
+ exclude: Exclude[];
1467
+ }
1468
+ /**
1469
+ * Type helper to make it easier to use translate.config.ts
1470
+ * @param config - {@link UserConfig}.
1471
+ */
1472
+ declare function defineConfig(config: UserConfig): ResolvedConfig;
1473
+ //#endregion
1474
+ export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, core, defineConfig, po, react };