@rushstack/webpack5-localization-plugin 0.11.26 → 0.12.0

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/CHANGELOG.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.12.0",
6
+ "tag": "@rushstack/webpack5-localization-plugin_v0.12.0",
7
+ "date": "Thu, 06 Feb 2025 01:11:16 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "Leverage webpack caching layer for localized and nonlocalized asset generation. Reduce unnecessary work."
12
+ }
13
+ ]
14
+ }
15
+ },
4
16
  {
5
17
  "version": "0.11.26",
6
18
  "tag": "@rushstack/webpack5-localization-plugin_v0.11.26",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @rushstack/webpack5-localization-plugin
2
2
 
3
- This log was last generated on Thu, 30 Jan 2025 16:10:36 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 06 Feb 2025 01:11:16 GMT and should not be manually modified.
4
+
5
+ ## 0.12.0
6
+ Thu, 06 Feb 2025 01:11:16 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Leverage webpack caching layer for localized and nonlocalized asset generation. Reduce unnecessary work.
4
11
 
5
12
  ## 0.11.26
6
13
  Thu, 30 Jan 2025 16:10:36 GMT
@@ -230,7 +230,7 @@ export declare interface _IStringPlaceholder {
230
230
  /**
231
231
  * The values of this string in each output locale.
232
232
  */
233
- valuesByLocale: Map<string, string>;
233
+ translations: ReadonlyMap<string, ReadonlyMap<string, string>>;
234
234
  /**
235
235
  * The key used to identify the source file containing the string.
236
236
  */
@@ -261,13 +261,12 @@ export declare interface ITrueHashPluginOptions {
261
261
  * @public
262
262
  */
263
263
  export declare class LocalizationPlugin implements WebpackPluginInstance {
264
- readonly stringKeys: Map<string, _IStringPlaceholder>;
264
+ private readonly _locFiles;
265
265
  /**
266
266
  * @internal
267
267
  */
268
268
  readonly _options: ILocalizationPluginOptions;
269
269
  private readonly _resolvedTranslatedStringsFromOptions;
270
- private _stringPlaceholderCounter;
271
270
  private readonly _stringPlaceholderMap;
272
271
  private _passthroughLocaleName;
273
272
  private _defaultLocale;
@@ -276,11 +275,9 @@ export declare class LocalizationPlugin implements WebpackPluginInstance {
276
275
  private _formatLocaleForFilename;
277
276
  private readonly _pseudolocalizers;
278
277
  /**
279
- * The outermost map's keys are the locale names.
280
- * The middle map's keys are the resolved, file names.
281
- * The innermost map's keys are the string identifiers and its values are the string values.
278
+ * The set of locales that have translations provided.
282
279
  */
283
- private _resolvedLocalizedStrings;
280
+ private _translatedLocales;
284
281
  constructor(options: ILocalizationPluginOptions);
285
282
  /**
286
283
  * Apply this plugin to the specified webpack compiler.
@@ -1,14 +1,16 @@
1
- import type { Asset, Chunk, Compilation, sources } from 'webpack';
1
+ import type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';
2
2
  import type { LocalizationPlugin } from './LocalizationPlugin';
3
3
  type FormatLocaleForFilenameFn = (locale: string) => string;
4
4
  export interface IProcessAssetOptionsBase {
5
5
  plugin: LocalizationPlugin;
6
6
  compilation: Compilation;
7
+ cache: ReturnType<Compilation['getCache']>;
7
8
  chunk: Chunk;
8
9
  asset: Asset;
9
10
  }
10
11
  export interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {
11
12
  fileName: string;
13
+ hasUrlGenerator: boolean;
12
14
  noStringsLocaleName: string;
13
15
  formatLocaleForFilenameFn: FormatLocaleForFilenameFn;
14
16
  }
@@ -16,6 +18,7 @@ export interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase
16
18
  locales: Set<string>;
17
19
  fillMissingTranslationStrings: boolean;
18
20
  defaultLocale: string;
21
+ passthroughLocaleName: string | undefined;
19
22
  filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];
20
23
  formatLocaleForFilenameFn: FormatLocaleForFilenameFn;
21
24
  }
@@ -24,7 +27,18 @@ export interface IProcessAssetResult {
24
27
  asset: sources.Source;
25
28
  }
26
29
  export declare const PLACEHOLDER_REGEX: RegExp;
27
- export declare function processLocalizedAsset(options: IProcessLocalizedAssetOptions): Record<string, string>;
28
- export declare function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): void;
30
+ export interface IProcessedAsset {
31
+ filename: string;
32
+ source: sources.CachedSource;
33
+ info: AssetInfo;
34
+ }
35
+ export interface IProcessLocalizedAssetResult {
36
+ localizedFiles: Record<string, string>;
37
+ processedAssets: IProcessedAsset[];
38
+ }
39
+ export declare function processLocalizedAssetCachedAsync(options: IProcessLocalizedAssetOptions): Promise<Record<string, string>>;
40
+ export declare function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult;
41
+ export declare function processNonLocalizedAssetCachedAsync(options: IProcessNonLocalizedAssetOptions): Promise<void>;
42
+ export declare function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset;
29
43
  export {};
30
44
  //# sourceMappingURL=AssetProcessor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.d.ts","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAa,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG7E,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,sBAAsB,CAAC;AAoBnF,KAAK,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAiB5D,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,gCAAiC,SAAQ,wBAAwB;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,E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AG,eAAe,CAsDnG"}
@@ -25,24 +25,54 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  return result;
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.processNonLocalizedAsset = exports.processLocalizedAsset = exports.PLACEHOLDER_REGEX = void 0;
28
+ exports.processNonLocalizedAsset = exports.processNonLocalizedAssetCachedAsync = exports.processLocalizedAsset = exports.processLocalizedAssetCachedAsync = exports.PLACEHOLDER_REGEX = void 0;
29
29
  const Constants = __importStar(require("./utilities/Constants"));
30
- exports.PLACEHOLDER_REGEX = new RegExp(`${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\*)_([A-C])_([0-9a-f]+)`, 'g');
30
+ exports.PLACEHOLDER_REGEX = new RegExp(`${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\*)_([0-9a-f$]+)_`, 'g');
31
+ async function processLocalizedAssetCachedAsync(options) {
32
+ const { compilation, asset, cache } = options;
33
+ const { source: originalSource } = asset;
34
+ const eTag = cache.getLazyHashedEtag(originalSource);
35
+ const { name: originName } = asset;
36
+ const cacheItem = cache.getItemCache(originName, eTag);
37
+ let output = await cacheItem.getPromise();
38
+ if (!output) {
39
+ output = processLocalizedAsset(options);
40
+ await cacheItem.storePromise(output);
41
+ }
42
+ for (const { filename, source, info } of output.processedAssets) {
43
+ if (originName === filename) {
44
+ // This helper throws if the asset doesn't already exist
45
+ // Use the function form so that the object identity of `related` is preserved.
46
+ // Since we already read the original info, we don't need fancy merge logic.
47
+ compilation.updateAsset(filename, source, () => info);
48
+ }
49
+ else {
50
+ // This helper throws if the asset already exists
51
+ compilation.emitAsset(filename, source, info);
52
+ }
53
+ }
54
+ return output.localizedFiles;
55
+ }
56
+ exports.processLocalizedAssetCachedAsync = processLocalizedAssetCachedAsync;
31
57
  function processLocalizedAsset(options) {
32
58
  const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;
33
59
  const { sources, WebpackError } = compilation.compiler.webpack;
34
- const rawSource = new sources.CachedSource(asset.source);
60
+ const { source: originalSource } = asset;
61
+ const rawSource = originalSource instanceof sources.CachedSource
62
+ ? originalSource
63
+ : new sources.CachedSource(originalSource);
35
64
  const assetSource = rawSource.source().toString();
36
65
  const parsedAsset = _parseStringToReconstructionSequence(options.plugin, assetSource, formatLocaleForFilenameFn);
37
66
  const { issues } = parsedAsset;
38
67
  const localizedFiles = {};
39
68
  chunk.localizedFiles = localizedFiles;
69
+ const processedAssets = [];
40
70
  const { info: originInfo, name: originName } = asset;
41
71
  if (!originInfo.related) {
42
72
  originInfo.related = {};
43
73
  }
44
74
  for (const locale of locales) {
45
- const { issues: localeIssues, result: localeResult } = _reconstructLocalized(new sources.ReplaceSource(rawSource, locale), parsedAsset.reconstructionSeries, locale, options.fillMissingTranslationStrings ? options.defaultLocale : undefined);
75
+ const { issues: localeIssues, result: localeResult } = _reconstructLocalized(new sources.ReplaceSource(rawSource, locale), parsedAsset.reconstructionSeries, locale, options.fillMissingTranslationStrings ? options.defaultLocale : undefined, options.passthroughLocaleName);
46
76
  for (const issue of localeIssues) {
47
77
  issues.push(issue);
48
78
  }
@@ -59,51 +89,80 @@ function processLocalizedAsset(options) {
59
89
  };
60
90
  const wrapped = new sources.CachedSource(localeResult);
61
91
  localizedFiles[locale] = fileName;
92
+ processedAssets.push({
93
+ filename: fileName,
94
+ source: wrapped,
95
+ info
96
+ });
62
97
  // If file already exists
63
- if (originName === fileName) {
64
- // This helper throws if the asset doesn't already exist
65
- // Use the function form so that the object identity of `related` is preserved.
66
- // Since we already read the original info, we don't need fancy merge logic.
67
- compilation.updateAsset(fileName, wrapped, () => info);
68
- }
69
- else {
98
+ if (originName !== fileName) {
70
99
  // If A.related points to B, B.related can't point to A or the stats emitter explodes
71
100
  // So just strip the related object for the localized assets
72
101
  info.related = undefined;
73
102
  // We omit the `related` property that does a self-reference.
74
103
  originInfo.related[locale] = fileName;
75
- // This helper throws if the asset already exists
76
- compilation.emitAsset(fileName, wrapped, info);
77
104
  }
78
105
  }
79
106
  if (issues.length > 0) {
80
107
  compilation.errors.push(new WebpackError(`localization:\n${issues.map((issue) => ` ${issue}`).join('\n')}`));
81
108
  }
82
- return localizedFiles;
109
+ return {
110
+ localizedFiles,
111
+ processedAssets
112
+ };
83
113
  }
84
114
  exports.processLocalizedAsset = processLocalizedAsset;
115
+ async function processNonLocalizedAssetCachedAsync(options) {
116
+ const { compilation, asset, cache } = options;
117
+ const { source: originalSource } = asset;
118
+ const eTag = cache.getLazyHashedEtag(originalSource);
119
+ const { name: originName } = asset;
120
+ const cacheItem = cache.getItemCache(originName, eTag);
121
+ let output = await cacheItem.getPromise();
122
+ if (!output) {
123
+ output = processNonLocalizedAsset(options);
124
+ await cacheItem.storePromise(output);
125
+ }
126
+ const { filename, source, info } = output;
127
+ compilation.updateAsset(originName, source, info);
128
+ if (originName !== filename) {
129
+ compilation.renameAsset(originName, filename);
130
+ }
131
+ }
132
+ exports.processNonLocalizedAssetCachedAsync = processNonLocalizedAssetCachedAsync;
85
133
  function processNonLocalizedAsset(options) {
86
- const { asset, fileName, compilation, formatLocaleForFilenameFn } = options;
134
+ const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;
87
135
  const { sources, WebpackError } = compilation.compiler.webpack;
88
- const rawSource = new sources.CachedSource(asset.source);
89
- const assetSource = rawSource.source().toString();
90
- const parsedAsset = _parseStringToReconstructionSequence(options.plugin, assetSource, formatLocaleForFilenameFn);
136
+ const rawSource = asset.source;
137
+ let cachedSource = rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);
91
138
  const { info: originInfo } = asset;
92
- const { issues } = parsedAsset;
93
139
  const locale = options.noStringsLocaleName;
94
- const { issues: localeIssues, result } = _reconstructNonLocalized(new sources.ReplaceSource(rawSource, locale), parsedAsset.reconstructionSeries, locale);
95
- for (const issue of localeIssues) {
96
- issues.push(issue);
140
+ if (hasUrlGenerator) {
141
+ const assetSource = cachedSource.source().toString();
142
+ const parsedAsset = _parseStringToReconstructionSequence(options.plugin, assetSource, formatLocaleForFilenameFn);
143
+ const { issues } = parsedAsset;
144
+ const { issues: localeIssues, result } = _reconstructNonLocalized(new sources.ReplaceSource(cachedSource, locale), parsedAsset.reconstructionSeries, locale);
145
+ for (const issue of localeIssues) {
146
+ issues.push(issue);
147
+ }
148
+ if (issues.length > 0) {
149
+ options.compilation.errors.push(new WebpackError(`localization:\n${issues.map((issue) => ` ${issue}`).join('\n')}`));
150
+ }
151
+ cachedSource = new sources.CachedSource(result);
152
+ }
153
+ else {
154
+ // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast
155
+ cachedSource.source();
97
156
  }
98
157
  const info = {
99
158
  ...originInfo,
100
159
  locale
101
160
  };
102
- const wrapped = new sources.CachedSource(result);
103
- compilation.updateAsset(fileName, wrapped, info);
104
- if (issues.length > 0) {
105
- options.compilation.errors.push(new WebpackError(`localization:\n${issues.map((issue) => ` ${issue}`).join('\n')}`));
106
- }
161
+ return {
162
+ filename: fileName,
163
+ source: cachedSource,
164
+ info
165
+ };
107
166
  }
108
167
  exports.processNonLocalizedAsset = processNonLocalizedAsset;
109
168
  const ESCAPE_MAP = new Map([
@@ -115,22 +174,21 @@ const ESCAPE_MAP = new Map([
115
174
  ]);
116
175
  const BACKSLASH_REGEX = /\\/g;
117
176
  const ESCAPE_REGEX = /[\r\n\t"']/g;
118
- function _reconstructLocalized(result, reconstructionSeries, locale, fallbackLocale) {
177
+ function _reconstructLocalized(result, reconstructionSeries, locale, fallbackLocale, passthroughLocale) {
178
+ var _a, _b;
119
179
  const issues = [];
120
180
  for (const element of reconstructionSeries) {
121
181
  switch (element.kind) {
122
182
  case 'localized': {
123
183
  const { data } = element;
124
- let newValue = data.valuesByLocale.get(locale);
184
+ const { stringName, translations } = data;
185
+ let newValue = locale === passthroughLocale ? stringName : (_a = translations.get(locale)) === null || _a === void 0 ? void 0 : _a.get(stringName);
186
+ if (fallbackLocale && newValue === undefined) {
187
+ newValue = (_b = translations.get(fallbackLocale)) === null || _b === void 0 ? void 0 : _b.get(stringName);
188
+ }
125
189
  if (newValue === undefined) {
126
- if (fallbackLocale) {
127
- newValue = data.valuesByLocale.get(fallbackLocale);
128
- }
129
- else {
130
- issues.push(`The string "${data.stringName}" in "${data.locFilePath}" is missing in ` +
131
- `the locale ${locale}`);
132
- newValue = '-- MISSING STRING --';
133
- }
190
+ issues.push(`The string "${stringName}" in "${data.locFilePath}" is missing in the locale ${locale}`);
191
+ newValue = '-- MISSING STRING --';
134
192
  }
135
193
  const escapedBackslash = element.escapedBackslash || '\\';
136
194
  if (newValue.includes('\\')) {
@@ -189,18 +247,25 @@ function _reconstructNonLocalized(result, reconstructionSeries, noStringsLocaleN
189
247
  function _parseStringToReconstructionSequence(plugin, source, formatLocaleForFilenameFn) {
190
248
  const issues = [];
191
249
  const reconstructionSeries = [];
192
- const jsonStringifyFormatLocaleForFilenameFn = (locale) => JSON.stringify(formatLocaleForFilenameFn(locale));
193
- for (const regexResult of source.matchAll(exports.PLACEHOLDER_REGEX)) {
194
- const [placeholder, escapedBackslash, elementLabel, placeholderSerialNumber] = regexResult;
195
- const start = regexResult.index;
196
- const end = start + placeholder.length;
197
- let localizedReconstructionElement;
250
+ let jsonStringifyFormatLocaleForFilenameFn;
251
+ let index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);
252
+ const increment = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;
253
+ while (index >= 0) {
254
+ const start = index;
255
+ const elementStart = index + increment;
256
+ const elementLabel = source.charAt(elementStart);
257
+ let end = elementStart + 2;
198
258
  switch (elementLabel) {
199
259
  case Constants.STRING_PLACEHOLDER_LABEL: {
200
- const stringData = plugin.getDataForSerialNumber(placeholderSerialNumber);
260
+ const backslashEnd = source.indexOf('_', end);
261
+ const escapedBackslash = source.slice(end, backslashEnd);
262
+ end = backslashEnd + 1;
263
+ const serialEnd = source.indexOf('_', end);
264
+ const serial = source.slice(end, serialEnd);
265
+ end = serialEnd + 1;
266
+ const stringData = plugin.getDataForSerialNumber(serial);
201
267
  if (!stringData) {
202
- issues.push(`Missing placeholder ${placeholder}`);
203
- continue;
268
+ issues.push(`Missing placeholder ${serial}`);
204
269
  }
205
270
  else {
206
271
  const localizedElement = {
@@ -210,7 +275,7 @@ function _parseStringToReconstructionSequence(plugin, source, formatLocaleForFil
210
275
  escapedBackslash,
211
276
  data: stringData
212
277
  };
213
- localizedReconstructionElement = localizedElement;
278
+ reconstructionSeries.push(localizedElement);
214
279
  }
215
280
  break;
216
281
  }
@@ -219,28 +284,27 @@ function _parseStringToReconstructionSequence(plugin, source, formatLocaleForFil
219
284
  kind: 'dynamic',
220
285
  start,
221
286
  end,
222
- escapedBackslash,
223
287
  valueFn: formatLocaleForFilenameFn
224
288
  };
225
- localizedReconstructionElement = dynamicElement;
289
+ reconstructionSeries.push(dynamicElement);
226
290
  break;
227
291
  }
228
292
  case Constants.JSONP_PLACEHOLDER_LABEL: {
293
+ jsonStringifyFormatLocaleForFilenameFn || (jsonStringifyFormatLocaleForFilenameFn = (locale) => JSON.stringify(formatLocaleForFilenameFn(locale)));
229
294
  const dynamicElement = {
230
295
  kind: 'dynamic',
231
296
  start,
232
297
  end,
233
- escapedBackslash,
234
298
  valueFn: jsonStringifyFormatLocaleForFilenameFn
235
299
  };
236
- localizedReconstructionElement = dynamicElement;
300
+ reconstructionSeries.push(dynamicElement);
237
301
  break;
238
302
  }
239
303
  default: {
240
- throw new Error(`Unexpected label ${elementLabel}`);
304
+ throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);
241
305
  }
242
306
  }
243
- reconstructionSeries.push(localizedReconstructionElement);
307
+ index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);
244
308
  }
245
309
  return {
246
310
  issues,
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;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D,MAAM;YACR,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,oBAAoB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n escapedBackslash: string;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])_([0-9a-f]+)`,\n 'g'\n);\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): Record<string, string> {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n // If file already exists\n if (originName === fileName) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(fileName, wrapped, () => info);\n } else {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n // This helper throws if the asset already exists\n compilation.emitAsset(fileName, wrapped, info);\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return localizedFiles;\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): void {\n const { asset, fileName, compilation, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.CachedSource = new sources.CachedSource(asset.source);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { info: originInfo } = asset;\n const { issues } = parsedAsset;\n\n const locale: string = options.noStringsLocaleName;\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(result);\n compilation.updateAsset(fileName, wrapped, info);\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n let newValue: string | undefined = data.valuesByLocale.get(locale);\n if (newValue === undefined) {\n if (fallbackLocale) {\n newValue = data.valuesByLocale.get(fallbackLocale)!;\n } else {\n issues.push(\n `The string \"${data.stringName}\" in \"${data.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n const jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn = (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n\n for (const regexResult of source.matchAll(PLACEHOLDER_REGEX)) {\n const [placeholder, escapedBackslash, elementLabel, placeholderSerialNumber] = regexResult;\n const start: number = regexResult.index;\n const end: number = start + placeholder.length;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringPlaceholder | undefined =\n plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n continue;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n escapedBackslash,\n valueFn: formatLocaleForFilenameFn\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n escapedBackslash,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n default: {\n throw new Error(`Unexpected label ${elementLabel}`);\n }\n }\n\n reconstructionSeries.push(localizedReconstructionElement);\n }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ACF,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBAC9C,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,6BAA6B,CAAC,CAAC,CAAC;gBAC7C,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,yBAAyB;iBACnC,CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAAC;gBACvC,sCAAsC,KAAtC,sCAAsC,GAAK,CAAC,MAAc,EAAE,EAAE,CAC5D,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAC;gBACpD,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,sCAAsC;iBAChD,CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,eAAe,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QAED,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n cache: ReturnType<Compilation['getCache']>;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n hasUrlGenerator: boolean;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n passthroughLocaleName: string | undefined;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\\\\\*)_([0-9a-f$]+)_`,\n 'g'\n);\n\nexport interface IProcessedAsset {\n filename: string;\n source: sources.CachedSource;\n info: AssetInfo;\n}\n\nexport interface IProcessLocalizedAssetResult {\n localizedFiles: Record<string, string>;\n processedAssets: IProcessedAsset[];\n}\n\ntype ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCache']>;\n\nexport async function processLocalizedAssetCachedAsync(\n options: IProcessLocalizedAssetOptions\n): Promise<Record<string, string>> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessLocalizedAssetResult | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n for (const { filename, source, info } of output.processedAssets) {\n if (originName === filename) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(filename, source, () => info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(filename, source, info);\n }\n }\n\n return output.localizedFiles;\n}\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const { source: originalSource } = asset;\n\n const rawSource: sources.CachedSource =\n originalSource instanceof sources.CachedSource\n ? originalSource\n : new sources.CachedSource(originalSource);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n const processedAssets: IProcessedAsset[] = [];\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined,\n options.passthroughLocaleName\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo & { locale: string } = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n processedAssets.push({\n filename: fileName,\n source: wrapped,\n info\n });\n\n // If file already exists\n if (originName !== fileName) {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return {\n localizedFiles,\n processedAssets\n };\n}\n\nexport async function processNonLocalizedAssetCachedAsync(\n options: IProcessNonLocalizedAssetOptions\n): Promise<void> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessedAsset | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processNonLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { filename, source, info } = output;\n compilation.updateAsset(originName, source, info);\n if (originName !== filename) {\n compilation.renameAsset(originName, filename);\n }\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset {\n const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.Source = asset.source;\n let cachedSource: sources.CachedSource =\n rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);\n\n const { info: originInfo } = asset;\n const locale: string = options.noStringsLocaleName;\n\n if (hasUrlGenerator) {\n const assetSource: string = cachedSource.source().toString();\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(cachedSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n cachedSource = new sources.CachedSource(result);\n } else {\n // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast\n cachedSource.source();\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n return {\n filename: fileName,\n source: cachedSource,\n info\n };\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined,\n passthroughLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n const { stringName, translations } = data;\n let newValue: string | undefined =\n locale === passthroughLocale ? stringName : translations.get(locale)?.get(stringName);\n if (fallbackLocale && newValue === undefined) {\n newValue = translations.get(fallbackLocale)?.get(stringName);\n }\n\n if (newValue === undefined) {\n issues.push(\n `The string \"${stringName}\" in \"${data.locFilePath}\" is missing in the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn | undefined;\n\n let index: number = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);\n const increment: number = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;\n while (index >= 0) {\n const start: number = index;\n const elementStart: number = index + increment;\n const elementLabel: string = source.charAt(elementStart);\n let end: number = elementStart + 2;\n\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const backslashEnd: number = source.indexOf('_', end);\n const escapedBackslash: string = source.slice(end, backslashEnd);\n end = backslashEnd + 1;\n const serialEnd: number = source.indexOf('_', end);\n const serial: string = source.slice(end, serialEnd);\n end = serialEnd + 1;\n\n const stringData: IStringPlaceholder | undefined = plugin.getDataForSerialNumber(serial);\n if (!stringData) {\n issues.push(`Missing placeholder ${serial}`);\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n reconstructionSeries.push(localizedElement);\n }\n break;\n }\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: formatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n jsonStringifyFormatLocaleForFilenameFn ||= (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n default: {\n throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);\n }\n }\n\n index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
@@ -16,7 +16,7 @@ export interface IStringPlaceholder {
16
16
  /**
17
17
  * The values of this string in each output locale.
18
18
  */
19
- valuesByLocale: Map<string, string>;
19
+ translations: ReadonlyMap<string, ReadonlyMap<string, string>>;
20
20
  /**
21
21
  * The key used to identify the source file containing the string.
22
22
  */
@@ -26,6 +26,11 @@ export interface IStringPlaceholder {
26
26
  */
27
27
  stringName: string;
28
28
  }
29
+ export interface IFileTranslationInfo {
30
+ placeholders: Map<string, IStringPlaceholder>;
31
+ translations: Map<string, ReadonlyMap<string, string>>;
32
+ renderedPlacholders: Record<string, string>;
33
+ }
29
34
  /**
30
35
  * Gets the instance of the LocalizationPlugin bound to the specified webpack compiler.
31
36
  * Used by loaders.
@@ -37,13 +42,12 @@ export declare function getPluginInstance(compiler: Compiler | undefined): Local
37
42
  * @public
38
43
  */
39
44
  export declare class LocalizationPlugin implements WebpackPluginInstance {
40
- readonly stringKeys: Map<string, IStringPlaceholder>;
45
+ private readonly _locFiles;
41
46
  /**
42
47
  * @internal
43
48
  */
44
49
  readonly _options: ILocalizationPluginOptions;
45
50
  private readonly _resolvedTranslatedStringsFromOptions;
46
- private _stringPlaceholderCounter;
47
51
  private readonly _stringPlaceholderMap;
48
52
  private _passthroughLocaleName;
49
53
  private _defaultLocale;
@@ -52,11 +56,9 @@ export declare class LocalizationPlugin implements WebpackPluginInstance {
52
56
  private _formatLocaleForFilename;
53
57
  private readonly _pseudolocalizers;
54
58
  /**
55
- * The outermost map's keys are the locale names.
56
- * The middle map's keys are the resolved, file names.
57
- * The innermost map's keys are the string identifiers and its values are the string values.
59
+ * The set of locales that have translations provided.
58
60
  */
59
- private _resolvedLocalizedStrings;
61
+ private _translatedLocales;
60
62
  constructor(options: ILocalizationPluginOptions);
61
63
  /**
62
64
  * Apply this plugin to the specified webpack compiler.
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationPlugin.d.ts","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[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