{"_id":"@al4k4z4m/console-mode","_rev":"4-4f8da13f2682d6581d5679e88c3aa5f8","name":"@al4k4z4m/console-mode","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@al4k4z4m/console-mode","version":"0.1.0","_id":"@al4k4z4m/console-mode@0.1.0","maintainers":[{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"}],"dist":{"shasum":"fcb6b1fcb115247f2fbde1cd45301c09a63837c4","tarball":"https://registry.npmjs.org/@al4k4z4m/console-mode/-/console-mode-0.1.0.tgz","fileCount":73,"integrity":"sha512-p1+LRcW6OGUxMe6ZeVMjPO2giuLPRSg4CM5vuabYIhlcFg/pjpe6xPABc132r8dKa+F2a85sIpYiuBtnjEm6sg==","signatures":[{"sig":"MEYCIQDKcfHbwtwgGxWR3Du+9BwRnk6xwpyJxNblnsTaw6ahOgIhAIlo0a6Q4CLcprxjXK7PbPsfCVnDU5XI+CClIOwBUPn5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":368501},"main":"./dist/console-mode.umd.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/console-mode.js","exports":{".":{"import":"./dist/console-mode.js","require":"./dist/console-mode.umd.cjs"}},"gitHead":"69785be7a150e1ff596b25dcb106aed231f6e2d5","scripts":{"dev":"vite","demo":"vite","test":"vitest","build":"vite build","preview":"vite preview"},"_npmUser":{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"},"_npmVersion":"11.7.0","description":"A zero-dependency, plug-and-play JavaScript framework for adding native, console-like controller support to web applications.","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.0","vitest":"^3.2.4","happy-dom":"^20.8.4","typescript":"~5.9.3","@vitest/coverage-v8":"^3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/console-mode_0.1.0_1773859733339_0.28906442679344724","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@al4k4z4m/console-mode","version":"0.1.1","_id":"@al4k4z4m/console-mode@0.1.1","maintainers":[{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"}],"dist":{"shasum":"a81abeda9a2a7a55ce0a7d64f89b462f0565df0e","tarball":"https://registry.npmjs.org/@al4k4z4m/console-mode/-/console-mode-0.1.1.tgz","fileCount":6,"integrity":"sha512-5uEhEkSraU7n8fW0y6tGr3Gsa8ddiO0Yb5iV3JveH30RWKR4MxRjITBMN2cEHfcuh9OTLUf3fOmo9GPLhvpOQQ==","signatures":[{"sig":"MEQCIEB2aspuAUc4TSDmrQStxP0TXg7otq9b87rvYAMyWVZfAiA5GkEQqooxxkr7AwzDrOMXfsviBOCf0uBWKcx9YqEA4Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30536},"main":"./dist/console-mode.umd.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/console-mode.js","exports":{".":{"import":"./dist/console-mode.js","require":"./dist/console-mode.umd.cjs"}},"gitHead":"69785be7a150e1ff596b25dcb106aed231f6e2d5","scripts":{"dev":"vite","demo":"vite","test":"vitest","build":"vite build","preview":"vite preview"},"_npmUser":{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"},"_npmVersion":"11.7.0","description":"A zero-dependency, plug-and-play JavaScript framework for adding native, console-like controller support to web applications. Bridge the gap between hardware polling and DOM-based UI navigation (Spatial Navigation).","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.0","vitest":"^3.2.4","happy-dom":"^20.8.4","typescript":"~5.9.3","@vitest/coverage-v8":"^3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/console-mode_0.1.1_1773860157337_0.32028543828968603","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@al4k4z4m/console-mode","version":"0.1.2","_id":"@al4k4z4m/console-mode@0.1.2","maintainers":[{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"}],"dist":{"shasum":"4b620a50e34eb5a9ccf679f311b4b95a240b3128","tarball":"https://registry.npmjs.org/@al4k4z4m/console-mode/-/console-mode-0.1.2.tgz","fileCount":6,"integrity":"sha512-XLsBC2KoibSdyx4p6t2705s4C5x9iSme50/c7vRYeyWrOHrrv97LTO9sV8VDbmliQbjp8+KRlhbQJLnigDHE1Q==","signatures":[{"sig":"MEUCIBjLeYkGev8l5SqTvHVd1jYStlXD9dw4o5MaY8vJ2je0AiEA6Zj3nej+8gee6Cdt+mY2Oe9Ss5lnsj+w81K4xCcqHs0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30536},"main":"./dist/console-mode.umd.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/console-mode.js","exports":{".":{"import":"./dist/console-mode.js","require":"./dist/console-mode.umd.cjs"}},"gitHead":"69785be7a150e1ff596b25dcb106aed231f6e2d5","scripts":{"dev":"vite","demo":"vite","test":"vitest","build":"vite build","preview":"vite preview"},"_npmUser":{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"},"_npmVersion":"11.7.0","description":"A zero-dependency, plug-and-play JavaScript framework for adding native, console-like controller support to web applications. Bridge the gap between hardware polling and DOM-based UI navigation (Spatial Navigation).","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.0","vitest":"^3.2.4","happy-dom":"^20.8.4","typescript":"~5.9.3","@vitest/coverage-v8":"^3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/console-mode_0.1.2_1773860443401_0.05020636618866603","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@al4k4z4m/console-mode","version":"0.1.3","description":"A zero-dependency framework for adding native controller support and spatial navigation to web applications.","type":"module","main":"./dist/console-mode.umd.cjs","module":"./dist/console-mode.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/console-mode.js","require":"./dist/console-mode.umd.cjs"}},"scripts":{"dev":"vite","demo":"vite","build":"vite build","test":"vitest","preview":"vite preview"},"devDependencies":{"@vitest/coverage-v8":"^3.2.4","happy-dom":"^20.8.4","typescript":"~5.9.3","vite":"^8.0.0","vitest":"^3.2.4"},"gitHead":"69785be7a150e1ff596b25dcb106aed231f6e2d5","_id":"@al4k4z4m/console-mode@0.1.3","_nodeVersion":"22.18.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-AGqhjrqLUrgZ6puKbStaV8XB+F1M0CJfMcxqChCMcq7twk4QrlO9PK33LbBEwcF/K85kkIhcjxjAuezCeP9VBQ==","shasum":"f4c6e48991dd0bc28410200a9fa259e8e8c0bc8c","tarball":"https://registry.npmjs.org/@al4k4z4m/console-mode/-/console-mode-0.1.3.tgz","fileCount":6,"unpackedSize":30648,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDQyuJVQmMLybtgth2Pr25TId7f2+rmqZ7X1V4u0WH3+QIhAJbEaQIHwmfVeuMMdXm90pNC3M0WR2y03rR51Qm4KnUe"}]},"_npmUser":{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"},"directories":{},"maintainers":[{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/console-mode_0.1.3_1773860638814_0.43731547552222727"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-18T18:48:53.227Z","modified":"2026-03-18T19:03:59.112Z","0.1.0":"2026-03-18T18:48:53.487Z","0.1.1":"2026-03-18T18:55:57.478Z","0.1.2":"2026-03-18T19:00:43.543Z","0.1.3":"2026-03-18T19:03:58.989Z"},"description":"A zero-dependency framework for adding native controller support and spatial navigation to web applications.","maintainers":[{"name":"al4k4z4m","email":"thewindsofaugust@gmail.com"}],"readme":"# @al4k4z4m/console-mode\r\n\r\nA zero-dependency, plug-and-play JavaScript framework for adding native, console-like controller support to web applications. Bridge the gap between hardware polling and DOM-based UI navigation (Spatial Navigation).\r\n\r\n## 🚀 Features\r\n- **Spatial Navigation:** Smart, proximity-based 2D navigation (Up/Down/Left/Right).\r\n- **Focus Memory:** Automatically remembers and restores focus within containers (`data-nav-container`).\r\n- **Dynamic DOM Support:** Automatically detects added/removed elements via `MutationObserver`.\r\n- **Hardware Ready:** Built-in 60Hz polling and optimized mapping for standard controllers and DualSense (PS5).\r\n- **Ultra-Lightweight:** ~2.1KB gzipped, 0 dependencies.\r\n\r\n## 📦 Installation\r\n```bash\r\nnpm install @al4k4z4m/console-mode\r\n```\r\n\r\n## 🛠 Quick Start\r\n\r\n### 1. Define Focusable Elements\r\nSimply add `data-nav-focusable` to any element you want the controller to reach.\r\n\r\n```html\r\n<nav data-nav-container=\"sidebar\">\r\n  <button data-nav-focusable>Home</button>\r\n  <button data-nav-focusable>Gallery</button>\r\n</nav>\r\n\r\n<main data-nav-container=\"content\">\r\n  <div class=\"card\" data-nav-focusable>Project 1</div>\r\n  <div class=\"card\" data-nav-focusable>Project 2</div>\r\n</main>\r\n```\r\n\r\n### 2. Initialize the Engine\r\n```javascript\r\nimport { FocusManager, GamepadPoller, GamepadMapper, GamepadManager } from '@al4k4z4m/console-mode';\r\n\r\nconst focusManager = new FocusManager();\r\nconst mapper = new GamepadMapper();\r\nconst manager = new GamepadManager();\r\n\r\n// Gamepad polling loop (60Hz)\r\nconst poller = new GamepadPoller((gamepads) => {\r\n  gamepads.forEach(pad => {\r\n    if (!pad) return;\r\n\r\n    // 1. Check Axes (Sticks & D-pad)\r\n    pad.axes.forEach((val, idx) => {\r\n      const intent = mapper.getIntentFromAxis(idx, val);\r\n      if (intent) focusManager.move(intent);\r\n    });\r\n\r\n    // 2. Check Buttons (Cross, Square, etc.)\r\n    pad.buttons.forEach((btn, idx) => {\r\n      if (btn.pressed) {\r\n        const intent = mapper.getIntentFromButton(idx);\r\n        if (intent === 'select') {\r\n          focusManager.getCurrentFocus()?.click();\r\n        }\r\n      }\r\n    });\r\n  });\r\n});\r\n\r\npoller.start();\r\n```\r\n\r\n## 🎮 DualSense (PS5) Support\r\nThis framework is pre-configured for the DualSense controller on Windows/Chrome:\r\n- **Cross Button (Index 1):** Mapped to `select`.\r\n- **D-Pad (Axis 9):** Fully supported via POV Hat mapping.\r\n- **Left Stick:** Mapped to standard navigation.\r\n\r\n## 📚 API Reference\r\n\r\n### HTML Attributes\r\n- `data-nav-focusable`: Marks an element as navigable.\r\n- `data-nav-container=\"id\"`: Groups elements. When focus enters the container, the framework restores the last focused child.\r\n\r\n### Event System\r\nElements dispatch custom events for easy styling or analytics:\r\n- `nav-focus`: Dispatched when an element gains focus.\r\n- `nav-blur`: Dispatched when an element loses focus.\r\n- `nav-focus-change`: Bubbles from the newly focused element.\r\n\r\n```javascript\r\ndocument.addEventListener('nav-focus', (e) => {\r\n  console.log('Focused element:', e.detail.element);\r\n});\r\n```\r\n\r\n## 📄 License\r\nMIT\r\n","readmeFilename":"README.md"}