@domandigital/craft 0.12.0 → 0.14.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/audit.d.cts CHANGED
@@ -93,6 +93,57 @@ interface SnapshotSection {
93
93
  role?: SectionRole;
94
94
  /** Version 2. */
95
95
  geometry?: SectionGeometry;
96
+ /** Version 2: short pill or label texts in the section ("Most popular", "New"), at most 5. */
97
+ badges?: string[];
98
+ /** Version 2: small round portraits (at most 96px, roughly square, radius 40% or more). */
99
+ avatars?: number;
100
+ /** Version 2: a horizontal scroller, snap track or prev/next control holds the content. */
101
+ carousel?: boolean;
102
+ /** Version 2: large standalone figures ("500+", "98%", "4.9/5") at 24px or more. */
103
+ figures?: number;
104
+ /**
105
+ * Version 2, craft 0.13 and later: the section's visible text, one block per
106
+ * heading, paragraph, list item or quote, each at most 300 characters, at
107
+ * most 40. Navigation, buttons and footers are left out. What the
108
+ * specificity and proof tells read.
109
+ */
110
+ text?: string[];
111
+ }
112
+ type ImageRole = "photo" | "illustration" | "icon" | "avatar" | "logo";
113
+ /**
114
+ * What the image's own bytes say about where it came from. Only a positive
115
+ * is evidence: most images carry no metadata at all, and a re-encode strips
116
+ * it, so no marker proves nothing.
117
+ */
118
+ interface ImageProvenance {
119
+ /** The IPTC digital source type found, if any: "trainedAlgorithmicMedia" or "compositeWithTrainedAlgorithmicMedia". */
120
+ digitalSourceType: string | null;
121
+ /** Where the marker sat: an XMP packet, a C2PA manifest, or somewhere else in the file. */
122
+ source: "xmp" | "c2pa" | "other" | null;
123
+ /** The file carries a C2PA manifest (Content Credentials), whatever it says. */
124
+ c2pa: boolean;
125
+ /** Bytes read, from the start of the file. */
126
+ bytes: number;
127
+ }
128
+ /** One image as the visitor sees it: an `img`, or a CSS background large enough to be a picture. */
129
+ interface SnapshotImage {
130
+ /** The URL the browser loaded, unwrapped from an image optimiser (`/_next/image?url=`), or a `data:` URI cut to 64 characters. */
131
+ src: string;
132
+ /** Host of `src`, or null for a `data:` URI. */
133
+ host: string | null;
134
+ width: number;
135
+ height: number;
136
+ top: number;
137
+ role: ImageRole;
138
+ alt: string | null;
139
+ /** Empty alt, `aria-hidden` or `role="presentation"`. */
140
+ decorative: boolean;
141
+ /** Index into `sections`, or null when the image sits outside them. */
142
+ section: number | null;
143
+ /** A CSS `background-image`, not an `img`. */
144
+ background: boolean;
145
+ /** Present when the bytes were read. */
146
+ provenance?: ImageProvenance;
96
147
  }
97
148
  /**
98
149
  * Measures of the rendered pixels, from a full-page screenshot (capped at
@@ -167,6 +218,18 @@ interface Snapshot {
167
218
  rhythmVariance?: number | null;
168
219
  /** Version 2: absent when the page could not be screenshotted. */
169
220
  visual?: SnapshotVisual;
221
+ /**
222
+ * Version 2, craft 0.13 and later: every image on the page, largest first, at
223
+ * most 60. Absent in older snapshots, which the imagery tells never judge.
224
+ */
225
+ images?: SnapshotImage[];
226
+ /**
227
+ * Version 2, craft 0.13 and later: the text a visitor reads before
228
+ * scrolling, at most 12 blocks. Navigation, a header without the headline,
229
+ * and the words on buttons and links are left out: this is the page's
230
+ * claim, not its menu or its calls to action.
231
+ */
232
+ firstScreenText?: string[];
170
233
  /** Set when a version 1 snapshot was read and upgraded in memory. */
171
234
  migratedFrom?: 1;
172
235
  /** The design-system measures trawl has collected since v7, kept so it can switch to this. */
@@ -326,6 +389,21 @@ interface FingerprintSection {
326
389
  centred: number;
327
390
  /** Content width over viewport width, 0 to 1. */
328
391
  width: number;
392
+ /** Left-right balance of the content, 0 to 1. Component comparison only. */
393
+ symmetry?: number;
394
+ /** Buttons in the section. */
395
+ controls?: number;
396
+ /** Cards side by side. */
397
+ cards?: number;
398
+ /** The section's own background, or null when it is the page ground. */
399
+ background?: Oklch | null;
400
+ /** Badge texts ("Most popular"), lower-cased. */
401
+ badges?: string[];
402
+ /** Small round portraits. */
403
+ avatars?: number;
404
+ carousel?: boolean;
405
+ /** Large standalone figures. */
406
+ figures?: number;
329
407
  }
330
408
  interface Fingerprint {
331
409
  version: 1 | 2;
@@ -393,6 +471,8 @@ interface SnapshotOptions {
393
471
  timeoutMs?: number;
394
472
  /** Take a screenshot and measure its pixels (`visual`). Default true. */
395
473
  visual?: boolean;
474
+ /** Read the first bytes of the page's larger images for AI provenance markers. Default true. */
475
+ provenance?: boolean;
396
476
  }
397
477
  interface MinimalPage {
398
478
  close?(): Promise<void>;
@@ -413,7 +493,21 @@ interface MinimalPage {
413
493
  height: number;
414
494
  };
415
495
  }): Promise<Uint8Array>;
496
+ /** Optional: Playwright's request context, which fetches outside the page's CORS rules. Without it, no image gets `provenance`. */
497
+ request?: {
498
+ get(url: string, options?: {
499
+ headers?: Record<string, string>;
500
+ timeout?: number;
501
+ }): Promise<{
502
+ ok(): boolean;
503
+ body(): Promise<Uint8Array>;
504
+ }>;
505
+ };
416
506
  }
507
+ /** At most this many images are read for provenance, largest first. */
508
+ declare const PROVENANCE_MAX_IMAGES = 24;
509
+ /** The most time the reads may take for one page, in ms, so a machine offline waits seconds, not minutes. */
510
+ declare const PROVENANCE_BUDGET_MS = 20000;
417
511
  /** The most of a page the screenshot measures read, in CSS px. A long page is judged on its opening. */
418
512
  declare const VISUAL_MAX_HEIGHT = 6000;
419
513
  interface MinimalBrowser {
@@ -465,4 +559,4 @@ interface AuditResult {
465
559
  /** Snapshot a URL, judge it against the rendered tells, and fingerprint it. */
466
560
  declare function audit(url: string, options?: SnapshotOptions & CheckOptions): Promise<AuditResult>;
467
561
 
468
- export { type AuditResult, type SnapshotOptions, type SnapshotResult, VISUAL_MAX_HEIGHT, audit, collectInPage, loadPlaywright, overlayInPage, snapshotPage, snapshotUrl, snapshotUrls };
562
+ export { type AuditResult, PROVENANCE_BUDGET_MS, PROVENANCE_MAX_IMAGES, type SnapshotOptions, type SnapshotResult, VISUAL_MAX_HEIGHT, audit, collectInPage, loadPlaywright, overlayInPage, snapshotPage, snapshotUrl, snapshotUrls };
package/dist/audit.d.ts CHANGED
@@ -93,6 +93,57 @@ interface SnapshotSection {
93
93
  role?: SectionRole;
94
94
  /** Version 2. */
95
95
  geometry?: SectionGeometry;
96
+ /** Version 2: short pill or label texts in the section ("Most popular", "New"), at most 5. */
97
+ badges?: string[];
98
+ /** Version 2: small round portraits (at most 96px, roughly square, radius 40% or more). */
99
+ avatars?: number;
100
+ /** Version 2: a horizontal scroller, snap track or prev/next control holds the content. */
101
+ carousel?: boolean;
102
+ /** Version 2: large standalone figures ("500+", "98%", "4.9/5") at 24px or more. */
103
+ figures?: number;
104
+ /**
105
+ * Version 2, craft 0.13 and later: the section's visible text, one block per
106
+ * heading, paragraph, list item or quote, each at most 300 characters, at
107
+ * most 40. Navigation, buttons and footers are left out. What the
108
+ * specificity and proof tells read.
109
+ */
110
+ text?: string[];
111
+ }
112
+ type ImageRole = "photo" | "illustration" | "icon" | "avatar" | "logo";
113
+ /**
114
+ * What the image's own bytes say about where it came from. Only a positive
115
+ * is evidence: most images carry no metadata at all, and a re-encode strips
116
+ * it, so no marker proves nothing.
117
+ */
118
+ interface ImageProvenance {
119
+ /** The IPTC digital source type found, if any: "trainedAlgorithmicMedia" or "compositeWithTrainedAlgorithmicMedia". */
120
+ digitalSourceType: string | null;
121
+ /** Where the marker sat: an XMP packet, a C2PA manifest, or somewhere else in the file. */
122
+ source: "xmp" | "c2pa" | "other" | null;
123
+ /** The file carries a C2PA manifest (Content Credentials), whatever it says. */
124
+ c2pa: boolean;
125
+ /** Bytes read, from the start of the file. */
126
+ bytes: number;
127
+ }
128
+ /** One image as the visitor sees it: an `img`, or a CSS background large enough to be a picture. */
129
+ interface SnapshotImage {
130
+ /** The URL the browser loaded, unwrapped from an image optimiser (`/_next/image?url=`), or a `data:` URI cut to 64 characters. */
131
+ src: string;
132
+ /** Host of `src`, or null for a `data:` URI. */
133
+ host: string | null;
134
+ width: number;
135
+ height: number;
136
+ top: number;
137
+ role: ImageRole;
138
+ alt: string | null;
139
+ /** Empty alt, `aria-hidden` or `role="presentation"`. */
140
+ decorative: boolean;
141
+ /** Index into `sections`, or null when the image sits outside them. */
142
+ section: number | null;
143
+ /** A CSS `background-image`, not an `img`. */
144
+ background: boolean;
145
+ /** Present when the bytes were read. */
146
+ provenance?: ImageProvenance;
96
147
  }
97
148
  /**
98
149
  * Measures of the rendered pixels, from a full-page screenshot (capped at
@@ -167,6 +218,18 @@ interface Snapshot {
167
218
  rhythmVariance?: number | null;
168
219
  /** Version 2: absent when the page could not be screenshotted. */
169
220
  visual?: SnapshotVisual;
221
+ /**
222
+ * Version 2, craft 0.13 and later: every image on the page, largest first, at
223
+ * most 60. Absent in older snapshots, which the imagery tells never judge.
224
+ */
225
+ images?: SnapshotImage[];
226
+ /**
227
+ * Version 2, craft 0.13 and later: the text a visitor reads before
228
+ * scrolling, at most 12 blocks. Navigation, a header without the headline,
229
+ * and the words on buttons and links are left out: this is the page's
230
+ * claim, not its menu or its calls to action.
231
+ */
232
+ firstScreenText?: string[];
170
233
  /** Set when a version 1 snapshot was read and upgraded in memory. */
171
234
  migratedFrom?: 1;
172
235
  /** The design-system measures trawl has collected since v7, kept so it can switch to this. */
@@ -326,6 +389,21 @@ interface FingerprintSection {
326
389
  centred: number;
327
390
  /** Content width over viewport width, 0 to 1. */
328
391
  width: number;
392
+ /** Left-right balance of the content, 0 to 1. Component comparison only. */
393
+ symmetry?: number;
394
+ /** Buttons in the section. */
395
+ controls?: number;
396
+ /** Cards side by side. */
397
+ cards?: number;
398
+ /** The section's own background, or null when it is the page ground. */
399
+ background?: Oklch | null;
400
+ /** Badge texts ("Most popular"), lower-cased. */
401
+ badges?: string[];
402
+ /** Small round portraits. */
403
+ avatars?: number;
404
+ carousel?: boolean;
405
+ /** Large standalone figures. */
406
+ figures?: number;
329
407
  }
330
408
  interface Fingerprint {
331
409
  version: 1 | 2;
@@ -393,6 +471,8 @@ interface SnapshotOptions {
393
471
  timeoutMs?: number;
394
472
  /** Take a screenshot and measure its pixels (`visual`). Default true. */
395
473
  visual?: boolean;
474
+ /** Read the first bytes of the page's larger images for AI provenance markers. Default true. */
475
+ provenance?: boolean;
396
476
  }
397
477
  interface MinimalPage {
398
478
  close?(): Promise<void>;
@@ -413,7 +493,21 @@ interface MinimalPage {
413
493
  height: number;
414
494
  };
415
495
  }): Promise<Uint8Array>;
496
+ /** Optional: Playwright's request context, which fetches outside the page's CORS rules. Without it, no image gets `provenance`. */
497
+ request?: {
498
+ get(url: string, options?: {
499
+ headers?: Record<string, string>;
500
+ timeout?: number;
501
+ }): Promise<{
502
+ ok(): boolean;
503
+ body(): Promise<Uint8Array>;
504
+ }>;
505
+ };
416
506
  }
507
+ /** At most this many images are read for provenance, largest first. */
508
+ declare const PROVENANCE_MAX_IMAGES = 24;
509
+ /** The most time the reads may take for one page, in ms, so a machine offline waits seconds, not minutes. */
510
+ declare const PROVENANCE_BUDGET_MS = 20000;
417
511
  /** The most of a page the screenshot measures read, in CSS px. A long page is judged on its opening. */
418
512
  declare const VISUAL_MAX_HEIGHT = 6000;
419
513
  interface MinimalBrowser {
@@ -465,4 +559,4 @@ interface AuditResult {
465
559
  /** Snapshot a URL, judge it against the rendered tells, and fingerprint it. */
466
560
  declare function audit(url: string, options?: SnapshotOptions & CheckOptions): Promise<AuditResult>;
467
561
 
468
- export { type AuditResult, type SnapshotOptions, type SnapshotResult, VISUAL_MAX_HEIGHT, audit, collectInPage, loadPlaywright, overlayInPage, snapshotPage, snapshotUrl, snapshotUrls };
562
+ export { type AuditResult, PROVENANCE_BUDGET_MS, PROVENANCE_MAX_IMAGES, type SnapshotOptions, type SnapshotResult, VISUAL_MAX_HEIGHT, audit, collectInPage, loadPlaywright, overlayInPage, snapshotPage, snapshotUrl, snapshotUrls };