@bennyblader/ddk-rn 0.2.1 → 0.2.3
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/cpp/ddk_ffi.cpp +36 -0
- package/cpp/ddk_ffi.hpp +2 -0
- package/lib/commonjs/ddk_ffi-ffi.js.map +1 -1
- package/lib/commonjs/ddk_ffi.js +12 -0
- package/lib/commonjs/ddk_ffi.js.map +1 -1
- package/lib/module/ddk_ffi-ffi.js.map +1 -1
- package/lib/module/ddk_ffi.js +11 -0
- package/lib/module/ddk_ffi.js.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts +2 -0
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts +1 -0
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts +2 -0
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi.d.ts +1 -0
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +1 -1
- package/package.json +20 -12
- package/react-native.config.js +13 -0
- package/scripts/postinstall.js +226 -173
- package/src/ddk_ffi-ffi.ts +4 -0
- package/src/ddk_ffi.ts +18 -0
- package/ubrn.config.yaml +23 -0
- package/cpp/bennyblader-ddk-rn.cpp +0 -16
- package/cpp/bennyblader-ddk-rn.h +0 -15
- package/src/NativeDdkRn.ts +0 -10
- package/src/index.tsx +0 -41
package/scripts/postinstall.js
CHANGED
|
@@ -2,48 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const https = require('https');
|
|
6
5
|
const { execSync } = require('child_process');
|
|
7
6
|
|
|
8
7
|
const packageRoot = path.join(__dirname, '..');
|
|
9
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
10
|
-
const version = packageJson.version;
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
const RELEASE_TAG = `v${version}`;
|
|
9
|
+
console.log('📦 DDK-RN Post-install: Generating turbo modules and building native libraries...');
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
// Check if uniffi-bindgen-react-native is available (prefer npx)
|
|
12
|
+
function hasUniffiBingen() {
|
|
13
|
+
try {
|
|
14
|
+
execSync('npx uniffi-bindgen-react-native --help', { stdio: 'ignore' });
|
|
15
|
+
return true;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
try {
|
|
18
|
+
execSync('uniffi-bindgen-react-native --help', { stdio: 'ignore' });
|
|
19
|
+
return true;
|
|
20
|
+
} catch (error2) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
16
25
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'cpp/ddk_ffi.hpp',
|
|
27
|
-
'cpp/ddk_ffi.cpp',
|
|
28
|
-
'cpp/bennyblader-ddk-rn.h',
|
|
29
|
-
'cpp/bennyblader-ddk-rn.cpp'
|
|
30
|
-
],
|
|
31
|
-
'Android libraries': [
|
|
32
|
-
'android/src/main/arm64-v8a/libddk_ffi.a',
|
|
33
|
-
'android/src/main/armeabi-v7a/libddk_ffi.a',
|
|
34
|
-
'android/src/main/x86/libddk_ffi.a',
|
|
35
|
-
'android/src/main/x86_64/libddk_ffi.a'
|
|
36
|
-
],
|
|
37
|
-
'iOS framework': [
|
|
38
|
-
'ios/DdkRn.xcframework/Info.plist',
|
|
39
|
-
'ios/DdkRn.xcframework/ios-arm64/libddk_ffi.a',
|
|
40
|
-
'ios/DdkRn.xcframework/ios-arm64-simulator/libddk_ffi.a'
|
|
41
|
-
],
|
|
42
|
-
'JavaScript modules': [
|
|
43
|
-
'lib/commonjs/index.js',
|
|
44
|
-
'lib/module/index.js'
|
|
45
|
-
]
|
|
46
|
-
};
|
|
26
|
+
// Get the uniffi command (prefer npx)
|
|
27
|
+
function getUniffiCommand() {
|
|
28
|
+
try {
|
|
29
|
+
execSync('npx uniffi-bindgen-react-native --help', { stdio: 'ignore' });
|
|
30
|
+
return 'npx uniffi-bindgen-react-native';
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return 'uniffi-bindgen-react-native';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
47
35
|
|
|
48
36
|
// Create directories if they don't exist
|
|
49
37
|
function ensureDir(dir) {
|
|
@@ -52,178 +40,243 @@ function ensureDir(dir) {
|
|
|
52
40
|
}
|
|
53
41
|
}
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
63
|
-
// Follow redirect
|
|
64
|
-
return downloadFile(response.headers.location, dest).then(resolve).catch(reject);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (response.statusCode !== 200) {
|
|
68
|
-
reject(new Error(`Failed to download: ${response.statusCode} ${response.statusMessage}`));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
response.pipe(file);
|
|
73
|
-
|
|
74
|
-
file.on('finish', () => {
|
|
75
|
-
file.close();
|
|
76
|
-
console.log(`✅ Downloaded ${path.basename(dest)}`);
|
|
77
|
-
resolve();
|
|
78
|
-
});
|
|
79
|
-
}).on('error', (err) => {
|
|
80
|
-
fs.unlink(dest, () => {}); // Delete partial file
|
|
81
|
-
reject(err);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function extractTarGz(tarPath, extractDir) {
|
|
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
|
+
|
|
87
50
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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');
|
|
91
58
|
} catch (error) {
|
|
92
|
-
throw new Error(`Failed to
|
|
59
|
+
throw new Error(`Failed to generate turbo module: ${error.message}`);
|
|
93
60
|
}
|
|
94
61
|
}
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let allFilesPresent = true;
|
|
63
|
+
// Build iOS libraries and create XCFramework
|
|
64
|
+
function buildIOS() {
|
|
100
65
|
const platform = process.platform;
|
|
101
66
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log(`\n⚠️ Skipping ${category} verification (not on macOS)`);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
console.log(`\n📋 Checking ${category}...`);
|
|
110
|
-
|
|
111
|
-
for (const file of files) {
|
|
112
|
-
const filePath = path.join(packageRoot, file);
|
|
113
|
-
if (fs.existsSync(filePath)) {
|
|
114
|
-
console.log(` ✅ ${file}`);
|
|
115
|
-
} else {
|
|
116
|
-
console.error(` ❌ Missing: ${file}`);
|
|
117
|
-
allFilesPresent = false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
67
|
+
if (platform !== 'darwin') {
|
|
68
|
+
console.log('\n⚠️ Skipping iOS build (not on macOS)');
|
|
69
|
+
return;
|
|
120
70
|
}
|
|
121
71
|
|
|
122
|
-
|
|
72
|
+
console.log('\n🍎 Building iOS libraries...');
|
|
73
|
+
const uniffiCmd = getUniffiCommand();
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const cmd = `${uniffiCmd} build ios --and-generate`;
|
|
77
|
+
console.log(`Running: ${cmd}`);
|
|
78
|
+
execSync(cmd, {
|
|
79
|
+
stdio: 'inherit',
|
|
80
|
+
cwd: packageRoot
|
|
81
|
+
});
|
|
82
|
+
console.log('✅ iOS libraries built');
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw new Error(`Failed to build iOS libraries: ${error.message}`);
|
|
85
|
+
}
|
|
123
86
|
}
|
|
124
87
|
|
|
125
|
-
|
|
126
|
-
|
|
88
|
+
// Build Android libraries
|
|
89
|
+
function buildAndroid() {
|
|
90
|
+
console.log('\n📱 Building Android libraries...');
|
|
91
|
+
|
|
92
|
+
// Check if Android NDK is available
|
|
93
|
+
if (!process.env.ANDROID_NDK_ROOT && !process.env.NDK_HOME) {
|
|
94
|
+
console.log('⚠️ Android NDK not found. Skipping Android build.');
|
|
95
|
+
console.log(' Set ANDROID_NDK_ROOT or NDK_HOME to build Android libraries.');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const uniffiCmd = getUniffiCommand();
|
|
127
100
|
|
|
128
101
|
try {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
console.log('\n📱 Setting up Android native libraries...');
|
|
137
|
-
await downloadFile(androidArchiveUrl, androidTarPath);
|
|
138
|
-
extractTarGz(androidTarPath, androidLibsDir);
|
|
139
|
-
fs.unlinkSync(androidTarPath); // Clean up tar file
|
|
140
|
-
|
|
141
|
-
// Download iOS XCFramework (only on macOS)
|
|
142
|
-
if (platform === 'darwin') {
|
|
143
|
-
const iosFrameworksDir = path.join(packageRoot, 'ios');
|
|
144
|
-
ensureDir(iosFrameworksDir);
|
|
145
|
-
|
|
146
|
-
const iosArchiveUrl = `https://github.com/${GITHUB_REPO}/releases/download/${RELEASE_TAG}/ios-xcframeworks.tar.gz`;
|
|
147
|
-
const iosTarPath = path.join(packageRoot, 'ios-xcframeworks.tar.gz');
|
|
148
|
-
|
|
149
|
-
console.log('\n🍎 Setting up iOS framework...');
|
|
150
|
-
await downloadFile(iosArchiveUrl, iosTarPath);
|
|
151
|
-
extractTarGz(iosTarPath, iosFrameworksDir);
|
|
152
|
-
fs.unlinkSync(iosTarPath); // Clean up tar file
|
|
153
|
-
} else {
|
|
154
|
-
console.log('\n⚠️ Skipping iOS framework (not on macOS)');
|
|
155
|
-
}
|
|
156
|
-
|
|
102
|
+
const cmd = `${uniffiCmd} build android --and-generate`;
|
|
103
|
+
console.log(`Running: ${cmd}`);
|
|
104
|
+
execSync(cmd, {
|
|
105
|
+
stdio: 'inherit',
|
|
106
|
+
cwd: packageRoot
|
|
107
|
+
});
|
|
108
|
+
console.log('✅ Android libraries built');
|
|
157
109
|
} catch (error) {
|
|
158
|
-
console.
|
|
159
|
-
console.
|
|
160
|
-
console.error('📋 Manual installation instructions:');
|
|
161
|
-
console.error(` 1. Download binaries from: https://github.com/${GITHUB_REPO}/releases/tag/${RELEASE_TAG}`);
|
|
162
|
-
console.error(' 2. Extract android-jni-libs.tar.gz to android/src/main/');
|
|
163
|
-
console.error(' 3. Extract ios-xcframeworks.tar.gz to ios/ (macOS only)');
|
|
164
|
-
console.error('');
|
|
165
|
-
console.error('Or report this issue at: https://github.com/bennyhodl/ddk-ffi/issues');
|
|
166
|
-
|
|
167
|
-
// Don't fail the installation completely
|
|
168
|
-
process.exit(0);
|
|
110
|
+
console.warn(`⚠️ Android build failed: ${error.message}`);
|
|
111
|
+
console.warn(' This may be due to missing Android NDK or Rust toolchains.');
|
|
169
112
|
}
|
|
170
113
|
}
|
|
171
114
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
115
|
+
// Fix the C++ include path issue
|
|
116
|
+
function fixCppIncludePath() {
|
|
117
|
+
const cppFile = path.join(packageRoot, 'cpp', 'bennyblader-ddk-rn.cpp');
|
|
118
|
+
if (fs.existsSync(cppFile)) {
|
|
119
|
+
let content = fs.readFileSync(cppFile, 'utf8');
|
|
120
|
+
if (content.includes('#include "/ddk_ffi.hpp"')) {
|
|
121
|
+
content = content.replace('#include "/ddk_ffi.hpp"', '#include "ddk_ffi.hpp"');
|
|
122
|
+
fs.writeFileSync(cppFile, content);
|
|
123
|
+
console.log('🔧 Fixed include path in C++ bindings');
|
|
124
|
+
}
|
|
180
125
|
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Verify all required files are present
|
|
129
|
+
function verifyAllFiles() {
|
|
130
|
+
console.log('\n🔍 Verifying installation...');
|
|
181
131
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
132
|
+
const sourceFiles = [
|
|
133
|
+
'src/ddk_ffi.ts',
|
|
134
|
+
'src/ddk_ffi-ffi.ts',
|
|
135
|
+
'cpp/ddk_ffi.hpp',
|
|
136
|
+
'cpp/ddk_ffi.cpp'
|
|
137
|
+
];
|
|
185
138
|
|
|
186
|
-
|
|
139
|
+
const generatedFiles = [
|
|
140
|
+
'src/NativeDdkRn.ts',
|
|
141
|
+
'src/index.tsx',
|
|
142
|
+
'cpp/bennyblader-ddk-rn.cpp',
|
|
143
|
+
'cpp/bennyblader-ddk-rn.h'
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
const platform = process.platform;
|
|
147
|
+
let allFilesPresent = true;
|
|
187
148
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
149
|
+
// Check source files (should be included in NPM package)
|
|
150
|
+
console.log('📋 Checking source files...');
|
|
151
|
+
for (const file of sourceFiles) {
|
|
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
|
+
}
|
|
191
159
|
}
|
|
192
160
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
161
|
+
// Check generated files (created by postinstall)
|
|
162
|
+
console.log('📋 Checking generated files...');
|
|
163
|
+
for (const file of generatedFiles) {
|
|
164
|
+
const filePath = path.join(packageRoot, file);
|
|
165
|
+
if (fs.existsSync(filePath)) {
|
|
166
|
+
console.log(` ✅ ${file}`);
|
|
167
|
+
} else {
|
|
168
|
+
console.error(` ❌ Missing: ${file}`);
|
|
169
|
+
allFilesPresent = false;
|
|
170
|
+
}
|
|
196
171
|
}
|
|
197
172
|
|
|
198
|
-
|
|
199
|
-
|
|
173
|
+
// Check platform-specific files
|
|
174
|
+
if (platform === 'darwin') {
|
|
175
|
+
console.log('📋 Checking iOS framework...');
|
|
176
|
+
const iosFramework = path.join(packageRoot, 'ios', 'DdkRn.xcframework', 'Info.plist');
|
|
177
|
+
if (fs.existsSync(iosFramework)) {
|
|
178
|
+
console.log(` ✅ ios/DdkRn.xcframework`);
|
|
179
|
+
} else {
|
|
180
|
+
console.error(` ❌ Missing: ios/DdkRn.xcframework`);
|
|
181
|
+
allFilesPresent = false;
|
|
182
|
+
}
|
|
200
183
|
} else {
|
|
201
|
-
console.log('
|
|
184
|
+
console.log('📋 Skipping iOS framework check (not on macOS)');
|
|
202
185
|
}
|
|
203
186
|
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
187
|
+
console.log('📋 Checking Android libraries...');
|
|
188
|
+
const androidLibs = [
|
|
189
|
+
'android/src/main/arm64-v8a/libddk_ffi.a',
|
|
190
|
+
'android/src/main/armeabi-v7a/libddk_ffi.a',
|
|
191
|
+
'android/src/main/x86/libddk_ffi.a',
|
|
192
|
+
'android/src/main/x86_64/libddk_ffi.a'
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
let androidLibsPresent = 0;
|
|
196
|
+
for (const lib of androidLibs) {
|
|
197
|
+
const libPath = path.join(packageRoot, lib);
|
|
198
|
+
if (fs.existsSync(libPath)) {
|
|
199
|
+
console.log(` ✅ ${lib}`);
|
|
200
|
+
androidLibsPresent++;
|
|
201
|
+
} else {
|
|
202
|
+
console.log(` ⚠️ Missing: ${lib}`);
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
205
|
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
if (androidLibsPresent === 0) {
|
|
207
|
+
console.log(' ⚠️ No Android libraries found (may be due to missing NDK)');
|
|
208
|
+
} else {
|
|
209
|
+
console.log(` ✅ Found ${androidLibsPresent}/${androidLibs.length} Android libraries`);
|
|
210
|
+
}
|
|
217
211
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
212
|
+
return allFilesPresent;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function main() {
|
|
216
|
+
// Skip in CI unless explicitly requested
|
|
217
|
+
if (process.env.CI && !process.env.GENERATE_BINDINGS) {
|
|
218
|
+
console.log('⚠️ Skipping binding generation in CI environment.');
|
|
219
|
+
console.log(' Set GENERATE_BINDINGS=1 to force generation in CI.');
|
|
220
|
+
process.exit(0);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Check prerequisites
|
|
224
|
+
if (!hasUniffiBingen()) {
|
|
225
|
+
console.error('❌ uniffi-bindgen-react-native not found!');
|
|
226
|
+
console.error(' Install it with: npm install -g uniffi-bindgen-react-native');
|
|
227
|
+
console.error(' Or add it as a dependency in your project.');
|
|
222
228
|
process.exit(1);
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
// Verify source files are present (should be included in NPM package)
|
|
232
|
+
const sourceFiles = [
|
|
233
|
+
'src/ddk_ffi.ts',
|
|
234
|
+
'src/ddk_ffi-ffi.ts',
|
|
235
|
+
'cpp/ddk_ffi.hpp',
|
|
236
|
+
'cpp/ddk_ffi.cpp'
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
console.log('🔍 Checking source files...');
|
|
240
|
+
for (const file of sourceFiles) {
|
|
241
|
+
const filePath = path.join(packageRoot, file);
|
|
242
|
+
if (!fs.existsSync(filePath)) {
|
|
243
|
+
console.error(`❌ Missing source file: ${file}`);
|
|
244
|
+
console.error(' This indicates a problem with the NPM package.');
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
console.log('✅ All source files present');
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
// Generate turbo module and build native libraries from existing JSI bindings
|
|
252
|
+
generateTurboModule();
|
|
253
|
+
fixCppIncludePath();
|
|
254
|
+
buildIOS();
|
|
255
|
+
buildAndroid();
|
|
256
|
+
|
|
257
|
+
// Verify all files are present
|
|
258
|
+
const allFilesPresent = verifyAllFiles();
|
|
259
|
+
|
|
260
|
+
if (!allFilesPresent) {
|
|
261
|
+
console.error('\n❌ Some required files are missing!');
|
|
262
|
+
console.error('The installation may have failed.');
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
console.log('\n✅ All files installed successfully!');
|
|
267
|
+
console.log('🎉 DDK-RN is ready to use!\n');
|
|
268
|
+
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.error('\n❌ Failed to complete installation:', error.message);
|
|
271
|
+
console.error('');
|
|
272
|
+
console.error('📋 This may be due to:');
|
|
273
|
+
console.error(' - Missing uniffi-bindgen-react-native (install globally)');
|
|
274
|
+
console.error(' - Missing Android NDK (for Android builds)');
|
|
275
|
+
console.error(' - Missing Xcode/iOS toolchain (for iOS builds on macOS)');
|
|
276
|
+
console.error('');
|
|
277
|
+
console.error('Report issues at: https://github.com/bennyhodl/ddk-ffi/issues');
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
227
280
|
}
|
|
228
281
|
|
|
229
282
|
// Run the main function
|
package/src/ddk_ffi-ffi.ts
CHANGED
|
@@ -111,6 +111,9 @@ interface NativeModuleInterface {
|
|
|
111
111
|
output: Uint8Array,
|
|
112
112
|
uniffi_out_err: UniffiRustCallStatus
|
|
113
113
|
): number;
|
|
114
|
+
ubrn_uniffi_ddk_ffi_fn_func_plz_work(
|
|
115
|
+
uniffi_out_err: UniffiRustCallStatus
|
|
116
|
+
): Uint8Array;
|
|
114
117
|
ubrn_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(
|
|
115
118
|
fundTransaction: Uint8Array,
|
|
116
119
|
privkey: Uint8Array,
|
|
@@ -142,6 +145,7 @@ interface NativeModuleInterface {
|
|
|
142
145
|
ubrn_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature(): number;
|
|
143
146
|
ubrn_uniffi_ddk_ffi_checksum_func_get_total_input_vsize(): number;
|
|
144
147
|
ubrn_uniffi_ddk_ffi_checksum_func_is_dust_output(): number;
|
|
148
|
+
ubrn_uniffi_ddk_ffi_checksum_func_plz_work(): number;
|
|
145
149
|
ubrn_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(): number;
|
|
146
150
|
ubrn_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature(): number;
|
|
147
151
|
ubrn_uniffi_ddk_ffi_checksum_func_version(): number;
|
package/src/ddk_ffi.ts
CHANGED
|
@@ -379,6 +379,19 @@ export function isDustOutput(output: TxOutput): boolean {
|
|
|
379
379
|
)
|
|
380
380
|
);
|
|
381
381
|
}
|
|
382
|
+
export function plzWork(): string {
|
|
383
|
+
return FfiConverterString.lift(
|
|
384
|
+
uniffiCaller.rustCall(
|
|
385
|
+
/*caller:*/ (callStatus) => {
|
|
386
|
+
return (() => {
|
|
387
|
+
console.debug(`-- uniffi_ddk_ffi_fn_func_plz_work`);
|
|
388
|
+
return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_plz_work;
|
|
389
|
+
})()(callStatus);
|
|
390
|
+
},
|
|
391
|
+
/*liftString:*/ FfiConverterString.lift
|
|
392
|
+
)
|
|
393
|
+
);
|
|
394
|
+
}
|
|
382
395
|
export function signFundTransactionInput(
|
|
383
396
|
fundTransaction: Transaction,
|
|
384
397
|
privkey: Array</*u8*/ number>,
|
|
@@ -1700,6 +1713,11 @@ function uniffiEnsureInitialized() {
|
|
|
1700
1713
|
'uniffi_ddk_ffi_checksum_func_is_dust_output'
|
|
1701
1714
|
);
|
|
1702
1715
|
}
|
|
1716
|
+
if (nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_plz_work() !== 32972) {
|
|
1717
|
+
throw new UniffiInternalError.ApiChecksumMismatch(
|
|
1718
|
+
'uniffi_ddk_ffi_checksum_func_plz_work'
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1703
1721
|
if (
|
|
1704
1722
|
nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input() !==
|
|
1705
1723
|
50531
|
package/ubrn.config.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
rust:
|
|
2
|
+
directory: ../ddk-ffi
|
|
3
|
+
manifestPath: Cargo.toml
|
|
4
|
+
|
|
5
|
+
bindings:
|
|
6
|
+
cpp: cpp
|
|
7
|
+
ts: src
|
|
8
|
+
|
|
9
|
+
android:
|
|
10
|
+
directory: android
|
|
11
|
+
packageName: com.ddkrn
|
|
12
|
+
|
|
13
|
+
ios:
|
|
14
|
+
directory: ios
|
|
15
|
+
targets:
|
|
16
|
+
- aarch64-apple-ios
|
|
17
|
+
- aarch64-apple-ios-sim
|
|
18
|
+
frameworkName: ios/DdkRn
|
|
19
|
+
|
|
20
|
+
turboModule:
|
|
21
|
+
cpp: cpp
|
|
22
|
+
ts: src
|
|
23
|
+
spec: NativeDdkRn
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
package/cpp/bennyblader-ddk-rn.h
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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/src/NativeDdkRn.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
|