feedscout 1.3.0 → 1.4.0
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.
|
@@ -4,7 +4,7 @@ const require_utils$1 = require('./utils.cjs');
|
|
|
4
4
|
|
|
5
5
|
//#region src/common/discover/index.ts
|
|
6
6
|
const discover = async (input, options, defaults) => {
|
|
7
|
-
const { methods, fetchFn, extractFn, normalizeUrlFn,
|
|
7
|
+
const { methods, fetchFn, extractFn, normalizeUrlFn, stopOnFirstMethod = false, stopOnFirstResult = false, concurrency = 3, includeInvalid = false, onProgress } = options;
|
|
8
8
|
const normalizedInput = await require_utils$1.normalizeInput(input, fetchFn);
|
|
9
9
|
if (normalizedInput.content) {
|
|
10
10
|
const result = await extractFn({
|
|
@@ -13,7 +13,7 @@ const discover = async (input, options, defaults) => {
|
|
|
13
13
|
});
|
|
14
14
|
if (result.isValid) return [result];
|
|
15
15
|
}
|
|
16
|
-
const rawUris = require_index.discoverUris(require_utils$1.normalizeMethodsConfig(normalizedInput, methods, defaults));
|
|
16
|
+
const rawUris = require_index.discoverUris(require_utils$1.normalizeMethodsConfig(normalizedInput, methods, defaults), stopOnFirstMethod);
|
|
17
17
|
const uris = [...new Set(rawUris.map((uri) => normalizeUrlFn(uri, normalizedInput.url)))];
|
|
18
18
|
const results = [];
|
|
19
19
|
let tested = 0;
|
|
@@ -4,7 +4,7 @@ import { normalizeInput, normalizeMethodsConfig } from "./utils.js";
|
|
|
4
4
|
|
|
5
5
|
//#region src/common/discover/index.ts
|
|
6
6
|
const discover = async (input, options, defaults) => {
|
|
7
|
-
const { methods, fetchFn, extractFn, normalizeUrlFn,
|
|
7
|
+
const { methods, fetchFn, extractFn, normalizeUrlFn, stopOnFirstMethod = false, stopOnFirstResult = false, concurrency = 3, includeInvalid = false, onProgress } = options;
|
|
8
8
|
const normalizedInput = await normalizeInput(input, fetchFn);
|
|
9
9
|
if (normalizedInput.content) {
|
|
10
10
|
const result = await extractFn({
|
|
@@ -13,7 +13,7 @@ const discover = async (input, options, defaults) => {
|
|
|
13
13
|
});
|
|
14
14
|
if (result.isValid) return [result];
|
|
15
15
|
}
|
|
16
|
-
const rawUris = discoverUris(normalizeMethodsConfig(normalizedInput, methods, defaults));
|
|
16
|
+
const rawUris = discoverUris(normalizeMethodsConfig(normalizedInput, methods, defaults), stopOnFirstMethod);
|
|
17
17
|
const uris = [...new Set(rawUris.map((uri) => normalizeUrlFn(uri, normalizedInput.url)))];
|
|
18
18
|
const results = [];
|
|
19
19
|
let tested = 0;
|
package/dist/common/types.d.cts
CHANGED
|
@@ -58,10 +58,11 @@ type DiscoverOptions<TValid> = {
|
|
|
58
58
|
fetchFn?: DiscoverFetchFn;
|
|
59
59
|
extractFn?: DiscoverExtractFn<TValid>;
|
|
60
60
|
normalizeUrlFn?: DiscoverNormalizeUrlFn;
|
|
61
|
-
|
|
61
|
+
stopOnFirstMethod?: boolean;
|
|
62
62
|
stopOnFirstResult?: boolean;
|
|
63
|
-
|
|
63
|
+
concurrency?: number;
|
|
64
64
|
onProgress?: DiscoverOnProgressFn;
|
|
65
|
+
includeInvalid?: boolean;
|
|
65
66
|
};
|
|
66
67
|
//#endregion
|
|
67
68
|
export { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOnProgressFn, DiscoverOptions, DiscoverProgress, DiscoverResult, LinkSelector };
|
package/dist/common/types.d.ts
CHANGED
|
@@ -58,10 +58,11 @@ type DiscoverOptions<TValid> = {
|
|
|
58
58
|
fetchFn?: DiscoverFetchFn;
|
|
59
59
|
extractFn?: DiscoverExtractFn<TValid>;
|
|
60
60
|
normalizeUrlFn?: DiscoverNormalizeUrlFn;
|
|
61
|
-
|
|
61
|
+
stopOnFirstMethod?: boolean;
|
|
62
62
|
stopOnFirstResult?: boolean;
|
|
63
|
-
|
|
63
|
+
concurrency?: number;
|
|
64
64
|
onProgress?: DiscoverOnProgressFn;
|
|
65
|
+
includeInvalid?: boolean;
|
|
65
66
|
};
|
|
66
67
|
//#endregion
|
|
67
68
|
export { DiscoverExtractFn, DiscoverFetchFn, DiscoverFetchFnOptions, DiscoverFetchFnResponse, DiscoverInput, DiscoverInputObject, DiscoverMethodsConfig, DiscoverNormalizeUrlFn, DiscoverOnProgressFn, DiscoverOptions, DiscoverProgress, DiscoverResult, LinkSelector };
|
|
@@ -4,11 +4,20 @@ const require_index$2 = require('./html/index.cjs');
|
|
|
4
4
|
const require_index$3 = require('./platform/index.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/common/uris/index.ts
|
|
7
|
-
const discoverUris = (config) => {
|
|
7
|
+
const discoverUris = (config, stopOnFirstMethod = false) => {
|
|
8
8
|
const uris = /* @__PURE__ */ new Set();
|
|
9
|
-
if (config.platform)
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (config.platform) {
|
|
10
|
+
for (const uri of require_index$3.discoverUrisFromPlatform(config.platform.html, config.platform.options)) uris.add(uri);
|
|
11
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
12
|
+
}
|
|
13
|
+
if (config.html) {
|
|
14
|
+
for (const uri of require_index$2.discoverUrisFromHtml(config.html.html, config.html.options)) uris.add(uri);
|
|
15
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
16
|
+
}
|
|
17
|
+
if (config.headers) {
|
|
18
|
+
for (const uri of require_index$1.discoverUrisFromHeaders(config.headers.headers, config.headers.options)) uris.add(uri);
|
|
19
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
20
|
+
}
|
|
12
21
|
if (config.guess) for (const uri of require_index.discoverUrisFromGuess(config.guess.options)) uris.add(uri);
|
|
13
22
|
return Array.from(uris);
|
|
14
23
|
};
|
|
@@ -4,11 +4,20 @@ import { discoverUrisFromHtml } from "./html/index.js";
|
|
|
4
4
|
import { discoverUrisFromPlatform } from "./platform/index.js";
|
|
5
5
|
|
|
6
6
|
//#region src/common/uris/index.ts
|
|
7
|
-
const discoverUris = (config) => {
|
|
7
|
+
const discoverUris = (config, stopOnFirstMethod = false) => {
|
|
8
8
|
const uris = /* @__PURE__ */ new Set();
|
|
9
|
-
if (config.platform)
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (config.platform) {
|
|
10
|
+
for (const uri of discoverUrisFromPlatform(config.platform.html, config.platform.options)) uris.add(uri);
|
|
11
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
12
|
+
}
|
|
13
|
+
if (config.html) {
|
|
14
|
+
for (const uri of discoverUrisFromHtml(config.html.html, config.html.options)) uris.add(uri);
|
|
15
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
16
|
+
}
|
|
17
|
+
if (config.headers) {
|
|
18
|
+
for (const uri of discoverUrisFromHeaders(config.headers.headers, config.headers.options)) uris.add(uri);
|
|
19
|
+
if (stopOnFirstMethod && uris.size > 0) return Array.from(uris);
|
|
20
|
+
}
|
|
12
21
|
if (config.guess) for (const uri of discoverUrisFromGuess(config.guess.options)) uris.add(uri);
|
|
13
22
|
return Array.from(uris);
|
|
14
23
|
};
|
package/package.json
CHANGED