@metascraper/helpers 5.46.11 → 5.46.14
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 +6 -6
- package/{index.js → src/index.js} +1 -36
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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.46.
|
|
6
|
-
"main": "index.js",
|
|
5
|
+
"version": "5.46.14",
|
|
6
|
+
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
9
9
|
"name": "microlink.io",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"audio-extensions": "0.0.0",
|
|
26
|
-
"chrono-node": "~2.
|
|
26
|
+
"chrono-node": "~2.8.0",
|
|
27
27
|
"condense-whitespace": "~2.0.0",
|
|
28
28
|
"data-uri-utils": "~1.0.8",
|
|
29
29
|
"debug-logfmt": "~1.2.3",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"is-uri": "~1.2.7",
|
|
36
36
|
"iso-639-3": "~2.2.0",
|
|
37
37
|
"isostring": "0.0.1",
|
|
38
|
-
"jsdom": "~26.
|
|
38
|
+
"jsdom": "~26.1.0",
|
|
39
39
|
"lodash": "~4.17.21",
|
|
40
40
|
"memoize-one": "~6.0.0",
|
|
41
41
|
"microsoft-capitalize": "~1.0.5",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"normalize-url": "~6.1.0",
|
|
44
44
|
"re2": "~1.21.4",
|
|
45
45
|
"smartquotes": "~2.3.2",
|
|
46
|
-
"tldts": "~
|
|
46
|
+
"tldts": "~7.0.6",
|
|
47
47
|
"url-regex-safe": "~4.0.0",
|
|
48
48
|
"video-extensions": "1"
|
|
49
49
|
},
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f30cf4a7a320d4a417f635b7ddd3c4eaef7943ae"
|
|
68
68
|
}
|
|
@@ -5,7 +5,6 @@ const debug = require('debug-logfmt')('metascraper:find-rule')
|
|
|
5
5
|
const condenseWhitespace = require('condense-whitespace')
|
|
6
6
|
const { getExtension: mimeExtension } = require('mime')
|
|
7
7
|
const capitalize = require('microsoft-capitalize')
|
|
8
|
-
const { JSDOM, VirtualConsole } = require('jsdom')
|
|
9
8
|
const isRelativeUrl = require('is-relative-url')
|
|
10
9
|
const fileExtension = require('file-extension')
|
|
11
10
|
const _normalizeUrl = require('normalize-url')
|
|
@@ -466,40 +465,6 @@ const composeRule =
|
|
|
466
465
|
const has = value =>
|
|
467
466
|
value !== undefined && !Number.isNaN(value) && hasValues(value)
|
|
468
467
|
|
|
469
|
-
const loadIframe = (url, $, { timeout = 5000 } = {}) =>
|
|
470
|
-
new Promise(resolve => {
|
|
471
|
-
const dom = new JSDOM($.html(), {
|
|
472
|
-
url,
|
|
473
|
-
virtualConsole: new VirtualConsole(),
|
|
474
|
-
runScripts: 'dangerously',
|
|
475
|
-
resources: 'usable'
|
|
476
|
-
})
|
|
477
|
-
|
|
478
|
-
const done = (html = '') => resolve($.load(html))
|
|
479
|
-
|
|
480
|
-
const listen = (element, method, fn) =>
|
|
481
|
-
element[`${method}EventListener`]('load', fn, {
|
|
482
|
-
capture: true,
|
|
483
|
-
once: true,
|
|
484
|
-
passive: true
|
|
485
|
-
})
|
|
486
|
-
|
|
487
|
-
const iframe = dom.window.document.querySelector('iframe')
|
|
488
|
-
if (!iframe) return done()
|
|
489
|
-
|
|
490
|
-
const timer = setTimeout(() => {
|
|
491
|
-
listen(iframe, 'remove', load)
|
|
492
|
-
done()
|
|
493
|
-
}, timeout)
|
|
494
|
-
|
|
495
|
-
function load () {
|
|
496
|
-
clearTimeout(timer)
|
|
497
|
-
done(iframe.contentDocument.documentElement.outerHTML)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
listen(iframe, 'add', load)
|
|
501
|
-
})
|
|
502
|
-
|
|
503
468
|
const getUrls = input => String(input).match(urlRegexForMatch) ?? []
|
|
504
469
|
|
|
505
470
|
module.exports = {
|
|
@@ -536,7 +501,7 @@ module.exports = {
|
|
|
536
501
|
iso6393,
|
|
537
502
|
jsonld,
|
|
538
503
|
lang,
|
|
539
|
-
loadIframe,
|
|
504
|
+
loadIframe: require('./load-iframe'),
|
|
540
505
|
logo,
|
|
541
506
|
memoizeOne,
|
|
542
507
|
mimeExtension,
|