{"id":13780409,"url":"https://github.com/MausTec/react-buttplug","last_synced_at":"2025-05-11T13:32:09.970Z","repository":{"id":119258020,"uuid":"336928864","full_name":"MausTec/react-buttplug","owner":"MausTec","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-19T03:19:52.000Z","size":3869,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-10T23:26:14.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MausTec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-08T01:25:24.000Z","updated_at":"2024-04-24T06:49:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"f094cfb0-a4ae-45ee-a483-b2cb21f3f0db","html_url":"https://github.com/MausTec/react-buttplug","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.06666666666666665,"last_synced_commit":"2e95ef524fba5ea9ec361aedca52fe9a32a5b7b3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MausTec%2Freact-buttplug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MausTec%2Freact-buttplug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MausTec%2Freact-buttplug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MausTec%2Freact-buttplug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MausTec","download_url":"https://codeload.github.com/MausTec/react-buttplug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225056812,"owners_count":17414215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:01:15.414Z","updated_at":"2024-11-17T15:31:10.289Z","avatar_url":"https://github.com/MausTec.png","language":"JavaScript","readme":"# react-buttplug\n\n\u003e React provider for Buttplug.io's `buttplug-ffi-js` library. Here there be WASM.\n\n[![NPM](https://img.shields.io/npm/v/@maustec/react-buttplug.svg)](https://www.npmjs.com/package/@maustec/react-buttplug) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Install\n\n```bash\nnpm install --save @maustec/react-buttplug\n```\n\nSince `buttplug` requires a WASM blob, you'll need to tell webpack that WASM files are `webassembly/experimental` typed..\nIf you're using `create-react-app`, check out `CRACO`:\n\n`https://github.com/gsoft-inc/craco`\n\nYour new rule should look something like this:\n\n```js\n{\n    test: /\\.wasm$/,\n    type: 'webassembly/experimental'\n}\n```\n\nCheck out `example/` for a create-react-app setup that initializes Buttplug.\n\n## Usage\n\nWrap your app in this and you'll be able to consume `ButtplugContext` wherever\nyou need control of buttplugs. Any methods of interest are available on the\ncontext.\n\n### First, provide your App.\n```jsx\nimport { ButtplugProvider } from '@maustec/react-buttplug'\nimport {\n  VibratorSearchButton,\n  VibratorControls\n} from 'the-next-examples'\n\nconst App = () =\u003e {\n  return (\n    \u003cButtplugProvider serverName={\"buttplugs.\"}\u003e\n      \u003cVibratorSearchButton /\u003e\n      \u003cVibratorControls /\u003e\n    \u003c/ButtplugProvider\u003e\n  )\n}\n```\n\n### Then consume the context to create, for example, a connect button:\n\n```jsx\nimport React, { useContext } from 'react'\nimport { ButtplugDeviceContext } from '@maustec/react-buttplug'\n\nconst VibratorSearchButton = () =\u003e {\n  const { buttplugReady, startSearching } = useContext(ButtplugDeviceContext);\n\n  const handleClick = (e) =\u003e {\n    e.preventDefault();\n    startSearching()\n      .then(console.log)\n      .catch(console.error)\n   }\n\n  if (buttplugReady) {\n    return (\n      \u003ca onClick={handleClick} href='#'\u003eStart Searching\u003c/a\u003e\n    )\n  } else {\n    return (\n      \u003cp\u003eWaiting for Buttplugs...\u003c/p\u003e\n    )\n  }\n}\n```\n\n### Finally, you can do things with the devices here:\n\n```jsx\nimport React, { useContext, useState } from 'react'\nimport {\n  ButtplugDeviceContext,\n  ButtplugDeviceController\n} from '@maustec/react-buttplug'\n\nconst VibratorControls = () =\u003e {\n  const { devices } = useContext(ButtplugDeviceContext)\n  const [ vibrateSpeed, setVibrateSpeed ] = useState(0.0);\n\n  const handleVibrateChange = (e) =\u003e {\n    setVibrateSpeed(parseFloat(e.target.value))\n  }\n\n  return (\n    \u003cdiv\u003e\n      \u003cinput type='number'\n             min='0'\n             max='1'\n             value={ vibrateSpeed }\n             onChange={ handleVibrateChange }\n      /\u003e\n\n      \u003cul\u003e\n        { devices.map((device) =\u003e (\n          \u003cButtplugDeviceController key={device.Index} device={device} vibrate={vibrateSpeed}\u003e\n            \u003cli\u003e{ device.Name }\u003c/li\u003e\n          \u003c/ButtplugDeviceController\u003e\n        )) }\n      \u003c/ul\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n## TODO\n\n- Find a way to indicate a pending device pairing, e.g. after clicking \"Pair\" and before `deviceadded` fires.\n\n## License\n\nMIT © [MausTec](https://github.com/MausTec)\n","funding_links":[],"categories":["Development and Libraries"],"sub_categories":["Other Frameworks and Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMausTec%2Freact-buttplug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMausTec%2Freact-buttplug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMausTec%2Freact-buttplug/lists"}