@rushstack/webpack4-localization-plugin 0.18.107 → 0.18.108

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,27 @@
1
1
  {
2
2
  "name": "@rushstack/webpack4-localization-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.18.108",
6
+ "tag": "@rushstack/webpack4-localization-plugin_v0.18.108",
7
+ "date": "Wed, 23 Jul 2025 20:55:57 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.13.17`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.14.0`"
15
+ },
16
+ {
17
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.15.4`"
18
+ },
19
+ {
20
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.74.1`"
21
+ }
22
+ ]
23
+ }
24
+ },
4
25
  {
5
26
  "version": "0.18.107",
6
27
  "tag": "@rushstack/webpack4-localization-plugin_v0.18.107",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @rushstack/webpack4-localization-plugin
2
2
 
3
- This log was last generated on Sat, 21 Jun 2025 00:13:15 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 23 Jul 2025 20:55:57 GMT and should not be manually modified.
4
+
5
+ ## 0.18.108
6
+ Wed, 23 Jul 2025 20:55:57 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.18.107
6
11
  Sat, 21 Jun 2025 00:13:15 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.d.ts","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAIxC,OAAO,KAAK,EAAE,kBAAkB,EAA0C,MAAM,sBAAsB,CAAC;AAgDvG,MAAM,WAAW,wBA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
164
  let regexResult;
165
165
  while ((regexResult = exports.PLACEHOLDER_REGEX.exec(source))) {
166
- // eslint-disable-line no-cond-assign
167
166
  const staticElement = {
168
167
  kind: 'static',
169
168
  staticString: source.substring(lastIndex, regexResult.index)
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,qDAAkD;AA8ErC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,qBAAS,CAAC,yBAAyB,uCAAuC,EAC7E,GAAG,CACJ,CAAC;AAEF,MAAa,cAAc;IAClB,MAAM,CAAC,qBAAqB,CACjC,OAAsC;QAEtC,MAAM,WAAW,GAAW,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAEnD,MAAM,WAAW,GAAiB,cAAc,CAAC,oCAAoC,CACnF,OAAO,CAAC,MAAM,EACd,WAAW,EACX,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,wBAAwB,EAAE,OAAO,CAAC,mBAAmB,CAAC,CACrG,CAAC;QACF,MAAM,kBAAkB,GAAmC,cAAc,CAAC,qBAAqB,CAC7F,WAAW,CAAC,oBAAoB,EAChC,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,6BAA6B,EACrC,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CACrB,CAAC;QAEF,MAAM,eAAe,GAAiB,cAAc,CAAC,oCAAoC,CACvF,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,GAAG,EAAE;YACH,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC,CACF,CAAC;QACF,MAAM,sBAAsB,GAAmC,cAAc,CAAC,qBAAqB,CACjG,eAAe,CAAC,oBAAoB,EACpC,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,6BAA6B,EACrC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CAAC;aAAM,IAAI,iBAAiB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,sGAAsG;YACtG,yGAAyG;YACzG,UAAU;YACV,EAAE;YACF,2GAA2G;YAC3G,oDAAoD;YACpD,MAAM,YAAY,GAAkC,EAAE,CAAC;YACvD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;gBAC3C,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YAED,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;gBACjD,YAAY,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC;YAED,OAAO,CAAC,MAAc,EAAE,YAAgC,EAAE,EAAE;gBAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC1C,CAAC;gBAED,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CACzE,YAAY,CACb,IAAI,YAAY,IAAI,CAAC;YACxB,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAlYD,wCAkYC","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 * as Webpack from 'webpack';\n\nimport { Constants } from './utilities/Constants';\nimport type { ILocaleElementMap } from './interfaces';\nimport type { LocalizationPlugin, IStringSerialNumberData as IStringData } from './LocalizationPlugin';\n\ninterface IReconstructionElement {\n kind: 'static' | 'localized' | 'dynamic';\n}\n\ninterface IStaticReconstructionElement extends IReconstructionElement {\n kind: 'static';\n staticString: string;\n}\n\ninterface ILocalizedReconstructionElement extends IReconstructionElement {\n kind: 'localized';\n values: ILocaleElementMap;\n size: number;\n stringName: string;\n escapedBackslash: string;\n locFilePath: string;\n}\n\ninterface IDynamicReconstructionElement extends IReconstructionElement {\n kind: 'dynamic';\n valueFn: (locale: string, token: string | undefined) => string;\n size: number;\n escapedBackslash: string;\n token?: string;\n}\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface IReconstructedString {\n source: string;\n size: number;\n}\n\ninterface ILocalizedReconstructionResult {\n result: Map<string, IReconstructedString>;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: IReconstructedString;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Webpack.compilation.Compilation;\n assetName: string;\n asset: IAsset;\n chunk: Webpack.compilation.Chunk;\n noStringsLocaleName: string;\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n}\n\nexport interface IAsset {\n size(): number;\n source(): string;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: IAsset;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])(\\\\+[^+]+\\\\+)?_(\\\\d+)`,\n 'g'\n);\n\nexport class AssetProcessor {\n public static processLocalizedAsset(\n options: IProcessLocalizedAssetOptions\n ): Map<string, IProcessAssetResult> {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAsset.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.asset.size()\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAssetName.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.assetName.length\n );\n\n const result: Map<string, IProcessAssetResult> = new Map<string, IProcessAssetResult>();\n for (const [locale, { source, size }] of reconstructedAsset.result) {\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => source;\n newAsset.size = () => size;\n\n result.set(locale, {\n filename: reconstructedAssetName.result.get(locale)!.source,\n asset: newAsset\n });\n }\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return result;\n }\n\n public static processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessAssetResult {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAsset.reconstructionSeries,\n options.asset.size(),\n options.noStringsLocaleName\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAssetName.reconstructionSeries,\n options.assetName.length,\n options.noStringsLocaleName\n );\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => reconstructedAsset.result.source;\n newAsset.size = () => reconstructedAsset.result.size;\n return {\n filename: reconstructedAssetName.result.source,\n asset: newAsset\n };\n }\n\n private static _reconstructLocalized(\n reconstructionSeries: IReconstructionElement[],\n locales: Set<string>,\n fillMissingTranslationStrings: boolean,\n defaultLocale: string,\n initialSize: number\n ): ILocalizedReconstructionResult {\n const localizedResults: Map<string, IReconstructedString> = new Map<string, IReconstructedString>();\n const issues: string[] = [];\n\n for (const locale of locales) {\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n let newValue: string | undefined = localizedElement.values[locale];\n if (!newValue) {\n if (fillMissingTranslationStrings) {\n newValue = localizedElement.values[defaultLocale];\n } else {\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = localizedElement.escapedBackslash || '\\\\';\n\n // Replace backslashes with the properly escaped backslash\n newValue = newValue.replace(/\\\\/g, escapedBackslash);\n\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.substr(escapedBackslash.length / 2);\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n newValue = newValue.replace(/\\r/g, `${escapingCharacterSequence}r`);\n newValue = newValue.replace(/\\n/g, `${escapingCharacterSequence}n`);\n newValue = newValue.replace(/\\t/g, `${escapingCharacterSequence}t`);\n newValue = newValue.replace(/\\\"/g, `${escapingCharacterSequence}u0022`);\n newValue = newValue.replace(/\\'/g, `${escapingCharacterSequence}u0027`);\n\n reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(locale, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n localizedResults.set(locale, {\n source: newAssetSource,\n size: initialSize + sizeDiff\n });\n }\n\n return {\n issues,\n result: localizedResults\n };\n }\n\n private static _reconstructNonLocalized(\n reconstructionSeries: IReconstructionElement[],\n initialSize: number,\n noStringsLocaleName: string\n ): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.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 reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(noStringsLocaleName, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n return {\n issues,\n result: {\n source: newAssetSource,\n size: initialSize + sizeDiff\n }\n };\n }\n\n private static _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n jsonpFunction: (locale: string, chunkIdToken: string | undefined) => string\n ): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let lastIndex: number = 0;\n let regexResult: RegExpExecArray | null;\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\n // eslint-disable-line no-cond-assign\n const staticElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substring(lastIndex, regexResult.index)\n };\n reconstructionSeries.push(staticElement);\n\n const [placeholder, escapedBackslash, elementLabel, token, placeholderSerialNumber] = regexResult;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringData | undefined = plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n const brokenLocalizedElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: placeholder\n };\n localizedReconstructionElement = brokenLocalizedElement;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n values: stringData.values,\n size: placeholder.length,\n locFilePath: stringData.locFilePath,\n escapedBackslash: escapedBackslash,\n stringName: stringData.stringName\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: (locale: string) => locale,\n size: placeholder.length,\n escapedBackslash: escapedBackslash\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: jsonpFunction,\n size: placeholder.length,\n escapedBackslash: escapedBackslash,\n token: token.substring(1, token.length - 1)\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 lastIndex = regexResult.index + placeholder.length;\n }\n\n const lastElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substr(lastIndex)\n };\n reconstructionSeries.push(lastElement);\n\n return {\n issues,\n reconstructionSeries\n };\n }\n\n private static _getJsonpFunction(\n chunk: Webpack.compilation.Chunk,\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean,\n noStringsLocaleName: string\n ): (locale: string, chunkIdToken: string | undefined) => string {\n const idsWithStrings: Set<number | string> = new Set<number | string>();\n const idsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const asyncChunks: Set<Webpack.compilation.Chunk> = chunk.getAllAsyncChunks();\n for (const asyncChunk of asyncChunks) {\n const chunkId: number | string | null = asyncChunk.id;\n\n if (chunkId === null || chunkId === undefined) {\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\n }\n\n if (chunkHasLocalizedModules(asyncChunk)) {\n idsWithStrings.add(chunkId);\n } else {\n idsWithoutStrings.add(chunkId);\n }\n }\n\n if (idsWithStrings.size === 0) {\n return () => JSON.stringify(noStringsLocaleName);\n } else if (idsWithoutStrings.size === 0) {\n return (locale: string) => JSON.stringify(locale);\n } else {\n // Generate an array [<locale>, <nostrings locale>] and an object that is used as an indexer into that\n // object that maps chunk IDs to 0s for chunks with localized strings and 1s for chunks without localized\n // strings\n //\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\n // number are localized and the those above are not.\n const chunkMapping: { [chunkId: string]: number } = {};\n for (const idWithStrings of idsWithStrings) {\n chunkMapping[idWithStrings] = 0;\n }\n\n for (const idWithoutStrings of idsWithoutStrings) {\n chunkMapping[idWithoutStrings] = 1;\n }\n\n return (locale: string, chunkIdToken: string | undefined) => {\n if (!locale) {\n throw new Error('Missing locale name.');\n }\n\n return `(${JSON.stringify([locale, noStringsLocaleName])})[${JSON.stringify(\n chunkMapping\n )}[${chunkIdToken}]]`;\n };\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AssetProcessor.js","sourceRoot":"","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AAE;YACF,2GAA2G;YAC3G,oDAAoD;YACpD,MAAM,YAAY,GAAkC,EAAE,CAAC;YACvD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;gBAC3C,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YAED,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;gBACjD,YAAY,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC;YAED,OAAO,CAAC,MAAc,EAAE,YAAgC,EAAE,EAAE;gBAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC1C,CAAC;gBAED,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CACzE,YAAY,CACb,IAAI,YAAY,IAAI,CAAC;YACxB,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAjYD,wCAiYC","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 * as Webpack from 'webpack';\n\nimport { Constants } from './utilities/Constants';\nimport type { ILocaleElementMap } from './interfaces';\nimport type { LocalizationPlugin, IStringSerialNumberData as IStringData } from './LocalizationPlugin';\n\ninterface IReconstructionElement {\n kind: 'static' | 'localized' | 'dynamic';\n}\n\ninterface IStaticReconstructionElement extends IReconstructionElement {\n kind: 'static';\n staticString: string;\n}\n\ninterface ILocalizedReconstructionElement extends IReconstructionElement {\n kind: 'localized';\n values: ILocaleElementMap;\n size: number;\n stringName: string;\n escapedBackslash: string;\n locFilePath: string;\n}\n\ninterface IDynamicReconstructionElement extends IReconstructionElement {\n kind: 'dynamic';\n valueFn: (locale: string, token: string | undefined) => string;\n size: number;\n escapedBackslash: string;\n token?: string;\n}\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface IReconstructedString {\n source: string;\n size: number;\n}\n\ninterface ILocalizedReconstructionResult {\n result: Map<string, IReconstructedString>;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: IReconstructedString;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Webpack.compilation.Compilation;\n assetName: string;\n asset: IAsset;\n chunk: Webpack.compilation.Chunk;\n noStringsLocaleName: string;\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n}\n\nexport interface IAsset {\n size(): number;\n source(): string;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: IAsset;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])(\\\\+[^+]+\\\\+)?_(\\\\d+)`,\n 'g'\n);\n\nexport class AssetProcessor {\n public static processLocalizedAsset(\n options: IProcessLocalizedAssetOptions\n ): Map<string, IProcessAssetResult> {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAsset.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.asset.size()\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAssetName.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.assetName.length\n );\n\n const result: Map<string, IProcessAssetResult> = new Map<string, IProcessAssetResult>();\n for (const [locale, { source, size }] of reconstructedAsset.result) {\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => source;\n newAsset.size = () => size;\n\n result.set(locale, {\n filename: reconstructedAssetName.result.get(locale)!.source,\n asset: newAsset\n });\n }\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return result;\n }\n\n public static processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessAssetResult {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAsset.reconstructionSeries,\n options.asset.size(),\n options.noStringsLocaleName\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAssetName.reconstructionSeries,\n options.assetName.length,\n options.noStringsLocaleName\n );\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => reconstructedAsset.result.source;\n newAsset.size = () => reconstructedAsset.result.size;\n return {\n filename: reconstructedAssetName.result.source,\n asset: newAsset\n };\n }\n\n private static _reconstructLocalized(\n reconstructionSeries: IReconstructionElement[],\n locales: Set<string>,\n fillMissingTranslationStrings: boolean,\n defaultLocale: string,\n initialSize: number\n ): ILocalizedReconstructionResult {\n const localizedResults: Map<string, IReconstructedString> = new Map<string, IReconstructedString>();\n const issues: string[] = [];\n\n for (const locale of locales) {\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n let newValue: string | undefined = localizedElement.values[locale];\n if (!newValue) {\n if (fillMissingTranslationStrings) {\n newValue = localizedElement.values[defaultLocale];\n } else {\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = localizedElement.escapedBackslash || '\\\\';\n\n // Replace backslashes with the properly escaped backslash\n newValue = newValue.replace(/\\\\/g, escapedBackslash);\n\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.substr(escapedBackslash.length / 2);\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n newValue = newValue.replace(/\\r/g, `${escapingCharacterSequence}r`);\n newValue = newValue.replace(/\\n/g, `${escapingCharacterSequence}n`);\n newValue = newValue.replace(/\\t/g, `${escapingCharacterSequence}t`);\n newValue = newValue.replace(/\\\"/g, `${escapingCharacterSequence}u0022`);\n newValue = newValue.replace(/\\'/g, `${escapingCharacterSequence}u0027`);\n\n reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(locale, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n localizedResults.set(locale, {\n source: newAssetSource,\n size: initialSize + sizeDiff\n });\n }\n\n return {\n issues,\n result: localizedResults\n };\n }\n\n private static _reconstructNonLocalized(\n reconstructionSeries: IReconstructionElement[],\n initialSize: number,\n noStringsLocaleName: string\n ): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.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 reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(noStringsLocaleName, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n return {\n issues,\n result: {\n source: newAssetSource,\n size: initialSize + sizeDiff\n }\n };\n }\n\n private static _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n jsonpFunction: (locale: string, chunkIdToken: string | undefined) => string\n ): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let lastIndex: number = 0;\n let regexResult: RegExpExecArray | null;\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\n const staticElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substring(lastIndex, regexResult.index)\n };\n reconstructionSeries.push(staticElement);\n\n const [placeholder, escapedBackslash, elementLabel, token, placeholderSerialNumber] = regexResult;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringData | undefined = plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n const brokenLocalizedElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: placeholder\n };\n localizedReconstructionElement = brokenLocalizedElement;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n values: stringData.values,\n size: placeholder.length,\n locFilePath: stringData.locFilePath,\n escapedBackslash: escapedBackslash,\n stringName: stringData.stringName\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: (locale: string) => locale,\n size: placeholder.length,\n escapedBackslash: escapedBackslash\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: jsonpFunction,\n size: placeholder.length,\n escapedBackslash: escapedBackslash,\n token: token.substring(1, token.length - 1)\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 lastIndex = regexResult.index + placeholder.length;\n }\n\n const lastElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substr(lastIndex)\n };\n reconstructionSeries.push(lastElement);\n\n return {\n issues,\n reconstructionSeries\n };\n }\n\n private static _getJsonpFunction(\n chunk: Webpack.compilation.Chunk,\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean,\n noStringsLocaleName: string\n ): (locale: string, chunkIdToken: string | undefined) => string {\n const idsWithStrings: Set<number | string> = new Set<number | string>();\n const idsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const asyncChunks: Set<Webpack.compilation.Chunk> = chunk.getAllAsyncChunks();\n for (const asyncChunk of asyncChunks) {\n const chunkId: number | string | null = asyncChunk.id;\n\n if (chunkId === null || chunkId === undefined) {\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\n }\n\n if (chunkHasLocalizedModules(asyncChunk)) {\n idsWithStrings.add(chunkId);\n } else {\n idsWithoutStrings.add(chunkId);\n }\n }\n\n if (idsWithStrings.size === 0) {\n return () => JSON.stringify(noStringsLocaleName);\n } else if (idsWithoutStrings.size === 0) {\n return (locale: string) => JSON.stringify(locale);\n } else {\n // Generate an array [<locale>, <nostrings locale>] and an object that is used as an indexer into that\n // object that maps chunk IDs to 0s for chunks with localized strings and 1s for chunks without localized\n // strings\n //\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\n // number are localized and the those above are not.\n const chunkMapping: { [chunkId: string]: number } = {};\n for (const idWithStrings of idsWithStrings) {\n chunkMapping[idWithStrings] = 0;\n }\n\n for (const idWithoutStrings of idsWithoutStrings) {\n chunkMapping[idWithoutStrings] = 1;\n }\n\n return (locale: string, chunkIdToken: string | undefined) => {\n if (!locale) {\n throw new Error('Missing locale name.');\n }\n\n return `(${JSON.stringify([locale, noStringsLocaleName])})[${JSON.stringify(\n chunkMapping\n )}[${chunkIdToken}]]`;\n };\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack4-localization-plugin",
3
- "version": "0.18.107",
3
+ "version": "0.18.108",
4
4
  "description": "This plugin facilitates localization with Webpack.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack4-localization-plugin.d.ts",
@@ -31,9 +31,9 @@
31
31
  "@types/tapable": "1.0.6",
32
32
  "loader-utils": "1.4.2",
33
33
  "minimatch": "~3.0.3",
34
- "@rushstack/localization-utilities": "0.13.16",
35
- "@rushstack/terminal": "0.15.3",
36
- "@rushstack/node-core-library": "5.13.1"
34
+ "@rushstack/localization-utilities": "0.13.17",
35
+ "@rushstack/node-core-library": "5.14.0",
36
+ "@rushstack/terminal": "0.15.4"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rushstack/set-webpack-public-path-plugin": "^4.1.16",
@@ -41,9 +41,10 @@
41
41
  "@types/minimatch": "3.0.5",
42
42
  "@types/node": "20.17.19",
43
43
  "@types/webpack": "4.41.32",
44
+ "eslint": "~9.25.1",
44
45
  "webpack": "~4.47.0",
45
- "@rushstack/heft": "0.74.0",
46
- "local-node-rig": "1.0.0"
46
+ "local-node-rig": "1.0.0",
47
+ "@rushstack/heft": "0.74.1"
47
48
  },
48
49
  "scripts": {
49
50
  "build": "heft build --clean",