@4players/odin-plugin-web 1.0.0-alpha.6 → 1.0.0-alpha.60

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/cmake/dependencies.cmake +31 -0
  3. package/cmake/options.cmake +53 -0
  4. package/esbuild.config.ts +49 -0
  5. package/lib/plugin/index.d.ts +45 -0
  6. package/lib/plugin/index.js +1 -0
  7. package/lib/worker/shared.js +1 -0
  8. package/lib/worker/unshared.js +1 -0
  9. package/package.json +38 -30
  10. package/backend/lib/audioController.d.ts +0 -102
  11. package/backend/lib/audioController.d.ts.map +0 -1
  12. package/backend/lib/audioController.js +0 -442
  13. package/backend/lib/audioController.js.map +0 -1
  14. package/backend/lib/config.d.ts +0 -11
  15. package/backend/lib/config.d.ts.map +0 -1
  16. package/backend/lib/config.js +0 -11
  17. package/backend/lib/config.js.map +0 -1
  18. package/backend/lib/connectionPool.d.ts +0 -17
  19. package/backend/lib/connectionPool.d.ts.map +0 -1
  20. package/backend/lib/connectionPool.js +0 -111
  21. package/backend/lib/connectionPool.js.map +0 -1
  22. package/backend/lib/index.d.ts +0 -53
  23. package/backend/lib/index.d.ts.map +0 -1
  24. package/backend/lib/index.js +0 -293
  25. package/backend/lib/index.js.map +0 -1
  26. package/backend/lib/mainConnection.d.ts +0 -40
  27. package/backend/lib/mainConnection.d.ts.map +0 -1
  28. package/backend/lib/mainConnection.js +0 -294
  29. package/backend/lib/mainConnection.js.map +0 -1
  30. package/backend/lib/roomConnection.d.ts +0 -37
  31. package/backend/lib/roomConnection.d.ts.map +0 -1
  32. package/backend/lib/roomConnection.js +0 -299
  33. package/backend/lib/roomConnection.js.map +0 -1
  34. package/backend/lib/rpcConnection.d.ts +0 -49
  35. package/backend/lib/rpcConnection.d.ts.map +0 -1
  36. package/backend/lib/rpcConnection.js +0 -235
  37. package/backend/lib/rpcConnection.js.map +0 -1
  38. package/backend/lib/token.d.ts +0 -16
  39. package/backend/lib/token.d.ts.map +0 -1
  40. package/backend/lib/token.js +0 -67
  41. package/backend/lib/token.js.map +0 -1
  42. package/backend/package.json +0 -16
  43. package/wasm/lib/index.d.ts +0 -97
  44. package/wasm/lib/index.js +0 -19
  45. package/wasm/package.json +0 -14
  46. package/worker/lib/common.d.ts +0 -27
  47. package/worker/lib/index.d.ts +0 -46
  48. package/worker/lib/index.js +0 -2
  49. package/worker/lib/messages.d.ts +0 -93
  50. package/worker/package.json +0 -16
package/README.md CHANGED
@@ -14,7 +14,7 @@ Contact us through the listed methods below to receive answers to your questions
14
14
 
15
15
  Join our official Discord server to chat with us directly and become a part of the 4Players ODIN community.
16
16
 
17
- [![Join us on Discord](https://developers.4players.io/images/join_discord.png)](https://4np.de/discord)
17
+ [![Join us on Discord](https://www.4players.io/images/join_discord.png)](https://4np.de/discord)
18
18
 
19
19
  ### Twitter
20
20
 
@@ -0,0 +1,31 @@
1
+ include(FetchContent)
2
+
3
+ ### Opus audio codec
4
+
5
+ message(STATUS "Installing Opus audio codec")
6
+
7
+ set(OPUS_BUILD_SHARED_LIBRARY CACHE BOOL OFF FORCE)
8
+ set(OPUS_BUILD_PROGRAMS CACHE BOOL ON FORCE)
9
+ set(OPUS_BUILD_TESTING CACHE BOOL OFF FORCE)
10
+ set(BUILD_TESTING CACHE BOOL OFF FORCE)
11
+ set(STACK_PROTECTOR_SUPPORTED CACHE BOOL OFF FORCE)
12
+ set(FORTIFY_SOURCE_SUPPORTED CACHE BOOL OFF FORCE)
13
+
14
+ FetchContent_Declare(
15
+ opus
16
+ GIT_REPOSITORY https://gitlab.4players.de/odin/deps/opus.git
17
+ GIT_TAG v1.5.2
18
+ )
19
+ FetchContent_MakeAvailable(opus)
20
+ target_link_libraries(${CMAKE_EXECUTABLE_NAME} PUBLIC opus)
21
+
22
+ ### RNN VAD
23
+
24
+ message(STATUS "Installing RNN VAD")
25
+
26
+ FetchContent_Declare(
27
+ rnn_vad
28
+ GIT_REPOSITORY https://gitlab.4players.de/odin/deps/rnn-vad.git
29
+ )
30
+ FetchContent_MakeAvailable(rnn_vad)
31
+ target_link_libraries(${CMAKE_EXECUTABLE_NAME} PUBLIC rnn_vad)
@@ -0,0 +1,53 @@
1
+ ### Set global compiler flags
2
+
3
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
4
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
5
+
6
+ ### Set compiler flags for the release configuration
7
+
8
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
9
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
10
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -O3")
11
+
12
+ ### Set compiler flags for the debug configuration
13
+
14
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
15
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
16
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g")
17
+
18
+ ### Conditional logic to include pthread when SharedArrayBuffer is enabled
19
+
20
+ if(NOT DEFINED SHARED_MEMORY)
21
+ message(STATUS "Enabling SharedArrayBuffer")
22
+
23
+ set(EXPORT_NAME "OdinWasmUnsharedMemory")
24
+ set(SHARED_MEMORY 0)
25
+ else()
26
+ message(STATUS "Disabling SharedArrayBuffer")
27
+
28
+ set(EXPORT_NAME "OdinWasmSharedMemory")
29
+ set(SHARED_MEMORY 1)
30
+
31
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pthread")
32
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -pthread")
33
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pthread")
34
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pthread")
35
+ endif()
36
+
37
+ ### Set flags for WebAssembly target output
38
+
39
+ set_target_properties(${CMAKE_EXECUTABLE_NAME} PROPERTIES
40
+ CXX_STANDARD 20
41
+ LINK_FLAGS "--bind \
42
+ -s SHARED_MEMORY=${SHARED_MEMORY} \
43
+ -s EXPORT_NAME=Load${EXPORT_NAME} \
44
+ -s MODULARIZE=1 \
45
+ -s WASM=1 \
46
+ -s SINGLE_FILE=1 \
47
+ -s ALLOW_TABLE_GROWTH=1 \
48
+ -s BINARYEN_ASYNC_COMPILATION=0 \
49
+ -s FILESYSTEM=0 \
50
+ -s ENVIRONMENT=web,worker \
51
+ -s EXPORTED_FUNCTIONS=_malloc,_free \
52
+ -s EXPORTED_RUNTIME_METHODS=HEAPU8,HEAPF32,HEAPU32,HEAP32"
53
+ )
@@ -0,0 +1,49 @@
1
+ import * as esbuild from 'esbuild';
2
+ import type { BuildOptions } from 'esbuild'; // Optional: for type safety
3
+
4
+ const packageVersion = process.env.npm_package_version;
5
+ const distPath = 'dist/odin-plugin';
6
+
7
+ if (!packageVersion) {
8
+ console.error(
9
+ 'Error: npm_package_version is not set. Please run this script using an npm script (e.g., npm run bundle).'
10
+ );
11
+ process.exit(1);
12
+ }
13
+
14
+ const sharedConfig: BuildOptions = {
15
+ entryPoints: ['lib/plugin/index.js'],
16
+ bundle: true,
17
+ minify: true,
18
+ platform: 'browser',
19
+ };
20
+
21
+ async function main() {
22
+ console.log(`Starting esbuild for version: ${packageVersion}`);
23
+ try {
24
+ // IIFE Build
25
+ await esbuild.build({
26
+ ...sharedConfig,
27
+ format: 'iife',
28
+ globalName: 'ODIN',
29
+ outfile: `${distPath}-iife_${packageVersion}.js`,
30
+ });
31
+ console.log(`Successfully built: ${distPath}-iife_${packageVersion}.js`);
32
+
33
+ // ESM Build
34
+ await esbuild.build({
35
+ ...sharedConfig,
36
+ format: 'esm',
37
+ outfile: `${distPath}-esm_${packageVersion}.js`,
38
+ });
39
+ console.log(`Successfully built: ${distPath}-esm_${packageVersion}.js`);
40
+
41
+ console.log('Build completed successfully.');
42
+ } catch (error) {
43
+ console.error('Build failed:');
44
+ console.error(error);
45
+ process.exit(1);
46
+ }
47
+ }
48
+
49
+ main().catch(console.error);
@@ -0,0 +1,45 @@
1
+ import { Backend, LogRecord, Logger } from '@4players/odin-common';
2
+
3
+ export type OnLogMessage = (formattedString: string, record: LogRecord) => void;
4
+ export type VifConfig = {
5
+ enabled: true;
6
+ attenuationLimit: number;
7
+ postFilterBeta: number;
8
+ } | {
9
+ enabled: false;
10
+ };
11
+ export type CreateAudioCaptureParameters = Backend.CreateAudioCaptureParameters & {
12
+ readonly device?: WebDevice;
13
+ };
14
+ export type AudioContextFactory = (sampleRate: number | undefined) => Promise<AudioContext>;
15
+ export type DeviceInfo = {
16
+ name: string;
17
+ deviceId: string;
18
+ kind: "audioinput" | "audiooutput";
19
+ };
20
+ export interface WebDevice extends Backend.Device {
21
+ readonly device: DeviceInfo;
22
+ }
23
+ export interface WebDeviceParameters extends Backend.DeviceParameters {
24
+ readonly device?: WebDevice;
25
+ onStatusChanged?: Backend.OnStatusChanged;
26
+ }
27
+ export declare function createPlugin(audioContextFactory: AudioContextFactory, options?: WebPluginOptions): WebPlugin;
28
+ export interface WebPluginOptions {
29
+ logger?: Logger;
30
+ onLogMessage?: OnLogMessage;
31
+ }
32
+ export declare const SESSION_ID: string;
33
+ export interface WebPlugin extends Backend.Plugin {
34
+ joinRoom(parameters: Backend.JoinRoomParameters): WebRoom;
35
+ enumerateDevices(): Promise<WebDevice[]>;
36
+ setOutputDevice(device: WebDeviceParameters): Promise<void>;
37
+ createAudioCapture(parameters: CreateAudioCaptureParameters): Promise<WebAudioCapture>;
38
+ }
39
+ export interface WebRoom extends Backend.Room {
40
+ }
41
+ export interface WebAudioCapture extends Backend.AudioCapture {
42
+ setVif(config: VifConfig): void;
43
+ }
44
+
45
+ export {};