Giter VIP home page Giter VIP logo

jutsu's Introduction

<Jutsu />

A jitsi meet component wrapper and custom hook moulded with react's chakra 💠

View live demo

NPM

Install

yarn add react-jutsu

Add the Jitsi Meet API js file to the html body

<body>
  <script src='https://meet.jit.si/external_api.js'></script>
</body>

You can choose to load the script another way, the hook will return an error until the jitsi API is available in window scope.

Two options

You can use the provided component for simple scenarios or the hook for access to the jitsi meet api

import { Jutsu } from 'react-jutsu' // Component
import { useJitsi } from 'react-jutsu' // Custom hook

Sample Usage (Hook)

import React, { useEffect } from 'react'
import { useJitsi } from 'react-jutsu'

const App = () => {
  const jitsiConfig = {
    roomName: 'konoha',
    displayName: 'Naruto Uzumaki',
    password: 'dattebayo',
    subject: 'fan',
    parentNode: 'jitsi-container',
  };
  const { loading, error, jitsi } = useJitsi(jitsiConfig);

  return (
    <div>
      {error && <p>{error}</p>}
      <div id={jitsiConfig.parentNode} />
    </div>
  );
}

Sample Usage (Component)

import React, { useState } from 'react'

import { Jutsu } from 'react-jutsu'

const App = () => {
  const [room, setRoom] = useState('')
  const [name, setName] = useState('')
  const [call, setCall] = useState(false)
  const [password, setPassword] = useState('')

  const handleClick = event => {
    event.preventDefault()
    if (room && name) setCall(true)
  }

  return call ? (
    <Jutsu
      roomName={room}
      displayName={name}
      password={password}
      onMeetingEnd={() => console.log('Meeting has ended')}
      loadingComponent={<p>loading ...</p>}
      errorComponent={<p>Oops, something went wrong</p>} />
  ) : (
    <form>
      <input id='room' type='text' placeholder='Room' value={room} onChange={(e) => setRoom(e.target.value)} />
      <input id='name' type='text' placeholder='Name' value={name} onChange={(e) => setName(e.target.value)} />
      <input id='password' type='text' placeholder='Password (optional)' value={password} onChange={(e) => setPassword(e.target.value)} />
      <button onClick={handleClick} type='submit'>
        Start / Join
      </button>
    </form>
  )
}

export default App

Supported Configuration

Check the Jitsi Meet API docs for full configuration and how to use api commands when using the useJitsi hook

Room Name

The meeting room name

This prop is required to start a meeting

Display Name

The participant's displayed name

This prop is optional

Password

The meeting room password

This prop is optional

onMeetingEnd

Callback function executed after readyToClose event is fired

This prop is optional

Subject

The meeting subject (what is displayed at the top)

This prop is optional

<Jutsu
  subject='fan'
  roomName='naruto'
  password='dattebayo'
  displayName='uzumaki'
  onMeetingEnd={() => console.log('Meeting has ended')}
/>

Domain

<Jutsu domain='my-custom-domain.com'>

Your Jitsi domain to use, the default value is meet.jit.si

Loading Component

<Jutsu loadingComponent={<ProgressBar />}>

An optional loading component, the default value is <p>Loading ...</p>

Error Component

<Jutsu errorComponent={<p>Oops, something went wrong...</p>}>

An optional error component, the default value is a <p> containing the error.

Styles

Internally Jutsu is constructed inside 2 containers, you can add custom styles for each by specifying containerStyles and jitsiContainerstyles

The default values set as

<div
  style={{...{
    width: '800px',
    height: '400px'
  }, ...containerStyles}}
>
  <div
    style={{...{
      display: loading ? 'none' : 'block', // <- used for loadingComponent logic
      width: '100%',
      height: '100%'
    }, ...jitsiContainerStyles}}
  />
</div>

An example override could be

<Jutsu containerStyles={{ width: '1200px', height: '800px' }}>

configOverwrite

Configuration object to overwrite.

This prop is optional More details about possible key/values here

interfaceConfigOverwrite

Interface configuration object to overwrite.

This prop is optional More details about possible key/values here

onError

Callback function to be called with an error as the only parameter if any.

This prop is optional

onJitsi

Callback function to be called with the jitsi API client when instantiated.

This prop is optional

any other prop

Any other prop passed to the component will be passed to jitsi API constructor as part of the options parameter.

For instance: jwt, devices, userInfo

License

MIT © this-fifo

jutsu's People

Contributors

aileo avatar byrnehollander avatar charlesinto avatar dependabot[bot] avatar felix-franz avatar gorbypark avatar meysamhit avatar santteegt avatar this-fifo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jutsu's Issues

Testing a Jutsu App

I am trying to write a simple test for Jutsu, but I keep running into an error that says:

TypeError: jitsi.executeCommand is not a function

This happens where we try:

render(<App />)

I do have an Error Boundary around this, so the error is isolated from the rest of the code, but it would be good to be able to test this in some way.

Any idea how to solve this ? I am not understanding this very well...

useJitsi not working

I used as a setup and it worked just fine, but I am finding hard to do the same using the Hook version. I did the same as the example provided.

import { useJitsi } from 'react-jutsu'
export default function MyPage(){
const jitsiConfig = {
    roomName: 'konoha',
    displayName: 'Naruto Uzumaki',
    password: 'dattebayo',
    subject: 'fan',
    parentNode: 'jitsi-container',
  };
  const { loading, error, jitsi } = useJitsi(jitsiConfig);
return ()
}

But useJitsi is returning null. Don't know why :(

Custom domain not working

Hi, Thanks for this awesome package.
i have problem with custom domain props. when i set the props is still going connect to meet.jit.si domain. any solution?
<Jutsu roomName={room} userName={name} password={password} domain='kelasonline.sicerdas.link' loadingComponent={<p>loading ...</p>} />

Height property with '%' not working

Hi! I was testing the hook and when I try to pass a percentage instead of pixels to height property it doesn't work.

It would be great if could help me with this. Thanks!

Significant audio lag using public Jitsi meet

First I’d like to say I love this module and appreciate all the work being done on it. That said, starting in last few weeks, I noticed when using public Jitsi servers and react-jutsu the audio would lag significantly behind the video. Up till that point, everything was working fine. Do you have any suggestions for fixing this issue?
I’m aware this likely could be a Jitsi issue but when I navigate to the public Jitsi meeting from my browser everything seems fine, I’ve talked to some of those in the Jitsi community and they don’t seem to be having this issue so thought I’d create one here in off chance it’s related to this module.

Add support for TypeScript

Typings serve for the TypeScript compiler to do type validations. Is it possible to make a typing for this library? Thanks.

expose jitsi api through a custom hook

The more I add executeCommands calls the more I realize it would be best to instead expose the api to those who want to further customize or control the jitsi meet client

I think this library could change to export 2 things:

  • A component for quick basic use with little customization <Jutsu />
  • A custom hook for those who want to use the jitsi meet client and do more things with it useJitsi()

addEventListener returning null

First of all thanks for this amazing work, actually I am trying to listen to an event whenever a user joins in a conference. I have used it like this

 jitsi.addEventListener('videoConferenceJoined', () => {
   console.log('Joined !')
   })

It is returning an error : Cannot read property 'addEventListener' of null.
But the command jitsi.executeCommand is working .

Override defaultLanguage in localStorage

Hello and thank you for such a great library.

Since we are not able to override the Jitsi language once the language key set to localStorage, is there a way to manually inject a script to an iframe?

I'm trying to achieve something like this:

const script = `<script>localStorage.removeItem('language')</script>`;
const iframe = document.getElementsByTagName("iframe")[0];
iframe.contentWindow.document.head.appendChild(script);

The code written above is not working, it's just for example of what I'm thinking is possible. I would like to remove the language key on e.g. onMeetingEnd event, that way I'll be able to change language each time I start a new call.

Thanks in advance!

How can I use executeCommand?

Hey there,

I'm trying to use executeCommand, but it's not working.
Please show me how to do this, thanks!

Code i'm using:

const jitsiConfig = {
        domain: 'meet.jit.si.',
        roomName: 'dev',
        displayName: 'Helpdesk Bot',
        parentNode: 'dashboard-room',
        configOverwrite: {
            startWithVideoMuted: true,
            startWithAudioMuted: true
        },
        interfaceConfigOverwrite: {
            TOOLBAR_BUTTONS: ['']
        },
};

const {jitsi} = useJitsi(jitsiConfig);

jitsi.executeCommand('toggleChat');

Code returns:
TypeError: Cannot read property 'executeCommand' of null

jitsi meet - tile view as default

Any way i could have the tile view setup as default in jutsu? (recompiling library or something?) what's the possibility on that?

Working through the install steps to use Jutsu

Hello @this-fifo

I'm back now looking at testing our jutsu. Once again thank you for making this available and pointing me to this project. I'd like get this setup and perhaps help with the steps (documentation). I'm working my way through the install process but with your permission (and patience) would like to ask for your help in what I am doing. This may be an iterative process as I try and figure things out and then ask for your help! Here is where I am so far:

The O/S I'm using is Ubuntu 18.04 - Please suggest another O/S if you prefer. I usually use CentOS but had this VM ready to install Jitsi on it and thought I would test out jutsu instead.

To begin I've started with the following:

sudo apt install npm
sudo npm install -g yarn
sudo yarn add react-jutsu 

I ran these above commands from my /home/ folder for the user I've logged in with so I now see a 'node_modules' folder, a package.json file and a yarn.lock file. I'm thinking I don't want to run jutsu from my home folder? What do you suggest? Install using # sudo yarn add react-jutsu and them moving this somehwhere?

Ok I'm at the part in your ReadMe where I need to "Add the Jitsi Meet API js file to the html body" What file to I edit and where in that file do I add this bit of code you've provided?

Thank you!

Is not working on mobile devices

I create a small app using this component, but for some reason is only working on desktop, in mobile is loading eternally.
Any thoughts?

Jitsi Call Closing event

Hey,

Can we handle Jitsi call closing event, because it displays advertisement after that and I dont want that.

Help with InterfaceConfigOverwrite

Hello,

I'm using jutsu to build an helpdesk application.
At this point I would like to remove some unnecessary buttons, but I can't figure out how to do it.

This is what I am using at the moment:

<Jutsu domain='jitsi.osl.frl'
        roomName='dev'
        displayName={studentName}
        onMeetingEnd={() => console.log('Meeting has ended')}
        loadingComponent={<p>loading ...</p>}
        errorComponent={<p>Oops, something went wrong</p>} 
        InterfaceConfigOverwrite={{
                DEFAULT_BACKGROUND: '#FFFFFF', 
                TOOLBAR_BUTTONS: ['microphone', 'camera', 'tileview']
        }}
 />

Both the DEFAULT_BACKGROUND and TOOLBAR_BUTTONS are not working for me.
Am I forgetting something, or am I doing it completely wrong?

Please let me know,

-Jelmer

Incompatible Module error

when i run yarn add react-jutsu i get this

yarn add v1.22.4
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=10". Got "8.10.0"
error Found incompatible module.

Update docs

After version 3.0.0 Jutsu now supports additional configurations like onError and onJitsi thanks to @aileo on #24 🙏

The useJitsi hook has also been refactored to return an object with loading and error props holding the state to make it more convenient to use

We should update the README.md file to include a description of how to use those

Adding ReadyToClose callback

Hi FIFO,

First off, great work! on simplifying Jitsi Meet API..
Question.. how do you add a callback to detect if the video conference is finished, ie : hang up.
Also is there any way to disable the annoying "chrome plugin not installed" popup? (and the thank you for using jitsi, at the end of conference?)
Thanks in advance.

Custom Width & Height

Another PR calls, it looks to me you are passing a static 800px by 400px, how to default using this size, but also allow custom size passed as props from component?

Returned jitsi object is null from useJitsi call

Jitsi supports a wide variety of functions that are used to control the iframe. Unfortunately at this point, none of them are available with the React component.

The api object (or client as it's called in the current codebase) might be returned so that it can be used to call functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.