@remedia/node 0.0.0-stage → 0.1.0-dev.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Twilight
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # @remedia/node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This directory contains the Rust N-API crate and public npm package for Remedia's embedded Node.js
4
+ bindings. The addon calls `remedia-core`, `remedia-discord`, and `remedia-observability` directly in
5
+ the Node process; it does not use `remedia-server` as an intermediary.
6
+
7
+ The TypeScript entrypoint exports `Remedia`, `PlaybackSession`, and `DiscordSession`. Playback
8
+ accepts local files, HTTP(S) URLs, in-memory `Buffer`/`Uint8Array` media, and binary Node.js
9
+ `Readable` streams. Standalone playback currently decodes into a null output; Discord sessions
10
+ encode PCM to Opus in `remedia-core` and send packets through the existing voice transport. The
11
+ application supplies its Discord Gateway send function and forwards raw Gateway packets to
12
+ `Remedia.receive()`; the TypeScript adapter handles OP 4 and collects matching voice dispatches
13
+ before opening the native transport. Session tokens and endpoints remain internal details.
14
+
15
+ Each `Remedia` owns an isolated observability context. Rust diagnostics are forwarded through a
16
+ bounded callback queue with `on('debug', listener)`; use `close()` to stop sessions, disconnect
17
+ transports, and shut down owned telemetry. Operational errors reject API Promises and remain
18
+ available on session state independently of diagnostic delivery.
19
+
20
+ Playback and voice sessions are typed Node `EventEmitter`s. Subscribe with exported
21
+ `PlaybackSessionEvents` and `VoiceSessionEvents` constants; `Remedia` forwards session lifecycle
22
+ events and provides `RemediaEvents`. `playbackStarted` means native processing began, while
23
+ `playbackCompleted` means natural EOF was processed, not that Discord buffers drained. Events are
24
+ generation-correlated. `play(source, { customMetadata })` keeps arbitrary application metadata in
25
+ JavaScript and includes it in that generation's lifecycle events. Ordered `hooks.beforePlay()`
26
+ middleware can cancel or reject a start before native playback. See the
27
+ [Node.js binding guide](https://github.com/twlite/remedia/blob/main/apps/docs/content/docs/node/bindings.mdx) for payloads and semantics.
28
+
29
+ ## Installation
30
+
31
+ Requires Node.js **22.18.0 or newer** (ESM).
32
+
33
+ ```sh
34
+ npm install @remedia/node
35
+ ```
36
+
37
+ Install FFmpeg 7 shared libraries separately before importing the package. npm does not install
38
+ FFmpeg or compile the addon. Required ABI majors are avcodec 61, avformat 61, avutil 59,
39
+ avfilter 10, and swresample 5. libopus is statically included; FFmpeg is dynamically linked.
40
+
41
+ Native runtime CI covers Linux x64/ARM64 glibc, macOS x64/ARM64, Windows x64 MSVC, and
42
+ FreeBSD x64. Additional build-only packages cover Linux x64/ARM64 musl, Linux ARMv7 hard-float GNU,
43
+ Windows x86/ARM64 MSVC, and Android ARM64/ARMv7 (API 24). Build-only targets have no native runtime
44
+ integration coverage. See the [distribution guide](https://github.com/twlite/remedia/blob/main/apps/docs/content/docs/node/distribution.mdx)
45
+ for verification limits and library discovery: `LD_LIBRARY_PATH` on Linux/FreeBSD,
46
+ `DYLD_LIBRARY_PATH` on macOS, and DLL directories on `PATH` on Windows. For load errors, check
47
+ matching architecture/ABI, transitive FFmpeg dependencies, and that optional npm dependencies were
48
+ installed. Windows also needs the Visual C++ v14 runtime.
49
+
50
+ ```js
51
+ import { Remedia } from '@remedia/node';
52
+
53
+ const remedia = await Remedia.create();
54
+ try {
55
+ const playback = remedia.createPlaybackSession();
56
+ await playback.play({ file: './audio.wav' });
57
+ console.log(await playback.wait());
58
+ } finally {
59
+ await remedia.close();
60
+ }
61
+ ```
62
+
63
+ This standalone session decodes into a null output; it does not play through local speakers.
64
+
65
+ ## Development
66
+
67
+ Install dependencies from the repository root, then run:
68
+
69
+ ```sh
70
+ pnpm --filter @remedia/node test
71
+ pnpm --filter @remedia/node build
72
+ ```
73
+
74
+ The test command builds the debug addon and runs local Node.js integration tests. `build` creates a
75
+ release addon and TypeScript declarations. N-API loader/declaration files are generated from the
76
+ Rust source by `@napi-rs/cli`; Vitest tests live in `tests/` and are grouped by behavior. Rust code
77
+ belongs in `src/`, TypeScript library code in `lib/`, and `dist/` is generated output. See the
78
+ [Node.js bindings topic](https://github.com/twlite/remedia/blob/main/apps/docs/content/docs/node/bindings.mdx) for the API and current
79
+ limitations.
80
+
81
+ ## License and media responsibility
82
+
83
+ Remedia is a general-purpose media processing and transport engine. It does not provide media
84
+ content or grant rights to access or use third-party media. Developers and operators are responsible
85
+ for ensuring their use complies with applicable laws, intellectual property rights, and third-party
86
+ service terms.
87
+
88
+ Remedia is provided under the [MIT License](./LICENSE) without warranty. Dependency terms remain
89
+ separate; see [third-party notices](./THIRD_PARTY_NOTICES.md), including bundled libopus and
90
+ independently installed FFmpeg.