@l10nmonster/helpers-android 3.0.1 → 3.0.2

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.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## @l10nmonster/helpers-android [3.0.2](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-android@3.0.1...@l10nmonster/helpers-android@3.0.2) (2025-12-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
7
+
8
+
9
+
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * **@l10nmonster/core:** upgraded to 3.1.1
15
+
1
16
  ## @l10nmonster/helpers-android [3.0.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/helpers-android@3.0.0...@l10nmonster/helpers-android@3.0.1) (2025-12-20)
2
17
 
3
18
 
package/filter.js CHANGED
@@ -7,6 +7,8 @@ import { XMLParser, XMLBuilder } from 'fast-xml-parser';
7
7
  import { default as formatXml } from 'xml-formatter';
8
8
  import { logVerbose } from '@l10nmonster/core';
9
9
 
10
+ /** @typedef {import('@l10nmonster/core').ResourceFilter} ResourceFilter */
11
+
10
12
  function collapseTextNodes(node) {
11
13
  return node.map(e => e['#text']).join('').trim();
12
14
  }
@@ -19,6 +21,7 @@ function isTranslatableNode(resNode, str) {
19
21
 
20
22
  /**
21
23
  * Class representing an AndroidFilter for parsing and translating Android resource files.
24
+ * @implements {ResourceFilter}
22
25
  */
23
26
  export class AndroidXMLFilter {
24
27
 
@@ -226,7 +229,8 @@ export class AndroidXMLFilter {
226
229
  }
227
230
  const builder = new XMLBuilder(parsingOptions);
228
231
  const roughXML = builder.build(parsedResource);
229
- // eslint-disable-next-line prefer-template
230
- return formatXml(roughXML, { collapseContent: true, indentation: this.indentation, lineSeparator: '\n' }) + '\n';
232
+
233
+ // @ts-ignore - xml-formatter types don't match actual module export
234
+ return `${formatXml(roughXML, { collapseContent: true, indentation: this.indentation, lineSeparator: '\n' })}\n`;
231
235
  }
232
236
  }
package/index.js CHANGED
@@ -5,6 +5,8 @@ const androidControlCharsToDecode = {
5
5
  n: '\n',
6
6
  t: '\t',
7
7
  };
8
+
9
+ /** @type {import('@l10nmonster/core').DecoderFunction} */
8
10
  export const escapesDecoder = regex.decoderMaker(
9
11
  'androidEscapesDecoder',
10
12
  /(?<node>\\(?<escapedChar>[@?\\'"])|\\(?<escapedControl>[nt])|\\u(?<codePoint>[0-9A-Za-z]{4}))/g,
@@ -16,7 +18,10 @@ export const escapesDecoder = regex.decoderMaker(
16
18
  )
17
19
  );
18
20
 
19
- // Android lint doesn't accept % but accepts %%. % should be replaced with '\u0025' but %% shouldn't
21
+ /**
22
+ * Android lint doesn't accept % but accepts %%. % should be replaced with '\u0025' but %% shouldn't
23
+ * @type {import('@l10nmonster/core').TextEncoderFunction}
24
+ */
20
25
  export const escapesEncoder = (str, flags = {}) => {
21
26
  let escapedStr = str.replaceAll(/[@\\'"]/g, '\\$&').replaceAll('\t', '\\t').replaceAll('\n', '\\n').replaceAll(/(?<!%)%(?!%)/g, '\\u0025');
22
27
  // eslint-disable-next-line prefer-template
@@ -26,9 +31,14 @@ export const escapesEncoder = (str, flags = {}) => {
26
31
  return escapedStr;
27
32
  };
28
33
 
34
+ /** @type {import('@l10nmonster/core').PartTransformer} */
35
+ // @ts-ignore - Part union type narrowing not supported by TypeScript in this pattern
29
36
  export const spaceCollapser = (parts) => parts.map(p => (p.t === 's' ? { ...p, v: p.v.replaceAll(/[ \f\n\r\t\v\u2028\u2029]+/g, ' ')} : p));
30
37
 
31
- // C-style placeholders (based on the ios one)
38
+ /**
39
+ * C-style placeholders (based on the ios one)
40
+ * @type {import('@l10nmonster/core').DecoderFunction}
41
+ */
32
42
  export const phDecoder = regex.decoderMaker(
33
43
  'iosPHDecoder',
34
44
  /(?<tag>%(?:\d\$)?[0#+-]?[0-9*]*\.?\d*[hl]{0,2}[jztL]?[diuoxXeEfgGaAcpsSn])/g,
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@l10nmonster/helpers-android",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Helpers to deal with Android file formats",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "scripts": {
8
- "test": "node --test"
8
+ "test": "node --test",
9
+ "typecheck": "tsc --noEmit"
9
10
  },
10
11
  "author": "Diego Lagunas",
11
12
  "license": "MIT",
@@ -14,6 +15,6 @@
14
15
  "xml-formatter": "^3"
15
16
  },
16
17
  "peerDependencies": {
17
- "@l10nmonster/core": "3.1.0"
18
+ "@l10nmonster/core": "3.1.1"
18
19
  }
19
20
  }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "include": [
4
+ "*.js",
5
+ "**/*.js"
6
+ ],
7
+ "exclude": [
8
+ "node_modules",
9
+ "**/node_modules",
10
+ "test/**",
11
+ "tests/**",
12
+ "**/*.test.js",
13
+ "**/*.spec.js",
14
+ "dist/**",
15
+ "ui/**",
16
+ "types/**"
17
+ ]
18
+ }
package/.releaserc.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "branches": [
3
- "main",
4
- {
5
- "name": "next",
6
- "prerelease": "alpha"
7
- },
8
- {
9
- "name": "beta",
10
- "prerelease": "beta"
11
- }
12
- ],
13
- "tagFormat": "@l10nmonster/helpers-android@${version}",
14
- "plugins": [
15
- "@semantic-release/commit-analyzer",
16
- "@semantic-release/release-notes-generator",
17
- {
18
- "path": "@semantic-release/changelog",
19
- "changelogFile": "CHANGELOG.md"
20
- },
21
- {
22
- "path": "@semantic-release/npm",
23
- "npmPublish": false
24
- },
25
- {
26
- "path": "@semantic-release/git",
27
- "assets": ["CHANGELOG.md", "package.json"],
28
- "message": "chore(release): @l10nmonster/helpers-android@${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
29
- }
30
- ]
31
- }