{"_id":"@botfather/vite-plugin-units-tools","_rev":"4-566e6a72dd23bab7993e8e64a8a8d077","name":"@botfather/vite-plugin-units-tools","dist-tags":{"latest":"2.0.2"},"versions":{"1.0.0":{"name":"@botfather/vite-plugin-units-tools","version":"1.0.0","license":"MIT","_id":"@botfather/vite-plugin-units-tools@1.0.0","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"homepage":"https://github.com/Botfather/units/tree/main/packages/vite-plugin-units-tools","bugs":{"url":"https://github.com/Botfather/units/issues"},"dist":{"shasum":"587df802a8ccb9281bbb00b113830859dc62483a","tarball":"https://registry.npmjs.org/@botfather/vite-plugin-units-tools/-/vite-plugin-units-tools-1.0.0.tgz","fileCount":4,"integrity":"sha512-Gz5ClbG1R8Kg2OQHlA8fAaC7GqmPSVbhPXqKxmYCdoqcyHttoW0oX8v8QrcwvyDGQoGBCpqhA2GeDZndMT3erQ==","signatures":[{"sig":"MEUCIQDK42efcURSBW61/rrFHEyOYTcKZBCtsiAhf1am5co28wIgSUJpMCCdeJwmkW3/tEUN80aK4CrQ6xq4/w0MpSVqZCg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2fvite-plugin-units-tools@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6994},"main":"./index.js","type":"module","_from":"file:botfather-vite-plugin-units-tools-1.0.0.tgz","types":"./index.d.ts","exports":{".":"./index.js"},"_npmUser":{"name":"botfather","email":"mohan.tushar.11@gmail.com"},"_resolved":"/tmp/f23f7290cf2edb44efaad05d67f691e1/botfather-vite-plugin-units-tools-1.0.0.tgz","_integrity":"sha512-Gz5ClbG1R8Kg2OQHlA8fAaC7GqmPSVbhPXqKxmYCdoqcyHttoW0oX8v8QrcwvyDGQoGBCpqhA2GeDZndMT3erQ==","repository":{"url":"git+https://github.com/Botfather/units.git","type":"git","directory":"packages/vite-plugin-units-tools"},"_npmVersion":"10.8.2","description":"Vite dev tools for Units (.ui) formatting, tokens, and highlighting.","directories":{},"_nodeVersion":"20.20.0","dependencies":{"@botfather/units":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"vite":">=4"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-units-tools_1.0.0_1772457775314_0.37776510894449933","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@botfather/vite-plugin-units-tools","version":"2.0.0","license":"MIT","_id":"@botfather/vite-plugin-units-tools@2.0.0","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"homepage":"https://github.com/Botfather/units/tree/main/packages/vite-plugin-units-tools","bugs":{"url":"https://github.com/Botfather/units/issues"},"dist":{"shasum":"6e098197d77ca0f4636faeb600b4826510dcf690","tarball":"https://registry.npmjs.org/@botfather/vite-plugin-units-tools/-/vite-plugin-units-tools-2.0.0.tgz","fileCount":4,"integrity":"sha512-mohhQvng3+y8vgPE4QUHz/AemyBhj3WiTBJ2K+AxuemNyliKJKsk7tM9Qfy+R4/+85/4625U6mEYd3e5/qxq8Q==","signatures":[{"sig":"MEQCIF077lOhVoGI/LeaplBJ6EXo4mc/xkMbpzsGleY7jkWBAiBsUsMMorlhgkbxjt5JKBSCutjTThbWhyFDe5NRS6Mqpw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2fvite-plugin-units-tools@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6994},"main":"./index.js","type":"module","_from":"file:botfather-vite-plugin-units-tools-2.0.0.tgz","types":"./index.d.ts","exports":{".":"./index.js"},"_npmUser":{"name":"botfather","email":"mohan.tushar.11@gmail.com"},"_resolved":"/tmp/37568463ee29a95f33565d45bd81e560/botfather-vite-plugin-units-tools-2.0.0.tgz","_integrity":"sha512-mohhQvng3+y8vgPE4QUHz/AemyBhj3WiTBJ2K+AxuemNyliKJKsk7tM9Qfy+R4/+85/4625U6mEYd3e5/qxq8Q==","repository":{"url":"git+https://github.com/Botfather/units.git","type":"git","directory":"packages/vite-plugin-units-tools"},"_npmVersion":"10.8.2","description":"Vite dev tools for Units (.ui) formatting, tokens, and highlighting.","directories":{},"_nodeVersion":"20.20.0","dependencies":{"@botfather/units":"2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"vite":">=4"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-units-tools_2.0.0_1772462415501_0.1341868216726807","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@botfather/vite-plugin-units-tools","version":"2.0.1","license":"MIT","_id":"@botfather/vite-plugin-units-tools@2.0.1","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"homepage":"https://github.com/Botfather/units/tree/main/packages/vite-plugin-units-tools","bugs":{"url":"https://github.com/Botfather/units/issues"},"dist":{"shasum":"6d201c6afa190676c513e417d4e77f104a72db75","tarball":"https://registry.npmjs.org/@botfather/vite-plugin-units-tools/-/vite-plugin-units-tools-2.0.1.tgz","fileCount":5,"integrity":"sha512-x4zj5kAEOoWPPrlhRavMygfSeT5A7eX62Kg/rEaN0zEzAZUXzBBUwS0w2xglaph0lvMpMWT4ij3KDi5F3811Vg==","signatures":[{"sig":"MEYCIQD1Cd43J79Rkng7Fm1E470c1XwfFO30QIhkMFizFZLN0AIhALP6p2+dIpcnlLR4RuHwnL7gXGPKVpamhYzs9A/PxYaV","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2fvite-plugin-units-tools@2.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12717},"main":"./index.js","type":"module","_from":"file:botfather-vite-plugin-units-tools-2.0.1.tgz","types":"./index.d.ts","exports":{".":"./index.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:73632916-b619-4faf-a29d-63e2f65b4534"}},"_resolved":"/tmp/e23c638ea95b05d4a7af546fd79ad3b8/botfather-vite-plugin-units-tools-2.0.1.tgz","_integrity":"sha512-x4zj5kAEOoWPPrlhRavMygfSeT5A7eX62Kg/rEaN0zEzAZUXzBBUwS0w2xglaph0lvMpMWT4ij3KDi5F3811Vg==","repository":{"url":"git+https://github.com/Botfather/units.git","type":"git","directory":"packages/vite-plugin-units-tools"},"_npmVersion":"11.17.0","description":"Vite dev tools for Units (.ui) formatting, tokens, and highlighting.","directories":{},"_nodeVersion":"24.16.0","dependencies":{"@botfather/units":"2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"vite":">=4"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-units-tools_2.0.1_1782204408329_0.39164633868242205","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@botfather/vite-plugin-units-tools","version":"2.0.2","description":"Vite dev tools for Units (.ui) formatting, tokens, and highlighting.","license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/Botfather/units.git","directory":"packages/vite-plugin-units-tools"},"homepage":"https://github.com/Botfather/units/tree/main/packages/vite-plugin-units-tools","bugs":{"url":"https://github.com/Botfather/units/issues"},"main":"./index.js","types":"./index.d.ts","exports":{".":"./index.js"},"dependencies":{"@botfather/units":"2.0.1"},"peerDependencies":{"vite":">=4"},"publishConfig":{"access":"public"},"_id":"@botfather/vite-plugin-units-tools@2.0.2","_integrity":"sha512-d9xPnq8R29+vSvbMLu6LdKDbucvnYZqrLzZ4L5lvGHRgpqY+l4khJb3pmIcjxmQbdjP1nvLRkGNFpCf5k/gslg==","_resolved":"/tmp/701f12bbf3429670c9b9fcca5f8249ce/botfather-vite-plugin-units-tools-2.0.2.tgz","_from":"file:botfather-vite-plugin-units-tools-2.0.2.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-d9xPnq8R29+vSvbMLu6LdKDbucvnYZqrLzZ4L5lvGHRgpqY+l4khJb3pmIcjxmQbdjP1nvLRkGNFpCf5k/gslg==","shasum":"14ad4135735f4118c0f50eee86dc917824f4675f","tarball":"https://registry.npmjs.org/@botfather/vite-plugin-units-tools/-/vite-plugin-units-tools-2.0.2.tgz","fileCount":5,"unpackedSize":12717,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2fvite-plugin-units-tools@2.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD70vDKETqpPVNibPPMsywPTPZ92FJhqUm5udPkuKA/twIgUC3virmzYbJcVDTP1/7EyRBf/bsTdWsaIHyHgiFfkKA="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:73632916-b619-4faf-a29d-63e2f65b4534"}},"directories":{},"maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-units-tools_2.0.2_1782219357008_0.7514786062745618"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-02T13:22:55.211Z","modified":"2026-06-23T12:55:57.434Z","1.0.0":"2026-03-02T13:22:55.480Z","2.0.0":"2026-03-02T14:40:15.645Z","2.0.1":"2026-06-23T08:46:48.467Z","2.0.2":"2026-06-23T12:55:57.151Z"},"bugs":{"url":"https://github.com/Botfather/units/issues"},"license":"MIT","homepage":"https://github.com/Botfather/units/tree/main/packages/vite-plugin-units-tools","repository":{"type":"git","url":"git+https://github.com/Botfather/units.git","directory":"packages/vite-plugin-units-tools"},"description":"Vite dev tools for Units (.ui) formatting, tokens, and highlighting.","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"readme":"# @botfather/vite-plugin-units-tools\n\nVite plugin providing dev-time virtual query imports for Units `.ui` files: formatted source text, token streams, syntax-highlighted HTML, and agent-targeted summary payloads. Primarily useful for documentation sites, playgrounds, and editor tooling built on Vite.\n\n## What is it?\n\nThis plugin complements `vite-plugin-units` with extra query variants for each `.ui` file. Instead of loading the AST, these queries give you human-readable or agent-targeted representations: canonical formatted text, a flat token array, syntax-highlighted HTML, or an object with formatted DSL and token estimates.\n\n## Installation\n\n```sh\nnpm install --save-dev @botfather/vite-plugin-units-tools\n```\n\nPeer dependency: Vite >= 4.\n\n## Setup\n\n```js\n// vite.config.js\nimport { defineConfig } from \"vite\";\nimport unitsPlugin from \"@botfather/vite-plugin-units\";\nimport unitsTools from \"@botfather/vite-plugin-units-tools\";\n\nexport default defineConfig({\n  plugins: [\n    unitsPlugin(),\n    unitsTools({ classPrefix: \"ui\" }),\n  ],\n});\n```\n\n## Query imports\n\n| Import syntax | Return type | Description |\n|---|---|---|\n| `import x from './foo.ui?format'` | `string` | Canonical formatted source via `formatUnits` |\n| `import x from './foo.ui?tokens'` | `Array<{type, value}>` | Flat token stream |\n| `import x from './foo.ui?highlight'` | `string` | HTML string of `<span class=\"…\">` elements |\n| `import x from './foo.ui?agent'` | `{ dsl, tokenEstimate, sourceTokenEstimate, tokenReduction, target }` | Agent-facing DSL + rough token estimates |\n\n### `?format`\n\nReturns the `.ui` source after running the canonical formatter. Useful for displaying normalized source in a docs page or playground.\n\n```js\nimport formatted from \"./Button.ui?format\";\n\ndocument.querySelector(\"pre\").textContent = formatted;\n```\n\n### `?tokens`\n\nReturns a flat array of token objects, each with `type` and `value` fields.\n\n```js\nimport tokens from \"./Button.ui?tokens\";\n\n// [{ type: 'ident', value: 'Button' }, { type: 'ws', value: ' ' }, ...]\n```\n\nToken types: `ws`, `comment`, `string`, `directive`, `expr`, `keyword`, `ident`, `number`, `punct`, `unknown`.\n\n### `?highlight`\n\nReturns an HTML string where each token is wrapped in a `<span>` with a class name based on its type.\n\n```js\nimport html from \"./Button.ui?highlight\";\n\ndocument.querySelector(\".code-block\").innerHTML = html;\n```\n\nWith `classPrefix: \"ui\"`, the output looks like:\n\n```html\n<span class=\"ui-tok-ident\">Button</span>\n<span class=\"ui-tok-ws\"> </span>\n<span class=\"ui-tok-punct\">(</span>\n...\n```\n\nApply your own CSS to style each token class.\n\n### `?agent`\n\nReturns an object intended for agent-context debugging:\n- `dsl`: formatted Units source\n- `sourceTokenEstimate`: rough token estimate from the original source\n- `tokenEstimate`: rough token estimate from formatted DSL\n- `tokenReduction`: `(sourceTokenEstimate - tokenEstimate) / sourceTokenEstimate`\n- `target`: target profile (`chat` by default, override with `?agent&target=planner`)\n\n```js\nimport agentPayload from \"./Button.ui?agent\";\n// { dsl, target, sourceTokenEstimate, tokenEstimate, tokenReduction }\n```\n\n## Options\n\n```ts\nunitsTools(options?: {\n  include?: RegExp;       // Only process paths matching this pattern\n  exclude?: RegExp;       // Skip paths matching this pattern\n  classPrefix?: string;   // Prefix for highlight span class names (default: \"\")\n                          // e.g. \"ui\" → class=\"ui-tok-ident\"\n  agentTarget?: string;   // Default target for ?agent query (default: \"chat\")\n})\n```\n\n## TypeScript\n\nAdd the type reference to your app entry or a `.d.ts` file to get typed `?format`, `?tokens`, `?highlight`, and `?agent` imports:\n\n```ts\n/// <reference types=\"@botfather/units/ui\" />\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}