@let-value/translate-extract 1.0.26 → 1.0.31

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 CHANGED
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
- const require_run = require('../run-BonabcP6.cjs');
2
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
3
+ const require_run = require('../run-BacOPd9p.cjs');
3
4
  let node_util = require("node:util");
4
- node_util = require_run.__toESM(node_util);
5
+ node_util = require_chunk.__toESM(node_util);
5
6
  let cosmiconfig = require("cosmiconfig");
6
- cosmiconfig = require_run.__toESM(cosmiconfig);
7
+ cosmiconfig = require_chunk.__toESM(cosmiconfig);
7
8
  let chalk = require("chalk");
8
- chalk = require_run.__toESM(chalk);
9
+ chalk = require_chunk.__toESM(chalk);
9
10
  let loglevel = require("loglevel");
10
- loglevel = require_run.__toESM(loglevel);
11
+ loglevel = require_chunk.__toESM(loglevel);
11
12
  let loglevel_plugin_prefix = require("loglevel-plugin-prefix");
12
- loglevel_plugin_prefix = require_run.__toESM(loglevel_plugin_prefix);
13
+ loglevel_plugin_prefix = require_chunk.__toESM(loglevel_plugin_prefix);
13
14
 
14
15
  //#region src/logger.ts
15
16
  const colors = {
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "../run-C_bYec-q.js";
2
+ import { run } from "../run-DcO6U79B.js";
3
3
  import { parseArgs } from "node:util";
4
4
  import { cosmiconfig } from "cosmiconfig";
5
5
  import chalk from "chalk";
@@ -0,0 +1,30 @@
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
+ });
@@ -0,0 +1,240 @@
1
+ import log, { LogLevelNames, Logger } from "loglevel";
2
+ import Parser from "tree-sitter";
3
+ import { PluralFormsLocale } from "@let-value/translate";
4
+
5
+ //#region src/logger.d.ts
6
+ type LogLevel = LogLevelNames;
7
+ //#endregion
8
+ //#region src/plugins/cleanup/cleanup.d.ts
9
+ declare function cleanup$1(): Plugin;
10
+ //#endregion
11
+ //#region src/plugins/core/queries/types.d.ts
12
+ interface Comments {
13
+ translator?: string;
14
+ reference?: string;
15
+ extracted?: string;
16
+ flag?: string;
17
+ previous?: string;
18
+ }
19
+ interface Translation {
20
+ context?: string;
21
+ id: string;
22
+ plural?: string;
23
+ message: string[];
24
+ comments?: Comments;
25
+ obsolete?: boolean;
26
+ }
27
+ //#endregion
28
+ //#region src/plugins/core/core.d.ts
29
+ declare function core$1(): Plugin<string, Translation[]>;
30
+ //#endregion
31
+ //#region src/plugins/po/po.d.ts
32
+ declare function po$1(): Plugin;
33
+ //#endregion
34
+ //#region src/plugins/react/react.d.ts
35
+ declare function react(): Plugin<string, Translation[]>;
36
+ //#endregion
37
+ //#region src/static.d.ts
38
+ declare function core(...props: Parameters<typeof core$1>): {
39
+ readonly static: {
40
+ readonly name: "core";
41
+ readonly props: [];
42
+ };
43
+ };
44
+ declare function react$1(...props: Parameters<typeof react>): {
45
+ readonly static: {
46
+ readonly name: "react";
47
+ readonly props: [];
48
+ };
49
+ };
50
+ declare function po(...props: Parameters<typeof po$1>): {
51
+ readonly static: {
52
+ readonly name: "po";
53
+ readonly props: [];
54
+ };
55
+ };
56
+ declare function cleanup(...props: Parameters<typeof cleanup$1>): {
57
+ readonly static: {
58
+ readonly name: "cleanup";
59
+ readonly props: [];
60
+ };
61
+ };
62
+ type StaticPlugin = ReturnType<typeof core> | ReturnType<typeof react$1> | ReturnType<typeof po> | ReturnType<typeof cleanup>;
63
+ //#endregion
64
+ //#region src/plugin.d.ts
65
+ type MaybePromise<T> = T | Promise<T>;
66
+ interface Context {
67
+ config: ResolvedConfig;
68
+ generatedAt: Date;
69
+ logger?: Logger;
70
+ }
71
+ interface ResolveArgs<TInput = unknown> {
72
+ entrypoint: string;
73
+ path: string;
74
+ namespace: string;
75
+ data?: TInput;
76
+ }
77
+ interface ResolveResult<TInput = unknown> {
78
+ entrypoint: string;
79
+ path: string;
80
+ namespace: string;
81
+ data?: TInput;
82
+ }
83
+ interface LoadArgs<TInput = unknown> {
84
+ entrypoint: string;
85
+ path: string;
86
+ namespace: string;
87
+ data?: TInput;
88
+ }
89
+ interface LoadResult<TInput = unknown> {
90
+ entrypoint: string;
91
+ path: string;
92
+ namespace: string;
93
+ data: TInput;
94
+ }
95
+ interface ProcessArgs<TInput = unknown> {
96
+ entrypoint: string;
97
+ path: string;
98
+ namespace: string;
99
+ data: TInput;
100
+ }
101
+ interface ProcessResult<TOutput = unknown> {
102
+ entrypoint: string;
103
+ path: string;
104
+ namespace: string;
105
+ data: TOutput;
106
+ }
107
+ type Filter = {
108
+ filter: RegExp;
109
+ namespace?: string;
110
+ };
111
+ type ResolveHook<TInput = unknown> = (args: ResolveArgs<TInput>) => MaybePromise<ResolveResult<TInput> | undefined>;
112
+ type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadResult<TInput> | undefined>;
113
+ type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
114
+ interface Build<TInput = unknown, TOutput = unknown> {
115
+ context: Context;
116
+ resolve(args: ResolveArgs<unknown>): void;
117
+ load(args: LoadArgs<unknown>): void;
118
+ process(args: ProcessArgs<unknown>): void;
119
+ defer(namespace: string): Promise<void>;
120
+ onResolve(options: Filter, hook: ResolveHook<TInput>): void;
121
+ onLoad(options: Filter, hook: LoadHook<TInput>): void;
122
+ onProcess(options: Filter, hook: ProcessHook<TInput, TOutput>): void;
123
+ }
124
+ interface Plugin<TInput = unknown, TOutput = unknown> {
125
+ name: string;
126
+ setup(build: Build<TInput, TOutput>): void;
127
+ }
128
+ type UniversalPlugin = Plugin | StaticPlugin;
129
+ //#endregion
130
+ //#region src/configuration.d.ts
131
+ type DestinationFn = (args: {
132
+ locale: string;
133
+ entrypoint: string;
134
+ path: string;
135
+ }) => string;
136
+ type ExcludeFn = (args: {
137
+ entrypoint: string;
138
+ path: string;
139
+ }) => boolean;
140
+ type Exclude = RegExp | ExcludeFn;
141
+ declare const defaultPlugins: {
142
+ core: typeof core;
143
+ po: typeof po;
144
+ cleanup: typeof cleanup;
145
+ };
146
+ type DefaultPlugins = typeof defaultPlugins;
147
+ /**
148
+ * Strategy to handle obsolete translations in existing locale files:
149
+ * - "mark": keep obsolete entries in the locale file but mark them as obsolete
150
+ * - "remove": remove obsolete entries from the locale file
151
+ */
152
+ type ObsoleteStrategy = "mark" | "remove";
153
+ interface EntrypointConfig {
154
+ entrypoint: string;
155
+ destination?: DestinationFn;
156
+ obsolete?: ObsoleteStrategy;
157
+ walk?: boolean;
158
+ exclude?: Exclude | Exclude[];
159
+ }
160
+ interface UserConfig {
161
+ /**
162
+ * Default locale to use as the base for extraction
163
+ * @default "en"
164
+ * @see {@link PluralFormsLocale} for available locales
165
+ */
166
+ defaultLocale?: PluralFormsLocale;
167
+ /**
168
+ * Array of locales to extract translations for
169
+ * @default [defaultLocale]
170
+ * @see {@link PluralFormsLocale} for available locales
171
+ */
172
+ locales?: PluralFormsLocale[];
173
+ /**
174
+ * Array of plugins to use or a function to override the default plugins
175
+ * @default DefaultPlugins
176
+ * @see {@link DefaultPlugins} for available plugins
177
+ */
178
+ plugins?: UniversalPlugin[] | ((defaultPlugins: DefaultPlugins) => UniversalPlugin[]);
179
+ /**
180
+ * One or more entrypoints to extract translations from, could be:
181
+ * - file path, will be treated as a single file entrypoint
182
+ * - glob pattern will be expanded to match files, each treated as a separate entrypoint
183
+ * - configuration object with options for the entrypoint
184
+ * @see {@link EntrypointConfig} for configuration options
185
+ */
186
+ entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;
187
+ /**
188
+ * Function to determine the destination path for each extracted locale file
189
+ * @default `./translations/entrypoint.locale.po`
190
+ * @see {@link DestinationFn}
191
+ * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig
192
+ */
193
+ destination?: DestinationFn;
194
+ /**
195
+ * Strategy to handle obsolete translations in existing locale files
196
+ * @default "mark"
197
+ * @see {@link ObsoleteStrategy} for available strategies
198
+ * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig
199
+ */
200
+ obsolete?: ObsoleteStrategy;
201
+ /**
202
+ * Whether to recursively walk dependencies of the entrypoints
203
+ * @default true
204
+ * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.
205
+ */
206
+ walk?: boolean;
207
+ /**
208
+ * Paths or patterns to exclude from extraction, applied to all entrypoints
209
+ * @default [/node_modules/, /dist/, /build/]
210
+ * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.
211
+ */
212
+ exclude?: Exclude | Exclude[];
213
+ /**
214
+ * Log level for the extraction process
215
+ * @default "info"
216
+ */
217
+ logLevel?: LogLevel;
218
+ }
219
+ interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
220
+ exclude?: Exclude[];
221
+ }
222
+ interface ResolvedConfig {
223
+ plugins: UniversalPlugin[];
224
+ entrypoints: ResolvedEntrypoint[];
225
+ defaultLocale: string;
226
+ locales: string[];
227
+ destination: DestinationFn;
228
+ obsolete: ObsoleteStrategy;
229
+ walk: boolean;
230
+ logLevel: LogLevel;
231
+ exclude: Exclude[];
232
+ }
233
+ /**
234
+ * Type helper to make it easier to use translate.config.ts
235
+ * @param config - {@link UserConfig}.
236
+ */
237
+ declare function defineConfig(config: UserConfig): ResolvedConfig;
238
+ //#endregion
239
+ export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, type Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, cleanup$1, core, core$1, defineConfig, po, po$1, react$1 as react, react as react$1 };
240
+ //# sourceMappingURL=configuration-CFa8J7EM.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-CFa8J7EM.d.ts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../src/plugins/react/react.ts","../src/static.ts","../src/plugin.ts","../src/configuration.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,QAAA,GAAW;;;iBCKP,SAAA,CAAA,GAAW;;;UCPV,QAAA;;;;EFEL,IAAA,CAAA,EAAA,MAAQ;;;UEMH,WAAA;EDDD,OAAA,CAAA,EAAA,MAAO;;;;ECPN,QAAA,CAAA,EAaF,QAbU;EAQR,QAAA,CAAA,EAAA,OAAW;;;;iBCCZ,MAAA,CAAA,GAAQ,eAAe;;;iBCCvB,IAAA,CAAA,GAAM;;;iBCHN,KAAA,CAAA,GAAS,eAAe;;;iBCJxB,IAAA,WAAe,kBAAkB;ENDrC,SAAA,MAAQ,EA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;SAAd,ECqCL,eDrCK,EAAA;aAAb,ECsCY,kBDtCZ,EAAA;EAAY,aAAA,EAAA,MAAA;EACL,OAAA,EAAA,MAAQ,EAAA;EAAA,WAAA,ECwCH,aDxCG;UAAqC,ECyC3C,gBDzC2C;MAAT,EAAA,OAAA;UAA6C,EC2C/E,QD3C+E;SAAX,EC4CrE,OD5CqE,EAAA;;;AAClF;;;AACU,iBCiFM,YAAA,CDjFN,MAAA,ECiF2B,UDjF3B,CAAA,ECiFwC,cDjFxC"}
@@ -0,0 +1,239 @@
1
+ import { PluralFormsLocale } from "@let-value/translate";
2
+ import { LogLevelNames, Logger } from "loglevel";
3
+
4
+ //#region src/logger.d.ts
5
+ type LogLevel = LogLevelNames;
6
+ //#endregion
7
+ //#region src/plugins/cleanup/cleanup.d.ts
8
+ declare function cleanup$1(): Plugin;
9
+ //#endregion
10
+ //#region src/plugins/core/queries/types.d.ts
11
+ interface Comments {
12
+ translator?: string;
13
+ reference?: string;
14
+ extracted?: string;
15
+ flag?: string;
16
+ previous?: string;
17
+ }
18
+ interface Translation {
19
+ context?: string;
20
+ id: string;
21
+ plural?: string;
22
+ message: string[];
23
+ comments?: Comments;
24
+ obsolete?: boolean;
25
+ }
26
+ //#endregion
27
+ //#region src/plugins/core/core.d.ts
28
+ declare function core$1(): Plugin<string, Translation[]>;
29
+ //#endregion
30
+ //#region src/plugins/po/po.d.ts
31
+ declare function po$1(): Plugin;
32
+ //#endregion
33
+ //#region src/plugins/react/react.d.ts
34
+ declare function react(): Plugin<string, Translation[]>;
35
+ //#endregion
36
+ //#region src/static.d.ts
37
+ declare function core(...props: Parameters<typeof core$1>): {
38
+ readonly static: {
39
+ readonly name: "core";
40
+ readonly props: [];
41
+ };
42
+ };
43
+ declare function react$1(...props: Parameters<typeof react>): {
44
+ readonly static: {
45
+ readonly name: "react";
46
+ readonly props: [];
47
+ };
48
+ };
49
+ declare function po(...props: Parameters<typeof po$1>): {
50
+ readonly static: {
51
+ readonly name: "po";
52
+ readonly props: [];
53
+ };
54
+ };
55
+ declare function cleanup(...props: Parameters<typeof cleanup$1>): {
56
+ readonly static: {
57
+ readonly name: "cleanup";
58
+ readonly props: [];
59
+ };
60
+ };
61
+ type StaticPlugin = ReturnType<typeof core> | ReturnType<typeof react$1> | ReturnType<typeof po> | ReturnType<typeof cleanup>;
62
+ //#endregion
63
+ //#region src/plugin.d.ts
64
+ type MaybePromise<T> = T | Promise<T>;
65
+ interface Context {
66
+ config: ResolvedConfig;
67
+ generatedAt: Date;
68
+ logger?: Logger;
69
+ }
70
+ interface ResolveArgs<TInput = unknown> {
71
+ entrypoint: string;
72
+ path: string;
73
+ namespace: string;
74
+ data?: TInput;
75
+ }
76
+ interface ResolveResult<TInput = unknown> {
77
+ entrypoint: string;
78
+ path: string;
79
+ namespace: string;
80
+ data?: TInput;
81
+ }
82
+ interface LoadArgs<TInput = unknown> {
83
+ entrypoint: string;
84
+ path: string;
85
+ namespace: string;
86
+ data?: TInput;
87
+ }
88
+ interface LoadResult<TInput = unknown> {
89
+ entrypoint: string;
90
+ path: string;
91
+ namespace: string;
92
+ data: TInput;
93
+ }
94
+ interface ProcessArgs<TInput = unknown> {
95
+ entrypoint: string;
96
+ path: string;
97
+ namespace: string;
98
+ data: TInput;
99
+ }
100
+ interface ProcessResult<TOutput = unknown> {
101
+ entrypoint: string;
102
+ path: string;
103
+ namespace: string;
104
+ data: TOutput;
105
+ }
106
+ type Filter = {
107
+ filter: RegExp;
108
+ namespace?: string;
109
+ };
110
+ type ResolveHook<TInput = unknown> = (args: ResolveArgs<TInput>) => MaybePromise<ResolveResult<TInput> | undefined>;
111
+ type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadResult<TInput> | undefined>;
112
+ type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
113
+ interface Build<TInput = unknown, TOutput = unknown> {
114
+ context: Context;
115
+ resolve(args: ResolveArgs<unknown>): void;
116
+ load(args: LoadArgs<unknown>): void;
117
+ process(args: ProcessArgs<unknown>): void;
118
+ defer(namespace: string): Promise<void>;
119
+ onResolve(options: Filter, hook: ResolveHook<TInput>): void;
120
+ onLoad(options: Filter, hook: LoadHook<TInput>): void;
121
+ onProcess(options: Filter, hook: ProcessHook<TInput, TOutput>): void;
122
+ }
123
+ interface Plugin<TInput = unknown, TOutput = unknown> {
124
+ name: string;
125
+ setup(build: Build<TInput, TOutput>): void;
126
+ }
127
+ type UniversalPlugin = Plugin | StaticPlugin;
128
+ //#endregion
129
+ //#region src/configuration.d.ts
130
+ type DestinationFn = (args: {
131
+ locale: string;
132
+ entrypoint: string;
133
+ path: string;
134
+ }) => string;
135
+ type ExcludeFn = (args: {
136
+ entrypoint: string;
137
+ path: string;
138
+ }) => boolean;
139
+ type Exclude = RegExp | ExcludeFn;
140
+ declare const defaultPlugins: {
141
+ core: typeof core;
142
+ po: typeof po;
143
+ cleanup: typeof cleanup;
144
+ };
145
+ type DefaultPlugins = typeof defaultPlugins;
146
+ /**
147
+ * Strategy to handle obsolete translations in existing locale files:
148
+ * - "mark": keep obsolete entries in the locale file but mark them as obsolete
149
+ * - "remove": remove obsolete entries from the locale file
150
+ */
151
+ type ObsoleteStrategy = "mark" | "remove";
152
+ interface EntrypointConfig {
153
+ entrypoint: string;
154
+ destination?: DestinationFn;
155
+ obsolete?: ObsoleteStrategy;
156
+ walk?: boolean;
157
+ exclude?: Exclude | Exclude[];
158
+ }
159
+ interface UserConfig {
160
+ /**
161
+ * Default locale to use as the base for extraction
162
+ * @default "en"
163
+ * @see {@link PluralFormsLocale} for available locales
164
+ */
165
+ defaultLocale?: PluralFormsLocale;
166
+ /**
167
+ * Array of locales to extract translations for
168
+ * @default [defaultLocale]
169
+ * @see {@link PluralFormsLocale} for available locales
170
+ */
171
+ locales?: PluralFormsLocale[];
172
+ /**
173
+ * Array of plugins to use or a function to override the default plugins
174
+ * @default DefaultPlugins
175
+ * @see {@link DefaultPlugins} for available plugins
176
+ */
177
+ plugins?: UniversalPlugin[] | ((defaultPlugins: DefaultPlugins) => UniversalPlugin[]);
178
+ /**
179
+ * One or more entrypoints to extract translations from, could be:
180
+ * - file path, will be treated as a single file entrypoint
181
+ * - glob pattern will be expanded to match files, each treated as a separate entrypoint
182
+ * - configuration object with options for the entrypoint
183
+ * @see {@link EntrypointConfig} for configuration options
184
+ */
185
+ entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;
186
+ /**
187
+ * Function to determine the destination path for each extracted locale file
188
+ * @default `./translations/entrypoint.locale.po`
189
+ * @see {@link DestinationFn}
190
+ * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig
191
+ */
192
+ destination?: DestinationFn;
193
+ /**
194
+ * Strategy to handle obsolete translations in existing locale files
195
+ * @default "mark"
196
+ * @see {@link ObsoleteStrategy} for available strategies
197
+ * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig
198
+ */
199
+ obsolete?: ObsoleteStrategy;
200
+ /**
201
+ * Whether to recursively walk dependencies of the entrypoints
202
+ * @default true
203
+ * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.
204
+ */
205
+ walk?: boolean;
206
+ /**
207
+ * Paths or patterns to exclude from extraction, applied to all entrypoints
208
+ * @default [/node_modules/, /dist/, /build/]
209
+ * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.
210
+ */
211
+ exclude?: Exclude | Exclude[];
212
+ /**
213
+ * Log level for the extraction process
214
+ * @default "info"
215
+ */
216
+ logLevel?: LogLevel;
217
+ }
218
+ interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
219
+ exclude?: Exclude[];
220
+ }
221
+ interface ResolvedConfig {
222
+ plugins: UniversalPlugin[];
223
+ entrypoints: ResolvedEntrypoint[];
224
+ defaultLocale: string;
225
+ locales: string[];
226
+ destination: DestinationFn;
227
+ obsolete: ObsoleteStrategy;
228
+ walk: boolean;
229
+ logLevel: LogLevel;
230
+ exclude: Exclude[];
231
+ }
232
+ /**
233
+ * Type helper to make it easier to use translate.config.ts
234
+ * @param config - {@link UserConfig}.
235
+ */
236
+ declare function defineConfig(config: UserConfig): ResolvedConfig;
237
+ //#endregion
238
+ export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, type Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, cleanup$1, core, core$1, defineConfig, po, po$1, react$1 as react, react as react$1 };
239
+ //# sourceMappingURL=configuration-nsGqA5N9.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-nsGqA5N9.d.cts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../src/plugins/react/react.ts","../src/static.ts","../src/plugin.ts","../src/configuration.ts"],"sourcesContent":[],"mappings":";;;;KAIY,QAAA,GAAW;;;iBCKP,SAAA,CAAA,GAAW;;;UCPV,QAAA;;;EFEL,SAAA,CAAA,EAAQ,MAAA;;;;ACKJ,UCCC,WAAA,CDDU;;;;ECPV,OAAA,EAAA,MAAQ,EAAA;EAQR,QAAA,CAAA,EAKF,QALa;;;;;iBCCZ,MAAA,CAAA,GAAQ,eAAe;;;iBCCvB,IAAA,CAAA,GAAM;;;iBCHN,KAAA,CAAA,GAAS,eAAe;;;ALL5B,iBMCI,IAAA,CNDO,GAAA,KAAA,EMCQ,UNDK,CAAA,OMCa,MNDb,CAAA,CAAA,EAAA;;;;ECKpB,CAAA;;iBKKA,OAAA,WAAgB,kBAAkB;;IJZjC,SAAQ,IAAA,EAAA,OAAA;IAQR,SAAA,KAAW,EAAA,EAAA;;;iBIYZ,EAAA,WAAa,kBAAkB;EHX/B,SAAI,MAAA,EAAA;IAAA,SAAA,IAAA,EAAA,IA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,MAAA,EAAA;aAAqC,ECwCxC,aDxCwC;UAAT,ECyClC,gBDzCkC;MAA6C,EAAA,OAAA;UAAX,EC2CpE,QD3CoE;SAAb,EC4CxD,OD5CwD,EAAA;;AACrE;;;;AAEgC,iBCgFhB,YAAA,CDhFgB,MAAA,ECgFK,UDhFL,CAAA,ECgFkB,cDhFlB"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,65 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_static = require('./static-CNiWpXhx.cjs');
3
+ let node_path = require("node:path");
4
+ node_path = require_chunk.__toESM(node_path);
5
+
6
+ //#region src/configuration.ts
7
+ const defaultPlugins = {
8
+ core: require_static.core,
9
+ po: require_static.po,
10
+ cleanup: require_static.cleanup
11
+ };
12
+ const defaultDestination = ({ entrypoint, locale }) => (0, node_path.join)((0, node_path.dirname)(entrypoint), "translations", `${(0, node_path.basename)(entrypoint, (0, node_path.extname)(entrypoint))}.${locale}.po`);
13
+ const defaultExclude = [
14
+ /(?:^|[\\/])node_modules(?:[\\/]|$)/,
15
+ /(?:^|[\\/])dist(?:[\\/]|$)/,
16
+ /(?:^|[\\/])build(?:[\\/]|$)/
17
+ ];
18
+ function normalizeExclude(exclude) {
19
+ if (!exclude) return [];
20
+ return Array.isArray(exclude) ? exclude : [exclude];
21
+ }
22
+ function resolveEntrypoint(ep) {
23
+ if (typeof ep === "string") return { entrypoint: ep };
24
+ const { entrypoint, destination, obsolete, walk, exclude } = ep;
25
+ return {
26
+ entrypoint,
27
+ destination,
28
+ obsolete,
29
+ walk,
30
+ exclude: exclude ? normalizeExclude(exclude) : void 0
31
+ };
32
+ }
33
+ function resolvePlugins(user) {
34
+ if (typeof user === "function") return user(defaultPlugins);
35
+ if (Array.isArray(user)) return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];
36
+ return Object.values(defaultPlugins).map((plugin) => plugin());
37
+ }
38
+ /**
39
+ * Type helper to make it easier to use translate.config.ts
40
+ * @param config - {@link UserConfig}.
41
+ */
42
+ function defineConfig(config) {
43
+ const defaultLocale = config.defaultLocale ?? "en";
44
+ const plugins = resolvePlugins(config.plugins);
45
+ const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
46
+ return {
47
+ plugins,
48
+ entrypoints,
49
+ defaultLocale,
50
+ locales: config.locales ?? [defaultLocale],
51
+ destination: config.destination ?? defaultDestination,
52
+ obsolete: config.obsolete ?? "mark",
53
+ walk: config.walk ?? true,
54
+ logLevel: config.logLevel ?? "info",
55
+ exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude
56
+ };
57
+ }
58
+
59
+ //#endregion
60
+ Object.defineProperty(exports, 'defineConfig', {
61
+ enumerable: true,
62
+ get: function () {
63
+ return defineConfig;
64
+ }
65
+ });
@@ -0,0 +1 @@
1
+ export { };