@let-value/translate-extract-static 1.1.2 → 1.1.6-beta.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.
- package/dist/bin/cli.cjs +3 -8
- package/dist/bin/{cli.js → cli.mjs} +2 -4
- package/dist/{binary-Ceo8ROxg.js → binary-B9VjMzKh.mjs} +4 -6
- package/dist/binary-USvBdAnM.cjs +32 -0
- package/dist/scripts/postinstall.cjs +3 -11
- package/dist/scripts/{postinstall.js → postinstall.mjs} +3 -8
- package/dist/src/index.cjs +27 -19
- package/dist/src/index.d.cts +53 -1096
- package/dist/src/index.d.mts +433 -0
- package/dist/src/{index.js → index.mjs} +26 -17
- package/package.json +44 -39
- package/dist/binary-B-BK0iD4.cjs +0 -37
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/src/index.d.ts +0 -1476
- /package/dist/bin/{cli.d.ts → cli.d.mts} +0 -0
- /package/dist/scripts/{postinstall.d.ts → postinstall.d.mts} +0 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
//#region ../node_modules/.pnpm/loglevel@1.9.2/node_modules/loglevel/index.d.ts
|
|
2
|
+
// Originally from Definitely Typed, see:
|
|
3
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b4683d7/types/loglevel/index.d.ts
|
|
4
|
+
// Original definitions by: Stefan Profanter <https://github.com/Pro>
|
|
5
|
+
// Gabor Szmetanko <https://github.com/szmeti>
|
|
6
|
+
// Christian Rackerseder <https://github.com/screendriver>
|
|
7
|
+
declare const log: log.RootLogger;
|
|
8
|
+
declare namespace log {
|
|
9
|
+
/**
|
|
10
|
+
* Log levels
|
|
11
|
+
*/
|
|
12
|
+
interface LogLevel {
|
|
13
|
+
TRACE: 0;
|
|
14
|
+
DEBUG: 1;
|
|
15
|
+
INFO: 2;
|
|
16
|
+
WARN: 3;
|
|
17
|
+
ERROR: 4;
|
|
18
|
+
SILENT: 5;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Possible log level numbers.
|
|
22
|
+
*/
|
|
23
|
+
type LogLevelNumbers = LogLevel[keyof LogLevel];
|
|
24
|
+
/**
|
|
25
|
+
* Possible log level descriptors, may be string, lower or upper case, or number.
|
|
26
|
+
*/
|
|
27
|
+
type LogLevelDesc = LogLevelNumbers | LogLevelNames | 'silent' | keyof LogLevel;
|
|
28
|
+
type LogLevelNames = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
29
|
+
type LoggingMethod = (...message: any[]) => void;
|
|
30
|
+
type MethodFactory = (methodName: LogLevelNames, level: LogLevelNumbers, loggerName: string | symbol) => LoggingMethod;
|
|
31
|
+
interface RootLogger extends Logger {
|
|
32
|
+
/**
|
|
33
|
+
* If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
|
|
34
|
+
* Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
|
|
35
|
+
* onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
|
|
36
|
+
* returns the loglevel object, which you can then bind to another name yourself.
|
|
37
|
+
*/
|
|
38
|
+
noConflict(): any;
|
|
39
|
+
/**
|
|
40
|
+
* This gets you a new logger object that works exactly like the root log object, but can have its level and
|
|
41
|
+
* logging methods set independently. All loggers must have a name (which is a non-empty string or a symbol)
|
|
42
|
+
* Calling * getLogger() multiple times with the same name will return an identical logger object.
|
|
43
|
+
* In large applications, it can be incredibly useful to turn logging on and off for particular modules as you are
|
|
44
|
+
* working with them. Using the getLogger() method lets you create a separate logger for each part of your
|
|
45
|
+
* application with its own logging level. Likewise, for small, independent modules, using a named logger instead
|
|
46
|
+
* of the default root logger allows developers using your module to selectively turn on deep, trace-level logging
|
|
47
|
+
* when trying to debug problems, while logging only errors or silencing logging altogether under normal
|
|
48
|
+
* circumstances.
|
|
49
|
+
* @param name The name of the produced logger
|
|
50
|
+
*/
|
|
51
|
+
getLogger(name: string | symbol): Logger;
|
|
52
|
+
/**
|
|
53
|
+
* This will return you the dictionary of all loggers created with getLogger, keyed off of their names.
|
|
54
|
+
*/
|
|
55
|
+
getLoggers(): {
|
|
56
|
+
[name: string]: Logger;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A .default property for ES6 default import compatibility
|
|
60
|
+
*/
|
|
61
|
+
default: RootLogger;
|
|
62
|
+
}
|
|
63
|
+
interface Logger {
|
|
64
|
+
/**
|
|
65
|
+
* Available log levels.
|
|
66
|
+
*/
|
|
67
|
+
readonly levels: LogLevel;
|
|
68
|
+
/**
|
|
69
|
+
* Plugin API entry point. This will be called for each enabled method each time the level is set
|
|
70
|
+
* (including initially), and should return a MethodFactory to be used for the given log method, at the given level,
|
|
71
|
+
* for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's
|
|
72
|
+
* recommended that this wraps the initially provided value of log.methodFactory
|
|
73
|
+
*/
|
|
74
|
+
methodFactory: MethodFactory;
|
|
75
|
+
/**
|
|
76
|
+
* Output trace message to console.
|
|
77
|
+
* This will also include a full stack trace
|
|
78
|
+
*
|
|
79
|
+
* @param msg any data to log to the console
|
|
80
|
+
*/
|
|
81
|
+
trace(...msg: any[]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Output debug message to console including appropriate icons
|
|
84
|
+
*
|
|
85
|
+
* @param msg any data to log to the console
|
|
86
|
+
*/
|
|
87
|
+
debug(...msg: any[]): void;
|
|
88
|
+
/**
|
|
89
|
+
* Output debug message to console including appropriate icons
|
|
90
|
+
*
|
|
91
|
+
* @param msg any data to log to the console
|
|
92
|
+
*/
|
|
93
|
+
log(...msg: any[]): void;
|
|
94
|
+
/**
|
|
95
|
+
* Output info message to console including appropriate icons
|
|
96
|
+
*
|
|
97
|
+
* @param msg any data to log to the console
|
|
98
|
+
*/
|
|
99
|
+
info(...msg: any[]): void;
|
|
100
|
+
/**
|
|
101
|
+
* Output warn message to console including appropriate icons
|
|
102
|
+
*
|
|
103
|
+
* @param msg any data to log to the console
|
|
104
|
+
*/
|
|
105
|
+
warn(...msg: any[]): void;
|
|
106
|
+
/**
|
|
107
|
+
* Output error message to console including appropriate icons
|
|
108
|
+
*
|
|
109
|
+
* @param msg any data to log to the console
|
|
110
|
+
*/
|
|
111
|
+
error(...msg: any[]): void;
|
|
112
|
+
/**
|
|
113
|
+
* This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
|
|
114
|
+
* or log.error("something") will output messages, but log.info("something") will not.
|
|
115
|
+
*
|
|
116
|
+
* @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
|
|
117
|
+
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
|
118
|
+
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
|
119
|
+
* false as the optional 'persist' second argument, persistence will be skipped.
|
|
120
|
+
*/
|
|
121
|
+
setLevel(level: LogLevelDesc, persist?: boolean): void;
|
|
122
|
+
/**
|
|
123
|
+
* Returns the current logging level, as a value from LogLevel.
|
|
124
|
+
* It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin
|
|
125
|
+
* development, and partly to let you optimize logging code as below, where debug data is only generated if the
|
|
126
|
+
* level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling
|
|
127
|
+
* on your code and you have hard numbers telling you that your log data generation is a real performance problem.
|
|
128
|
+
*/
|
|
129
|
+
getLevel(): LogLevel[keyof LogLevel];
|
|
130
|
+
/**
|
|
131
|
+
* This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when
|
|
132
|
+
* initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings.
|
|
133
|
+
* For example, your application might set the log level to error in a production environment, but when debugging
|
|
134
|
+
* an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set
|
|
135
|
+
* using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting
|
|
136
|
+
* to error.
|
|
137
|
+
*
|
|
138
|
+
* The level argument takes is the same values that you might pass to setLevel(). Levels set using
|
|
139
|
+
* setDefaultLevel() never persist to subsequent page loads.
|
|
140
|
+
*
|
|
141
|
+
* @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
|
|
142
|
+
*/
|
|
143
|
+
setDefaultLevel(level: LogLevelDesc): void;
|
|
144
|
+
/**
|
|
145
|
+
* This resets the current log level to the default level (or `warn` if no explicit default was set) and clears
|
|
146
|
+
* the persisted level if one was previously persisted.
|
|
147
|
+
*/
|
|
148
|
+
resetLevel(): void;
|
|
149
|
+
/**
|
|
150
|
+
* This enables all log messages, and is equivalent to log.setLevel("trace").
|
|
151
|
+
*
|
|
152
|
+
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
|
153
|
+
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
|
154
|
+
* false as the optional 'persist' second argument, persistence will be skipped.
|
|
155
|
+
*/
|
|
156
|
+
enableAll(persist?: boolean): void;
|
|
157
|
+
/**
|
|
158
|
+
* This disables all log messages, and is equivalent to log.setLevel("silent").
|
|
159
|
+
*
|
|
160
|
+
* @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
|
|
161
|
+
* back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
|
|
162
|
+
* false as the optional 'persist' second argument, persistence will be skipped.
|
|
163
|
+
*/
|
|
164
|
+
disableAll(persist?: boolean): void;
|
|
165
|
+
/**
|
|
166
|
+
* Rebuild the logging methods on this logger and its child loggers.
|
|
167
|
+
*
|
|
168
|
+
* This is mostly intended for plugin developers, but can be useful if you update a logger's `methodFactory` or
|
|
169
|
+
* if you want to apply the root logger’s level to any *pre-existing* child loggers (this updates the level on
|
|
170
|
+
* any child logger that hasn't used `setLevel()` or `setDefaultLevel()`).
|
|
171
|
+
*/
|
|
172
|
+
rebuild(): void;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region ../translate/dist/index.d.mts
|
|
177
|
+
//#region src/locales.d.ts
|
|
178
|
+
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"; //#endregion
|
|
179
|
+
//#region src/config.d.ts
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region ../extract/dist/configuration-oHJyypq5.d.mts
|
|
182
|
+
//#region src/logger.d.ts
|
|
183
|
+
type Logger$1 = log.Logger;
|
|
184
|
+
type LogLevelNames$1 = log.LogLevelNames;
|
|
185
|
+
type LogLevel$1 = LogLevelNames$1; //#endregion
|
|
186
|
+
//#region src/plugins/cleanup/cleanup.d.ts
|
|
187
|
+
declare function cleanup$1(): Plugin; //#endregion
|
|
188
|
+
//#region src/plugins/core/queries/types.d.ts
|
|
189
|
+
interface Comments {
|
|
190
|
+
translator?: string;
|
|
191
|
+
reference?: string;
|
|
192
|
+
extracted?: string;
|
|
193
|
+
flag?: string;
|
|
194
|
+
previous?: string;
|
|
195
|
+
}
|
|
196
|
+
interface Translation {
|
|
197
|
+
context?: string;
|
|
198
|
+
id: string;
|
|
199
|
+
plural?: string;
|
|
200
|
+
message: string[];
|
|
201
|
+
comments?: Comments;
|
|
202
|
+
obsolete?: boolean;
|
|
203
|
+
} //#endregion
|
|
204
|
+
//#region src/plugins/core/core.d.ts
|
|
205
|
+
declare function core$1(): Plugin<string, Translation[]>; //#endregion
|
|
206
|
+
//#region src/plugins/po/po.d.ts
|
|
207
|
+
declare function po$1(): Plugin; //#endregion
|
|
208
|
+
//#region src/plugins/react/react.d.ts
|
|
209
|
+
declare function react$1(): Plugin<string, Translation[]>; //#endregion
|
|
210
|
+
//#region src/static.d.ts
|
|
211
|
+
declare function core(...props: Parameters<typeof core$1>): {
|
|
212
|
+
readonly static: {
|
|
213
|
+
readonly name: "core";
|
|
214
|
+
readonly props: [];
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
declare function react(...props: Parameters<typeof react$1>): {
|
|
218
|
+
readonly static: {
|
|
219
|
+
readonly name: "react";
|
|
220
|
+
readonly props: [];
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
declare function po(...props: Parameters<typeof po$1>): {
|
|
224
|
+
readonly static: {
|
|
225
|
+
readonly name: "po";
|
|
226
|
+
readonly props: [];
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
declare function cleanup(...props: Parameters<typeof cleanup$1>): {
|
|
230
|
+
readonly static: {
|
|
231
|
+
readonly name: "cleanup";
|
|
232
|
+
readonly props: [];
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
type StaticPlugin = ReturnType<typeof core> | ReturnType<typeof react> | ReturnType<typeof po> | ReturnType<typeof cleanup>; //#endregion
|
|
236
|
+
//#region src/plugin.d.ts
|
|
237
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
238
|
+
interface Context {
|
|
239
|
+
config: ResolvedConfig;
|
|
240
|
+
generatedAt: Date;
|
|
241
|
+
paths: Set<string>;
|
|
242
|
+
logger?: Logger$1;
|
|
243
|
+
}
|
|
244
|
+
interface ImportReference {
|
|
245
|
+
spec: string;
|
|
246
|
+
kind: "static" | "dynamic";
|
|
247
|
+
typeOnly: boolean;
|
|
248
|
+
}
|
|
249
|
+
interface ResolveArgs<TInput = unknown> {
|
|
250
|
+
entrypoint: string;
|
|
251
|
+
path: string;
|
|
252
|
+
namespace: string;
|
|
253
|
+
import?: ImportReference;
|
|
254
|
+
data?: TInput;
|
|
255
|
+
}
|
|
256
|
+
interface ResolveResult<TInput = unknown> {
|
|
257
|
+
entrypoint: string;
|
|
258
|
+
path: string;
|
|
259
|
+
namespace: string;
|
|
260
|
+
import?: ImportReference;
|
|
261
|
+
data?: TInput;
|
|
262
|
+
}
|
|
263
|
+
interface LoadArgs<TInput = unknown> {
|
|
264
|
+
entrypoint: string;
|
|
265
|
+
path: string;
|
|
266
|
+
namespace: string;
|
|
267
|
+
data?: TInput;
|
|
268
|
+
}
|
|
269
|
+
interface LoadResult<TInput = unknown> {
|
|
270
|
+
entrypoint: string;
|
|
271
|
+
path: string;
|
|
272
|
+
namespace: string;
|
|
273
|
+
data: TInput;
|
|
274
|
+
}
|
|
275
|
+
interface ProcessArgs<TInput = unknown> {
|
|
276
|
+
entrypoint: string;
|
|
277
|
+
path: string;
|
|
278
|
+
namespace: string;
|
|
279
|
+
data: TInput;
|
|
280
|
+
}
|
|
281
|
+
interface ProcessResult<TOutput = unknown> {
|
|
282
|
+
entrypoint: string;
|
|
283
|
+
path: string;
|
|
284
|
+
namespace: string;
|
|
285
|
+
data: TOutput;
|
|
286
|
+
}
|
|
287
|
+
type Filter = {
|
|
288
|
+
filter: RegExp;
|
|
289
|
+
namespace?: string;
|
|
290
|
+
};
|
|
291
|
+
type ResolveHook<TInput = unknown> = (args: ResolveArgs<TInput>) => MaybePromise<ResolveResult<TInput> | undefined>;
|
|
292
|
+
type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadResult<TInput> | undefined>;
|
|
293
|
+
type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
|
|
294
|
+
interface Build<TInput = unknown, TOutput = unknown> {
|
|
295
|
+
context: Context;
|
|
296
|
+
source(path: string): void;
|
|
297
|
+
resolve(args: ResolveArgs<unknown>): void;
|
|
298
|
+
load(args: LoadArgs<unknown>): void;
|
|
299
|
+
process(args: ProcessArgs<unknown>): void;
|
|
300
|
+
defer(namespace: string): Promise<void>;
|
|
301
|
+
onResolve(options: Filter, hook: ResolveHook<TInput>): void;
|
|
302
|
+
onLoad(options: Filter, hook: LoadHook<TInput>): void;
|
|
303
|
+
onProcess(options: Filter, hook: ProcessHook<TInput, TOutput>): void;
|
|
304
|
+
}
|
|
305
|
+
interface Plugin<TInput = unknown, TOutput = unknown> {
|
|
306
|
+
name: string;
|
|
307
|
+
setup(build: Build<TInput, TOutput>): void;
|
|
308
|
+
}
|
|
309
|
+
type UniversalPlugin = Plugin | StaticPlugin; //#endregion
|
|
310
|
+
//#region src/exclude.d.ts
|
|
311
|
+
declare const defaultExclude: {
|
|
312
|
+
readonly modules: ({
|
|
313
|
+
path
|
|
314
|
+
}: ResolveArgs) => boolean;
|
|
315
|
+
readonly dist: ({
|
|
316
|
+
path
|
|
317
|
+
}: ResolveArgs) => boolean;
|
|
318
|
+
readonly build: ({
|
|
319
|
+
path
|
|
320
|
+
}: ResolveArgs) => boolean;
|
|
321
|
+
readonly types: ({
|
|
322
|
+
import: imp
|
|
323
|
+
}: ResolveArgs) => boolean;
|
|
324
|
+
};
|
|
325
|
+
type DefaultExclude = typeof defaultExclude; //#endregion
|
|
326
|
+
//#region src/configuration.d.ts
|
|
327
|
+
type DestinationFn = (args: {
|
|
328
|
+
locale: string;
|
|
329
|
+
entrypoint: string;
|
|
330
|
+
path: string;
|
|
331
|
+
}) => string;
|
|
332
|
+
type ExcludeFn = (args: ResolveArgs) => boolean;
|
|
333
|
+
type Exclude = RegExp | ExcludeFn;
|
|
334
|
+
type ExcludeConfig = RegExp | Exclude[] | ((defaultExclude: DefaultExclude) => Exclude[]);
|
|
335
|
+
declare const defaultPlugins: {
|
|
336
|
+
core: typeof core;
|
|
337
|
+
po: typeof po;
|
|
338
|
+
cleanup: typeof cleanup;
|
|
339
|
+
};
|
|
340
|
+
type DefaultPlugins = typeof defaultPlugins;
|
|
341
|
+
/**
|
|
342
|
+
* Strategy to handle obsolete translations in existing locale files:
|
|
343
|
+
* - "mark": keep obsolete entries in the locale file but mark them as obsolete
|
|
344
|
+
* - "remove": remove obsolete entries from the locale file
|
|
345
|
+
*/
|
|
346
|
+
type ObsoleteStrategy = "mark" | "remove";
|
|
347
|
+
interface EntrypointConfig {
|
|
348
|
+
entrypoint: string;
|
|
349
|
+
destination?: DestinationFn;
|
|
350
|
+
obsolete?: ObsoleteStrategy;
|
|
351
|
+
walk?: boolean;
|
|
352
|
+
exclude?: ExcludeConfig;
|
|
353
|
+
}
|
|
354
|
+
interface UserConfig {
|
|
355
|
+
/**
|
|
356
|
+
* Default locale to use as the base for extraction
|
|
357
|
+
* @default "en"
|
|
358
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
359
|
+
*/
|
|
360
|
+
defaultLocale?: PluralFormsLocale;
|
|
361
|
+
/**
|
|
362
|
+
* Array of locales to extract translations for
|
|
363
|
+
* @default [defaultLocale]
|
|
364
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
365
|
+
*/
|
|
366
|
+
locales?: PluralFormsLocale[];
|
|
367
|
+
/**
|
|
368
|
+
* Array of plugins to use or a function to override the default plugins
|
|
369
|
+
* @default DefaultPlugins
|
|
370
|
+
* @see {@link DefaultPlugins} for available plugins
|
|
371
|
+
*/
|
|
372
|
+
plugins?: UniversalPlugin[] | ((defaultPlugins: DefaultPlugins) => UniversalPlugin[]);
|
|
373
|
+
/**
|
|
374
|
+
* One or more entrypoints to extract translations from, could be:
|
|
375
|
+
* - file path, will be treated as a single file entrypoint
|
|
376
|
+
* - glob pattern will be expanded to match files, each treated as a separate entrypoint
|
|
377
|
+
* - configuration object with options for the entrypoint
|
|
378
|
+
* @see {@link EntrypointConfig} for configuration options
|
|
379
|
+
*/
|
|
380
|
+
entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;
|
|
381
|
+
/**
|
|
382
|
+
* Function to determine the destination path for each extracted locale file
|
|
383
|
+
* @default `./translations/entrypoint.locale.po`
|
|
384
|
+
* @see {@link DestinationFn}
|
|
385
|
+
* @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig
|
|
386
|
+
*/
|
|
387
|
+
destination?: DestinationFn;
|
|
388
|
+
/**
|
|
389
|
+
* Strategy to handle obsolete translations in existing locale files
|
|
390
|
+
* @default "mark"
|
|
391
|
+
* @see {@link ObsoleteStrategy} for available strategies
|
|
392
|
+
* @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig
|
|
393
|
+
*/
|
|
394
|
+
obsolete?: ObsoleteStrategy;
|
|
395
|
+
/**
|
|
396
|
+
* Whether to recursively walk dependencies of the entrypoints
|
|
397
|
+
* @default true
|
|
398
|
+
* @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.
|
|
399
|
+
*/
|
|
400
|
+
walk?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Paths or patterns to exclude from extraction, applied to all entrypoints
|
|
403
|
+
* @default [/node_modules/, /dist/, /build/]
|
|
404
|
+
* @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.
|
|
405
|
+
*/
|
|
406
|
+
exclude?: ExcludeConfig;
|
|
407
|
+
/**
|
|
408
|
+
* Log level for the extraction process
|
|
409
|
+
* @default "info"
|
|
410
|
+
*/
|
|
411
|
+
logLevel?: LogLevel$1;
|
|
412
|
+
}
|
|
413
|
+
interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
|
|
414
|
+
exclude?: Exclude[];
|
|
415
|
+
}
|
|
416
|
+
interface ResolvedConfig {
|
|
417
|
+
plugins: UniversalPlugin[];
|
|
418
|
+
entrypoints: ResolvedEntrypoint[];
|
|
419
|
+
defaultLocale: string;
|
|
420
|
+
locales: string[];
|
|
421
|
+
destination: DestinationFn;
|
|
422
|
+
obsolete: ObsoleteStrategy;
|
|
423
|
+
walk: boolean;
|
|
424
|
+
logLevel: LogLevel$1;
|
|
425
|
+
exclude: Exclude[];
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Type helper to make it easier to use translate.config.ts
|
|
429
|
+
* @param config - {@link UserConfig}.
|
|
430
|
+
*/
|
|
431
|
+
declare function defineConfig(config: UserConfig): ResolvedConfig; //#endregion
|
|
432
|
+
//#endregion
|
|
433
|
+
export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeConfig, ExcludeFn, Filter, ImportReference, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, core, defineConfig, po, react };
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { basename, dirname, extname, join } from "node:path";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
//#region ../extract/dist/exclude-CpTGSisK.mjs
|
|
3
|
+
function normalizedPath(path) {
|
|
4
|
+
return path.replace(/\\/g, "/");
|
|
5
|
+
}
|
|
6
|
+
function isInsideDirectory(path, directory) {
|
|
7
|
+
return normalizedPath(path).split("/").some((part) => part === directory);
|
|
8
|
+
}
|
|
9
|
+
const defaultExclude = {
|
|
10
|
+
modules: ({ path }) => isInsideDirectory(path, "node_modules"),
|
|
11
|
+
dist: ({ path }) => isInsideDirectory(path, "dist"),
|
|
12
|
+
build: ({ path }) => isInsideDirectory(path, "build"),
|
|
13
|
+
types: ({ import: imp }) => imp?.typeOnly ?? false
|
|
14
|
+
};
|
|
15
|
+
const defaultExcludes = Object.values(defaultExclude);
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../extract/dist/src/static.mjs
|
|
4
18
|
function core(...props) {
|
|
5
19
|
return { static: {
|
|
6
20
|
name: "core",
|
|
@@ -25,24 +39,22 @@ function cleanup(...props) {
|
|
|
25
39
|
props
|
|
26
40
|
} };
|
|
27
41
|
}
|
|
28
|
-
|
|
29
42
|
//#endregion
|
|
30
|
-
//#region ../extract/src/
|
|
43
|
+
//#region ../extract/dist/src/core.mjs
|
|
31
44
|
const defaultPlugins = {
|
|
32
45
|
core,
|
|
33
46
|
po,
|
|
34
47
|
cleanup
|
|
35
48
|
};
|
|
36
49
|
const defaultDestination = ({ entrypoint, locale }) => join(dirname(entrypoint), "translations", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);
|
|
37
|
-
const defaultExclude = [
|
|
38
|
-
/(?:^|[\\/])node_modules(?:[\\/]|$)/,
|
|
39
|
-
/(?:^|[\\/])dist(?:[\\/]|$)/,
|
|
40
|
-
/(?:^|[\\/])build(?:[\\/]|$)/
|
|
41
|
-
];
|
|
42
50
|
function normalizeExclude(exclude) {
|
|
43
51
|
if (!exclude) return [];
|
|
44
52
|
return Array.isArray(exclude) ? exclude : [exclude];
|
|
45
53
|
}
|
|
54
|
+
function resolveExcludes(exclude) {
|
|
55
|
+
if (typeof exclude === "function") return exclude(defaultExclude);
|
|
56
|
+
return [...defaultExcludes, ...normalizeExclude(exclude)];
|
|
57
|
+
}
|
|
46
58
|
function resolveEntrypoint(ep) {
|
|
47
59
|
if (typeof ep === "string") return { entrypoint: ep };
|
|
48
60
|
const { entrypoint, destination, obsolete, walk, exclude } = ep;
|
|
@@ -51,7 +63,7 @@ function resolveEntrypoint(ep) {
|
|
|
51
63
|
destination,
|
|
52
64
|
obsolete,
|
|
53
65
|
walk,
|
|
54
|
-
exclude: exclude ?
|
|
66
|
+
exclude: exclude ? resolveExcludes(exclude) : void 0
|
|
55
67
|
};
|
|
56
68
|
}
|
|
57
69
|
function resolvePlugins(user) {
|
|
@@ -65,20 +77,17 @@ function resolvePlugins(user) {
|
|
|
65
77
|
*/
|
|
66
78
|
function defineConfig(config) {
|
|
67
79
|
const defaultLocale = config.defaultLocale ?? "en";
|
|
68
|
-
const plugins = resolvePlugins(config.plugins);
|
|
69
|
-
const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
|
|
70
80
|
return {
|
|
71
|
-
plugins,
|
|
72
|
-
entrypoints,
|
|
81
|
+
plugins: resolvePlugins(config.plugins),
|
|
82
|
+
entrypoints: (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint),
|
|
73
83
|
defaultLocale,
|
|
74
84
|
locales: config.locales ?? [defaultLocale],
|
|
75
85
|
destination: config.destination ?? defaultDestination,
|
|
76
86
|
obsolete: config.obsolete ?? "mark",
|
|
77
87
|
walk: config.walk ?? true,
|
|
78
88
|
logLevel: config.logLevel ?? "info",
|
|
79
|
-
exclude:
|
|
89
|
+
exclude: resolveExcludes(config.exclude)
|
|
80
90
|
};
|
|
81
91
|
}
|
|
82
|
-
|
|
83
92
|
//#endregion
|
|
84
|
-
export { cleanup, core, defineConfig, po, react };
|
|
93
|
+
export { cleanup, core, defineConfig, po, react };
|
package/package.json
CHANGED
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"name": "@let-value/translate-extract-static",
|
|
3
|
+
"version": "1.1.6-beta.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/let-value/translate"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"extract": "./dist/bin/cli.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"postinstall.cjs"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/src/index.cjs",
|
|
17
|
+
"module": "./dist/src/index.mjs",
|
|
18
|
+
"types": "./dist/src/index.d.mts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/src/index.d.mts",
|
|
22
|
+
"import": "./dist/src/index.mjs",
|
|
23
|
+
"require": "./dist/src/index.cjs"
|
|
10
24
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"@types/bun": "1.3.8",
|
|
34
|
-
"@types/node": "22.10.2",
|
|
35
|
-
"tsdown": "0.15.2",
|
|
36
|
-
"typescript": "5.9.2"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"detect-libc": "2.1.2"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"detect-libc": "2.1.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/bun": "1.3.14",
|
|
32
|
+
"@types/node": "26.0.1",
|
|
33
|
+
"typescript": "6.0.3",
|
|
34
|
+
"vite-plus": "latest",
|
|
35
|
+
"@let-value/translate-extract": "1.1.6-beta.1",
|
|
36
|
+
"@let-value/translate": "1.1.6-beta.1"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"postinstall": "node postinstall.cjs",
|
|
40
|
+
"build": "vp pack",
|
|
41
|
+
"check": "vp check",
|
|
42
|
+
"format": "vp fmt",
|
|
43
|
+
"typecheck": "tsc --build",
|
|
44
|
+
"test": "vp test"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/binary-B-BK0iD4.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
node_path = require_chunk.__toESM(node_path);
|
|
4
|
-
let detect_libc = require("detect-libc");
|
|
5
|
-
detect_libc = require_chunk.__toESM(detect_libc);
|
|
6
|
-
|
|
7
|
-
//#region src/binary.ts
|
|
8
|
-
const root = (0, node_path.resolve)(__dirname, "..");
|
|
9
|
-
const platform = process.platform;
|
|
10
|
-
const arch = process.arch;
|
|
11
|
-
const libc = (0, detect_libc.familySync)() || null;
|
|
12
|
-
function getBinaryName(platform$1, arch$1, libc$1) {
|
|
13
|
-
const extension = platform$1 === "win32" ? ".exe" : "";
|
|
14
|
-
return `extract-${platform$1}-${arch$1}${libc$1 ? `-${libc$1}` : ""}${extension}`;
|
|
15
|
-
}
|
|
16
|
-
const binaryName = getBinaryName(platform, arch, libc);
|
|
17
|
-
const binaryPath = (0, node_path.resolve)(root, "prebuilts", binaryName);
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
Object.defineProperty(exports, 'binaryName', {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return binaryName;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, 'binaryPath', {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return binaryPath;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, 'platform', {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return platform;
|
|
36
|
-
}
|
|
37
|
-
});
|
package/dist/chunk-CUT6urMc.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, '__toESM', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return __toESM;
|
|
29
|
-
}
|
|
30
|
-
});
|