@pagepocket/lighterceptor 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# lighterceptor
|
|
1
|
+
# @pagepocket/lighterceptor
|
|
2
2
|
|
|
3
|
-
Capture
|
|
4
|
-
|
|
3
|
+
Capture outbound requests an HTML/JS/CSS payload would trigger in a jsdom
|
|
4
|
+
environment, without hitting the network.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
pnpm add lighterceptor
|
|
9
|
+
pnpm add @pagepocket/lighterceptor
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Quick Start
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
import { Lighterceptor } from "lighterceptor";
|
|
15
|
+
import { Lighterceptor } from "@pagepocket/lighterceptor";
|
|
16
16
|
|
|
17
17
|
const html = `
|
|
18
18
|
<!doctype html>
|
|
@@ -35,11 +35,11 @@ console.log(result.requests);
|
|
|
35
35
|
|
|
36
36
|
## Recursion (Dependency Graph)
|
|
37
37
|
|
|
38
|
-
Enable recursion to keep walking JS/CSS/HTML dependencies. This is useful
|
|
39
|
-
|
|
38
|
+
Enable recursion to keep walking JS/CSS/HTML dependencies. This is useful when
|
|
39
|
+
HTML loads CSS/JS, and those assets load more assets.
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
-
import { Lighterceptor } from "lighterceptor";
|
|
42
|
+
import { Lighterceptor } from "@pagepocket/lighterceptor";
|
|
43
43
|
|
|
44
44
|
const html = `
|
|
45
45
|
<!doctype html>
|
|
@@ -111,18 +111,18 @@ type LighterceptorResult = {
|
|
|
111
111
|
Use this when you need low-level access to jsdom.
|
|
112
112
|
|
|
113
113
|
```ts
|
|
114
|
-
import { createJSDOMWithInterceptor } from "lighterceptor";
|
|
114
|
+
import { createJSDOMWithInterceptor } from "@pagepocket/lighterceptor";
|
|
115
115
|
|
|
116
116
|
const dom = createJSDOMWithInterceptor({
|
|
117
117
|
html: "<img src='https://example.com/logo.png'>",
|
|
118
118
|
domOptions: {
|
|
119
119
|
pretendToBeVisual: true,
|
|
120
|
-
runScripts: "dangerously"
|
|
120
|
+
runScripts: "dangerously"
|
|
121
121
|
},
|
|
122
122
|
interceptor: (url, options) => {
|
|
123
123
|
console.log("Intercepted", url, options.source);
|
|
124
124
|
return "";
|
|
125
|
-
}
|
|
125
|
+
}
|
|
126
126
|
});
|
|
127
127
|
```
|
|
128
128
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagepocket/lighterceptor",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Capture outbound requests from HTML/JS/CSS in a jsdom environment.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|