Skip to content

Commit

Permalink
added: Typescript interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Nov 3, 2023
1 parent a0d15f0 commit d8da1fe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
23 changes: 23 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { RiotComponentWrapper, RiotComponent } from 'riot'
import { URLWithParams } from 'rawth'

export * from 'rawth'
export type Route = RiotComponentWrapper<
RiotComponent<{
path: string
'on-before-mount'?: (path: URLWithParams) => void
'on-mounted'?: (path: URLWithParams) => void
'on-before-unmount'?: (path: URLWithParams) => void
'on-unmounted'?: (path: URLWithParams) => void
}>
>
export type Router = RiotComponentWrapper<
RiotComponent<{
base?: string
'initial-route'?: string
'on-started'?: (route: string) => void
}>
>
export declare function getCurrentRoute(): string
export declare function initDomListeners(): void
export declare function setBase(base: string): void
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
"sinon-chai": "^3.7.0"
},
"peerDependency": {
"riot": "^6.0.0 || ^7.0.0"
"riot": "^6.0.0 || ^7.0.0 || ^9.0.0"
},
"dependencies": {
"@riotjs/util": "^2.2.3",
"bianco.attr": "^1.1.1",
"bianco.query": "^1.1.4",
"bianco.events": "^1.1.1",
"bianco.query": "^1.1.4",
"cumpa": "^2.0.1",
"rawth": "^3.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/route-hoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const routeHoc = ({ slots, attributes }) => {
this.slot.unmount({}, this.context, true)
this.clearDOM(false)
this.state.route = null
this.callLifecycleProperty('onUnmounted', this.state.route)
this.callLifecycleProperty('onUnmounted', route)
},
onRoute(route) {
this.state.route = route
Expand Down
4 changes: 2 additions & 2 deletions src/set-base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HASH, SLASH } from './constants.js'
import { defaults } from 'rawth'
import { configure } from 'rawth'
import { getWindow } from './util.js'

export const normalizeInitialSlash = (str) =>
Expand Down Expand Up @@ -33,5 +33,5 @@ export const normalizeBase = (base) => {
}

export default function setBase(base) {
defaults.base = normalizeBase(base)
configure({ base: normalizeBase(base) })
}

0 comments on commit d8da1fe

Please sign in to comment.