{"id":17000139,"url":"https://github.com/iam-medvedev/eyedropper-polyfill","last_synced_at":"2025-03-22T15:31:13.687Z","repository":{"id":187295488,"uuid":"676663416","full_name":"iam-medvedev/eyedropper-polyfill","owner":"iam-medvedev","description":"EyeDropper API Polyfill","archived":false,"fork":false,"pushed_at":"2023-08-09T19:35:09.000Z","size":959,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T19:24:24.569Z","etag":null,"topics":["api","eye-dropper","eyedropper","polyfill"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eyedropper-polyfill","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/iam-medvedev.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}},"created_at":"2023-08-09T18:05:04.000Z","updated_at":"2025-01-17T15:43:31.000Z","dependencies_parsed_at":"2023-08-09T19:51:03.323Z","dependency_job_id":null,"html_url":"https://github.com/iam-medvedev/eyedropper-polyfill","commit_stats":null,"previous_names":["iam-medvedev/eyedropper-polyfill"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-medvedev%2Feyedropper-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-medvedev%2Feyedropper-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-medvedev%2Feyedropper-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iam-medvedev%2Feyedropper-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iam-medvedev","download_url":"https://codeload.github.com/iam-medvedev/eyedropper-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874546,"owners_count":20524577,"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":["api","eye-dropper","eyedropper","polyfill"],"created_at":"2024-10-14T04:11:12.272Z","updated_at":"2025-03-22T15:31:12.853Z","avatar_url":"https://github.com/iam-medvedev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `eyedropper-polyfill`\n\n`eyedropper-polyfill` provides a polyfill implementation for the [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper), allowing you to capture colors from any part of a webpage.\n\nThis package was inspired by the EyeDropper API and the need for a consistent color selection mechanism across various browsers where the EyeDropper API is not [natively supported](https://caniuse.com/mdn-api_eyedropper).\n\n[DEMO](https://stackblitz.com/edit/vitejs-vite-qwd1pv?file=main.js)\n\n## Table of Contents\n\n- [`eyedropper-polyfill`](#eyedropper-polyfill)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Opening the EyeDropper](#opening-the-eyedropper)\n    - [Aborting](#aborting)\n  - [Limitations](#limitations)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Features\n\n- Provides a polyfilled implementation of the EyeDropper API for capturing colors from web pages.\n- Supports selection of colors from different parts of the webpage.\n- Offers a magnifier for precise color selection.\n- Handles asynchronous operations and signal abortions.\n\n## Installation\n\n```bash\nyarn add eyedropper-polyfill\n```\n\nor\n\n```bash\nnpm install eyedropper-polyfill\n```\n\nor\n\n```typescript\nimport 'https://esm.sh/eyedropper-polyfill@latest';\n```\n\n## Usage\n\nImport the `EyeDropperPolyfill` from the package:\n\n```typescript\nimport 'eyedropper-polyfill';\n```\n\nIt will create EyeDropper support via `window.EyeDropper`.\n\n### Opening the EyeDropper\n\n```typescript\nconst eyeDropper = new window.EyeDropper();\n\neyeDropper\n  .open()\n  .then((colorSelectionResult) =\u003e {\n    // Use the selected color information\n    console.log('Selected color:', colorSelectionResult.sRGBHex);\n  })\n  .catch((error) =\u003e {\n    console.error('Error:', error);\n  });\n```\n\n### Aborting\n\n```typescript\nconst eyeDropper = new window.EyeDropper();\nconst abortController = new window.AbortController();\nconst signal = abortController.signal;\n\n// Set up an event listener to abort the operation after a certain time\nsetTimeout(() =\u003e {\n  abortController.abort();\n}, 5000); // Abort after 5 seconds\n\neyeDropper\n  .open({ signal })\n  .then((colorSelectionResult) =\u003e {\n    // Use the selected color information\n    console.log('Selected color:', colorSelectionResult.sRGBHex);\n  })\n  .catch((error) =\u003e {\n    if (error.name === 'AbortError') {\n      console.log('Operation was aborted.');\n    } else {\n      console.error('Error:', error);\n    }\n  });\n```\n\n## Limitations\n\nSince this package is based on [html2canvas](https://html2canvas.hertzen.com), you can look at their [limitations](https://html2canvas.hertzen.com/documentation.html#limitations).\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions, please open an issue on the [GitHub repository](https://github.com/iam-medvedev/eyedropper-polyfill).\n\n## License\n\nThis package is distributed under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiam-medvedev%2Feyedropper-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiam-medvedev%2Feyedropper-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiam-medvedev%2Feyedropper-polyfill/lists"}