@zohodesk/client_build_tool 0.0.11-exp.11 → 0.0.11-exp.13

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.
@@ -176,6 +176,7 @@ var _default = {
176
176
  },
177
177
  i18nIndexing: {
178
178
  enable: false,
179
+ devMode: false,
179
180
  jsResourcePath: './deskapp/properties/JSResources.properties',
180
181
  propertiesFolderPath: './deskapp/properties',
181
182
  numericMapPath: './deskapp/properties/i18n-numeric-map.json',
@@ -99,6 +99,7 @@ var _default = {
99
99
  },
100
100
  i18nIndexing: {
101
101
  enable: false,
102
+ devMode: false,
102
103
  jsResourcePath: './deskapp/properties/JSResources.properties',
103
104
  propertiesFolderPath: './deskapp/properties',
104
105
  numericMapPath: './deskapp/properties/i18n-numeric-map.json',
@@ -81,7 +81,7 @@ class I18nNumericIndexPlugin {
81
81
  }
82
82
 
83
83
  if (this.options.generateManifest) {
84
- const cleanName = filename.replace(/\[locale\]/g, locale).replace(/\[contenthash\]/g, '').replace(/\.js$/, '.js');
84
+ const cleanName = filename.replace(/\[locale\]/g, locale).replace(/\.\[contenthash\]/g, '').replace(/\.js$/, '.js');
85
85
  const cleanNameWithType = fileType ? cleanName.replace(/\.js$/, `.${fileType}.js`) : cleanName;
86
86
  const manifestKey = cleanNameWithType.split('/').pop();
87
87
  this.manifest[manifestKey] = outputPath.split('/').pop();
@@ -103,7 +103,8 @@ class I18nNumericIndexPlugin {
103
103
 
104
104
  const {
105
105
  sortedKeys,
106
- totalKeys
106
+ totalKeys,
107
+ originalKeyToNumericId
107
108
  } = this.getNumericMap(compilation);
108
109
  const {
109
110
  jsResourceBase,
@@ -113,28 +114,31 @@ class I18nNumericIndexPlugin {
113
114
  if (!locales.length) return callback();
114
115
  const numericKeysSet = new Set(sortedKeys);
115
116
  const englishData = allI18n.en_US || jsResourceBase;
117
+ const isDevMode = this.options.devMode || process.env.NODE_ENV === 'development';
116
118
  locales.forEach(locale => {
117
119
  const localeData = allI18n[locale] || {};
118
120
  const numericData = {};
119
-
120
- for (let i = 0; i < totalKeys; i++) {
121
- const key = sortedKeys[i];
122
-
123
- if (key && jsResourceBase[key] !== undefined) {
124
- numericData[i] = localeData[key] ?? englishData[key];
125
- }
126
- }
127
-
128
- const dynamicData = {};
121
+ const unmappedData = {};
129
122
  Object.keys(jsResourceBase).forEach(key => {
130
- if (!numericKeysSet.has(key)) {
131
- dynamicData[key] = localeData[key] ?? englishData[key];
123
+ const translation = localeData[key] ?? englishData[key];
124
+
125
+ if (originalKeyToNumericId && originalKeyToNumericId.hasOwnProperty(key)) {
126
+ const numericId = originalKeyToNumericId[key];
127
+ numericData[numericId] = translation;
128
+ } else if (numericKeysSet.has(key)) {
129
+ const index = sortedKeys.indexOf(key);
130
+
131
+ if (index !== -1) {
132
+ numericData[index] = translation;
133
+ }
134
+ } else {
135
+ unmappedData[key] = translation;
132
136
  }
133
137
  });
134
138
 
135
139
  if (this.options.singleFile) {
136
140
  const combinedData = { ...numericData,
137
- ...dynamicData
141
+ ...unmappedData
138
142
  };
139
143
 
140
144
  if (Object.keys(combinedData).length > 0) {
@@ -146,8 +150,8 @@ class I18nNumericIndexPlugin {
146
150
  this.emitChunk(compilation, this.options.numericFilenameTemplate, locale, numericData, 'numeric');
147
151
  }
148
152
 
149
- if (Object.keys(dynamicData).length > 0) {
150
- this.emitChunk(compilation, this.options.dynamicFilenameTemplate, locale, dynamicData, 'dynamic');
153
+ if (Object.keys(unmappedData).length > 0) {
154
+ this.emitChunk(compilation, this.options.dynamicFilenameTemplate, locale, unmappedData, 'dynamic');
151
155
  }
152
156
  }
153
157
  });
@@ -56,6 +56,7 @@ function i18nIdReplaceLoaderConfig(options, webpackContext) {
56
56
  allI18nData: allI18nData,
57
57
  sourceMaps: false,
58
58
  numericMapPath: numericMapPath,
59
+ devMode: options.i18nIndexing?.devMode || false,
59
60
  includePaths: options.i18nIndexing?.loaderOptions?.includePaths || [],
60
61
  excludePaths: options.i18nIndexing?.loaderOptions?.excludePaths || ['node_modules', 'tests']
61
62
  };
@@ -61,6 +61,8 @@ module.exports = function i18nIdReplaceLoader(source, map) {
61
61
  return callback(null, source, map);
62
62
  }
63
63
 
64
+ const isDevMode = options.devMode || process.env.NODE_ENV === 'development';
65
+
64
66
  try {
65
67
  const ast = parser.parse(source, {
66
68
  sourceType: 'module',
@@ -1,10 +1,5 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Shared properties file parsing utility
5
- * Handles consistent parsing across all i18n tools
6
- */
7
- // Decode Unicode escape sequences (for values only)
8
3
  function decodeUnicodeEscapes(str) {
9
4
  if (typeof str !== 'string') {
10
5
  return str;
@@ -14,12 +9,6 @@ function decodeUnicodeEscapes(str) {
14
9
  return String.fromCharCode(parseInt(hex, 16));
15
10
  });
16
11
  }
17
- /**
18
- * Parse properties file content into key-value pairs
19
- * @param {string} content - Properties file content
20
- * @returns {Object} Parsed key-value pairs
21
- */
22
-
23
12
 
24
13
  function parseProperties(content) {
25
14
  const lines = content.split(/\r?\n/);
@@ -29,8 +18,7 @@ function parseProperties(content) {
29
18
 
30
19
  if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
31
20
  return;
32
- } // Find unescaped separator (= or :)
33
-
21
+ }
34
22
 
35
23
  let separatorIndex = -1;
36
24
 
@@ -46,9 +34,7 @@ function parseProperties(content) {
46
34
  let value = trimmedLine.substring(separatorIndex + 1).trim();
47
35
 
48
36
  if (key) {
49
- // Handle escaped spaces in keys only
50
- key = key.replace(/\\ /g, ' '); // Decode Unicode escape sequences ONLY in values, not keys
51
-
37
+ key = key.replace(/\\ /g, ' ');
52
38
  value = decodeUnicodeEscapes(value);
53
39
  data[key] = value;
54
40
  }
@@ -56,12 +42,6 @@ function parseProperties(content) {
56
42
  });
57
43
  return data;
58
44
  }
59
- /**
60
- * Parse properties file content into a Set of keys only
61
- * @param {string} content - Properties file content
62
- * @returns {Set<string>} Set of keys
63
- */
64
-
65
45
 
66
46
  function parsePropertiesToKeySet(content) {
67
47
  const lines = content.split(/\r?\n/);
@@ -71,8 +51,7 @@ function parsePropertiesToKeySet(content) {
71
51
 
72
52
  if (trimmedLine.startsWith('#') || trimmedLine.startsWith('!') || trimmedLine === '') {
73
53
  return;
74
- } // Find unescaped separator (= or :)
75
-
54
+ }
76
55
 
77
56
  let separatorIndex = -1;
78
57
 
@@ -87,7 +66,6 @@ function parsePropertiesToKeySet(content) {
87
66
  let key = trimmedLine.substring(0, separatorIndex).trim();
88
67
 
89
68
  if (key) {
90
- // Handle escaped spaces in keys only
91
69
  key = key.replace(/\\ /g, ' ');
92
70
  keys.add(key);
93
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/client_build_tool",
3
- "version": "0.0.11-exp.11",
3
+ "version": "0.0.11-exp.13",
4
4
  "description": "A CLI tool to build web applications and client libraries",
5
5
  "main": "lib/index.js",
6
6
  "bin": {