nitrogen 0.29.4 → 0.29.6
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/README.md +5 -1
- package/lib/autolinking/android/createCMakeExtension.js +7 -4
- package/lib/views/CppHybridViewComponent.js +4 -2
- package/lib/views/kotlin/KotlinHybridViewManager.js +4 -0
- package/package.json +2 -2
- package/src/autolinking/android/createCMakeExtension.ts +7 -4
- package/src/views/CppHybridViewComponent.ts +6 -3
- package/src/views/kotlin/KotlinHybridViewManager.ts +4 -0
package/README.md
CHANGED
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
Install [nitrogen](https://npmjs.org/nitrogen) as a `devDependency` in your
|
|
15
|
+
Install [nitrogen](https://npmjs.org/nitrogen) as a `devDependency` in your Nitro Module:
|
|
16
16
|
```sh
|
|
17
17
|
npm i nitrogen -D
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Then, generate your specs;
|
|
20
21
|
|
|
22
|
+
```sh
|
|
23
|
+
npx nitrogen
|
|
24
|
+
```
|
|
21
25
|
|
|
22
26
|
## Usage
|
|
23
27
|
|
|
@@ -32,6 +32,12 @@ ${createFileMetadataString(`${name}+autolinking.cmake`, '#')}
|
|
|
32
32
|
# include(\${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/${name}+autolinking.cmake)
|
|
33
33
|
# \`\`\`
|
|
34
34
|
|
|
35
|
+
# Define a flag to check if we are building properly
|
|
36
|
+
add_definitions(-D${buildingWithDefinition})
|
|
37
|
+
|
|
38
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
39
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
40
|
+
|
|
35
41
|
# Add all headers that were generated by Nitrogen
|
|
36
42
|
include_directories(
|
|
37
43
|
"../nitrogen/generated/shared/c++"
|
|
@@ -51,12 +57,9 @@ target_sources(
|
|
|
51
57
|
${indent(androidFiles.join('\n'), ' ')}
|
|
52
58
|
)
|
|
53
59
|
|
|
54
|
-
# Define a flag to check if we are building properly
|
|
55
|
-
add_definitions(-D${buildingWithDefinition})
|
|
56
|
-
|
|
57
60
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
58
61
|
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
59
|
-
|
|
62
|
+
target_compile_definitions(
|
|
60
63
|
${name} PRIVATE
|
|
61
64
|
-DFOLLY_NO_CONFIG=1
|
|
62
65
|
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createIndentation, indent } from '../utils.js';
|
|
2
|
-
import { createFileMetadataString, escapeCppName, isFunction, } from '../syntax/helpers.js';
|
|
2
|
+
import { createFileMetadataString, escapeCppName, isFunction, isNotDuplicate, } from '../syntax/helpers.js';
|
|
3
3
|
import { getHybridObjectName } from '../syntax/getHybridObjectName.js';
|
|
4
4
|
import { includeHeader } from '../syntax/c++/includeNitroHeader.js';
|
|
5
5
|
import { createHostComponentJs } from './createHostComponentJs.js';
|
|
@@ -38,7 +38,9 @@ export function createViewComponentShadowNodeFiles(spec) {
|
|
|
38
38
|
const props = [...spec.properties, getHybridRefProperty(spec)];
|
|
39
39
|
const properties = props.map((p) => `CachedProp<${p.type.getCode('c++')}> ${escapeCppName(p.name)};`);
|
|
40
40
|
const cases = props.map((p) => `case hashString("${p.name}"): return true;`);
|
|
41
|
-
const includes = props
|
|
41
|
+
const includes = props
|
|
42
|
+
.flatMap((p) => p.getRequiredImports('c++').map((i) => includeHeader(i, true)))
|
|
43
|
+
.filter(isNotDuplicate);
|
|
42
44
|
// .hpp code
|
|
43
45
|
const shadowIndent = createIndentation(shadowNodeClassName.length);
|
|
44
46
|
const componentHeaderCode = `
|
|
@@ -89,6 +89,10 @@ ${createFileMetadataString(`J${stateUpdaterName}.hpp`)}
|
|
|
89
89
|
|
|
90
90
|
#pragma once
|
|
91
91
|
|
|
92
|
+
#ifndef RN_SERIALIZABLE_STATE
|
|
93
|
+
#error ${spec.config.getAndroidCxxLibName()} was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
|
|
94
|
+
#endif
|
|
95
|
+
|
|
92
96
|
#include <fbjni/fbjni.h>
|
|
93
97
|
#include <react/fabric/StateWrapperImpl.h>
|
|
94
98
|
#include <react/fabric/CoreComponentsRegistry.h>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitrogen",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.6",
|
|
4
4
|
"description": "The code-generator for react-native-nitro-modules.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"chalk": "^5.3.0",
|
|
39
|
-
"react-native-nitro-modules": "^0.29.
|
|
39
|
+
"react-native-nitro-modules": "^0.29.6",
|
|
40
40
|
"ts-morph": "^25.0.0",
|
|
41
41
|
"yargs": "^17.7.2",
|
|
42
42
|
"zod": "^4.0.5"
|
|
@@ -49,6 +49,12 @@ ${createFileMetadataString(`${name}+autolinking.cmake`, '#')}
|
|
|
49
49
|
# include(\${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/${name}+autolinking.cmake)
|
|
50
50
|
# \`\`\`
|
|
51
51
|
|
|
52
|
+
# Define a flag to check if we are building properly
|
|
53
|
+
add_definitions(-D${buildingWithDefinition})
|
|
54
|
+
|
|
55
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
56
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
57
|
+
|
|
52
58
|
# Add all headers that were generated by Nitrogen
|
|
53
59
|
include_directories(
|
|
54
60
|
"../nitrogen/generated/shared/c++"
|
|
@@ -68,12 +74,9 @@ target_sources(
|
|
|
68
74
|
${indent(androidFiles.join('\n'), ' ')}
|
|
69
75
|
)
|
|
70
76
|
|
|
71
|
-
# Define a flag to check if we are building properly
|
|
72
|
-
add_definitions(-D${buildingWithDefinition})
|
|
73
|
-
|
|
74
77
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
75
78
|
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
76
|
-
|
|
79
|
+
target_compile_definitions(
|
|
77
80
|
${name} PRIVATE
|
|
78
81
|
-DFOLLY_NO_CONFIG=1
|
|
79
82
|
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
createFileMetadataString,
|
|
6
6
|
escapeCppName,
|
|
7
7
|
isFunction,
|
|
8
|
+
isNotDuplicate,
|
|
8
9
|
} from '../syntax/helpers.js'
|
|
9
10
|
import { getHybridObjectName } from '../syntax/getHybridObjectName.js'
|
|
10
11
|
import { includeHeader } from '../syntax/c++/includeNitroHeader.js'
|
|
@@ -75,9 +76,11 @@ export function createViewComponentShadowNodeFiles(
|
|
|
75
76
|
(p) => `CachedProp<${p.type.getCode('c++')}> ${escapeCppName(p.name)};`
|
|
76
77
|
)
|
|
77
78
|
const cases = props.map((p) => `case hashString("${p.name}"): return true;`)
|
|
78
|
-
const includes = props
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const includes = props
|
|
80
|
+
.flatMap((p) =>
|
|
81
|
+
p.getRequiredImports('c++').map((i) => includeHeader(i, true))
|
|
82
|
+
)
|
|
83
|
+
.filter(isNotDuplicate)
|
|
81
84
|
|
|
82
85
|
// .hpp code
|
|
83
86
|
const shadowIndent = createIndentation(shadowNodeClassName.length)
|
|
@@ -115,6 +115,10 @@ ${createFileMetadataString(`J${stateUpdaterName}.hpp`)}
|
|
|
115
115
|
|
|
116
116
|
#pragma once
|
|
117
117
|
|
|
118
|
+
#ifndef RN_SERIALIZABLE_STATE
|
|
119
|
+
#error ${spec.config.getAndroidCxxLibName()} was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
|
|
120
|
+
#endif
|
|
121
|
+
|
|
118
122
|
#include <fbjni/fbjni.h>
|
|
119
123
|
#include <react/fabric/StateWrapperImpl.h>
|
|
120
124
|
#include <react/fabric/CoreComponentsRegistry.h>
|