{"_id":"@aegisjsproject/commands","_rev":"3-d1c0304b352573ceb95f1b03251dda32","name":"@aegisjsproject/commands","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aegisjsproject/commands","version":"1.0.0","keywords":["aegisjsproject","commands","invoker","comamnds-api"],"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","_id":"@aegisjsproject/commands@1.0.0","maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"homepage":"https://github.com/AegisJSProject/commands#readme","bugs":{"url":"https://github.com/AegisJSProject/commands/issues"},"dist":{"shasum":"7466e0a37f070755af34417377d67b680338b3c6","tarball":"https://registry.npmjs.org/@aegisjsproject/commands/-/commands-1.0.0.tgz","fileCount":9,"integrity":"sha512-hACPfRsiDZjx61++T3n3DQXLyjozcSLxH/76ecOoKqZF9sM9cA7w5nuXH6IeM5orR9YfVuzxPsaGXD2+hf3VPA==","signatures":[{"sig":"MEYCIQCrNQKwhi5jufh5phOYCq/eg+fbbZ6I1Oy75arOrm9owQIhALD/QHbEon/xM/wn6VjT6DxeexpWyLQv4SXkN0wv99G1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aegisjsproject%2fcommands@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":40778},"main":"./commands.cjs","type":"module","unpkg":"./commands.min.js","module":"./commands.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":"./commands.js","require":"./commands.cjs"},"./*":{"import":"./*.js","require":"./*.cjs"},"./*.js":{"import":"./*.js","require":"./*.cjs"},"./*.cjs":{"import":"./*.js","require":"./*.cjs"},"./*.mjs":{"import":"./*.js","require":"./*.cjs"}},"funding":[{"url":"https://liberapay.com/shgysk8zer0","type":"librepay"},{"url":"https://github.com/sponsors/shgysk8zer0","type":"github"}],"gitHead":"0560cb58d3a8a073ad961acd9467b98838cb0f9e","private":false,"scripts":{"test":"npm run lint:js && npm run run:tests","build":"npm run build:js","clean":"rm -f ./*.cjs","start":"npx @shgysk8zer0/http-server -c './http.config.js'","fix:js":"eslint . --fix","lint:js":"eslint .","prepare":"npm test && npm run build","build:js":"npm run clean && rollup -c rollup.config.js","run:tests":"node --test","preversion":"npm test && npm run build","create:lock":"npm i --package-lock-only --ignore-scripts --no-audit --no-fund","version:bump":"npm run version:bump:patch","version:bump:major":"npm version --no-git-tag-version major && npm run create:lock","version:bump:minor":"npm version --no-git-tag-version minor && npm run create:lock","version:bump:patch":"npm version --no-git-tag-version patch && npm run create:lock"},"_npmUser":{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"},"repository":{"url":"git+https://github.com/AegisJSProject/commands.git","type":"git"},"_npmVersion":"10.1.0","description":"A lightweight command system for handling DOM interactions through custom events and the `commandfor` attribute.","directories":{},"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.36.0","rollup":"^4.52.3","@rollup/plugin-terser":"^0.4.4","@shgysk8zer0/polyfills":"^0.4.13","@shgysk8zer0/http-server":"^1.1.1","@shgysk8zer0/eslint-config":"^1.0.4"},"_npmOperationalInternal":{"tmp":"tmp/commands_1.0.0_1759084466271_0.8941860793450294","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aegisjsproject/commands","version":"1.0.1","keywords":["aegisjsproject","commands","invoker","comamnds-api"],"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","_id":"@aegisjsproject/commands@1.0.1","maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"homepage":"https://github.com/AegisJSProject/commands#readme","bugs":{"url":"https://github.com/AegisJSProject/commands/issues"},"dist":{"shasum":"7dc7b8b3ebdc714e44096d540ff5a90b51678d90","tarball":"https://registry.npmjs.org/@aegisjsproject/commands/-/commands-1.0.1.tgz","fileCount":11,"integrity":"sha512-3hGqDdk+fGC3qPfFU83V0nNECY+JxFYStz0g1LPyuCYkQg73dqFptj+uY8SIGH5AmVy1N7768o0CBgmDcw2DuQ==","signatures":[{"sig":"MEUCIQDC6X79I3aIH1BBheIycqvWpUh27wYsfu+cxhgnRKWT4QIgE1Cz2ilrmigimG4swgfnqHwha2M4WnbDzwhi1Ee/Jeo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aegisjsproject%2fcommands@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":66851},"main":"./commands.cjs","type":"module","unpkg":"./commands.min.js","module":"./commands.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":"./commands.js","require":"./commands.cjs"},"./*":{"import":"./*.js","require":"./*.cjs"},"./*.js":{"import":"./*.js","require":"./*.cjs"},"./*.cjs":{"import":"./*.js","require":"./*.cjs"},"./*.mjs":{"import":"./*.js","require":"./*.cjs"}},"funding":[{"url":"https://liberapay.com/shgysk8zer0","type":"librepay"},{"url":"https://github.com/sponsors/shgysk8zer0","type":"github"}],"gitHead":"cec707fe64d71ac92f7e46bd1d1741fd7f2aeadd","private":false,"scripts":{"test":"npm run lint:js && npm run run:tests","build":"npm run build:js","clean":"rm -f ./*.cjs","start":"npx @shgysk8zer0/http-server -c './http.config.js'","fix:js":"eslint . --fix","lint:js":"eslint .","prepare":"npm test && npm run build","build:js":"npm run clean && rollup -c rollup.config.js","run:tests":"node --test","preversion":"npm test && npm run build","create:lock":"npm i --package-lock-only --ignore-scripts --no-audit --no-fund","version:bump":"npm run version:bump:patch","version:bump:major":"npm version --no-git-tag-version major && npm run create:lock","version:bump:minor":"npm version --no-git-tag-version minor && npm run create:lock","version:bump:patch":"npm version --no-git-tag-version patch && npm run create:lock"},"_npmUser":{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"},"repository":{"url":"git+https://github.com/AegisJSProject/commands.git","type":"git"},"_npmVersion":"10.1.0","description":"A lightweight command system for handling DOM interactions through custom events and the `commandfor` attribute.","directories":{},"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.36.0","rollup":"^4.52.3","@rollup/plugin-terser":"^0.4.4","@shgysk8zer0/polyfills":"^0.4.13","@shgysk8zer0/http-server":"^1.1.1","@shgysk8zer0/eslint-config":"^1.0.4"},"_npmOperationalInternal":{"tmp":"tmp/commands_1.0.1_1759960287112_0.46828893455687415","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aegisjsproject/commands","version":"1.0.2","description":"A lightweight command system for handling DOM interactions through custom events and the `commandfor` attribute.","keywords":["aegisjsproject","commands","invoker","comamnds-api"],"type":"module","main":"./commands.cjs","module":"./commands.js","unpkg":"./commands.min.js","exports":{".":{"import":"./commands.js","require":"./commands.cjs"},"./*.js":{"import":"./*.js","require":"./*.cjs"},"./*.mjs":{"import":"./*.js","require":"./*.cjs"},"./*.cjs":{"import":"./*.js","require":"./*.cjs"},"./*":{"import":"./*.js","require":"./*.cjs"}},"engines":{"node":">=18.0.0"},"private":false,"scripts":{"test":"npm run lint:js && npm run run:tests","start":"npx @shgysk8zer0/http-server -c './http.config.js'","preversion":"npm test && npm run build","prepare":"npm test && npm run build","lint:js":"eslint .","fix:js":"eslint . --fix","build":"npm run build:js","run:tests":"node --test","clean":"rm -f ./*.cjs","build:js":"npm run clean && rollup -c rollup.config.js","create:lock":"npm i --package-lock-only --ignore-scripts --no-audit --no-fund","version:bump":"npm run version:bump:patch","version:bump:patch":"npm version --no-git-tag-version patch && npm run create:lock","version:bump:minor":"npm version --no-git-tag-version minor && npm run create:lock","version:bump:major":"npm version --no-git-tag-version major && npm run create:lock"},"repository":{"type":"git","url":"git+https://github.com/AegisJSProject/commands.git"},"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","funding":[{"type":"librepay","url":"https://liberapay.com/shgysk8zer0"},{"type":"github","url":"https://github.com/sponsors/shgysk8zer0"}],"bugs":{"url":"https://github.com/AegisJSProject/commands/issues"},"homepage":"https://github.com/AegisJSProject/commands#readme","devDependencies":{"@rollup/plugin-terser":"^1.0.0","@shgysk8zer0/eslint-config":"^1.0.7","@shgysk8zer0/http-server":"^1.1.1","@shgysk8zer0/importmap":"^1.8.1","@shgysk8zer0/polyfills":"^0.6.2","eslint":"^10.0.2","rollup":"^4.59.0"},"gitHead":"151812ee1c2617c39c55afbf66af9da6f52dfafe","_id":"@aegisjsproject/commands@1.0.2","_nodeVersion":"24.10.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-bdSC8HFhs4vmCg7blIq9DLdcd/nizwbR74Swwx766/JSZ2qqFcfD2SfgZjs9b3YGleSu8lSppE3rBnlTW8sEhg==","shasum":"72d9cac8552617f0ce8bc179a05fdd02f3194baa","tarball":"https://registry.npmjs.org/@aegisjsproject/commands/-/commands-1.0.2.tgz","fileCount":11,"unpackedSize":67650,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aegisjsproject%2fcommands@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICHnxakzXyKfrQ3x3J/K9SU9sa5FPW7xbZPK176VEc9DAiBkGjJhzoP8zMOwqfPnpRYZEAk/BLhDrlkSEpLc4C5L4Q=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:40df9710-a134-4273-b859-7f72bcd84cb2"}},"directories":{},"maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/commands_1.0.2_1772748986795_0.6909187002361121"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-28T18:34:26.170Z","modified":"2026-03-05T22:16:27.256Z","1.0.0":"2025-09-28T18:34:26.476Z","1.0.1":"2025-10-08T21:51:27.286Z","1.0.2":"2026-03-05T22:16:26.935Z"},"bugs":{"url":"https://github.com/AegisJSProject/commands/issues"},"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","homepage":"https://github.com/AegisJSProject/commands#readme","keywords":["aegisjsproject","commands","invoker","comamnds-api"],"repository":{"type":"git","url":"git+https://github.com/AegisJSProject/commands.git"},"description":"A lightweight command system for handling DOM interactions through custom events and the `commandfor` attribute.","maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"readme":"# `@aegisjsproject/commands`\n\nA lightweight command system for handling DOM interactions through `command` events and the `commandfor` attribute.\n\n[![CodeQL](https://github.com/AegisJSProject/commands/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AegisJSProject/commands/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/AegisJSProject/commands/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/AegisJSProject/commands/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/AegisJSProject/commands.svg)](https://github.com/AegisJSProject/commands/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/AegisJSProject/commands.svg)](https://github.com/AegisJSProject/commands/commits/master)\n[![GitHub release](https://img.shields.io/github/release/AegisJSProject/commands?logo=github)](https://github.com/AegisJSProject/commands/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@aegisjsproject/commands)](https://www.npmjs.com/package/@aegisjsproject/commands)\n![node-current](https://img.shields.io/node/v/@aegisjsproject/commands)\n![npm bundle size gzipped](https://img.shields.io/bundlephobia/minzip/@aegisjsproject/commands)\n[![npm](https://img.shields.io/npm/dw/@aegisjsproject/commands?logo=npm)](https://www.npmjs.com/package/@aegisjsproject/commands)\n\n[![GitHub followers](https://img.shields.io/github/followers/AegisJSProject.svg?style=social)](https://github.com/AegisJSProject)\n![GitHub forks](https://img.shields.io/github/forks/AegisJSProject/commands.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/AegisJSProject/commands.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n<!-- - [Security Policy](./.github/SECURITY.md) -->\n\n## Core Concept\n\nThis library is based on the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API).\nElements with a `commandfor` attribute automatically dispatch `command` events to their target elements when triggered. The\nlibrary handles these events with built-in commands or custom registered handlers.\n\n```html\n<!-- Using Built-In Commands -->\n<button commandfor=\"my-element\" command=\"show-modal\">Show Modal</button>\n<dialog id=\"my-element\">\n  <p>Hello, World!</p>\n  <button commandfor=\"my-element\" command=\"close\">Close</button>\n</dialog>\n<!-- Using Custom Commands -->\n<button commandfor=\"another-el\" command=\"--aegis-command-remove\">Remove Element</button>\n<div id=\"another-el\">This content will be removed.</div>\n```\n\n## Custom, pre-registered Commands\n\n- `--aegis-command-hide`/`--aegis-command-unhide` - Controls hidden attribute\n- `--aegis-command-disable`/`--aegis-command-enable` - Controls disabled attribute\n- `--aegis-command-remove` - Removes element from DOM\n- `--aegis-command-scroll-into-view` - Scrolls element into view (respects `prefers-reduced-motion`)\n- `--aegis-command-request-fullscreen`/`--aegis-command-exit-fullscreen`/`--aegis-command-toggle-fullscreen` - Fullscreen API\n- `--aegis-command-show-picker` - Opens input picker (date, color, etc.)\n- `--aegis-command-step-up`/`--aegis-command-step-down` - Steps numeric inputs\n- `--aegis-command-open-details`/`--aegis-command-close-details`/`--aegis-command-toggle-details` - Controls <details> elements\n- `--aegis-command-play-media`/`--aegis-command-pause-media` - Media element controls\n- `--aegis-command-request-picture-in-picture` - Picture-in-picture for videos\n- `--aegis-command-copy-text` - Copies element's textContent to clipboard\n\n## API\n\n### `observeCommands(target?)`\nSets up automatic command handling. Call once during initialization.\n\n```js\nimport { observeCommands } from './commands.js';\nobserveCommands(); // Observes document.body by default\n```\n\n### `registerCommand(command, callback)`\nRegisters custom commands (must be prefixed with `--`).\n\n```js\nimport { registerCommand } from './commands.js';\n\nregisterCommand('--my-command', (event) => {\n  console.log('Custom command triggered on', event.target);\n});\n```\n\n### `createCommand(callback)`\nGenerates a unique command string and registers the callback.\n\n```js\nimport { createCommand } from './commands.js';\n\nconst cmd = createCommand((event) => {\n  event.target.style.color = 'red';\n});\n// Use `cmd` as the command attribute value\n```\n\n### `command(callback)`\nConvenience function that returns a complete attribute string.\n\n```js\nimport { command } from './commands.js';\n\nelement.innerHTML = `<button ${command(e => alert('clicked'))}>Click me</button>`;\n```\n\n### `listenForCommands(target, init?)`\nManually add command listener to specific elements.\n\n```js\nimport { listenForCommands } from './commands.js';\nlistenForCommands(myElement, { once: true });\n```\n\n## Usage Patterns\n\n### Basic Setup\n```js\nimport { observeCommands } from './commands.js';\nobserveCommands();\n```\n\n### Custom Commands\n```js\nimport { observeCommands, registerCommand } from './commands.js';\n\nregisterCommand('--toggle-class', (event) => {\n  event.target.classList.toggle('active');\n});\n\nobserveCommands();\n```\n\n### Dynamic Command Generation\n```js\nimport { observeCommands, createCommand } from './commands.js';\n\nconst toggleColor = createCommand((event) => {\n  const colors = ['red', 'blue', 'green'];\n  const current = colors.indexOf(event.target.style.color);\n  event.target.style.color = colors[(current + 1) % colors.length];\n});\n\ndocument.body.innerHTML += `<button commandfor=\"target\" command=\"${toggleColor}\">Change Color</button>`;\nobserveCommands();\n```\n\n## CommandEvent Properties\n\nCommand events extend regular events with:\n- `source` - The element that triggered the command (the button/trigger)\n- `command` - The command string that was executed#\n\n# Memory Considerations\n\n> [!WARNING]\n> Command listeners are not automatically removed when elements are deleted. If you're frequently adding/removing elements with `commandfor` attributes in long-running applications, consider using `listenForCommands()` with `{ once: true }` for one-time interactions, or manually manage listeners for dynamic content.\n\n## Security\n\nCommand registration closes automatically after initial setup. Call `closeCommandRegistration()` explicitly if needed for additional security.\n","readmeFilename":"README.md"}