@d-zero/beholder 2.1.5 → 3.0.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.
- package/CHANGELOG.md +44 -0
- package/README.md +9 -276
- package/dist/dom-evaluation.d.ts +100 -62
- package/dist/dom-evaluation.js +498 -195
- package/dist/index.d.ts +1 -1
- package/dist/meta/classify.d.ts +52 -0
- package/dist/meta/classify.js +731 -0
- package/dist/meta/id-extractors.d.ts +40 -0
- package/dist/meta/id-extractors.js +196 -0
- package/dist/meta/keys.d.ts +41 -0
- package/dist/meta/keys.js +507 -0
- package/dist/meta/parsers.d.ts +74 -0
- package/dist/meta/parsers.js +293 -0
- package/dist/meta/tag-detection.d.ts +59 -0
- package/dist/meta/tag-detection.js +120 -0
- package/dist/meta/types.d.ts +874 -0
- package/dist/meta/types.js +12 -0
- package/dist/scraper.js +22 -18
- package/dist/types.d.ts +8 -37
- package/package.json +5 -4
- package/src/dom-evaluation.spec.ts +521 -0
- package/src/dom-evaluation.ts +655 -227
- package/src/index.ts +43 -0
- package/src/meta/classify.spec.ts +281 -0
- package/src/meta/classify.ts +810 -0
- package/src/meta/id-extractors.spec.ts +69 -0
- package/src/meta/id-extractors.ts +206 -0
- package/src/meta/keys.ts +568 -0
- package/src/meta/parsers.spec.ts +178 -0
- package/src/meta/parsers.ts +304 -0
- package/src/meta/simple-wappalyzer.d.ts +37 -0
- package/src/meta/tag-detection.spec.ts +134 -0
- package/src/meta/tag-detection.ts +161 -0
- package/src/meta/types.ts +949 -0
- package/src/scraper.ts +32 -16
- package/src/types.ts +54 -54
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export { detectCDN } from '@d-zero/shared/detect-cdn';
|
|
|
18
18
|
export type { CDNType } from '@d-zero/shared/detect-cdn';
|
|
19
19
|
export type { ScrapeResult, ResourceEntry, PageData } from './types.js';
|
|
20
20
|
export type { ScraperOptions, ChangePhaseEvent, ScraperEventTypes } from './types.js';
|
|
21
|
-
export type { Resource, AnchorData, Meta, ImageElement, SkippedPageData, NetworkLog, } from './types.js';
|
|
21
|
+
export type { Resource, AnchorData, Meta, ImageElement, SkippedPageData, NetworkLog, OpenGraphMeta, OgArticleMeta, OgBookMeta, OgProfileMeta, OgMusicMeta, OgVideoNsMeta, TwitterMeta, FbMeta, FediverseMeta, AppleMeta, MsApplicationMeta, VerificationMeta, GoogleMeta, GeoMeta, CitationMeta, RdfaMeta, MicrodataMeta, AmpMeta, LegacyMeta, MobileMeta, MicroformatsMeta, PinterestMeta, SlackMeta, LinkedInMeta, ExperimentalMeta, WikiMeta, LinkMeta, LinkEntry, JsonLdEntry, OthersBucket, ScriptEntry, IframeEntry, TagsMeta, TagDetail, TagEntry, TagSource, ViewportMeta, RobotsMeta, ReferrerMeta, FormatDetectionMeta, HttpEquivMeta, HttpEquivRefresh, RawHeadEntry, } from './types.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-function classifier that turns `RawHeadEntry[]` (collected on the browser
|
|
3
|
+
* side by `collectHead`) into a typed `Meta` object.
|
|
4
|
+
*
|
|
5
|
+
* The classifier is the **only place** where dot-paths from `keys.ts` get
|
|
6
|
+
* resolved against the `Meta` shape. Parsers (viewport/robots/refresh/etc.)
|
|
7
|
+
* are dispatched on the fly for the few entries that need value normalization.
|
|
8
|
+
*
|
|
9
|
+
* Unknown entries (names/properties/rels not in the lookup tables) are
|
|
10
|
+
* preserved in {@link Meta.others} so consumers never lose information.
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { Meta, RawHeadEntry, TagsMeta } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Options for {@link classify}.
|
|
16
|
+
*/
|
|
17
|
+
export type ClassifyOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* When `true`, copies the input `raw` entries onto `Meta._raw` for debugging.
|
|
20
|
+
* Default `false` to keep the serialized `Meta` small.
|
|
21
|
+
*/
|
|
22
|
+
readonly includeRaw?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-computed `TagsMeta` from `tag-detection.ts`. When omitted, an empty
|
|
25
|
+
* `TagsMeta` (with `detected: {}` and `entries: []`) is used.
|
|
26
|
+
*/
|
|
27
|
+
readonly tags?: TagsMeta;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Builds the empty `Meta` skeleton with all required fields initialized.
|
|
31
|
+
*/
|
|
32
|
+
/** Returns a fresh `Meta` skeleton with all required fields initialized. */
|
|
33
|
+
export declare function emptyMeta(): Meta;
|
|
34
|
+
/**
|
|
35
|
+
* Writes `value` to `target` along `dotPath`. Intermediate objects are created
|
|
36
|
+
* on demand. When `multi` is `true`, the leaf is treated as an array and `value`
|
|
37
|
+
* is appended; otherwise the first assignment wins (subsequent calls are no-ops).
|
|
38
|
+
*
|
|
39
|
+
* Exported for the unit tests in `classify.spec.ts`.
|
|
40
|
+
* @param target
|
|
41
|
+
* @param dotPath
|
|
42
|
+
* @param value
|
|
43
|
+
* @param multi
|
|
44
|
+
*/
|
|
45
|
+
export declare function setByPath(target: Record<string, unknown>, dotPath: string, value: unknown, multi: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* Top-level classifier. Takes a list of raw entries collected from the page
|
|
48
|
+
* and produces a populated `Meta`.
|
|
49
|
+
* @param raw
|
|
50
|
+
* @param options
|
|
51
|
+
*/
|
|
52
|
+
export declare function classify(raw: readonly RawHeadEntry[], options?: ClassifyOptions): Meta;
|