@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/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;