Skip to content

Commit 57017d1

Browse files
authored
Merge pull request #14 from diffusionstudio/konstantin/feature/opus-wasm-encoder
nextjs opus lib js compile fix
2 parents 5b5185d + 118acfb commit 57017d1

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@diffusionstudio/core",
33
"private": false,
4-
"version": "1.0.0-rc.5",
4+
"version": "1.0.0-rc.6",
55
"type": "module",
66
"description": "Build bleeding edge video processing applications",
77
"files": [

src/encoders/opus/opus.encoder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* Public License, v. 2.0 that can be found in the LICENSE file.
66
*/
77

8-
import createModule from './opus';
98
import { createOpusHead } from './opus.utils';
10-
import { OPUS_WASM_PATH, SUPPORTED_RATES } from './opus.fixtures';
9+
import { OPUS_WASM_PATH, OPUS_JS_PATH, SUPPORTED_RATES } from './opus.fixtures';
1110
import { EncoderError } from '../../errors';
1211

1312
import type {
@@ -40,6 +39,7 @@ export class OpusEncoder {
4039
* @param config The sample rate and channel count to use
4140
*/
4241
public async configure(config: OpusEncoderConfig): Promise<void> {
42+
const opusModule = await import(/* @vite-ignore *//* webpackIgnore: true */OPUS_JS_PATH);
4343
const { numberOfChannels, sampleRate } = this.config = config;
4444

4545
if (!SUPPORTED_RATES.includes(sampleRate)) {
@@ -50,7 +50,7 @@ export class OpusEncoder {
5050
}
5151

5252
// create new wasm module
53-
this.opus = await createModule({
53+
this.opus = await opusModule.default({
5454
locateFile(path: string, scriptDirectory: string) {
5555
if (path.endsWith('.wasm')) {
5656
return OPUS_WASM_PATH;

src/encoders/opus/opus.fixtures.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
*/
1111
export const SUPPORTED_RATES = [8000, 12000, 16000, 24000, 48000];
1212
export const OPUS_WASM_PATH = 'https://cdn.jsdelivr.net/npm/@diffusionstudio/[email protected]/dist/opus.wasm';
13+
export const OPUS_JS_PATH = 'https://cdn.jsdelivr.net/npm/@diffusionstudio/[email protected]/dist/opus.js';

src/encoders/opus/opus.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)