-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split client and server types
- Loading branch information
1 parent
6bea50b
commit c007f53
Showing
49 changed files
with
268 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ node_modules/ | |
coverage/ | ||
build/ | ||
dist/ | ||
*.tsbuildinfo |
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
File renamed without changes.
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 @@ | ||
#!/usr/bin/env node | ||
|
||
import { program } from './api.js'; | ||
|
||
program.parse(); |
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,12 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"outDir": "../../build/cli", | ||
"types": ["node"] | ||
}, | ||
"include": ["./"], | ||
"references": [ | ||
{ "path": "../server" } | ||
] | ||
} |
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
File renamed without changes.
File renamed without changes.
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,55 @@ | ||
/** | ||
* Functions to be injected into the test page to control the client test runs. | ||
* | ||
* Keep these funcs self-contained so that they can be serialized and injected. | ||
*/ | ||
|
||
// No coverage support for this kind of functions yet | ||
/* c8 ignore start */ | ||
|
||
/** | ||
* Dispatches an init event after the test scripts are successfully imported. | ||
*/ | ||
export const init = (uuid: string) => { | ||
window.dispatchEvent(new CustomEvent(`__wrightplay_${uuid}_init__`)); | ||
}; | ||
|
||
/** | ||
* Injects the test script and resolves with the exit code. | ||
*/ | ||
export const inject = (uuid: string) => ( | ||
new Promise<number>((resolve) => { | ||
const script = document.createElement('script'); | ||
|
||
// Detect inject error | ||
script.addEventListener('error', () => { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to inject test script'); | ||
resolve(1); | ||
}, { once: true }); | ||
|
||
// Detect init error | ||
const onUncaughtError = () => { | ||
// eslint-disable-next-line no-console | ||
console.error('Uncaught error detected while initializing the tests'); | ||
resolve(1); | ||
}; | ||
window.addEventListener('error', onUncaughtError, { once: true }); | ||
|
||
// Detect init end | ||
window.addEventListener(`__wrightplay_${uuid}_init__`, () => { | ||
window.removeEventListener('error', onUncaughtError); | ||
}, { once: true }); | ||
|
||
// Detect test done | ||
window.addEventListener(`__wrightplay_${uuid}_done__`, ({ exitCode }) => { | ||
window.removeEventListener('error', onUncaughtError); | ||
resolve(exitCode); | ||
}, { once: true }); | ||
|
||
// Inject | ||
script.src = '/stdin.js'; | ||
script.type = 'module'; | ||
document.head.append(script); | ||
}) | ||
); |
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,12 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"lib": ["ESNext", "DOM"], | ||
"outDir": "../../build/client" | ||
}, | ||
"include": ["./"], | ||
"references": [ | ||
{ "path": "../common" } | ||
] | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/WS/route/RouteHandler.ts → src/client/ws/route/RouteHandler.ts
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
2 changes: 1 addition & 1 deletion
2
src/WS/route/RouteRequest.ts → src/client/ws/route/RouteRequest.ts
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,37 @@ | ||
/** | ||
* APIs that are common to Node.js and the DOM. | ||
* | ||
* Better if a lib provides these types. | ||
* | ||
* https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1402 | ||
*/ | ||
|
||
declare global { | ||
interface URL { | ||
hash: string; | ||
host: string; | ||
hostname: string; | ||
href: string; | ||
readonly origin: string; | ||
password: string; | ||
pathname: string; | ||
port: string; | ||
protocol: string; | ||
search: string; | ||
readonly searchParams: URLSearchParams; | ||
username: string; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
|
||
interface URLConstructor { | ||
new(input: string, base?: string | URL): URL; | ||
createObjectURL(object: Blob): string; | ||
revokeObjectURL(url: string): void; | ||
readonly prototype: URL; | ||
} | ||
|
||
const URL: typeof URLConstructor; | ||
} | ||
|
||
export {}; |
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,8 +1,5 @@ | ||
export default class Handle { | ||
constructor( | ||
/** | ||
* @internal | ||
*/ | ||
readonly id: number, | ||
) {} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,11 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"lib": ["ES2022", "ESNext.Disposable"], | ||
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"outDir": "../../build/common" | ||
}, | ||
"include": ["./"] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.