nitrogen 0.35.4 → 0.35.5

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.
@@ -32,6 +32,10 @@ val ${name}: ${type.getTypeCode('kotlin', false)}
32
32
  .map((i) => `import ${i.name}`)
33
33
  .filter(isNotDuplicate);
34
34
  const secondaryConstructor = createKotlinConstructor(structType);
35
+ const equalityComparators = structType.properties.map((p) => `Objects.deepEquals(this.${p.escapedName}, other.${p.escapedName})`);
36
+ const propertiesList = structType.properties
37
+ .map((p) => p.escapedName)
38
+ .join(',\n');
35
39
  const code = `
36
40
  ${createFileMetadataString(`${structType.structName}.kt`)}
37
41
 
@@ -39,6 +43,7 @@ package ${packageName}
39
43
 
40
44
  import androidx.annotation.Keep
41
45
  import com.facebook.proguard.annotations.DoNotStrip
46
+ import java.util.Objects
42
47
  ${extraImports.join('\n')}
43
48
 
44
49
  /**
@@ -51,6 +56,18 @@ data class ${structType.structName}(
51
56
  ) {
52
57
  ${indent(secondaryConstructor, ' ')}
53
58
 
59
+ override fun equals(other: Any?): Boolean {
60
+ if (this === other) return true
61
+ if (other !is ${structType.structName}) return false
62
+ return ${equalityComparators.join(`\n && `)}
63
+ }
64
+
65
+ override fun hashCode(): Int {
66
+ return arrayOf(
67
+ ${indent(propertiesList, ' ')}
68
+ ).contentDeepHashCode()
69
+ }
70
+
54
71
  companion object {
55
72
  /**
56
73
  * Constructor called from C++
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.35.4",
3
+ "version": "0.35.5",
4
4
  "description": "The code-generator for react-native-nitro-modules.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "chalk": "^5.3.0",
38
- "react-native-nitro-modules": "^0.35.4",
38
+ "react-native-nitro-modules": "^0.35.5",
39
39
  "ts-morph": "^27.0.0",
40
40
  "yargs": "^18.0.0",
41
41
  "zod": "^4.0.5"
@@ -45,6 +45,13 @@ val ${name}: ${type.getTypeCode('kotlin', false)}
45
45
 
46
46
  const secondaryConstructor = createKotlinConstructor(structType)
47
47
 
48
+ const equalityComparators = structType.properties.map(
49
+ (p) => `Objects.deepEquals(this.${p.escapedName}, other.${p.escapedName})`
50
+ )
51
+ const propertiesList = structType.properties
52
+ .map((p) => p.escapedName)
53
+ .join(',\n')
54
+
48
55
  const code = `
49
56
  ${createFileMetadataString(`${structType.structName}.kt`)}
50
57
 
@@ -52,6 +59,7 @@ package ${packageName}
52
59
 
53
60
  import androidx.annotation.Keep
54
61
  import com.facebook.proguard.annotations.DoNotStrip
62
+ import java.util.Objects
55
63
  ${extraImports.join('\n')}
56
64
 
57
65
  /**
@@ -64,6 +72,18 @@ data class ${structType.structName}(
64
72
  ) {
65
73
  ${indent(secondaryConstructor, ' ')}
66
74
 
75
+ override fun equals(other: Any?): Boolean {
76
+ if (this === other) return true
77
+ if (other !is ${structType.structName}) return false
78
+ return ${equalityComparators.join(`\n && `)}
79
+ }
80
+
81
+ override fun hashCode(): Int {
82
+ return arrayOf(
83
+ ${indent(propertiesList, ' ')}
84
+ ).contentDeepHashCode()
85
+ }
86
+
67
87
  companion object {
68
88
  /**
69
89
  * Constructor called from C++