@bennyblader/ddk-rn 0.2.3 ā 0.2.4
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/android/build.gradle +1 -0
- package/cpp/bennyblader-ddk-rn.cpp +16 -0
- package/cpp/bennyblader-ddk-rn.h +15 -0
- package/package.json +3 -5
- package/scripts/postinstall.js +24 -58
- package/src/NativeDdkRn.ts +10 -0
- package/src/index.tsx +41 -0
package/android/build.gradle
CHANGED
|
@@ -133,6 +133,7 @@ dependencies {
|
|
|
133
133
|
//noinspection GradleDynamicVersion
|
|
134
134
|
implementation "com.facebook.react:react-native:+"
|
|
135
135
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
136
|
+
implementation "net.java.dev.jna:jna:5.17.0@aar"
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
if (isNewArchitectureEnabled()) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include "bennyblader-ddk-rn.h"
|
|
3
|
+
#include "/ddk_ffi.hpp"
|
|
4
|
+
|
|
5
|
+
namespace bennyblader_ddkrn {
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
|
9
|
+
NativeDdkFfi::registerModule(runtime, callInvoker);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef BENNYBLADER_DDKRN_H
|
|
2
|
+
#define BENNYBLADER_DDKRN_H
|
|
3
|
+
// Generated by uniffi-bindgen-react-native
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
#include <ReactCommon/CallInvoker.h>
|
|
7
|
+
|
|
8
|
+
namespace bennyblader_ddkrn {
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker);
|
|
12
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#endif /* BENNYBLADER_DDKRN_H */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bennyblader/ddk-rn",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "dlcdevkit bindings for react-native",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -19,10 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"src
|
|
23
|
-
"
|
|
24
|
-
"cpp/ddk_ffi.hpp",
|
|
25
|
-
"cpp/ddk_ffi.cpp",
|
|
22
|
+
"src",
|
|
23
|
+
"cpp",
|
|
26
24
|
"lib",
|
|
27
25
|
"android/build.gradle",
|
|
28
26
|
"android/CMakeLists.txt",
|
package/scripts/postinstall.js
CHANGED
|
@@ -6,7 +6,7 @@ const { execSync } = require('child_process');
|
|
|
6
6
|
|
|
7
7
|
const packageRoot = path.join(__dirname, '..');
|
|
8
8
|
|
|
9
|
-
console.log('š¦ DDK-RN Post-install:
|
|
9
|
+
console.log('š¦ DDK-RN Post-install: Building native libraries...');
|
|
10
10
|
|
|
11
11
|
// Check if uniffi-bindgen-react-native is available (prefer npx)
|
|
12
12
|
function hasUniffiBingen() {
|
|
@@ -40,26 +40,6 @@ function ensureDir(dir) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// Generate turbo module specifications from existing JSI bindings
|
|
44
|
-
function generateTurboModule() {
|
|
45
|
-
console.log('\nā” Generating turbo module from existing bindings...');
|
|
46
|
-
|
|
47
|
-
const configFile = path.join(packageRoot, 'ubrn.config.yaml');
|
|
48
|
-
const uniffiCmd = getUniffiCommand();
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const cmd = `${uniffiCmd} generate jsi turbo-module ddk_ffi --config "${configFile}" --native-bindings`;
|
|
52
|
-
console.log(`Running: ${cmd}`);
|
|
53
|
-
execSync(cmd, {
|
|
54
|
-
stdio: 'inherit',
|
|
55
|
-
cwd: packageRoot
|
|
56
|
-
});
|
|
57
|
-
console.log('ā
Turbo module generated');
|
|
58
|
-
} catch (error) {
|
|
59
|
-
throw new Error(`Failed to generate turbo module: ${error.message}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
43
|
// Build iOS libraries and create XCFramework
|
|
64
44
|
function buildIOS() {
|
|
65
45
|
const platform = process.platform;
|
|
@@ -112,7 +92,7 @@ function buildAndroid() {
|
|
|
112
92
|
}
|
|
113
93
|
}
|
|
114
94
|
|
|
115
|
-
// Fix the C++ include path issue
|
|
95
|
+
// Fix the C++ include path issue if needed
|
|
116
96
|
function fixCppIncludePath() {
|
|
117
97
|
const cppFile = path.join(packageRoot, 'cpp', 'bennyblader-ddk-rn.cpp');
|
|
118
98
|
if (fs.existsSync(cppFile)) {
|
|
@@ -129,14 +109,13 @@ function fixCppIncludePath() {
|
|
|
129
109
|
function verifyAllFiles() {
|
|
130
110
|
console.log('\nš Verifying installation...');
|
|
131
111
|
|
|
132
|
-
const
|
|
112
|
+
const requiredFiles = [
|
|
113
|
+
// Core JSI bindings (shipped with package)
|
|
133
114
|
'src/ddk_ffi.ts',
|
|
134
115
|
'src/ddk_ffi-ffi.ts',
|
|
135
116
|
'cpp/ddk_ffi.hpp',
|
|
136
|
-
'cpp/ddk_ffi.cpp'
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const generatedFiles = [
|
|
117
|
+
'cpp/ddk_ffi.cpp',
|
|
118
|
+
// Generated turbo module files (shipped with package)
|
|
140
119
|
'src/NativeDdkRn.ts',
|
|
141
120
|
'src/index.tsx',
|
|
142
121
|
'cpp/bennyblader-ddk-rn.cpp',
|
|
@@ -146,21 +125,9 @@ function verifyAllFiles() {
|
|
|
146
125
|
const platform = process.platform;
|
|
147
126
|
let allFilesPresent = true;
|
|
148
127
|
|
|
149
|
-
// Check
|
|
150
|
-
console.log('š Checking
|
|
151
|
-
for (const file of
|
|
152
|
-
const filePath = path.join(packageRoot, file);
|
|
153
|
-
if (fs.existsSync(filePath)) {
|
|
154
|
-
console.log(` ā
${file}`);
|
|
155
|
-
} else {
|
|
156
|
-
console.error(` ā Missing: ${file}`);
|
|
157
|
-
allFilesPresent = false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Check generated files (created by postinstall)
|
|
162
|
-
console.log('š Checking generated files...');
|
|
163
|
-
for (const file of generatedFiles) {
|
|
128
|
+
// Check required files
|
|
129
|
+
console.log('š Checking required files...');
|
|
130
|
+
for (const file of requiredFiles) {
|
|
164
131
|
const filePath = path.join(packageRoot, file);
|
|
165
132
|
if (fs.existsSync(filePath)) {
|
|
166
133
|
console.log(` ā
${file}`);
|
|
@@ -170,18 +137,15 @@ function verifyAllFiles() {
|
|
|
170
137
|
}
|
|
171
138
|
}
|
|
172
139
|
|
|
173
|
-
// Check platform-specific files
|
|
140
|
+
// Check platform-specific files (generated during postinstall)
|
|
174
141
|
if (platform === 'darwin') {
|
|
175
142
|
console.log('š Checking iOS framework...');
|
|
176
143
|
const iosFramework = path.join(packageRoot, 'ios', 'DdkRn.xcframework', 'Info.plist');
|
|
177
144
|
if (fs.existsSync(iosFramework)) {
|
|
178
145
|
console.log(` ā
ios/DdkRn.xcframework`);
|
|
179
146
|
} else {
|
|
180
|
-
console.
|
|
181
|
-
allFilesPresent = false;
|
|
147
|
+
console.log(` ā ļø iOS framework not built yet (will be built on first use)`);
|
|
182
148
|
}
|
|
183
|
-
} else {
|
|
184
|
-
console.log('š Skipping iOS framework check (not on macOS)');
|
|
185
149
|
}
|
|
186
150
|
|
|
187
151
|
console.log('š Checking Android libraries...');
|
|
@@ -196,15 +160,12 @@ function verifyAllFiles() {
|
|
|
196
160
|
for (const lib of androidLibs) {
|
|
197
161
|
const libPath = path.join(packageRoot, lib);
|
|
198
162
|
if (fs.existsSync(libPath)) {
|
|
199
|
-
console.log(` ā
${lib}`);
|
|
200
163
|
androidLibsPresent++;
|
|
201
|
-
} else {
|
|
202
|
-
console.log(` ā ļø Missing: ${lib}`);
|
|
203
164
|
}
|
|
204
165
|
}
|
|
205
166
|
|
|
206
167
|
if (androidLibsPresent === 0) {
|
|
207
|
-
console.log(' ā ļø
|
|
168
|
+
console.log(' ā ļø Android libraries not built yet (may be due to missing NDK)');
|
|
208
169
|
} else {
|
|
209
170
|
console.log(` ā
Found ${androidLibsPresent}/${androidLibs.length} Android libraries`);
|
|
210
171
|
}
|
|
@@ -214,9 +175,9 @@ function verifyAllFiles() {
|
|
|
214
175
|
|
|
215
176
|
async function main() {
|
|
216
177
|
// Skip in CI unless explicitly requested
|
|
217
|
-
if (process.env.CI && !process.env.
|
|
218
|
-
console.log('ā ļø Skipping
|
|
219
|
-
console.log(' Set
|
|
178
|
+
if (process.env.CI && !process.env.BUILD_NATIVE_LIBS) {
|
|
179
|
+
console.log('ā ļø Skipping native library builds in CI environment.');
|
|
180
|
+
console.log(' Set BUILD_NATIVE_LIBS=1 to force builds in CI.');
|
|
220
181
|
process.exit(0);
|
|
221
182
|
}
|
|
222
183
|
|
|
@@ -232,8 +193,12 @@ async function main() {
|
|
|
232
193
|
const sourceFiles = [
|
|
233
194
|
'src/ddk_ffi.ts',
|
|
234
195
|
'src/ddk_ffi-ffi.ts',
|
|
196
|
+
'src/NativeDdkRn.ts',
|
|
197
|
+
'src/index.tsx',
|
|
235
198
|
'cpp/ddk_ffi.hpp',
|
|
236
|
-
'cpp/ddk_ffi.cpp'
|
|
199
|
+
'cpp/ddk_ffi.cpp',
|
|
200
|
+
'cpp/bennyblader-ddk-rn.cpp',
|
|
201
|
+
'cpp/bennyblader-ddk-rn.h'
|
|
237
202
|
];
|
|
238
203
|
|
|
239
204
|
console.log('š Checking source files...');
|
|
@@ -248,9 +213,10 @@ async function main() {
|
|
|
248
213
|
console.log('ā
All source files present');
|
|
249
214
|
|
|
250
215
|
try {
|
|
251
|
-
//
|
|
252
|
-
generateTurboModule();
|
|
216
|
+
// Fix include path if needed
|
|
253
217
|
fixCppIncludePath();
|
|
218
|
+
|
|
219
|
+
// Build native libraries only (turbo module already generated)
|
|
254
220
|
buildIOS();
|
|
255
221
|
buildAndroid();
|
|
256
222
|
|
|
@@ -263,7 +229,7 @@ async function main() {
|
|
|
263
229
|
process.exit(1);
|
|
264
230
|
}
|
|
265
231
|
|
|
266
|
-
console.log('\nā
|
|
232
|
+
console.log('\nā
Installation completed successfully!');
|
|
267
233
|
console.log('š DDK-RN is ready to use!\n');
|
|
268
234
|
|
|
269
235
|
} catch (error) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
installRustCrate(): boolean;
|
|
7
|
+
cleanupRustCrate(): boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('DdkRn');
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
import installer from './NativeDdkRn';
|
|
3
|
+
|
|
4
|
+
// Register the rust crate with Hermes
|
|
5
|
+
// - the boolean flag ensures this loads exactly once, even if the JS
|
|
6
|
+
// code is reloaded (e.g. during development with metro).
|
|
7
|
+
let rustInstalled = false;
|
|
8
|
+
if (!rustInstalled) {
|
|
9
|
+
installer.installRustCrate();
|
|
10
|
+
rustInstalled = true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Export the generated bindings to the app.
|
|
14
|
+
export * from './/ddk_ffi';
|
|
15
|
+
|
|
16
|
+
// Now import the bindings so we can:
|
|
17
|
+
// - intialize them
|
|
18
|
+
// - export them as namespaced objects as the default export.
|
|
19
|
+
import * as ddk_ffi from './/ddk_ffi';
|
|
20
|
+
|
|
21
|
+
// Initialize the generated bindings: mostly checksums, but also callbacks.
|
|
22
|
+
// - the boolean flag ensures this loads exactly once, even if the JS code
|
|
23
|
+
// is reloaded (e.g. during development with metro).
|
|
24
|
+
let initialized = false;
|
|
25
|
+
if (!initialized) {
|
|
26
|
+
ddk_ffi.default.initialize();
|
|
27
|
+
initialized = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// This provides parity with the index.web.ts version of this file.
|
|
31
|
+
// The web version relies on an asynchronous fetch, which this doesn't
|
|
32
|
+
// need, so we just no-op.
|
|
33
|
+
export async function uniffiInitAsync() {
|
|
34
|
+
// NOOP.
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Export the crates as individually namespaced objects.
|
|
38
|
+
export default {
|
|
39
|
+
ddk_ffi,
|
|
40
|
+
};
|
|
41
|
+
|