-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): add hmr and update api
- Loading branch information
1 parent
e5e7af9
commit 0dfadc7
Showing
7 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import { pagesMap } from '@internal/pagesMap' | ||
import type { PagesMap } from '@internal/pagesMap' | ||
import { pagesMap } from '../composables/index.js' | ||
import { resolvers } from '../resolvers.js' | ||
|
||
/** | ||
* Get all paths of pages | ||
* | ||
* @returns all paths of pages | ||
*/ | ||
export const getPagesPath = (): string[] => Object.keys(pagesMap.value) | ||
|
||
/** | ||
* Check whether the page exists | ||
* | ||
* @param path path of the page | ||
* @returns whether the page exists | ||
*/ | ||
export const hasPage = (path: string): boolean => | ||
pagesMap.has(resolvers.resolvePagePath(pagesMap, path)) | ||
export const isPageExist = (path: string): boolean => | ||
pagesMap.value.has(resolvers.resolvePagePath(pagesMap.value, path)) | ||
|
||
/** | ||
* Resolve final path and meta with given path | ||
* | ||
* @param path path of the page | ||
* @returns resolved path and meta | ||
*/ | ||
export const resolve = <PageMeta>( | ||
path: string, | ||
): { path: string; meta: PageMeta | null } => { | ||
path = resolvers.resolvePagePath(pagesMap, path) | ||
path = resolvers.resolvePagePath(pagesMap.value, path) | ||
|
||
return { | ||
path, | ||
meta: (pagesMap as PagesMap<PageMeta>).get(path)?.meta ?? null, | ||
meta: (pagesMap.value as PagesMap<PageMeta>).get(path)?.meta ?? null, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters