Skip to content

Commit

Permalink
Add Cache Route Option (#48)
Browse files Browse the repository at this point in the history
* Support URI syntax characters (#35)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Expand path regex (#37)

* Added brackets and braces to list of chars

* Added escape char

* Support URI syntax characters (#35) (#36)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Fix memory leak caused by not removing animationend event listener (#41)

* Bump braces from 3.0.2 to 3.0.3 (#40)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump ws from 7.5.9 to 7.5.10 in /examples/vanilla (#39)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated docs

* Bump ws from 7.5.9 to 7.5.10 in /examples/lit (#43)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump braces from 3.0.2 to 3.0.3 in /examples/vanilla (#42)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated docs

* Fix memory leak (#44) (#45)

* Support URI syntax characters (#35)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Expand path regex (#37)

* Added brackets and braces to list of chars

* Added escape char

* Support URI syntax characters (#35) (#36)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Fix memory leak caused by not removing animationend event listener (#41)

* Bump braces from 3.0.2 to 3.0.3 (#40)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...




* Bump ws from 7.5.9 to 7.5.10 in /examples/vanilla (#39)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...




* Updated docs

* Bump ws from 7.5.9 to 7.5.10 in /examples/lit (#43)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...




* Bump braces from 3.0.2 to 3.0.3 in /examples/vanilla (#42)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...




* Updated docs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Stefan Buys <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jn42lm1 <[email protected]>

* Add option to cache route component templates (#46)

* Fix memory leak (#44)

* Support URI syntax characters (#35)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Expand path regex (#37)

* Added brackets and braces to list of chars

* Added escape char

* Support URI syntax characters (#35) (#36)

* Extend regex pattern with additional characters

* Version bump

* Added missing dot char

* Added missing percentile char

* Fix memory leak caused by not removing animationend event listener (#41)

* Bump braces from 3.0.2 to 3.0.3 (#40)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump ws from 7.5.9 to 7.5.10 in /examples/vanilla (#39)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated docs

* Bump ws from 7.5.9 to 7.5.10 in /examples/lit (#43)

Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump braces from 3.0.2 to 3.0.3 in /examples/vanilla (#42)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated docs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Stefan Buys <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jn42lm1 <[email protected]>

* Document clear cache function

* Set the title bar color to identify the project easier

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Stefan Buys <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jn42lm1 <[email protected]>

* Update cache loader to be safe in case the cached component has been garbage collected

* Bump braces from 3.0.2 to 3.0.3 in /examples/lit (#47)

Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Updated docs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Stefan Buys <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jn42lm1 <[email protected]>
  • Loading branch information
4 people authored Aug 26, 2024
1 parent 2262662 commit ce154d4
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 57 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
"workbench.editor.enablePreview": true,
// Enable/disable default HTML formatter.
"html.format.enable": false,
// Set a custom title bar color.
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#920b0b" // Change this color!
}
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ The ```Route``` object contains the following properties:
| -------- | ---- | ----------- |
| **name** | string | The unique identifier for the route, must be the tag name of the web component if tag is not set. |
| **tag** | string | Optional, the registered custom-element tag name for your page web component, e.g. ```'view-login'``` |
| **path** | string | The relative URL path for the route to set in the browser navigation bar, e.g. ```'/login'``` |
| **title** | string | The window title to show when the route is loaded, e.g. ```'Login'``` |
| **animation** | string | Optional, animation to apply when loading the route. Can be one of ```fade```, ```slide```, ```pop```
| **cache** | boolean | Optional, indicator if the route template should be cached and reused, or recreated every time the route is navigated to.
| **load** | function | Optional, function to execute before navigating to the route. Typically used to lazy load the page web component, e.g. <br>```() => import('./views/ViewLogin')``` |
| **guard** | function | Optional, function to execute to check if a route may be navigated to. Typically used to limit access to routes., e.g. <br>```() => !this._isUserLoggedIn()``` |
| **isDefault** | boolean | Optional, flag to set this route as the default route to load when the browser URL path is empty or default, e.g. ```/```. Note: can only be applied to 1 route. |
Expand Down Expand Up @@ -315,6 +317,12 @@ The ```<omni-router>``` tag dispatches the following events, that may be useful
| navigation-started | Fired before the route starts navigating, e.g. after ```guard``` is successful, but before ```load``` is called. |
| navigation-started | Fired after the route page has completely rendered on screen, e.g. after it was fully animated in. |

The ```<omni-router>``` tag provides the following functions:

| Function | Description |
| -------- | ----------- |
| ```clearCache(): void``` | Clear the cache of route components. |

<br>

### Router Class
Expand Down
66 changes: 45 additions & 21 deletions examples/lit/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@capitec/omni-router",
"version": "0.2.7",
"version": "0.3.1",
"description": "Framework agnostic, zero dependency, client-side web component router",
"author": "Capitec",
"license": "MIT",
Expand Down Expand Up @@ -56,4 +56,4 @@
"typedoc": "^0.22.15",
"typescript": "^4.6.4"
}
}
}
30 changes: 15 additions & 15 deletions src/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class RouterImpl {
/** Indicator if the router should log out debug messages. */
DEBUG = false;

// --------------
// INITIALIZATION
// --------------
// ---------------------
// region INITIALIZATION
// ---------------------

/**
* Initialize the router.
Expand All @@ -114,9 +114,9 @@ class RouterImpl {
return this;
}

// ----------
// PROPERTIES
// ----------
// -----------------
// region PROPERTIES
// -----------------

/**
* Get the currently location routed to.
Expand Down Expand Up @@ -181,9 +181,9 @@ class RouterImpl {
return this._routes.find(r => r.isFallback);
}

// --------------
// PUBLIC METHODS
// --------------
// ---------------------
// region PUBLIC METHODS
// ---------------------

/**
* Registers a callback function to be invoked when the router dispatches an event.
Expand Down Expand Up @@ -611,9 +611,9 @@ class RouterImpl {
return this.pop(delta);
}

// --------------
// EVENT HANDLERS
// --------------
// ---------------------
// region EVENT HANDLERS
// ---------------------

/**
* Render the registered route of the current browser URL when a browser navigation button was pressed or navigation API for the back, forward, and go actions was called.
Expand Down Expand Up @@ -663,9 +663,9 @@ class RouterImpl {
this._reportDebug('_onPopState.end');
}

// ---------------
// PRIVATE METHODS
// ---------------
// ----------------------
// region PRIVATE METHODS
// ----------------------

/**
* Report a debug message to the console if debugging is enabled.
Expand Down
Loading

0 comments on commit ce154d4

Please sign in to comment.