Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with React Native / Expo #144

Open
4 of 10 tasks
kitce opened this issue Jun 3, 2024 · 0 comments
Open
4 of 10 tasks

Usage with React Native / Expo #144

kitce opened this issue Jun 3, 2024 · 0 comments

Comments

@kitce
Copy link

kitce commented Jun 3, 2024

What is the issue about?

  • Bug
  • Feature request
  • Usage question
  • Documentation
  • Contributing / Development

What part(s) of Essentia.js is involved?

  • essentia.js-core (vanilla algorithms)
  • essentia.js-model (machine learning algorithms)
  • essentia.js-plot (plotting utility module)
  • essentia.js-extractor (typical algorithm combinations utility)
  • essentia-wasm

Description

Thank you creating this library, it looks interesting. I am planning to develop a mobile app to integrate Essentia.js in React Native / Expo. Although it supports modern browsers, it seems to not work with React Native.

It will be great to have an example or documentation on integrating Essential.js into React Native / Expo.

Steps to reproduce / Code snippets / Screenshots

What I have tried:

// index.tsx
import Essentia from 'essentia.js/dist/essentia.js-core.es.js';
import EssentiaWASM from 'essentia.js/dist/essentia-wasm.web.js';

const EssentiaWasm = await EssentiaWASM();
                           ^^^ ReferenceError: Property 'document' doesn't exist

The essentia-wasm.web.js may assume this is a browser environment, therefore some code failed on React Native environment.

Then I tried to import the .wasm file and pass it into the Essentia constructor directly, but Expo cannot import the raw binary file data, instead it returns the ID(?) of the imported module, I guess that's why the Essentia class fails to initiate an instance.

// metro.config.js
config.resolver.assetExts.push('wasm');

// index.tsx
import Essentia from 'essentia.js/dist/essentia.js-core.es.js';
import EssentiaWasm from 'essentia.js/dist/essentia-wasm.web.wasm'; // `EssentiaWasm` is just a number here

const essentia = new Essentia(EssentiaWasm);
                     ^^^ TypeError: Cannot read property 'prototype' of undefined

System info

Expo: 51.0.9
React Native: 0.74.1
Device: iOS Simulator iPhone 15 Pro iOS 17.2
Essentia.js: 0.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant