@bennyblader/ddk-rn 0.2.4 ā 0.2.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.
- package/ddk-ffi/Cargo.lock +1096 -0
- package/ddk-ffi/Cargo.toml +31 -0
- package/ddk-ffi/build.rs +3 -0
- package/ddk-ffi/rust-toolchain.toml +10 -0
- package/ddk-ffi/scratchpad.txt +243 -0
- package/ddk-ffi/src/ddk_ffi.udl +230 -0
- package/ddk-ffi/src/lib.rs +1093 -0
- package/ddk-ffi/src/uniffi-bindgen.rs +3 -0
- package/ddk-ffi/uniffi.toml +18 -0
- package/package.json +4 -1
- package/scripts/postinstall.js +45 -3
- package/scripts/prepare-rust-src.js +51 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# uniffi.toml
|
|
2
|
+
[bindings.typescript]
|
|
3
|
+
logLevel = "verbose"
|
|
4
|
+
|
|
5
|
+
[bindings.cpp]
|
|
6
|
+
|
|
7
|
+
[turbo_module]
|
|
8
|
+
# The name of your Turbo Module as it appears in React Native
|
|
9
|
+
name = "Ddk"
|
|
10
|
+
# The iOS framework name
|
|
11
|
+
ios_framework = "Ddk"
|
|
12
|
+
# The Android package name
|
|
13
|
+
android_package = "dev.bennyblader.ddk"
|
|
14
|
+
|
|
15
|
+
[namespace.ddk_ffi]
|
|
16
|
+
# Configuration specific to your ddk_ffi namespace
|
|
17
|
+
# This tells the generator how to handle this particular namespace
|
|
18
|
+
js_module_name = "Ddk"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bennyblader/ddk-rn",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "dlcdevkit bindings for react-native",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"src",
|
|
23
23
|
"cpp",
|
|
24
24
|
"lib",
|
|
25
|
+
"ddk-ffi",
|
|
25
26
|
"android/build.gradle",
|
|
26
27
|
"android/CMakeLists.txt",
|
|
27
28
|
"android/cpp-adapter.cpp",
|
|
@@ -33,10 +34,12 @@
|
|
|
33
34
|
"ios/DdkRn.h",
|
|
34
35
|
"ios/DdkRn.mm",
|
|
35
36
|
"scripts/postinstall.js",
|
|
37
|
+
"scripts/prepare-rust-src.js",
|
|
36
38
|
"ubrn.config.yaml",
|
|
37
39
|
"*.podspec",
|
|
38
40
|
"react-native.config.js",
|
|
39
41
|
"README.md",
|
|
42
|
+
"!ddk-ffi/target",
|
|
40
43
|
"!**/*.a",
|
|
41
44
|
"!**/*.so",
|
|
42
45
|
"!**/*.dylib",
|
package/scripts/postinstall.js
CHANGED
|
@@ -5,6 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const { execSync } = require('child_process');
|
|
6
6
|
|
|
7
7
|
const packageRoot = path.join(__dirname, '..');
|
|
8
|
+
const ddkFfiRoot = path.join(packageRoot, 'ddk-ffi');
|
|
8
9
|
|
|
9
10
|
console.log('š¦ DDK-RN Post-install: Building native libraries...');
|
|
10
11
|
|
|
@@ -52,6 +53,9 @@ function buildIOS() {
|
|
|
52
53
|
console.log('\nš Building iOS libraries...');
|
|
53
54
|
const uniffiCmd = getUniffiCommand();
|
|
54
55
|
|
|
56
|
+
// Update ubrn.config.yaml to point to the included Rust source
|
|
57
|
+
updateConfigFile();
|
|
58
|
+
|
|
55
59
|
try {
|
|
56
60
|
const cmd = `${uniffiCmd} build ios --and-generate`;
|
|
57
61
|
console.log(`Running: ${cmd}`);
|
|
@@ -78,6 +82,9 @@ function buildAndroid() {
|
|
|
78
82
|
|
|
79
83
|
const uniffiCmd = getUniffiCommand();
|
|
80
84
|
|
|
85
|
+
// Update ubrn.config.yaml to point to the included Rust source
|
|
86
|
+
updateConfigFile();
|
|
87
|
+
|
|
81
88
|
try {
|
|
82
89
|
const cmd = `${uniffiCmd} build android --and-generate`;
|
|
83
90
|
console.log(`Running: ${cmd}`);
|
|
@@ -92,6 +99,25 @@ function buildAndroid() {
|
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
|
|
102
|
+
// Update the ubrn.config.yaml to use the local Rust source
|
|
103
|
+
function updateConfigFile() {
|
|
104
|
+
const configPath = path.join(packageRoot, 'ubrn.config.yaml');
|
|
105
|
+
|
|
106
|
+
if (fs.existsSync(configPath)) {
|
|
107
|
+
let config = fs.readFileSync(configPath, 'utf8');
|
|
108
|
+
|
|
109
|
+
// Update the Rust directory to point to the included ddk-ffi
|
|
110
|
+
if (!config.includes('directory: ddk-ffi')) {
|
|
111
|
+
config = config.replace(
|
|
112
|
+
/rust:\s*\n\s*directory:\s*[^\n]+/,
|
|
113
|
+
'rust:\n directory: ddk-ffi'
|
|
114
|
+
);
|
|
115
|
+
fs.writeFileSync(configPath, config);
|
|
116
|
+
console.log('š Updated config to use included Rust source');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
95
121
|
// Fix the C++ include path issue if needed
|
|
96
122
|
function fixCppIncludePath() {
|
|
97
123
|
const cppFile = path.join(packageRoot, 'cpp', 'bennyblader-ddk-rn.cpp');
|
|
@@ -119,7 +145,11 @@ function verifyAllFiles() {
|
|
|
119
145
|
'src/NativeDdkRn.ts',
|
|
120
146
|
'src/index.tsx',
|
|
121
147
|
'cpp/bennyblader-ddk-rn.cpp',
|
|
122
|
-
'cpp/bennyblader-ddk-rn.h'
|
|
148
|
+
'cpp/bennyblader-ddk-rn.h',
|
|
149
|
+
// Rust source (shipped with package)
|
|
150
|
+
'ddk-ffi/Cargo.toml',
|
|
151
|
+
'ddk-ffi/src/lib.rs',
|
|
152
|
+
'ddk-ffi/src/ddk_ffi.udl'
|
|
123
153
|
];
|
|
124
154
|
|
|
125
155
|
const platform = process.platform;
|
|
@@ -144,7 +174,7 @@ function verifyAllFiles() {
|
|
|
144
174
|
if (fs.existsSync(iosFramework)) {
|
|
145
175
|
console.log(` ā
ios/DdkRn.xcframework`);
|
|
146
176
|
} else {
|
|
147
|
-
console.log(` ā ļø iOS framework not built yet (will be built
|
|
177
|
+
console.log(` ā ļø iOS framework not built yet (will be built now)`);
|
|
148
178
|
}
|
|
149
179
|
}
|
|
150
180
|
|
|
@@ -189,6 +219,14 @@ async function main() {
|
|
|
189
219
|
process.exit(1);
|
|
190
220
|
}
|
|
191
221
|
|
|
222
|
+
// Check if Rust source is included
|
|
223
|
+
if (!fs.existsSync(ddkFfiRoot)) {
|
|
224
|
+
console.error('ā Rust source not found in package!');
|
|
225
|
+
console.error(` Expected at: ${ddkFfiRoot}`);
|
|
226
|
+
console.error(' This indicates a problem with the NPM package.');
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
|
|
192
230
|
// Verify source files are present (should be included in NPM package)
|
|
193
231
|
const sourceFiles = [
|
|
194
232
|
'src/ddk_ffi.ts',
|
|
@@ -198,7 +236,10 @@ async function main() {
|
|
|
198
236
|
'cpp/ddk_ffi.hpp',
|
|
199
237
|
'cpp/ddk_ffi.cpp',
|
|
200
238
|
'cpp/bennyblader-ddk-rn.cpp',
|
|
201
|
-
'cpp/bennyblader-ddk-rn.h'
|
|
239
|
+
'cpp/bennyblader-ddk-rn.h',
|
|
240
|
+
'ddk-ffi/Cargo.toml',
|
|
241
|
+
'ddk-ffi/src/lib.rs',
|
|
242
|
+
'ddk-ffi/src/ddk_ffi.udl'
|
|
202
243
|
];
|
|
203
244
|
|
|
204
245
|
console.log('š Checking source files...');
|
|
@@ -239,6 +280,7 @@ async function main() {
|
|
|
239
280
|
console.error(' - Missing uniffi-bindgen-react-native (install globally)');
|
|
240
281
|
console.error(' - Missing Android NDK (for Android builds)');
|
|
241
282
|
console.error(' - Missing Xcode/iOS toolchain (for iOS builds on macOS)');
|
|
283
|
+
console.error(' - Missing Rust toolchain');
|
|
242
284
|
console.error('');
|
|
243
285
|
console.error('Report issues at: https://github.com/bennyhodl/ddk-ffi/issues');
|
|
244
286
|
process.exit(1);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const ddkRnRoot = path.join(__dirname, '..');
|
|
8
|
+
const projectRoot = path.join(ddkRnRoot, '..');
|
|
9
|
+
const ddkFfiSource = path.join(projectRoot, 'ddk-ffi');
|
|
10
|
+
const ddkFfiDest = path.join(ddkRnRoot, 'ddk-ffi');
|
|
11
|
+
|
|
12
|
+
console.log('š¦ Preparing Rust source for npm package...');
|
|
13
|
+
|
|
14
|
+
function copyDirectory(src, dest) {
|
|
15
|
+
// Remove existing destination if it exists
|
|
16
|
+
if (fs.existsSync(dest)) {
|
|
17
|
+
console.log(`šļø Removing existing ${path.basename(dest)}...`);
|
|
18
|
+
execSync(`rm -rf "${dest}"`, { stdio: 'inherit' });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Create destination directory
|
|
22
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
23
|
+
|
|
24
|
+
// Copy all files except target directory
|
|
25
|
+
console.log(`š Copying ${path.basename(src)} to ${path.basename(dest)}...`);
|
|
26
|
+
execSync(`rsync -av --exclude=target/ --exclude=.git/ "${src}/" "${dest}/"`, {
|
|
27
|
+
stdio: 'inherit'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function main() {
|
|
32
|
+
try {
|
|
33
|
+
// Check if source exists
|
|
34
|
+
if (!fs.existsSync(ddkFfiSource)) {
|
|
35
|
+
console.error(`ā Source directory not found: ${ddkFfiSource}`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Copy the Rust source
|
|
40
|
+
copyDirectory(ddkFfiSource, ddkFfiDest);
|
|
41
|
+
|
|
42
|
+
console.log('ā
Rust source prepared for npm package');
|
|
43
|
+
console.log(`š Location: ${ddkFfiDest}`);
|
|
44
|
+
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('ā Failed to prepare Rust source:', error.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
main();
|