@metascraper/helpers 5.50.1 → 5.50.6
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/package.json +12 -12
- package/src/load-iframe/worker.js +21 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@metascraper/helpers",
|
|
3
3
|
"description": "Collection of helper functions used by metascraper",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-helpers",
|
|
5
|
-
"version": "5.50.
|
|
5
|
+
"version": "5.50.6",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -23,28 +23,28 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"audio-extensions": "0.0.0",
|
|
26
|
-
"chrono-node": "2.9.
|
|
26
|
+
"chrono-node": "2.9.1",
|
|
27
27
|
"condense-whitespace": "~2.0.0",
|
|
28
|
-
"data-uri-utils": "~1.0.
|
|
28
|
+
"data-uri-utils": "~1.0.13",
|
|
29
29
|
"debug-logfmt": "~1.4.7",
|
|
30
30
|
"entities": "~7.0.1",
|
|
31
31
|
"file-extension": "~4.0.5",
|
|
32
32
|
"has-values": "~2.0.1",
|
|
33
33
|
"image-extensions": "~1.1.0",
|
|
34
34
|
"is-relative-url": "~3.0.0",
|
|
35
|
-
"is-uri": "~1.2.
|
|
35
|
+
"is-uri": "~1.2.14",
|
|
36
36
|
"iso-639-3": "~2.2.0",
|
|
37
37
|
"isostring": "0.0.1",
|
|
38
|
-
"jsdom": "~
|
|
39
|
-
"jsonrepair": "~3.
|
|
40
|
-
"lodash": "~4.18.
|
|
38
|
+
"jsdom": "~29.1.1",
|
|
39
|
+
"jsonrepair": "~3.14.0",
|
|
40
|
+
"lodash": "~4.18.1",
|
|
41
41
|
"memoize-one": "~6.0.0",
|
|
42
|
-
"microsoft-capitalize": "~1.0.
|
|
42
|
+
"microsoft-capitalize": "~1.0.8",
|
|
43
43
|
"mime": "3",
|
|
44
44
|
"normalize-url": "6",
|
|
45
|
-
"re2": "~1.
|
|
45
|
+
"re2": "~1.24.1",
|
|
46
46
|
"smartquotes": "~2.3.2",
|
|
47
|
-
"tldts": "~7.
|
|
47
|
+
"tldts": "~7.4.2",
|
|
48
48
|
"url-regex-safe": "~4.0.0",
|
|
49
49
|
"video-extensions": "1"
|
|
50
50
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"cheerio": "latest"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">= 22"
|
|
56
|
+
"node": ">= 22.13"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
59
59
|
"src"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "b5b9252a59dcd55281bdfe4f44e4118339bd0571"
|
|
69
69
|
}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { workerData, parentPort } = require('node:worker_threads')
|
|
4
|
-
const { JSDOM, VirtualConsole } = require('jsdom')
|
|
4
|
+
const { JSDOM, VirtualConsole, requestInterceptor } = require('jsdom')
|
|
5
|
+
|
|
6
|
+
const iframeInterceptor = requestInterceptor(async (request, { element }) => {
|
|
7
|
+
if (element?.localName !== 'iframe') return
|
|
8
|
+
|
|
9
|
+
const response = await fetch(request)
|
|
10
|
+
if (!response.ok) return new Response('', { status: response.status })
|
|
11
|
+
|
|
12
|
+
const headers = new Headers(response.headers)
|
|
13
|
+
headers.delete('content-encoding')
|
|
14
|
+
headers.delete('content-length')
|
|
15
|
+
return new Response(response.body, {
|
|
16
|
+
headers,
|
|
17
|
+
status: response.status,
|
|
18
|
+
statusText: response.statusText
|
|
19
|
+
})
|
|
20
|
+
})
|
|
5
21
|
|
|
6
22
|
async function main ({ url, html, timeout }) {
|
|
7
23
|
const dom = new JSDOM(html, {
|
|
8
24
|
url,
|
|
9
25
|
virtualConsole: new VirtualConsole(),
|
|
10
26
|
runScripts: 'dangerously',
|
|
11
|
-
resources:
|
|
27
|
+
resources: { interceptors: [iframeInterceptor] }
|
|
12
28
|
})
|
|
13
29
|
|
|
14
30
|
const iframe = dom.window.document.querySelector('iframe')
|
|
@@ -34,4 +50,6 @@ async function main ({ url, html, timeout }) {
|
|
|
34
50
|
return Promise.race([waitForIframe, timeoutReached])
|
|
35
51
|
}
|
|
36
52
|
|
|
37
|
-
main(workerData)
|
|
53
|
+
main(workerData)
|
|
54
|
+
.then(html => parentPort.postMessage(html))
|
|
55
|
+
.catch(() => parentPort.postMessage(undefined))
|