-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev-app: wait for vite to notice the new example before navigating to it
- Loading branch information
1 parent
41f18d2
commit 678e377
Showing
8 changed files
with
73 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ExampleDescription } from "../../shared"; | ||
|
||
function getTestCaseUrl(description: ExampleDescription): string{ | ||
return new URL(`/test-case/#/${description.id}`, location.href).toString() | ||
} | ||
|
||
function getUseCaseUrl(description: ExampleDescription): string{ | ||
return new URL(`/examples/${description.id}/`, location.href).toString() | ||
} | ||
|
||
export function getExampleUrl(description: ExampleDescription): string{ | ||
if(description.kind === 'test-case'){ | ||
return getTestCaseUrl(description) | ||
} | ||
return getUseCaseUrl(description) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
async function isFound(url: string): Promise<boolean>{ | ||
const response = await fetch(url); | ||
return response.status === 200; | ||
} | ||
|
||
const retryInterval = 400; | ||
const maxRetries = 10; | ||
|
||
export async function waitUntilFound(url: string): Promise<void>{ | ||
let found = await isFound(url); | ||
let retryCount = 0; | ||
while(!found && retryCount < maxRetries){ | ||
console.log(`${url} was not found. Retrying in ${retryInterval}ms...`) | ||
retryCount++; | ||
await new Promise(res => setTimeout(res, retryInterval)) | ||
found = await isFound(url); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ExampleMetadata{ | ||
dirPath: string | ||
dirName: string | ||
title: string | ||
} |
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