@harmonia-audio/compat 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AudioPlayer: () => import_voice.AudioPlayer,
24
+ AudioPlayerState: () => import_voice2.AudioPlayerState,
25
+ AudioPlayerStatus: () => import_voice.AudioPlayerState,
26
+ EndBehaviorType: () => EndBehaviorType,
27
+ HarmoniaVoiceError: () => import_voice.HarmoniaVoiceError,
28
+ NoSubscriberBehavior: () => NoSubscriberBehavior,
29
+ StreamType: () => StreamType,
30
+ VoiceConnection: () => import_voice.VoiceConnection,
31
+ VoiceConnectionState: () => import_voice2.VoiceConnectionState,
32
+ VoiceConnectionStatus: () => import_voice.VoiceConnectionState,
33
+ createAudioPlayer: () => createAudioPlayer,
34
+ createAudioResource: () => import_voice.createAudioResource,
35
+ getVoiceConnection: () => import_voice.getVoiceConnection,
36
+ getVoiceConnections: () => import_voice.getVoiceConnections,
37
+ joinVoiceChannel: () => import_voice.joinVoiceChannel
38
+ });
39
+ module.exports = __toCommonJS(index_exports);
40
+ var import_voice = require("@harmonia-audio/voice");
41
+ var import_voice2 = require("@harmonia-audio/voice");
42
+ var import_voice3 = require("@harmonia-audio/voice");
43
+ function createAudioPlayer(options) {
44
+ return new import_voice3.AudioPlayer(options);
45
+ }
46
+ var StreamType = /* @__PURE__ */ ((StreamType2) => {
47
+ StreamType2["Arbitrary"] = "arbitrary";
48
+ StreamType2["Raw"] = "raw";
49
+ StreamType2["OggOpus"] = "ogg/opus";
50
+ StreamType2["WebmOpus"] = "webm/opus";
51
+ StreamType2["Opus"] = "opus";
52
+ return StreamType2;
53
+ })(StreamType || {});
54
+ var EndBehaviorType = /* @__PURE__ */ ((EndBehaviorType2) => {
55
+ EndBehaviorType2[EndBehaviorType2["Manual"] = 0] = "Manual";
56
+ EndBehaviorType2[EndBehaviorType2["AfterSilence"] = 1] = "AfterSilence";
57
+ EndBehaviorType2[EndBehaviorType2["AfterInactivity"] = 2] = "AfterInactivity";
58
+ return EndBehaviorType2;
59
+ })(EndBehaviorType || {});
60
+ var NoSubscriberBehavior = /* @__PURE__ */ ((NoSubscriberBehavior2) => {
61
+ NoSubscriberBehavior2["Pause"] = "pause";
62
+ NoSubscriberBehavior2["Play"] = "play";
63
+ NoSubscriberBehavior2["Stop"] = "stop";
64
+ return NoSubscriberBehavior2;
65
+ })(NoSubscriberBehavior || {});
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ AudioPlayer,
69
+ AudioPlayerState,
70
+ AudioPlayerStatus,
71
+ EndBehaviorType,
72
+ HarmoniaVoiceError,
73
+ NoSubscriberBehavior,
74
+ StreamType,
75
+ VoiceConnection,
76
+ VoiceConnectionState,
77
+ VoiceConnectionStatus,
78
+ createAudioPlayer,
79
+ createAudioResource,
80
+ getVoiceConnection,
81
+ getVoiceConnections,
82
+ joinVoiceChannel
83
+ });
84
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @harmonia/compat — Drop-in replacement for @discordjs/voice.\n *\n * Change your import from `@discordjs/voice` to `@harmonia/compat` and\n * everything should work identically.\n *\n * @example\n * ```ts\n * // Before:\n * // import { joinVoiceChannel, createAudioPlayer } from '@discordjs/voice';\n *\n * // After:\n * import { joinVoiceChannel, createAudioPlayer } from '@harmonia/compat';\n * ```\n */\n\nexport {\n\tjoinVoiceChannel,\n\ttype JoinVoiceChannelOptions,\n\tgetVoiceConnection,\n\tgetVoiceConnections,\n\tVoiceConnection,\n\ttype VoiceConnectionOptions,\n\tVoiceConnectionState as VoiceConnectionStatus,\n\tAudioPlayer,\n\tAudioPlayerState as AudioPlayerStatus,\n\tcreateAudioResource,\n\ttype AudioResourceOptions,\n\tHarmoniaVoiceError,\n} from \"@harmonia-audio/voice\";\n\n// Re-export enum values that match @discordjs/voice naming\nexport { VoiceConnectionState, AudioPlayerState } from \"@harmonia-audio/voice\";\n\nimport { AudioPlayer, type AudioPlayerOptions } from \"@harmonia-audio/voice\";\n\n/**\n * Create an AudioPlayer instance. Matches `createAudioPlayer()` from @discordjs/voice.\n *\n * @example\n * ```ts\n * const player = createAudioPlayer();\n * ```\n */\nexport function createAudioPlayer(\n\toptions?: AudioPlayerOptions,\n): AudioPlayer {\n\treturn new AudioPlayer(options);\n}\n\n/**\n * Enum matching @discordjs/voice StreamType.\n *\n * @example\n * ```ts\n * createAudioResource(stream, { inputType: StreamType.Opus });\n * ```\n */\nexport enum StreamType {\n\tArbitrary = \"arbitrary\",\n\tRaw = \"raw\",\n\tOggOpus = \"ogg/opus\",\n\tWebmOpus = \"webm/opus\",\n\tOpus = \"opus\",\n}\n\n/**\n * Enum matching @discordjs/voice EndBehaviorType.\n *\n * @example\n * ```ts\n * receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence } });\n * ```\n */\nexport enum EndBehaviorType {\n\tManual = 0,\n\tAfterSilence = 1,\n\tAfterInactivity = 2,\n}\n\n/**\n * No-op adapter creator for testing. Matches @discordjs/voice.\n *\n * @example\n * ```ts\n * const adapter = NoSubscriberBehavior.Pause;\n * ```\n */\nexport enum NoSubscriberBehavior {\n\tPause = \"pause\",\n\tPlay = \"play\",\n\tStop = \"stop\",\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,mBAaO;AAGP,IAAAA,gBAAuD;AAEvD,IAAAA,gBAAqD;AAU9C,SAAS,kBACf,SACc;AACd,SAAO,IAAI,0BAAY,OAAO;AAC/B;AAUO,IAAK,aAAL,kBAAKC,gBAAL;AACN,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,SAAM;AACN,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,UAAO;AALI,SAAAA;AAAA,GAAA;AAgBL,IAAK,kBAAL,kBAAKC,qBAAL;AACN,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,kBAAe,KAAf;AACA,EAAAA,kCAAA,qBAAkB,KAAlB;AAHW,SAAAA;AAAA,GAAA;AAcL,IAAK,uBAAL,kBAAKC,0BAAL;AACN,EAAAA,sBAAA,WAAQ;AACR,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,UAAO;AAHI,SAAAA;AAAA,GAAA;","names":["import_voice","StreamType","EndBehaviorType","NoSubscriberBehavior"]}
@@ -0,0 +1,71 @@
1
+ import { AudioPlayerOptions, AudioPlayer } from '@harmonia-audio/voice';
2
+ export { AudioPlayer, AudioPlayerState, AudioPlayerState as AudioPlayerStatus, AudioResourceOptions, HarmoniaVoiceError, JoinVoiceChannelOptions, VoiceConnection, VoiceConnectionOptions, VoiceConnectionState, VoiceConnectionState as VoiceConnectionStatus, createAudioResource, getVoiceConnection, getVoiceConnections, joinVoiceChannel } from '@harmonia-audio/voice';
3
+
4
+ /**
5
+ * @harmonia/compat — Drop-in replacement for @discordjs/voice.
6
+ *
7
+ * Change your import from `@discordjs/voice` to `@harmonia/compat` and
8
+ * everything should work identically.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // Before:
13
+ * // import { joinVoiceChannel, createAudioPlayer } from '@discordjs/voice';
14
+ *
15
+ * // After:
16
+ * import { joinVoiceChannel, createAudioPlayer } from '@harmonia/compat';
17
+ * ```
18
+ */
19
+
20
+ /**
21
+ * Create an AudioPlayer instance. Matches `createAudioPlayer()` from @discordjs/voice.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const player = createAudioPlayer();
26
+ * ```
27
+ */
28
+ declare function createAudioPlayer(options?: AudioPlayerOptions): AudioPlayer;
29
+ /**
30
+ * Enum matching @discordjs/voice StreamType.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * createAudioResource(stream, { inputType: StreamType.Opus });
35
+ * ```
36
+ */
37
+ declare enum StreamType {
38
+ Arbitrary = "arbitrary",
39
+ Raw = "raw",
40
+ OggOpus = "ogg/opus",
41
+ WebmOpus = "webm/opus",
42
+ Opus = "opus"
43
+ }
44
+ /**
45
+ * Enum matching @discordjs/voice EndBehaviorType.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence } });
50
+ * ```
51
+ */
52
+ declare enum EndBehaviorType {
53
+ Manual = 0,
54
+ AfterSilence = 1,
55
+ AfterInactivity = 2
56
+ }
57
+ /**
58
+ * No-op adapter creator for testing. Matches @discordjs/voice.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const adapter = NoSubscriberBehavior.Pause;
63
+ * ```
64
+ */
65
+ declare enum NoSubscriberBehavior {
66
+ Pause = "pause",
67
+ Play = "play",
68
+ Stop = "stop"
69
+ }
70
+
71
+ export { EndBehaviorType, NoSubscriberBehavior, StreamType, createAudioPlayer };
@@ -0,0 +1,71 @@
1
+ import { AudioPlayerOptions, AudioPlayer } from '@harmonia-audio/voice';
2
+ export { AudioPlayer, AudioPlayerState, AudioPlayerState as AudioPlayerStatus, AudioResourceOptions, HarmoniaVoiceError, JoinVoiceChannelOptions, VoiceConnection, VoiceConnectionOptions, VoiceConnectionState, VoiceConnectionState as VoiceConnectionStatus, createAudioResource, getVoiceConnection, getVoiceConnections, joinVoiceChannel } from '@harmonia-audio/voice';
3
+
4
+ /**
5
+ * @harmonia/compat — Drop-in replacement for @discordjs/voice.
6
+ *
7
+ * Change your import from `@discordjs/voice` to `@harmonia/compat` and
8
+ * everything should work identically.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // Before:
13
+ * // import { joinVoiceChannel, createAudioPlayer } from '@discordjs/voice';
14
+ *
15
+ * // After:
16
+ * import { joinVoiceChannel, createAudioPlayer } from '@harmonia/compat';
17
+ * ```
18
+ */
19
+
20
+ /**
21
+ * Create an AudioPlayer instance. Matches `createAudioPlayer()` from @discordjs/voice.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const player = createAudioPlayer();
26
+ * ```
27
+ */
28
+ declare function createAudioPlayer(options?: AudioPlayerOptions): AudioPlayer;
29
+ /**
30
+ * Enum matching @discordjs/voice StreamType.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * createAudioResource(stream, { inputType: StreamType.Opus });
35
+ * ```
36
+ */
37
+ declare enum StreamType {
38
+ Arbitrary = "arbitrary",
39
+ Raw = "raw",
40
+ OggOpus = "ogg/opus",
41
+ WebmOpus = "webm/opus",
42
+ Opus = "opus"
43
+ }
44
+ /**
45
+ * Enum matching @discordjs/voice EndBehaviorType.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence } });
50
+ * ```
51
+ */
52
+ declare enum EndBehaviorType {
53
+ Manual = 0,
54
+ AfterSilence = 1,
55
+ AfterInactivity = 2
56
+ }
57
+ /**
58
+ * No-op adapter creator for testing. Matches @discordjs/voice.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const adapter = NoSubscriberBehavior.Pause;
63
+ * ```
64
+ */
65
+ declare enum NoSubscriberBehavior {
66
+ Pause = "pause",
67
+ Play = "play",
68
+ Stop = "stop"
69
+ }
70
+
71
+ export { EndBehaviorType, NoSubscriberBehavior, StreamType, createAudioPlayer };
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ // src/index.ts
2
+ import {
3
+ joinVoiceChannel,
4
+ getVoiceConnection,
5
+ getVoiceConnections,
6
+ VoiceConnection,
7
+ VoiceConnectionState,
8
+ AudioPlayer,
9
+ AudioPlayerState,
10
+ createAudioResource,
11
+ HarmoniaVoiceError
12
+ } from "@harmonia-audio/voice";
13
+ import { VoiceConnectionState as VoiceConnectionState2, AudioPlayerState as AudioPlayerState2 } from "@harmonia-audio/voice";
14
+ import { AudioPlayer as AudioPlayer2 } from "@harmonia-audio/voice";
15
+ function createAudioPlayer(options) {
16
+ return new AudioPlayer2(options);
17
+ }
18
+ var StreamType = /* @__PURE__ */ ((StreamType2) => {
19
+ StreamType2["Arbitrary"] = "arbitrary";
20
+ StreamType2["Raw"] = "raw";
21
+ StreamType2["OggOpus"] = "ogg/opus";
22
+ StreamType2["WebmOpus"] = "webm/opus";
23
+ StreamType2["Opus"] = "opus";
24
+ return StreamType2;
25
+ })(StreamType || {});
26
+ var EndBehaviorType = /* @__PURE__ */ ((EndBehaviorType2) => {
27
+ EndBehaviorType2[EndBehaviorType2["Manual"] = 0] = "Manual";
28
+ EndBehaviorType2[EndBehaviorType2["AfterSilence"] = 1] = "AfterSilence";
29
+ EndBehaviorType2[EndBehaviorType2["AfterInactivity"] = 2] = "AfterInactivity";
30
+ return EndBehaviorType2;
31
+ })(EndBehaviorType || {});
32
+ var NoSubscriberBehavior = /* @__PURE__ */ ((NoSubscriberBehavior2) => {
33
+ NoSubscriberBehavior2["Pause"] = "pause";
34
+ NoSubscriberBehavior2["Play"] = "play";
35
+ NoSubscriberBehavior2["Stop"] = "stop";
36
+ return NoSubscriberBehavior2;
37
+ })(NoSubscriberBehavior || {});
38
+ export {
39
+ AudioPlayer,
40
+ AudioPlayerState2 as AudioPlayerState,
41
+ AudioPlayerState as AudioPlayerStatus,
42
+ EndBehaviorType,
43
+ HarmoniaVoiceError,
44
+ NoSubscriberBehavior,
45
+ StreamType,
46
+ VoiceConnection,
47
+ VoiceConnectionState2 as VoiceConnectionState,
48
+ VoiceConnectionState as VoiceConnectionStatus,
49
+ createAudioPlayer,
50
+ createAudioResource,
51
+ getVoiceConnection,
52
+ getVoiceConnections,
53
+ joinVoiceChannel
54
+ };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @harmonia/compat — Drop-in replacement for @discordjs/voice.\n *\n * Change your import from `@discordjs/voice` to `@harmonia/compat` and\n * everything should work identically.\n *\n * @example\n * ```ts\n * // Before:\n * // import { joinVoiceChannel, createAudioPlayer } from '@discordjs/voice';\n *\n * // After:\n * import { joinVoiceChannel, createAudioPlayer } from '@harmonia/compat';\n * ```\n */\n\nexport {\n\tjoinVoiceChannel,\n\ttype JoinVoiceChannelOptions,\n\tgetVoiceConnection,\n\tgetVoiceConnections,\n\tVoiceConnection,\n\ttype VoiceConnectionOptions,\n\tVoiceConnectionState as VoiceConnectionStatus,\n\tAudioPlayer,\n\tAudioPlayerState as AudioPlayerStatus,\n\tcreateAudioResource,\n\ttype AudioResourceOptions,\n\tHarmoniaVoiceError,\n} from \"@harmonia-audio/voice\";\n\n// Re-export enum values that match @discordjs/voice naming\nexport { VoiceConnectionState, AudioPlayerState } from \"@harmonia-audio/voice\";\n\nimport { AudioPlayer, type AudioPlayerOptions } from \"@harmonia-audio/voice\";\n\n/**\n * Create an AudioPlayer instance. Matches `createAudioPlayer()` from @discordjs/voice.\n *\n * @example\n * ```ts\n * const player = createAudioPlayer();\n * ```\n */\nexport function createAudioPlayer(\n\toptions?: AudioPlayerOptions,\n): AudioPlayer {\n\treturn new AudioPlayer(options);\n}\n\n/**\n * Enum matching @discordjs/voice StreamType.\n *\n * @example\n * ```ts\n * createAudioResource(stream, { inputType: StreamType.Opus });\n * ```\n */\nexport enum StreamType {\n\tArbitrary = \"arbitrary\",\n\tRaw = \"raw\",\n\tOggOpus = \"ogg/opus\",\n\tWebmOpus = \"webm/opus\",\n\tOpus = \"opus\",\n}\n\n/**\n * Enum matching @discordjs/voice EndBehaviorType.\n *\n * @example\n * ```ts\n * receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence } });\n * ```\n */\nexport enum EndBehaviorType {\n\tManual = 0,\n\tAfterSilence = 1,\n\tAfterInactivity = 2,\n}\n\n/**\n * No-op adapter creator for testing. Matches @discordjs/voice.\n *\n * @example\n * ```ts\n * const adapter = NoSubscriberBehavior.Pause;\n * ```\n */\nexport enum NoSubscriberBehavior {\n\tPause = \"pause\",\n\tPlay = \"play\",\n\tStop = \"stop\",\n}\n"],"mappings":";AAgBA;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEwB;AAAA,EACxB;AAAA,EACoB;AAAA,EACpB;AAAA,EAEA;AAAA,OACM;AAGP,SAAS,wBAAAA,uBAAsB,oBAAAC,yBAAwB;AAEvD,SAAS,eAAAC,oBAA4C;AAU9C,SAAS,kBACf,SACc;AACd,SAAO,IAAIA,aAAY,OAAO;AAC/B;AAUO,IAAK,aAAL,kBAAKC,gBAAL;AACN,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,SAAM;AACN,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,UAAO;AALI,SAAAA;AAAA,GAAA;AAgBL,IAAK,kBAAL,kBAAKC,qBAAL;AACN,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,kBAAe,KAAf;AACA,EAAAA,kCAAA,qBAAkB,KAAlB;AAHW,SAAAA;AAAA,GAAA;AAcL,IAAK,uBAAL,kBAAKC,0BAAL;AACN,EAAAA,sBAAA,WAAQ;AACR,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,UAAO;AAHI,SAAAA;AAAA,GAAA;","names":["VoiceConnectionState","AudioPlayerState","AudioPlayer","StreamType","EndBehaviorType","NoSubscriberBehavior"]}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@harmonia-audio/compat",
3
+ "version": "0.1.0",
4
+ "description": "Compatibility layer for @discordjs/voice migration",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "@harmonia-audio/voice": "0.1.0",
27
+ "@harmonia-audio/codec": "0.1.0"
28
+ },
29
+ "devDependencies": {
30
+ "tsup": "^8.3.5",
31
+ "typescript": "^5.7.2",
32
+ "vitest": "^2.1.8",
33
+ "rimraf": "^6.0.1"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "test": "vitest run",
38
+ "typecheck": "tsc --noEmit",
39
+ "clean": "rimraf dist"
40
+ }
41
+ }