{"id":20995095,"url":"https://github.com/blackboxvision/use-torch-light","last_synced_at":"2025-05-14T21:30:57.810Z","repository":{"id":43970188,"uuid":"249598186","full_name":"BlackBoxVision/use-torch-light","owner":"BlackBoxVision","description":"🔦Hook to enable/disable the camera torchlight via Web APIs","archived":false,"fork":false,"pushed_at":"2023-03-02T22:00:32.000Z","size":973,"stargazers_count":12,"open_issues_count":12,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-09T15:38:43.700Z","etag":null,"topics":["camera","camera-flash","library","react","react-hook","react-hooks","torchlight"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlackBoxVision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-03-24T02:54:51.000Z","updated_at":"2025-04-20T20:45:23.000Z","dependencies_parsed_at":"2024-01-23T17:41:48.868Z","dependency_job_id":"08c3a639-b11e-40c5-882f-2f264b29bd21","html_url":"https://github.com/BlackBoxVision/use-torch-light","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"2c0fd287911ef3320b06af77753cc6e1b89252ed"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackBoxVision%2Fuse-torch-light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackBoxVision%2Fuse-torch-light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackBoxVision%2Fuse-torch-light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackBoxVision%2Fuse-torch-light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackBoxVision","download_url":"https://codeload.github.com/BlackBoxVision/use-torch-light/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254230808,"owners_count":22036246,"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":["camera","camera-flash","library","react","react-hook","react-hooks","torchlight"],"created_at":"2024-11-19T07:21:34.484Z","updated_at":"2025-05-14T21:30:56.029Z","avatar_url":"https://github.com/BlackBoxVision.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UseTorchLight [![npm version](https://badge.fury.io/js/%40blackbox-vision%2Fuse-torch-light.svg)](https://badge.fury.io/js/%40blackbox-vision%2Fuse-torch-light) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) [![Known Vulnerabilities](https://snyk.io/test/github/blackboxvision/use-torch-light/badge.svg)](https://snyk.io/test/github/blackboxvision/use-torch-light)\n\n🔦 **useTorchLight** is a hook to enable/disable camera flash. Check out the [demo](https://zittu.csb.app).\n\n## Install\n\nYou can install this library via NPM or YARN.\n\n### NPM\n\n```bash\nnpm i @blackbox-vision/use-torch-light\n```\n\n### YARN\n\n```bash\nyarn add @blackbox-vision/use-torch-light\n```\n\n## Warning\n\n**useTorchLight** relies on [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) whose spec isn't complete at all browsers currently. You can check the state of ImageCapture in browsers [here](https://caniuse.com/#search=imagecapture).\n\n**We're currently trying to make the hook most consistent as possible by providing cross-browser checks and dispatching errors or alerts via success and error callbacks.**\n\n## Usage\n\nThe usage is really simple:\n\n```javascript\nimport React, { useState, useRef } from 'react';\nimport { QrReader } from '@blackbox-vision/react-qr-reader';\nimport { useTorchLight } from '@blackbox-vision/use-torch-light';\n\nconst Test = (props) =\u003e {\n  const streamRef = useRef(null);\n\n  const [error, setError] = useState(null);\n  const [data, setData] = useState('No result');\n\n  const [on, toggle] = useTorchLight(streamRef.current);\n\n  const setRef = ({ stream }) =\u003e {\n    streamRef.current = stream;\n  };\n\n  return (\n    \u003c\u003e\n      \u003cQrReader\n        onLoad={setRef}\n        onScan={setData}\n        onError={setError}\n        style={{ width: '100%' }}\n      /\u003e\n      \u003cbutton onClick={toggle}\u003e{on ? 'Disable Torch' : 'Enable Torch'}\u003c/button\u003e\n      \u003cp\u003e{JSON.stringify(data, null, 2)}\u003c/p\u003e\n      \u003cp\u003e{JSON.stringify(error, null, 2)}\u003c/p\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n## Issues\n\nPlease, open an [issue](https://github.com/BlackBoxVision/use-torch-light/issues) following one of the issues templates. We will do our best to fix them.\n\n## Contributing\n\nIf you want to contribute to this project see [contributing](https://github.com/BlackBoxVision/use-torch-light/blob/master/CONTRIBUTING.md) for more information.\n\n## License\n\nDistributed under the **MIT license**. See [LICENSE](https://github.com/BlackBoxVision/use-torch-light/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackboxvision%2Fuse-torch-light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackboxvision%2Fuse-torch-light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackboxvision%2Fuse-torch-light/lists"}