Skip to content

Commit

Permalink
Ported core of puppeteer-extra to deno
Browse files Browse the repository at this point in the history
  • Loading branch information
lino-levan committed Aug 31, 2022
0 parents commit 28f131f
Show file tree
Hide file tree
Showing 20 changed files with 1,480 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"deno.enable": true,
"deno.unstable": true,
"deno.importMap": "./import_map.json",
"spellright.language": [
"en"
],
"spellright.documentTypes": [
"latex",
"plaintext"
]
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# deno-puppeteer-extra

This is the monorepo for deno port of
[puppeteer-extra](https://github.com/berstend/puppeteer-extra).

Documentation for each package is located in their individual directories.
General docs can be found inside of the puppeteer_extra directory.

## FAQ

### How does this compare to the Node version?

It doesn't. Just kidding, `deno-puppeteer-extra` is basically a fork of
[puppeteer-extra](https://github.com/berstend/puppeteer-extra). It's not
perfect, or even 1:1 yet, but most of the critical modules have been added.
5 changes: 5 additions & 0 deletions common/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function debug(...args: any[]) {
if (Deno.args.includes("debug")) {
console.log(...args);
}
}
21 changes: 21 additions & 0 deletions common/merge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function isObject(item: any) {
return (item && typeof item === "object" && !Array.isArray(item));
}

export default function merge(target: any, source: any) {
const output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach((key) => {
if (isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] });
} else {
output[key] = merge(target[key], source[key]);
}
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}
11 changes: 11 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"importMap": "import_map.json",
"tasks": {
"test": "deno test -A"
},
"lint": {
"rules": {
"exclude": ["no-explicit-any"]
}
}
}
9 changes: 9 additions & 0 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"imports": {
"puppeteer": "https://deno.land/x/puppeteer@16.2.0/mod.ts",
"puppeteer/": "https://deno.land/x/puppeteer@16.2.0/",
"assert": "https://deno.land/std@0.153.0/testing/asserts.ts",
"@": "./mod.ts",
"@/": "./"
}
}
3 changes: 3 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as puppeteer } from "./packages/puppeteer_extra/src/mod.ts";
export { PuppeteerExtraPlugin } from "./packages/puppeteer_extra_plugin/src/mod.ts";
export { default as puppeteer_extra_plugin_anonymize_ua } from "./packages/puppeteer_extra_plugin_anonymize_ua/mod.ts";
10 changes: 10 additions & 0 deletions packages/puppeteer_extra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# puppeteer-extra

> A light-weight wrapper around deno-puppeteer to enable plugins through a clean
> interface.
## Quickstart

```typescript
import { puppeteer } from "https://deno.land/x/puppeteer_extra/mod.ts";
```
Loading

0 comments on commit 28f131f

Please sign in to comment.