{"id":14385185,"url":"https://github.com/leeluolee/stateman","last_synced_at":"2025-04-04T22:02:08.369Z","repository":{"id":24144723,"uuid":"27534172","full_name":"leeluolee/stateman","owner":"leeluolee","description":"A tiny foundation that providing nested state-based routing for complex web application.","archived":false,"fork":false,"pushed_at":"2022-01-04T11:47:42.000Z","size":6657,"stargazers_count":387,"open_issues_count":12,"forks_count":36,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-28T21:01:38.474Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://leeluolee.github.io/stateman","language":"JavaScript","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/leeluolee.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}},"created_at":"2014-12-04T09:57:22.000Z","updated_at":"2025-02-28T11:04:24.000Z","dependencies_parsed_at":"2022-07-06T05:01:27.439Z","dependency_job_id":null,"html_url":"https://github.com/leeluolee/stateman","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeluolee%2Fstateman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeluolee%2Fstateman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeluolee%2Fstateman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeluolee%2Fstateman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leeluolee","download_url":"https://codeload.github.com/leeluolee/stateman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256102,"owners_count":20909240,"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":[],"created_at":"2024-08-28T18:02:01.058Z","updated_at":"2025-04-04T22:02:08.352Z","avatar_url":"https://github.com/leeluolee.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","8. 路由和链接(Routing And URLs)"],"sub_categories":[],"readme":"StateMan\n=======\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/leeluolee/stateman?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\n[![Build Status](http://img.shields.io/travis/regularjs/regular/master.svg?style=flat-square)](http://travis-ci.org/regularjs/regular)\n\n\nstateman: A tiny foundation that provides nested state-based routing for complex web applications. \n\n\nstateman is highly inspired by [ui-router](https://github.com/angular-ui/ui-router); you will find many features similar to it.\n\nBut stateman is a __standalone library__ with an extremely tiny codebase (5kb minified). Feel free to integrate it with whatever framework you like! \n\n\n\n## Reference\n\n- [English](http://leeluolee.github.io/stateman/)\n- [中文手册](http://leeluolee.github.io/stateman/?API-zh)\n\n\n## Feature\n\n0. nested routing support.\n1. standalone with tiny codebase.\n2. async routing support if you need asynchronous logic in navigating. Support Promise\n3. html5 history supported, fallback to hash-based in old browser. \n5. [concise API](https://github.com/leeluolee/stateman/tree/master/docs/API.md), deadly simple to getting start with it.\n6. support IE6+ and other modern browsers.\n7. __well tested, born in large product.__\n\n\n## Quick Start\n\nYou may need a static server to run the demo. [puer](https://github.com/leeluolee/puer) is simple to get start.\n\njust paste the code to your own `index.html`, and load it up in a browser. \n\n```html\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003ctitle\u003eStateMan Test\u003c/title\u003e\n  \u003cscript src=\"https://rawgit.com/leeluolee/stateman/master/stateman.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cul\u003e\n  \u003cli\u003e\u003ca href=\"#/home\"\u003e/home\"\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#/contact\"\u003e/contact\"\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#/contact/list\"\u003e/contact/list\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#/contact/2\"\u003e/contact/2\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#/contact/2/option\"\u003e/contact/2/option\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#/contact/2/message\"\u003e/contact/2/message\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n  \n\u003cscript\u003e\n  var config = {\n    enter: function(){\n      console.log(\"enter: \" + this.name)\n    },\n    leave: function(){\n      console.log(\"leave: \" + this.name)\n    }\n  }\n\n  function create(o){\n    o = o || {};\n    o.enter= config.enter;\n    o.leave = config.leave;\n    return o;\n  }\n\n  var stateman = new StateMan();\n\n  stateman\n    .state(\"home\", config)\n    .state(\"contact\", config)\n    .state(\"contact.list\", config )\n    .state(\"contact.detail\", create({url: \":id(\\\\d+)\"}))\n    .state(\"contact.detail.option\", config)\n    .state(\"contact.detail.message\", config)\n    .start({});\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n\nopen the console to see the output when navigating.\n\n\n## Demos\n\n###1.  [Simple Layout Demo:](http://leeluolee.github.io/stateman/example/layout.html) \n\nThe code in this demo is for demonstration only. In a production development, you will want a view layer to create nested views.\n\n###2. A simple SPA built upon [Regularjs (Living Template)](https://github.com/regularjs/regular) + requirejs + stateman: [Link](http://regularjs.github.io/regular-state/requirejs/index-min.html)\n\nI create a simple wrapping ([regular-state](https://github.com/regularjs/regular-state)) to integrate stateman with Regularjs, which makes it easy to build a single Page Application.  thanks to the concise API, [the code](https://github.com/regularjs/regular-state/blob/master/example/requirejs/index.js#L83) is very clean. You will find that integrating stateman with other libraries is also simple.\n\n\n\n\n## Browser Support \n\n1. Modern browsers, including mobile devices\n2. IE6+\n\n\n## Installation\n\n### Bower\n\n```javascript\nbower install stateman\n```\n\n`stateman.js` have been packaged as a standard UMD, so you can use it in AMD, CommonJS and as a global.\n\n### npm (browserify or other based on commonjs)\n\n```js\nnpm install stateman\n```\n\nTo use:\n\n```js\nvar StateMan = require('stateman');\n```\n\n### [spm](http://spmjs.io/package/stateman)\n\n```js\nspm install stateman\n```\n\nTo use:\n\n```js\nvar StateMan = require('stateman');\n```\n\n### Component\n\n```js\ncomponent install leeluolee/stateman\n```\n\nTo use:\n\n```js\nvar StateMan = require('leeluolee/stateman');\n```\n\n\n\n### Direct downloads\n\n1. [stateman.js](https://rawgit.com/leeluolee/stateman/master/stateman.js)\n2. [stateman.min.js](https://rawgit.com/leeluolee/stateman/master/stateman.min.js)\n\n\n\n\n\n\n\n## Examples\n\nSome basic examples can be found in [the examples directory](https://github.com/leeluolee/stateman/tree/master/example).\n\n__run demo local__\n\n1. clone this repo\n2. `npm install gulp -g \u0026\u0026 npm install`\n3. `gulp server`\n4.  check the example folder\n\n\n\n## LICENSE\n\nMIT.\n\n\n## ChangLog\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeluolee%2Fstateman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleeluolee%2Fstateman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeluolee%2Fstateman/lists"}