{"_id":"@artkravchenko/rudy-history","_rev":"1-5d72d5da0d1ab2d9b4a7178397021d51","name":"@artkravchenko/rudy-history","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@artkravchenko/rudy-history","version":"1.0.1","description":"Fork of the history package for Rudy","repository":{"type":"git","url":"git+https://github.com/artkravchenko/rudy-history.git"},"license":"MIT","author":{"name":"Michael Jackson"},"main":"index.js","module":"es/index.js","scripts":{"start":"webpack-dev-server -d --content-base ./ --history-api-fallback --inline modules/index.js","build":"node ./tools/build.js","prepublish":"node ./tools/build.js","clean":"git clean -fdX .","release":"node ./tools/release.js","lint":"eslint modules","test":"karma start --single-run"},"dependencies":{"invariant":"^2.2.1","loose-envify":"^1.2.0","resolve-pathname":"^2.2.0","value-equal":"^0.4.0","warning":"^3.0.0"},"devDependencies":{"babel-cli":"^6.18.0","babel-core":"^6.23.1","babel-eslint":"^7.0.0","babel-loader":"^6.2.10","babel-plugin-dev-expression":"^0.2.1","babel-plugin-transform-object-assign":"^6.8.0","babel-preset-es2015":"^6.9.0","babel-preset-stage-1":"^6.5.0","eslint":"^3.3.0","eslint-plugin-import":"^2.0.0","expect":"^1.20.1","gzip-size":"^3.0.0","in-publish":"^2.0.0","karma":"^1.2.0","karma-browserstack-launcher":"^1.0.1","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-mocha":"^1.0.1","karma-mocha-reporter":"^2.0.4","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^2.0.1","mocha":"^3.0.2","pretty-bytes":"^4.0.2","readline-sync":"^1.4.4","webpack":"^1.13.1","webpack-dev-server":"^1.14.1"},"browserify":{"transform":["loose-envify"]},"keywords":["history","location"],"gitHead":"84b77430a1878a0da37d7c1e13f92200822f6f36","bugs":{"url":"https://github.com/artkravchenko/rudy-history/issues"},"homepage":"https://github.com/artkravchenko/rudy-history#readme","_id":"@artkravchenko/rudy-history@1.0.1","_nodeVersion":"12.3.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-4tZ64GksHOHyYSTyGKGGXUyTWT1Kz5DPsmtGrg8U9tbHZ1PNRGb6JbvguadO+zjxO+xo2hThif08a3627FksxA==","shasum":"6c17a564d6b2b4d5c811cf6ddede64c233aae63f","tarball":"https://registry.npmjs.org/@artkravchenko/rudy-history/-/rudy-history-1.0.1.tgz","fileCount":22,"unpackedSize":162406,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdB1WSCRA9TVsSAnZWagAAUvwQAIe+WqIREkaBWroY9pqf\nRlo5wgHkWxjuBnh0G6IICkAqPMb5VRH4lfmv7uHiZEoew+iOc7XQyPo/1FkN\nWK0Dh5iE1m1gPP8Bkw2/n+8dV/hCjTY4oM2nwL7OorPSBYd1ISyGGlJAkxd4\nuXfgpAFj+pWFNRabJT8cnJ9rZFdfvaOv+fZN35SKcWq56IWHrQOOTXfLv9Ew\n1WwIHipHDoLHjSazUbFig6588DoPmeVVUovaYiY4n7pMbHUoObAWi4G3UM+w\neRLiziPG3jEAoP0AUWT+KODGAAxzzHslRgP9Gc0eMGHT+v6k+8BmIba8arUO\nPj6PLp/g4sfC/iv0t/DuzgIrN2/cL7zsLGe4YvUiIXA5CLLx3xjS/hMuSYAm\nMBXnq11S8ly/VOaFzADMYckuheOgaZL7OSxxVGyIxMTJxIiR5Qtt7wJtw7II\nVZlFabqTgxCo3JCsvP7vDLlrIpZUvbhOUPnyqhRDK6ahTKceCB0eWbOPAu9z\nzE85dx1Cw2xFAFCgMBhQvsvV+esMK1h1AoykpI7BXkkQgK8gd8uT3iU05Vl+\nvXD2WoZaMcu1Z3P1EZlEj9619x0w74UIa8NEgGLYV4aPwCOwDL/UcFJZYUc6\nWzdV4YqEPksilcKT8dk2UyATbtt2JAIPNdzZ0tdqmza8o+Tpd52qdcOIFoC1\n24Ds\r\n=rLTP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAFXRARJDCkcY03QvpoAAjvVqjr91wKMKHteDor8v3d1AiEAnLLo9dlLCWYeHTULWfcpyd0C5tqSOLdL9lweYYN/LTk="}]},"maintainers":[{"name":"oopscurity","email":"kravchenkofirst@gmail.com"}],"_npmUser":{"name":"oopscurity","email":"kravchenkofirst@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rudy-history_1.0.1_1560761746196_0.566169442855694"},"_hasShrinkwrap":false}},"time":{"created":"2019-06-17T08:55:45.930Z","1.0.1":"2019-06-17T08:55:46.324Z","modified":"2022-04-04T15:39:32.084Z"},"maintainers":[{"name":"oopscurity","email":"kravchenkofirst@gmail.com"}],"description":"Fork of the history package for Rudy","homepage":"https://github.com/artkravchenko/rudy-history#readme","keywords":["history","location"],"repository":{"type":"git","url":"git+https://github.com/artkravchenko/rudy-history.git"},"author":{"name":"Michael Jackson"},"bugs":{"url":"https://github.com/artkravchenko/rudy-history/issues"},"license":"MIT","readme":"> NOTE: this is a fork of the `history` package with `basename` functionality added to the memory history. It's specifically for use with [https://github.com/faceyspacey/redux-first-router](Rudy). Other modifications may follow.\n\n# history [![Travis][build-badge]][build] [![npm package][npm-badge]][npm]\n\n[build-badge]: https://img.shields.io/travis/ReactTraining/history/master.svg?style=flat-square\n[build]: https://travis-ci.org/ReactTraining/history\n\n[npm-badge]: https://img.shields.io/npm/v/history.svg?style=flat-square\n[npm]: https://www.npmjs.org/package/history\n\n[`history`](https://www.npmjs.com/package/history) is a JavaScript library that lets you easily manage session history anywhere JavaScript runs. `history` abstracts away the differences in various environments and provides a minimal API that lets you manage the history stack, navigate, confirm navigation, and persist state between sessions.\n\n## Installation\n\nUsing [npm](https://www.npmjs.com/):\n\n    $ npm install --save history\n\nThen with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:\n\n```js\n// using ES6 modules\nimport createHistory from 'history/createBrowserHistory'\n\n// using CommonJS modules\nvar createHistory = require('history').createBrowserHistory\n```\n\nThe UMD build is also available on [unpkg](https://unpkg.com):\n\n```html\n<script src=\"https://unpkg.com/history/umd/history.min.js\"></script>\n```\n\nYou can find the library on `window.History`.\n\n## Usage\n\n`history` provides 3 different methods for creating a `history` object, depending on your environment.\n\n- `createBrowserHistory` is for use in modern web browsers that support the [HTML5 history API](http://diveintohtml5.info/history.html) (see [cross-browser compatibility](http://caniuse.com/#feat=history))\n- `createMemoryHistory` is used as a reference implementation and may also be used in non-DOM environments, like [React Native](https://facebook.github.io/react-native/) or tests\n- `createHashHistory` is for use in legacy web browsers\n\nDepending on the method you want to use to keep track of history, you'll `import` (or `require`) one of these methods directly from the package root (i.e. `history/createBrowserHistory`). The remainder of this document uses the term `createHistory` to refer to any of these implementations.\n\nBasic usage looks like this:\n\n```js\nimport createHistory from 'history/createBrowserHistory'\n\nconst history = createHistory()\n\n// Get the current location.\nconst location = history.location\n\n// Listen for changes to the current location.\nconst unlisten = history.listen((location, action) => {\n  // location is an object like window.location\n  console.log(action, location.pathname, location.state)\n})\n\n// Use push, replace, and go to navigate around.\nhistory.push('/home', { some: 'state' })\n\n// To stop listening, call the function returned from listen().\nunlisten()\n```\n\nThe options that each `create` method takes, along with its default values, are:\n\n```js\ncreateBrowserHistory({\n  basename: '',             // The base URL of the app (see below)\n  forceRefresh: false,      // Set true to force full page refreshes\n  keyLength: 6,             // The length of location.key\n  // A function to use to confirm navigation with the user (see below)\n  getUserConfirmation: (message, callback) => callback(window.confirm(message))\n})\n\ncreateMemoryHistory({\n  initialEntries: [ '/' ],  // The initial URLs in the history stack\n  initialIndex: 0,          // The starting index in the history stack\n  keyLength: 6,             // The length of location.key\n  // A function to use to confirm navigation with the user. Required\n  // if you return string prompts from transition hooks (see below)\n  getUserConfirmation: null\n})\n\ncreateHashHistory({\n  basename: '',             // The base URL of the app (see below)\n  hashType: 'slash',        // The hash type to use (see below)\n  // A function to use to confirm navigation with the user (see below)\n  getUserConfirmation: (message, callback) => callback(window.confirm(message))\n})\n```\n\n### Properties\n\nEach `history` object has the following properties:\n\n- `history.length` - The number of entries in the history stack\n- `history.location` - The current location (see below)\n- `history.action` - The current navigation action (see below)\n\nAdditionally, `createMemoryHistory` provides `history.index` and `history.entries` properties that let you inspect the history stack.\n\n### Listening\n\nYou can listen for changes to the current location using `history.listen`:\n\n```js\nhistory.listen((location, action) => {\n  console.log(`The current URL is ${location.pathname}${location.search}${location.hash}`)\n  console.log(`The last navigation action was ${action}`)\n})\n```\n\nThe `location` object implements a subset of [the `window.location` interface](https://developer.mozilla.org/en-US/docs/Web/API/Location), including:\n\n- `location.pathname` - The path of the URL\n- `location.search` - The URL query string\n- `location.hash` - The URL hash fragment\n\nLocations may also have the following properties:\n\n- `location.state` - Some extra state for this location that does not reside in the URL (supported in `createBrowserHistory` and `createMemoryHistory`)\n- `location.key` - A unique string representing this location (supported in `createBrowserHistory` and `createMemoryHistory`)\n\nThe `action` is one of `PUSH`, `REPLACE`, or `POP` depending on how the user got to the current URL.\n\n### Navigation\n\n`history` objects may be used programmatically change the current location using the following methods:\n\n- `history.push(path, [state])`\n- `history.replace(path, [state])`\n- `history.go(n)`\n- `history.goBack()`\n- `history.goForward()`\n- `history.canGo(n)` (only in `createMemoryHistory`)\n\nWhen using `push` or `replace` you can either specify both the URL path and state as separate arguments or include everything in a single location-like object as the first argument.\n\n1. A URL path *or*\n2. A location-like object with `{ pathname, search, hash, state }`\n\n```js\n// Push a new entry onto the history stack.\nhistory.push('/home')\n\n// Push a new entry onto the history stack with a query string\n// and some state. Location state does not appear in the URL.\nhistory.push('/home?the=query', { some: 'state' })\n\n// If you prefer, use a single location-like object to specify both\n// the URL and state. This is equivalent to the example above.\nhistory.push({\n  pathname: '/home',\n  search: '?the=query',\n  state: { some: 'state' }\n})\n\n// Go back to the previous history entry. The following\n// two lines are synonymous.\nhistory.go(-1)\nhistory.goBack()\n```\n\n**Note:** Location state is only supported in `createBrowserHistory` and `createMemoryHistory`.\n\n### Blocking Transitions\n\n`history` lets you register a prompt message that will be shown to the user before location listeners are notified. This allows you to make sure the user wants to leave the current page before they navigate away.\n\n```js\n// Register a simple prompt message that will be shown the\n// user before they navigate away from the current page.\nconst unblock = history.block('Are you sure you want to leave this page?')\n\n// Or use a function that returns the message when it's needed.\nhistory.block((location, action) => {\n  // The location and action arguments indicate the location\n  // we're transitioning to and how we're getting there.\n\n  // A common use case is to prevent the user from leaving the\n  // page if there's a form they haven't submitted yet.\n  if (input.value !== '')\n    return 'Are you sure you want to leave this page?'\n})\n\n// To stop blocking transitions, call the function returned from block().\nunblock()\n```\n\n**Note:** You'll need to provide a `getUserConfirmation` function to use this feature with `createMemoryHistory` (see below).\n\n### Customizing the Confirm Dialog\n\nBy default, [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm) is used to show prompt messages to the user. If you need to override this behavior (or if you're using `createMemoryHistory`, which doesn't assume a DOM environment), provide a `getUserConfirmation` function when you create your history object.\n\n```js\nconst history = createHistory({\n  getUserConfirmation(message, callback) {\n    // Show some custom dialog to the user and call\n    // callback(true) to continue the transiton, or\n    // callback(false) to abort it.\n  }\n})\n```\n\n### Using a Base URL\n\nIf all the URLs in your app are relative to some other \"base\" URL, use the `basename` option. This option transparently adds the given string to the front of all URLs you use.\n\n```js\nconst history = createHistory({\n  basename: '/the/base'\n})\n\nhistory.listen(location => {\n  console.log(location.pathname) // /home\n})\n\nhistory.push('/home') // URL is now /the/base/home\n```\n\n**Note:** `basename` is not suppported in `createMemoryHistory`.\n\n### Forcing Full Page Refreshes in createBrowserHistory\n\nBy default `createBrowserHistory` uses HTML5 `pushState` and `replaceState` to prevent reloading the entire page from the server while navigating around. If instead you would like to reload as the URL changes, use the `forceRefresh` option.\n\n```js\nconst history = createBrowserHistory({\n  forceRefresh: true\n})\n```\n\n### Modifying the Hash Type in createHashHistory\n\nBy default `createHashHistory` uses a leading slash in hash-based URLs. You can use the `hashType` option to use a different hash formatting.\n\n\n```js\nconst history = createHashHistory({\n  hashType: 'slash' // the default\n})\n\nhistory.push('/home') // window.location.hash is #/home\n\nconst history = createHashHistory({\n  hashType: 'noslash' // Omit the leading slash\n})\n\nhistory.push('/home') // window.location.hash is #home\n\nconst history = createHashHistory({\n  hashType: 'hashbang' // Google's legacy AJAX URL format\n})\n\nhistory.push('/home') // window.location.hash is #!/home\n```\n\n## Thanks\n\nA big thank-you to [Dan Shaw](https://www.npmjs.com/~dshaw) for letting us use the `history` npm package name! Thanks Dan!\n\nAlso, thanks to [BrowserStack](https://www.browserstack.com/) for providing the infrastructure that allows us to run our build in real browsers.\n","readmeFilename":"README.md"}