-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
"Await"ing JZZ fails to enumerate MIDI devices #22
Comments
Both TypeScript and React are not my strongest skills, I would appreciate some help on those... |
JZZ is written in pure JavaScript. Regarding the error in the _log array - you can ignore those: JZZ tries to initialize various MIDI engines before it finds the one working on the current system. |
This is my first project using TypeScript. :) I will see if I can figure it out as well. |
I have just updated dependencies in https://www.npmjs.com/package/jazz-midi-electron |
I'm not sure this will help. Will it? At the moment I'm just using 'jzz' in my React project without |
I guess you have the latest JZZ version then... |
The pull request is NOT good. I am not completely sure why it works, and it could be written much more cleanly. However, it's still worth taking a look. This does not seem to be a TypeScript issue, but a general one about the way JZZ is being accessed somehow. I have not tested for regressions. My research led me to believe that the call is somehow losing "context", likely due to the global variable in some way. I wish I knew why this started returning results with this change. |
I encourage rejection of the pull request, I made it mostly as a starting point for further research, but I am likely to proceed with my project with the change as is. |
I still need to access JZZ using the following: // useEffect(() => {
// ...
async function initJZZ() {
let x = await JZZ.default({sysex:true}).or('oh no!').and('Everything is good!');
console.dir(x.info());
}
initJZZ();
// ...
// }, []); This probably isn't a good design pattern for a number of reasons but I was just focused on getting MIDI devices enumerated. |
By the way, on which system/browser did you see the "navigator" error? |
I have created a minimal test-case in React and "pure JavaScript". Basic Repro
Make code look like this: import React, { useEffect } from 'react';
import logo from './logo.svg';
import './App.css';
import * as JZZ from 'jzz';
function App() {
useEffect(() => {
async function initJZZ() {
let x = await JZZ().or("fail").and("ok");
console.log(x.info());
}
initJZZ();
}, []);
return (
// ...
Apply Fix
Tested on Win10 1903 with Chrome Version 77.0.3865.120 (Official Build) (64-bit). |
And which patch do you mean? #23 or something else? |
Yes, 23. |
Made an even smaller standalone test. <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JZZ Ultra-mini test</title>
</head>
<body>
<h1>JZZ Ultra-mini test</h1>
<p>Hello.</p>
</body>
<script src="./JZZ.js"></script>
<script>
async function initJZZ() {
let j = await JZZ();
console.log(j.info());
}
initJZZ();
</script>
</html> Does not require React or a webserver. Simply open it in a browser. Same symptom/problem, same patch fixes it. |
EDIT: This also doesn't work unless the patch is applied. <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JZZ Ultra-mini test</title>
</head>
<body>
<h1>JZZ Ultra-mini test</h1>
<p>Hello.</p>
</body>
<script src="./JZZ.js"></script>
<script>
let j = JZZ();
j.then(() => {console.log(j.info())});
</script>
</html> |
The Pull Request #24 seems to be a better patch. |
Thank you. With any luck this change didn't break anyone else's project, but mine is going very well now. |
Thanks a lot for a very helpful discussion! |
I tried to use JZZ in TypeScript by the documentation,
Trying to call
JZZ()
yieldsThis expression is not callable.
Experimentally, I changed the import to the following:
Written like this, I am able to use
JZZ()
.However,
x.info().outputs
andx.info().inputs
are empty even though "Everything is good!" is logged into the console. It seems that there are some internal errors inside JZZ.The above failure was caused while in
useEffect
of a React functional component.However, referencing issue #6, I put in some raw WebMIDI code in
useEffect()
and it seems to have worked.I can only assume that something in JZZ doesn't like TypeScript or how it's referenced within React.
The end goal is either a PWA (Progressive Web Application) hosted on Firebase and/or an Electron app written in React to configure a specific MIDI device using SysEx.
The text was updated successfully, but these errors were encountered: