svelte-guard-history-router
Advanced tools
Comparing version 2.24.0 to 2.24.1
{ | ||
"name": "svelte-guard-history-router", | ||
"version": "2.24.0", | ||
"version": "2.24.1", | ||
"publishConfig": { | ||
@@ -10,7 +10,7 @@ "access": "public" | ||
"keywords": [ | ||
"svelte", | ||
"component", | ||
"router", | ||
"spa", | ||
"web", | ||
"component" | ||
"svelte", | ||
"web" | ||
], | ||
@@ -25,5 +25,6 @@ "contributors": [ | ||
"scripts": { | ||
"start": "rollup -c example/rollup.config.mjs -w", | ||
"test": "ava --timeout 2m && npm run testcafe", | ||
"testcafe": "testcafe $BROWSER:headless testcafe/*.js -s test-results --app-init-delay 5000 --app \"rollup -c example/rollup.config.mjs -w\"", | ||
"start": "rollup -c tests/app/rollup.config.mjs -w", | ||
"test": "npm run test:ava && npm run test:cafe", | ||
"test:ava": "ava --timeout 2m tests/*.mjs", | ||
"test:cafe": "testcafe $BROWSER:headless tests/cafe/*.js -s build/test --app-init-delay 1000 --app \"rollup -c tests/app/rollup.config.mjs -w\"", | ||
"docs": "documentation readme ./src/index.mjs --section=API", | ||
@@ -36,11 +37,12 @@ "lint": "documentation lint ./src/index.mjs" | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"ava": "^3.11.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"ava": "^3.11.1", | ||
"documentation": "^13.0.2", | ||
"rollup": "^2.23.0", | ||
"jsdom": "^16.4.0", | ||
"rollup": "^2.28.1", | ||
"rollup-plugin-dev": "^1.1.2", | ||
"rollup-plugin-svelte": "^5.2.3", | ||
"semantic-release": "^17.1.1", | ||
"svelte": "^3.24.0", | ||
"testcafe": "^1.8.8" | ||
"rollup-plugin-svelte": "^6.0.1", | ||
"semantic-release": "^17.1.2", | ||
"svelte": "^3.25.1", | ||
"testcafe": "^1.9.3" | ||
}, | ||
@@ -47,0 +49,0 @@ "repository": { |
413
README.md
@@ -6,7 +6,6 @@ [![Svelte v3](https://img.shields.io/badge/svelte-v3-orange.svg)](https://svelte.dev) | ||
[![downloads](http://img.shields.io/npm/dm/svelte-guard-history-router.svg?style=flat-square)](https://npmjs.org/package/svelte-guard-history-router) | ||
[![Build Status](https://travis-ci.com/arlac77/svelte-guard-history-router.svg?branch=master)](https://travis-ci.com/arlac77/svelte-guard-history-router) | ||
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/svelte-guard-history-router.svg?style=flat-square)](https://github.com/arlac77/svelte-guard-history-router/issues) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/arlac77/svelte-guard-history-router.git) | ||
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/svelte-guard-history-router/badge.svg)](https://snyk.io/test/github/arlac77/svelte-guard-history-router) | ||
[![Build Action Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fsvelte-guard-history-router%2Fbadge&style=flat)](https://actions-badge.atrox.dev/arlac77/svelte-guard-history-router/goto) | ||
[![Coverage Status](https://coveralls.io/repos/arlac77/svelte-guard-history-router/badge.svg)](https://coveralls.io/r/arlac77/svelte-guard-history-router) | ||
@@ -108,408 +107,4 @@ # svelte-guard-history-router | ||
### Table of Contents | ||
## Table of Contents | ||
- [Key](#key) | ||
- [Properties](#properties) | ||
- [BaseRouter](#baserouter) | ||
- [Parameters](#parameters) | ||
- [Properties](#properties-1) | ||
- [component](#component) | ||
- [value](#value) | ||
- [replace](#replace) | ||
- [Parameters](#parameters-1) | ||
- [push](#push) | ||
- [Parameters](#parameters-2) | ||
- [finalizePush](#finalizepush) | ||
- [Parameters](#parameters-3) | ||
- [continue](#continue) | ||
- [abort](#abort) | ||
- [subscribe](#subscribe) | ||
- [Parameters](#parameters-4) | ||
- [updateActive](#updateactive) | ||
- [Parameters](#parameters-5) | ||
- [addRoute](#addroute) | ||
- [Parameters](#parameters-6) | ||
- [routeFor](#routefor) | ||
- [Parameters](#parameters-7) | ||
- [nameValueStore](#namevaluestore) | ||
- [Parameters](#parameters-8) | ||
- [Properties](#properties-2) | ||
- [Transition](#transition) | ||
- [Parameters](#parameters-9) | ||
- [Properties](#properties-3) | ||
- [start](#start) | ||
- [end](#end) | ||
- [redirect](#redirect) | ||
- [Parameters](#parameters-10) | ||
- [continue](#continue-1) | ||
- [abort](#abort-1) | ||
- [Parameters](#parameters-11) | ||
- [SkeletonRoute](#skeletonroute) | ||
- [Properties](#properties-4) | ||
- [path](#path) | ||
- [enter](#enter) | ||
- [Parameters](#parameters-12) | ||
- [leave](#leave) | ||
- [Parameters](#parameters-13) | ||
- [propertiesFor](#propertiesfor) | ||
- [Parameters](#parameters-14) | ||
- [commonAncestor](#commonancestor) | ||
- [Parameters](#parameters-15) | ||
- [propertyMapping](#propertymapping) | ||
- [objectFor](#objectfor) | ||
- [Parameters](#parameters-16) | ||
- [Guard](#guard) | ||
- [enter](#enter-1) | ||
- [Parameters](#parameters-17) | ||
- [leave](#leave-1) | ||
- [Parameters](#parameters-18) | ||
- [redirectGuard](#redirectguard) | ||
- [Parameters](#parameters-19) | ||
- [sequenceGuard](#sequenceguard) | ||
- [Parameters](#parameters-20) | ||
- [parallelGuard](#parallelguard) | ||
- [Parameters](#parameters-21) | ||
- [WaitingGuard](#waitingguard) | ||
- [Parameters](#parameters-22) | ||
## Key | ||
Keys also act as svelte stores and can be subscribed. | ||
```js | ||
export const article = derived( | ||
[articles, router.keys.article], | ||
([$articles, $id], set) => { | ||
set($articles.find(a => a.id === $id)); | ||
return () => {}; | ||
} | ||
); | ||
``` | ||
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
### Properties | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `value` **any** | ||
- `subscriptions` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)** | ||
## BaseRouter | ||
key subscriptions: | ||
```js | ||
const aKey = router.keys.aKey; | ||
$aKey // fired if value of aKey changes | ||
``` | ||
### Parameters | ||
- `routes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<Route>** (optional, default `[]`) | ||
- `base` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** url (optional, default `""`) | ||
### Properties | ||
- `linkNodes` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)>** nodes having their active state updated | ||
- `routes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<Route>** | ||
- `keys` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** collected keys of all routes | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** value mapping from keys (from current route) | ||
- `route` **Route** current | ||
- `transition` **[Transition](#transition)** ongoing transition | ||
- `base` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** url | ||
### component | ||
Current component. | ||
Either from a redirected transition or from the current route | ||
Returns **SvelteComponent** | ||
### value | ||
Value if the current route | ||
Returns **any** | ||
### replace | ||
Replace current route | ||
#### Parameters | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** former state | ||
### push | ||
Leave current route and enter route for given path | ||
The work is done by a Transition | ||
#### Parameters | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** where to go | ||
Returns **[Transition](#transition)** running transition | ||
### finalizePush | ||
Called from a transition to manifest the new destination. | ||
If path is undefined the transition has been aborderd | ||
#### Parameters | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
### continue | ||
Continue a transition to its original destination. | ||
Shortcut for this.transition.continue() | ||
Does nothing if there is no transition. | ||
### abort | ||
Abort a transition. | ||
Shortcut for this.transition.abort() | ||
Does nothing if there is no transition. | ||
### subscribe | ||
Router subscription | ||
Changes in the current route will trigger a update | ||
#### Parameters | ||
- `subscription` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** | ||
### updateActive | ||
Update the active state of a node | ||
#### Parameters | ||
- `node` **[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)** | ||
### addRoute | ||
Add a new route. | ||
#### Parameters | ||
- `route` **Route** | ||
### routeFor | ||
Find Route for a given object | ||
#### Parameters | ||
- `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
Returns **Route** able to support given object | ||
## nameValueStore | ||
Create a named object wich can act as a store | ||
### Parameters | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `initialValue` **any** | ||
### Properties | ||
- `value` **any** | ||
Returns **Store** | ||
## Transition | ||
Transition between routes | ||
### Parameters | ||
- `router` **Router** | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** destination | ||
### Properties | ||
- `router` **Router** | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** destination | ||
- `state` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
### start | ||
Start the transition | ||
- leave old route | ||
- find matching target route @see matcher() | ||
- set params | ||
- set current route | ||
- enter new route | ||
### end | ||
- **See: Router.finalizePush | ||
** | ||
Cleanup transition | ||
Update Nodes active state | ||
### redirect | ||
Halt current transition and go to another route. | ||
To proceed with the original route by calling [continue()](continue()) | ||
The original transition will cept in place and be continued afterwards | ||
#### Parameters | ||
- `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** new route to enter temporary | ||
### continue | ||
Continue a redirected route to its original destination. | ||
Does nothing if the transition has not been redirected | ||
### abort | ||
Bring back the router into the state before the transition has started | ||
#### Parameters | ||
- `e` **(Exception | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** | ||
## SkeletonRoute | ||
Route | ||
### Properties | ||
- `_path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `component` **SvelteComponent** target to show | ||
- `linkComponent` **SvelteComponent** content for [ObjectLink](ObjectLink) | ||
- `priority` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** | ||
- `keys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** as found in the path | ||
- `regex` **RegEx** | ||
- `value` **any** | ||
### path | ||
Full path of the Route including all parents | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** path | ||
### enter | ||
Enter the route from a former one. | ||
#### Parameters | ||
- `transition` **[Transition](#transition)** | ||
- `untilRoute` **Route** the common ancestor with the former route | ||
### leave | ||
Leave the route to a new one. | ||
#### Parameters | ||
- `transition` **[Transition](#transition)** | ||
- `untilRoute` **Route** the common ancestor with the next route | ||
### propertiesFor | ||
Extract properties from object. | ||
#### Parameters | ||
- `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** properties extracted from given objects | ||
### commonAncestor | ||
Find common ancestor with another Route | ||
#### Parameters | ||
- `other` **Route** | ||
Returns **(Route | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** common ancestor Route between receiver and other | ||
### propertyMapping | ||
Map properties to objects attributes. | ||
Keys are the property names and values are the keys in the resulting object. | ||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
### objectFor | ||
Deliver object for a given set of properties | ||
#### Parameters | ||
- `transition` | ||
- `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** for matching properties | ||
## Guard | ||
Enforces conditions of routes | ||
Like the presents of values in the context | ||
### enter | ||
Called while entering a route (current outlet is not yet set) | ||
#### Parameters | ||
- `transition` **[Transition](#transition)** | ||
### leave | ||
Called before leaving a route | ||
#### Parameters | ||
- `transition` **[Transition](#transition)** | ||
## redirectGuard | ||
Redirects to a given url if condition is met | ||
### Parameters | ||
- `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `condition` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** redirects when returning true | ||
## sequenceGuard | ||
Execute guards in a sequence | ||
### Parameters | ||
- `children` **Iterable<[Guard](#guard)>** | ||
## parallelGuard | ||
Execute guards in a parallel | ||
### Parameters | ||
- `children` **Iterable<[Guard](#guard)>** | ||
## WaitingGuard | ||
**Extends Guard** | ||
Shows a component during transition | ||
### Parameters | ||
- `component` **SvelteComponent** to show up during th transition | ||
- `rampUpTime` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** initial delay for the componnt to show up (optional, default `300`) | ||
# install | ||
@@ -516,0 +111,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
693
29413
10
139