react-native-audio-concat 0.2.0
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/AudioConcat.podspec +30 -0
- package/LICENSE +20 -0
- package/README.md +39 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcat.kt +349 -0
- package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcatPackage.kt +22 -0
- package/ios/AudioConcat.swift +75 -0
- package/lib/module/AudioConcat.nitro.js +4 -0
- package/lib/module/AudioConcat.nitro.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AudioConcat.nitro.d.ts +16 -0
- package/lib/typescript/src/AudioConcat.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +28 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/audioconcat+autolinking.cmake +82 -0
- package/nitrogen/generated/android/audioconcat+autolinking.gradle +27 -0
- package/nitrogen/generated/android/audioconcatOnLoad.cpp +44 -0
- package/nitrogen/generated/android/audioconcatOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JAudioData.hpp +53 -0
- package/nitrogen/generated/android/c++/JAudioDataOrSilence.cpp +26 -0
- package/nitrogen/generated/android/c++/JAudioDataOrSilence.hpp +72 -0
- package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp +77 -0
- package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JSilentData.hpp +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioData.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioDataOrSilence.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/HybridAudioConcatSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/SilentData.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/audioconcatOnLoad.kt +35 -0
- package/nitrogen/generated/ios/AudioConcat+autolinking.rb +60 -0
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.cpp +48 -0
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp +160 -0
- package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Umbrella.hpp +53 -0
- package/nitrogen/generated/ios/AudioConcatAutolinking.mm +33 -0
- package/nitrogen/generated/ios/AudioConcatAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.hpp +81 -0
- package/nitrogen/generated/ios/swift/AudioData.swift +35 -0
- package/nitrogen/generated/ios/swift/AudioDataOrSilence.swift +18 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridAudioConcatSpec.swift +49 -0
- package/nitrogen/generated/ios/swift/HybridAudioConcatSpec_cxx.swift +142 -0
- package/nitrogen/generated/ios/swift/SilentData.swift +35 -0
- package/nitrogen/generated/shared/c++/AudioData.hpp +67 -0
- package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/SilentData.hpp +67 -0
- package/package.json +168 -0
- package/src/AudioConcat.nitro.ts +19 -0
- package/src/index.tsx +38 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SilentData.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::audioconcat {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A struct which can be represented as a JavaScript object (SilentData).
|
|
29
|
+
*/
|
|
30
|
+
struct SilentData {
|
|
31
|
+
public:
|
|
32
|
+
double durationMs SWIFT_PRIVATE;
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
SilentData() = default;
|
|
36
|
+
explicit SilentData(double durationMs): durationMs(durationMs) {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace margelo::nitro::audioconcat
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro {
|
|
42
|
+
|
|
43
|
+
// C++ SilentData <> JS SilentData (object)
|
|
44
|
+
template <>
|
|
45
|
+
struct JSIConverter<margelo::nitro::audioconcat::SilentData> final {
|
|
46
|
+
static inline margelo::nitro::audioconcat::SilentData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
48
|
+
return margelo::nitro::audioconcat::SilentData(
|
|
49
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "durationMs"))
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::audioconcat::SilentData& arg) {
|
|
53
|
+
jsi::Object obj(runtime);
|
|
54
|
+
obj.setProperty(runtime, "durationMs", JSIConverter<double>::toJSI(runtime, arg.durationMs));
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
57
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
58
|
+
if (!value.isObject()) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
jsi::Object obj = value.getObject(runtime);
|
|
62
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "durationMs"))) return false;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-audio-concat",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "audio-concat for react-native",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"example": "yarn workspace react-native-audio-concat-example",
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"typecheck": "tsc",
|
|
40
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
42
|
+
"prepare": "bob build",
|
|
43
|
+
"release": "release-it --only-version",
|
|
44
|
+
"nitrogen": "nitrogen"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react-native",
|
|
48
|
+
"ios",
|
|
49
|
+
"android"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/felixchen-dev/react-native-audio-concat.git"
|
|
54
|
+
},
|
|
55
|
+
"author": "Meng Chan <hi@felixchen.dev> (https://github.com/felixchen-dev)",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/felixchen-dev/react-native-audio-concat/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/felixchen-dev/react-native-audio-concat#readme",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
66
|
+
"@eslint/compat": "^1.3.2",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
68
|
+
"@eslint/js": "^9.35.0",
|
|
69
|
+
"@evilmartians/lefthook": "^1.12.3",
|
|
70
|
+
"@react-native/babel-preset": "0.81.1",
|
|
71
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
72
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
73
|
+
"@types/jest": "^29.5.14",
|
|
74
|
+
"@types/react": "^19.1.0",
|
|
75
|
+
"commitlint": "^19.8.1",
|
|
76
|
+
"del-cli": "^6.0.0",
|
|
77
|
+
"eslint": "^9.35.0",
|
|
78
|
+
"eslint-config-prettier": "^10.1.8",
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"nitrogen": "^0.29.8",
|
|
82
|
+
"prettier": "^3.6.2",
|
|
83
|
+
"react": "19.1.0",
|
|
84
|
+
"react-native": "0.81.1",
|
|
85
|
+
"react-native-builder-bob": "^0.40.13",
|
|
86
|
+
"react-native-nitro-modules": "^0.29.8",
|
|
87
|
+
"release-it": "^19.0.4",
|
|
88
|
+
"turbo": "^2.5.6",
|
|
89
|
+
"typescript": "^5.9.2"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*",
|
|
94
|
+
"react-native-nitro-modules": "^0.29.8"
|
|
95
|
+
},
|
|
96
|
+
"workspaces": [
|
|
97
|
+
"example"
|
|
98
|
+
],
|
|
99
|
+
"packageManager": "yarn@3.6.1",
|
|
100
|
+
"jest": {
|
|
101
|
+
"preset": "react-native",
|
|
102
|
+
"modulePathIgnorePatterns": [
|
|
103
|
+
"<rootDir>/example/node_modules",
|
|
104
|
+
"<rootDir>/lib/"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"commitlint": {
|
|
108
|
+
"extends": [
|
|
109
|
+
"@commitlint/config-conventional"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"release-it": {
|
|
113
|
+
"git": {
|
|
114
|
+
"commitMessage": "chore: release ${version}",
|
|
115
|
+
"tagName": "v${version}"
|
|
116
|
+
},
|
|
117
|
+
"npm": {
|
|
118
|
+
"publish": true
|
|
119
|
+
},
|
|
120
|
+
"github": {
|
|
121
|
+
"release": true
|
|
122
|
+
},
|
|
123
|
+
"plugins": {
|
|
124
|
+
"@release-it/conventional-changelog": {
|
|
125
|
+
"preset": {
|
|
126
|
+
"name": "angular"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"prettier": {
|
|
132
|
+
"quoteProps": "consistent",
|
|
133
|
+
"singleQuote": true,
|
|
134
|
+
"tabWidth": 2,
|
|
135
|
+
"trailingComma": "es5",
|
|
136
|
+
"useTabs": false
|
|
137
|
+
},
|
|
138
|
+
"react-native-builder-bob": {
|
|
139
|
+
"source": "src",
|
|
140
|
+
"output": "lib",
|
|
141
|
+
"targets": [
|
|
142
|
+
[
|
|
143
|
+
"custom",
|
|
144
|
+
{
|
|
145
|
+
"script": "nitrogen",
|
|
146
|
+
"clean": "nitrogen/"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"module",
|
|
151
|
+
{
|
|
152
|
+
"esm": true
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
"typescript",
|
|
157
|
+
{
|
|
158
|
+
"project": "tsconfig.build.json"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
"create-react-native-library": {
|
|
164
|
+
"languages": "kotlin-swift",
|
|
165
|
+
"type": "nitro-module",
|
|
166
|
+
"version": "0.54.5"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
type SilentData = {
|
|
4
|
+
durationMs: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type AudioData = {
|
|
8
|
+
filePath: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AudioDataOrSilence = AudioData | SilentData;
|
|
12
|
+
|
|
13
|
+
export interface AudioConcat
|
|
14
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
15
|
+
concatAudioFiles(
|
|
16
|
+
data: AudioDataOrSilence[],
|
|
17
|
+
outputPath: string
|
|
18
|
+
): Promise<string>;
|
|
19
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { AudioConcat, AudioDataOrSilence } from './AudioConcat.nitro';
|
|
3
|
+
|
|
4
|
+
const AudioConcatHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<AudioConcat>('AudioConcat');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Concat audio files and silence periods into a single output file.
|
|
9
|
+
*
|
|
10
|
+
* @param data - Array of audio files and silence periods to merge.
|
|
11
|
+
* Each item can be either:
|
|
12
|
+
* - `{ filePath: string }` for an audio file
|
|
13
|
+
* - `{ durationMs: number }` for a silence period
|
|
14
|
+
* @param outputPath - Absolute path where the merged audio file will be saved (M4A format)
|
|
15
|
+
* @returns Promise that resolves with the output file path
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const data = [
|
|
20
|
+
* { filePath: '/path/to/audio1.m4a' },
|
|
21
|
+
* { durationMs: 500 }, // 500ms silence
|
|
22
|
+
* { filePath: '/path/to/audio2.m4a' },
|
|
23
|
+
* { durationMs: 1000 }, // 1 second silence
|
|
24
|
+
* { filePath: '/path/to/audio3.m4a' }
|
|
25
|
+
* ];
|
|
26
|
+
* const output = '/path/to/merged.m4a';
|
|
27
|
+
* const result = await concatAudioFiles(data, output);
|
|
28
|
+
* console.log('concat file:', result);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function concatAudioFiles(
|
|
32
|
+
data: AudioDataOrSilence[],
|
|
33
|
+
outputPath: string
|
|
34
|
+
): Promise<string> {
|
|
35
|
+
return AudioConcatHybridObject.concatAudioFiles(data, outputPath);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { AudioDataOrSilence } from './AudioConcat.nitro';
|