-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7424cdc
commit 627472e
Showing
4 changed files
with
58 additions
and
76 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 |
---|---|---|
@@ -1,53 +1,6 @@ | ||
import { Client } from "./src/client.ts"; | ||
import { BuildOptions, Cookie, ScreenshotOptions } from "./src/interfaces.ts"; | ||
import { Page } from "./src/page.ts"; | ||
import { getChromeArgs } from "./src/utility.ts"; | ||
|
||
export type { BuildOptions, Cookie, ScreenshotOptions }; | ||
|
||
const defaultOptions = { | ||
hostname: "localhost", | ||
debuggerPort: 9292, | ||
binaryPath: undefined, | ||
}; | ||
|
||
export async function build( | ||
{ | ||
hostname = "localhost", | ||
debuggerPort = 9292, | ||
binaryPath, | ||
}: BuildOptions = defaultOptions, | ||
): Promise<{ | ||
browser: Client; | ||
page: Page; | ||
}> { | ||
const buildArgs = getChromeArgs(debuggerPort, binaryPath); | ||
const path = buildArgs.splice(0, 1)[0]; | ||
const command = new Deno.Command(path, { | ||
args: buildArgs, | ||
stderr: "piped", | ||
stdout: "piped", | ||
}); | ||
const browserProcess = command.spawn(); | ||
|
||
return await Client.create( | ||
{ | ||
hostname, | ||
port: debuggerPort, | ||
}, | ||
browserProcess, | ||
); | ||
} | ||
|
||
export async function connect({ | ||
hostname = "localhost", | ||
debuggerPort = 9292, | ||
}: BuildOptions = defaultOptions) { | ||
console.log(hostname, debuggerPort); | ||
return await Client.create( | ||
{ | ||
hostname, | ||
port: debuggerPort, | ||
}, | ||
); | ||
} | ||
export { Client }; |
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