{"id":18584585,"url":"https://github.com/ui-router/visualizer","last_synced_at":"2025-04-04T13:13:04.856Z","repository":{"id":3828725,"uuid":"50962056","full_name":"ui-router/visualizer","owner":"ui-router","description":"UI-Router state visualizer and transition visualizer","archived":false,"fork":false,"pushed_at":"2023-01-07T06:47:34.000Z","size":5392,"stargazers_count":214,"open_issues_count":77,"forks_count":33,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T12:09:23.861Z","etag":null,"topics":["angular","angularjs","javascript","react","router","state-tree","state-visualizer","svg","transition","transition-visualizer","typescript","ui-router","visualizer"],"latest_commit_sha":null,"homepage":null,"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/ui-router.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-03T00:26:21.000Z","updated_at":"2025-02-08T13:40:52.000Z","dependencies_parsed_at":"2023-01-13T13:00:24.889Z","dependency_job_id":null,"html_url":"https://github.com/ui-router/visualizer","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-router%2Fvisualizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-router%2Fvisualizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-router%2Fvisualizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ui-router%2Fvisualizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ui-router","download_url":"https://codeload.github.com/ui-router/visualizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182401,"owners_count":20897381,"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":["angular","angularjs","javascript","react","router","state-tree","state-visualizer","svg","transition","transition-visualizer","typescript","ui-router","visualizer"],"created_at":"2024-11-07T00:28:03.624Z","updated_at":"2025-04-04T13:13:04.836Z","avatar_url":"https://github.com/ui-router.png","language":"TypeScript","readme":"# UI-Router State Visualizer and Transition Visualizer\n\nTry the [Demo plunker](http://plnkr.co/edit/MZ7ypavytxD1Ty1UHozo?p=info)\n\n![Image of Visualizer](https://pbs.twimg.com/media/Cn7epJ_UMAAHWqu.jpg)\n\n## What\n\nVisualizes the state tree and transitions in UI-Router 1.0+.\n\nThis script augments your app with two components:\n\n1. State Visualizer: Your UI-Router state tree, showing the active state and its active ancestors (green nodes)\n\n   - Clicking a state will transition to that state.\n   - If your app is large, state trees can be collapsed by double-clicking a state.\n   - Supports different layouts and zoom.\n\n2. Transition Visualizer: A list of each transition (from one state to another)\n\n   - Color coded Transition status (success/error/ignored/redirected)\n   - Hover over a Transition to show which states were entered/exited, or retained during the transition.\n   - Click the Transition to see details (parameter values and resolve data)\n\n## How\n\nThe Visualizer is a UI-Router plugin.\nRegister the plugin with the `UIRouter` object.\n\n### Locate the Plugin\n\n- Using a `\u003cscript\u003e` tag\n\n  Add the script as a tag in your HTML.\n\n  ```html\n  \u003cscript src=\"//unpkg.com/@uirouter/visualizer@4\"\u003e\u003c/script\u003e\n  ```\n\n  The visualizer Plugin can be found (as a global variable) on the window object.\n\n  ```js\n  var Visualizer = window['@uirouter/visualizer'].Visualizer;\n  ```\n\n- Using `require` or `import` (SystemJS, Webpack, etc)\n\n  Add the npm package to your project\n\n  ```\n  npm install @uirouter/visualizer\n  ```\n\n  - Use `require` or ES6 `import`:\n\n  ```js\n  var Visualizer = require('@uirouter/visualizer').Visualizer;\n  ```\n\n  ```js\n  import { Visualizer } from '@uirouter/visualizer';\n  ```\n\n### Register the plugin\n\nFirst get a reference to the `UIRouter` object instance.\nThis differs by framework (AngularJS, Angular, React, etc. See below for details).\n\nAfter getting a reference to the `UIRouter` object, register the `Visualizer` plugin\n\n```js\nvar pluginInstance = uiRouterInstance.plugin(Visualizer);\n```\n\n---\n\n# \u0026nbsp;\n\n---\n\n### Configuring the plugin\n\nYou can pass a configuration object when registering the plugin.\nThe configuration object may have the following fields:\n\n- `state`: (boolean) State Visualizer is not rendered when this is `false`\n- `transition`: (boolean) Transition Visualizer is not rendered when this is `false`\n- `stateVisualizer.node.label`: (function) A function that returns the label for a node\n- `stateVisualizer.node.classes`: (function) A function that returns classnames to apply to a node\n\n#### `stateVisualizer.node.label`\n\nThe labels for tree nodes can be customized.\n\nProvide a function that accepts the node object and the default label and returns a string:\n\n```\nfunction(node, defaultLabel) { return \"label\"; }\n```\n\nThis example adds ` (future)` to future states.\n_Note: `node.self` contains a reference to the state declaration object._\n\n```js\nvar options = {\n  stateVisualizer: {\n    node: {\n      label: function (node, defaultLabel) {\n        return node.self.name.endsWith('.**') ? defaultLabel + ' (future)' : defaultLabel;\n      },\n    },\n  },\n};\n\nvar pluginInstance = uiRouterInstance.plugin(Visualizer, options);\n```\n\n#### `stateVisualizer.node.classes`\n\nThe state tree visualizer can be configured to add additional classes to nodes.\nExample below marks every node with angular.js view with `is-ng1` class.\n\n```js\nvar options = {\n  stateVisualizer: {\n    node: {\n      classes(node) {\n        return Object.entries(node.views || {}).some((routeView) =\u003e routeView[1] \u0026\u0026 routeView[1].$type === 'ng1')\n          ? 'is-ng1'\n          : '';\n      },\n    },\n  },\n};\n\nvar pluginInstance = uiRouterInstance.plugin(Visualizer, options);\n```\n\n### Getting a reference to the `UIRouter` object\n\n#### Angular 1\n\nInject the `$uiRouter` router instance in a run block.\n\n```js\n// inject the router instance into a `run` block by name\napp.run(function ($uiRouter) {\n  var pluginInstance = $uiRouter.plugin(Visualizer);\n});\n```\n\n#### Angular 2\n\nUse a config function in your root module's `UIRouterModule.forRoot()`.\nThe router instance is passed to the config function.\n\n```js\nimport { Visualizer } from \"@uirouter/visualizer\";\n\n...\n\nexport function configRouter(router: UIRouter) {\n  var pluginInstance = router.plugin(Visualizer);\n}\n\n...\n\n@NgModule({\n  imports: [ UIRouterModule.forRoot({ config: configRouter }) ]\n  ...\n```\n\n#### React (Imperative)\n\nCreate the UI-Router instance manually by calling `new UIRouterReact();`\n\n```js\nvar Visualizer = require('@uirouter/visualizer').Visualizer;\nvar router = new UIRouterReact();\nvar pluginInstance = router.plugin(Visualizer);\n```\n\n#### React (Declarative)\n\nAdd the plugin to your `UIRouter` component\n\n```js\nvar Visualizer = require('@uirouter/visualizer').Visualizer;\n\n...\nrender() {\n  return \u003cUIRouter plugins=[Visualizer]\u003e\u003c/UIRouter\u003e\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fui-router%2Fvisualizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fui-router%2Fvisualizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fui-router%2Fvisualizer/lists"}