@zohodesk/client_build_tool 0.0.11-exp.15 → 0.0.11-exp.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.configI18nNumericIndexPlugin = configI18nNumericIndexPlugin;
7
-
8
- var _I18nNumericIndexPlugin = require("../custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin");
9
-
10
- var _I18nNumericIndexHtmlInjectorPlugin = require("../custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin");
11
-
12
- var _readI18nValues = require("../custom_plugins/I18nSplitPlugin/readI18nValues");
13
-
14
- function configI18nNumericIndexPlugin(options) {
15
- if (!(options.i18nIndexing && options.i18nIndexing.enable)) {
16
- return null;
17
- }
18
-
19
- const i18nOpts = options.i18nIndexing; // Check for required options based on singleFile mode
20
-
21
- const baseRequiredOptions = ['jsResourcePath', 'propertiesFolderPath', 'numericMapPath', 'jsonpFunc', 'htmlTemplateLabel', 'localeVarName']; // Add template requirements based on mode
22
-
23
- const requiredOptions = i18nOpts.singleFile ? [...baseRequiredOptions, 'singleFileTemplate'] : [...baseRequiredOptions, 'numericFilenameTemplate', 'dynamicFilenameTemplate'];
24
- const missingOptions = requiredOptions.filter(opt => !i18nOpts[opt]);
25
-
26
- if (missingOptions.length > 0) {
27
- return null;
28
- }
29
-
30
- const {
31
- locales,
32
- allI18nObject
33
- } = (0, _readI18nValues.readI18nValues)({
34
- jsResource: i18nOpts.jsResourcePath,
35
- propertiesFolder: i18nOpts.propertiesFolderPath,
36
- disableDefault: false
37
- }); // Validate template patterns based on mode
38
-
39
- if (i18nOpts.singleFile) {
40
- if (i18nOpts.singleFileTemplate && !i18nOpts.singleFileTemplate.includes('[locale]')) {
41
- return null;
42
- }
43
- } else {
44
- if (!i18nOpts.numericFilenameTemplate?.includes('[locale]')) {
45
- return null;
46
- }
47
-
48
- if (!i18nOpts.dynamicFilenameTemplate?.includes('[locale]')) {
49
- return null;
50
- }
51
- }
52
-
53
- const i18nAssetsPublicPathPrefix = '';
54
- const hasContentHashInNumeric = i18nOpts.numericFilenameTemplate.includes('[contenthash]');
55
- const hasContentHashInDynamic = i18nOpts.dynamicFilenameTemplate.includes('[contenthash]');
56
- const hasContentHashInSingle = i18nOpts.singleFileTemplate?.includes('[contenthash]');
57
- const shouldIncludeContentHash = i18nOpts.singleFile ? hasContentHashInSingle : hasContentHashInNumeric || hasContentHashInDynamic;
58
- const finalIncludeContentHash = i18nOpts.includeContentHash !== undefined ? i18nOpts.includeContentHash : shouldIncludeContentHash;
59
- const numericIndexPluginOptions = {
60
- enable: i18nOpts.enable,
61
- jsResourcePath: i18nOpts.jsResourcePath,
62
- propertiesFolderPath: i18nOpts.propertiesFolderPath,
63
- numericMapPath: i18nOpts.numericMapPath,
64
- locales,
65
- allI18nObject,
66
- numericFilenameTemplate: i18nOpts.numericFilenameTemplate,
67
- dynamicFilenameTemplate: i18nOpts.dynamicFilenameTemplate,
68
- singleFileTemplate: i18nOpts.singleFileTemplate,
69
- jsonpFunc: i18nOpts.jsonpFunc,
70
- singleFile: i18nOpts.singleFile || false,
71
- includeContentHash: finalIncludeContentHash,
72
- generateManifest: i18nOpts.generateManifest || false,
73
- manifestPath: i18nOpts.manifestPath
74
- };
75
- const htmlInjectorOptions = {
76
- numericFilenameTemplate: i18nOpts.numericFilenameTemplate,
77
- dynamicFilenameTemplate: i18nOpts.dynamicFilenameTemplate,
78
- htmlTemplateLabel: i18nOpts.htmlTemplateLabel,
79
- i18nAssetsPublicPathPrefix
80
- };
81
- const i18nNumericPluginInstance = new _I18nNumericIndexPlugin.I18nNumericIndexPlugin(numericIndexPluginOptions);
82
- const htmlInjectorPluginInstance = new _I18nNumericIndexHtmlInjectorPlugin.I18nNumericIndexHtmlInjectorPlugin(htmlInjectorOptions);
83
- return [i18nNumericPluginInstance, htmlInjectorPluginInstance];
84
- }
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- function decodeUnicodeEscapes(str) {
4
- if (typeof str !== 'string') {
5
- return str;
6
- }
7
-
8
- return str.replace(/\\u([0-9a-fA-F]{4})/g, (match, hex) => {
9
- return String.fromCharCode(parseInt(hex, 16));
10
- });
11
- }
12
-
13
- function parseProperties(content) {
14
- const lines = content.split(/\r?\n/);
15
- const data = {};
16
- lines.forEach(line => {
17
- const trimmedLine = line.trim();
18
-
19
- if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
20
- return;
21
- }
22
-
23
- let separatorIndex = -1;
24
-
25
- for (let i = 0; i < trimmedLine.length; i++) {
26
- if ((trimmedLine[i] === '=' || trimmedLine[i] === ':') && (i === 0 || trimmedLine[i - 1] !== '\\')) {
27
- separatorIndex = i;
28
- break;
29
- }
30
- }
31
-
32
- if (separatorIndex > 0) {
33
- let key = trimmedLine.substring(0, separatorIndex).trim();
34
- let value = trimmedLine.substring(separatorIndex + 1).trim();
35
-
36
- if (key) {
37
- key = key.replace(/\\ /g, ' ');
38
- value = decodeUnicodeEscapes(value);
39
- data[key] = value;
40
- }
41
- }
42
- });
43
- return data;
44
- }
45
-
46
- function parsePropertiesToKeySet(content) {
47
- const lines = content.split(/\r?\n/);
48
- const keys = new Set();
49
- lines.forEach(line => {
50
- const trimmedLine = line.trim();
51
-
52
- if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
53
- return;
54
- }
55
-
56
- let separatorIndex = -1;
57
-
58
- for (let i = 0; i < trimmedLine.length; i++) {
59
- if ((trimmedLine[i] === '=' || trimmedLine[i] === ':') && (i === 0 || trimmedLine[i - 1] !== '\\')) {
60
- separatorIndex = i;
61
- break;
62
- }
63
- }
64
-
65
- if (separatorIndex > 0) {
66
- let key = trimmedLine.substring(0, separatorIndex).trim();
67
-
68
- if (key) {
69
- key = key.replace(/\\ /g, ' ');
70
- keys.add(key);
71
- }
72
- }
73
- });
74
- return keys;
75
- }
76
-
77
- module.exports = {
78
- parseProperties,
79
- parsePropertiesToKeySet,
80
- decodeUnicodeEscapes
81
- };