@guardian/commercial-core 4.25.0 → 5.0.1

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.
Files changed (41) hide show
  1. package/dist/cjs/ad-sizes.d.ts +5 -5
  2. package/dist/cjs/ad-sizes.js +5 -0
  3. package/dist/cjs/create-ad-slot.d.ts +2 -2
  4. package/dist/cjs/event-timer.d.ts +1 -0
  5. package/dist/cjs/event-timer.js +41 -41
  6. package/dist/cjs/global.d.ts +1 -7
  7. package/dist/cjs/lib/breakpoint.d.ts +1 -1
  8. package/dist/cjs/messenger.d.ts +9 -9
  9. package/dist/cjs/send-commercial-metrics.d.ts +5 -4
  10. package/dist/cjs/targeting/build-page-targeting-consentless.d.ts +2 -2
  11. package/dist/cjs/targeting/build-page-targeting.d.ts +4 -4
  12. package/dist/cjs/targeting/content.d.ts +2 -2
  13. package/dist/cjs/targeting/personalised.d.ts +4 -4
  14. package/dist/cjs/targeting/pick-targeting-values.d.ts +1 -1
  15. package/dist/cjs/targeting/session.d.ts +3 -3
  16. package/dist/cjs/targeting/shared.d.ts +1 -1
  17. package/dist/cjs/targeting/viewport.d.ts +2 -2
  18. package/dist/cjs/targeting/youtube-ima.d.ts +1 -1
  19. package/dist/cjs/targeting/youtube.d.ts +1 -1
  20. package/dist/cjs/types.d.ts +26 -20
  21. package/dist/esm/ad-sizes.d.ts +5 -5
  22. package/dist/esm/ad-sizes.js +5 -0
  23. package/dist/esm/create-ad-slot.d.ts +2 -2
  24. package/dist/esm/event-timer.d.ts +1 -0
  25. package/dist/esm/event-timer.js +41 -41
  26. package/dist/esm/global.d.ts +1 -7
  27. package/dist/esm/lib/breakpoint.d.ts +1 -1
  28. package/dist/esm/messenger.d.ts +9 -9
  29. package/dist/esm/send-commercial-metrics.d.ts +5 -4
  30. package/dist/esm/targeting/build-page-targeting-consentless.d.ts +2 -2
  31. package/dist/esm/targeting/build-page-targeting.d.ts +4 -4
  32. package/dist/esm/targeting/content.d.ts +2 -2
  33. package/dist/esm/targeting/personalised.d.ts +4 -4
  34. package/dist/esm/targeting/pick-targeting-values.d.ts +1 -1
  35. package/dist/esm/targeting/session.d.ts +3 -3
  36. package/dist/esm/targeting/shared.d.ts +1 -1
  37. package/dist/esm/targeting/viewport.d.ts +2 -2
  38. package/dist/esm/targeting/youtube-ima.d.ts +1 -1
  39. package/dist/esm/targeting/youtube.d.ts +1 -1
  40. package/dist/esm/types.d.ts +26 -20
  41. package/package.json +94 -85
@@ -1,5 +1,5 @@
1
1
  import type { Breakpoint } from './lib/breakpoint';
2
- declare type AdSizeString = 'fluid' | `${number},${number}`;
2
+ type AdSizeString = 'fluid' | `${number},${number}`;
3
3
  /**
4
4
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
5
5
  * more semantic `width`/`height` properties and keep things readonly.
@@ -27,10 +27,10 @@ declare class AdSize extends Array<number> {
27
27
  get width(): number;
28
28
  get height(): number;
29
29
  }
30
- declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'cascade';
31
- declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky' | 'crossword-banner';
32
- declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
33
- declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
30
+ type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'cascade';
31
+ type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky' | 'crossword-banner' | 'exclusion';
32
+ type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
33
+ type SlotSizeMappings = Record<SlotName, SizeMapping>;
34
34
  declare const createAdSize: (width: number, height: number) => AdSize;
35
35
  declare const standardAdSizes: {
36
36
  '970x250': AdSize;
@@ -272,6 +272,11 @@ const slotSizeMappings = {
272
272
  tablet: [adSizes.outOfPage, adSizes.empty, adSizes.leaderboard],
273
273
  phablet: [adSizes.outOfPage, adSizes.empty, adSizes.leaderboard],
274
274
  },
275
+ exclusion: {
276
+ mobile: [adSizes.empty],
277
+ phablet: [adSizes.empty],
278
+ desktop: [adSizes.empty],
279
+ },
275
280
  };
276
281
  exports.slotSizeMappings = slotSizeMappings;
277
282
  const getAdSize = (size) => adSizes[size];
@@ -1,6 +1,6 @@
1
1
  import type { SizeMapping } from './ad-sizes';
2
- declare type SlotName = 'im' | 'high-merch' | 'high-merch-lucky' | 'high-merch-paid' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
3
- declare type CreateSlotOptions = {
2
+ type SlotName = 'im' | 'high-merch' | 'high-merch-lucky' | 'high-merch-paid' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
3
+ type CreateSlotOptions = {
4
4
  classes?: string;
5
5
  name?: string;
6
6
  };
@@ -1,3 +1,4 @@
1
+ import type { ConnectionType } from './types';
1
2
  declare class Event {
2
3
  name: string;
3
4
  ts: DOMHighResTimeStamp;
@@ -9,6 +9,47 @@ class Event {
9
9
  }
10
10
  }
11
11
  class EventTimer {
12
+ /**
13
+ * Initialise the EventTimer class on page.
14
+ * Returns the singleton instance of the EventTimer class and binds
15
+ * to window.guardian.commercialTimer. If it's been previously
16
+ * initialised and bound it returns the original instance
17
+ * Note: We save to window.guardian.commercialTimer because
18
+ * different bundles (DCR / DCP) can use commercial core, and we want
19
+ * all timer events saved to a single instance per-page
20
+ * @returns {EventTimer} Instance of EventTimer
21
+ */
22
+ static init() {
23
+ var _a;
24
+ return ((_a = window.guardian).commercialTimer || (_a.commercialTimer = new EventTimer()));
25
+ }
26
+ /**
27
+ * Just a helper method to access the singleton instance of EventTimer.
28
+ * Typical use case is EventTimer.get().trigger
29
+ */
30
+ static get() {
31
+ return this.init();
32
+ }
33
+ /**
34
+ * Returns all commercial timers. CMP-related timers are not tracked
35
+ * by EventTimer so they need to be concatenated to EventTimer's private events array.
36
+ */
37
+ get events() {
38
+ return typeof window.performance !== 'undefined' &&
39
+ 'getEntriesByName' in window.performance
40
+ ? [
41
+ ...this._events,
42
+ ...EventTimer._externallyDefinedEventNames
43
+ .map((eventName) => {
44
+ const entry = window.performance.getEntriesByName(eventName)[0];
45
+ return entry
46
+ ? new Event(eventName, entry)
47
+ : undefined;
48
+ })
49
+ .filter((entry) => entry instanceof Event),
50
+ ]
51
+ : this._events;
52
+ }
12
53
  constructor() {
13
54
  this._events = [];
14
55
  this.startTS = window.performance.now();
@@ -67,47 +108,6 @@ class EventTimer {
67
108
  }
68
109
  : {};
69
110
  }
70
- /**
71
- * Initialise the EventTimer class on page.
72
- * Returns the singleton instance of the EventTimer class and binds
73
- * to window.guardian.commercialTimer. If it's been previously
74
- * initialised and bound it returns the original instance
75
- * Note: We save to window.guardian.commercialTimer because
76
- * different bundles (DCR / DCP) can use commercial core, and we want
77
- * all timer events saved to a single instance per-page
78
- * @returns {EventTimer} Instance of EventTimer
79
- */
80
- static init() {
81
- var _a;
82
- return ((_a = window.guardian).commercialTimer || (_a.commercialTimer = new EventTimer()));
83
- }
84
- /**
85
- * Just a helper method to access the singleton instance of EventTimer.
86
- * Typical use case is EventTimer.get().trigger
87
- */
88
- static get() {
89
- return this.init();
90
- }
91
- /**
92
- * Returns all commercial timers. CMP-related timers are not tracked
93
- * by EventTimer so they need to be concatenated to EventTimer's private events array.
94
- */
95
- get events() {
96
- return typeof window.performance !== 'undefined' &&
97
- 'getEntriesByName' in window.performance
98
- ? [
99
- ...this._events,
100
- ...EventTimer._externallyDefinedEventNames
101
- .map((eventName) => {
102
- const entry = window.performance.getEntriesByName(eventName)[0];
103
- return entry
104
- ? new Event(eventName, entry)
105
- : undefined;
106
- })
107
- .filter((entry) => entry instanceof Event),
108
- ]
109
- : this._events;
110
- }
111
111
  /**
112
112
  * Adds an event timer property
113
113
  *
@@ -1,13 +1,7 @@
1
1
  /// <reference types="google.analytics" />
2
- import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig } from './types';
2
+ import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig, NetworkInformation } from './types';
3
3
  import type { EventTimer } from '.';
4
4
  declare global {
5
- type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
6
- interface NetworkInformation extends EventTarget {
7
- readonly type?: ConnectionType;
8
- readonly downlink?: number;
9
- readonly effectiveType?: string;
10
- }
11
5
  interface Navigator {
12
6
  readonly connection: NetworkInformation;
13
7
  }
@@ -1,4 +1,4 @@
1
- declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
1
+ type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
2
2
  declare const isBreakpoint: (s: string) => s is Breakpoint;
3
3
  export type { Breakpoint };
4
4
  export { isBreakpoint };
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * The type of iframe messages we accept
3
3
  */
4
- declare type MessageType = 'background' | 'click' | 'disable-refresh' | 'get-page-targeting' | 'get-page-url' | 'get-styles' | 'measure-ad-load' | 'passback' | 'resize' | 'set-ad-height' | 'scroll' | 'type' | 'viewport';
4
+ type MessageType = 'background' | 'click' | 'disable-refresh' | 'get-page-targeting' | 'get-page-url' | 'get-styles' | 'measure-ad-load' | 'passback' | 'resize' | 'set-ad-height' | 'scroll' | 'type' | 'viewport';
5
5
  /**
6
6
  * Callbacks that can be registered to fire when receiving messages from an iframe
7
7
  */
8
- declare type ListenerCallback = (
8
+ type ListenerCallback = (
9
9
  /**
10
10
  * The data payload sent by an iframe, and has type `unknown` because we can't
11
11
  * predict what the iframe will send. It is the responsibility of the callback
@@ -22,7 +22,7 @@ ret: unknown,
22
22
  * Reference to the iframe that is the source of the message
23
23
  */
24
24
  iframe?: HTMLIFrameElement) => unknown;
25
- declare type RespondProxy = (error: {
25
+ type RespondProxy = (error: {
26
26
  message: string;
27
27
  } | null, result: unknown) => void;
28
28
  /**
@@ -34,28 +34,28 @@ declare type RespondProxy = (error: {
34
34
  *
35
35
  * This is useful for listeners such as viewport or scroll where the values change over time
36
36
  */
37
- declare type PersistentListenerCallback = (respondProxy: RespondProxy, specs: unknown,
37
+ type PersistentListenerCallback = (respondProxy: RespondProxy, specs: unknown,
38
38
  /**
39
39
  * Reference to the iframe that is the source of the message
40
40
  */
41
41
  iframe?: HTMLIFrameElement) => void;
42
- declare type ListenerOptions = {
42
+ type ListenerOptions = {
43
43
  window?: WindowProxy;
44
44
  };
45
- declare type MessengerErrorHandler = (err: Error, features: Record<string, string>) => void;
45
+ type MessengerErrorHandler = (err: Error, features: Record<string, string>) => void;
46
46
  /**
47
47
  * Types of functions to register a listener for a given type of iframe message
48
48
  */
49
- declare type RegisterListener = (type: MessageType, callback: ListenerCallback, options?: ListenerOptions) => void;
49
+ type RegisterListener = (type: MessageType, callback: ListenerCallback, options?: ListenerOptions) => void;
50
50
  /**
51
51
  * Types of functions to register a persistent listener for a given type of iframe message
52
52
  */
53
- declare type RegisterPersistentListener = (type: MessageType, callback: PersistentListenerCallback, options?: ListenerOptions) => void;
53
+ type RegisterPersistentListener = (type: MessageType, callback: PersistentListenerCallback, options?: ListenerOptions) => void;
54
54
  /**
55
55
  * Types of functions to unregister a listener for a given type of iframe message
56
56
  *
57
57
  */
58
- declare type UnregisterListener = (type: MessageType, callback?: ListenerCallback, options?: ListenerOptions) => void;
58
+ type UnregisterListener = (type: MessageType, callback?: ListenerCallback, options?: ListenerOptions) => void;
59
59
  /**
60
60
  * Register a listener for a given type of iframe message
61
61
  *
@@ -1,16 +1,17 @@
1
- declare type Metric = {
1
+ import type { ConnectionType } from './types';
2
+ type Metric = {
2
3
  name: string;
3
4
  value: number;
4
5
  };
5
- declare type Property = {
6
+ type Property = {
6
7
  name: string;
7
8
  value: string;
8
9
  };
9
- declare type TimedEvent = {
10
+ type TimedEvent = {
10
11
  name: string;
11
12
  ts: number;
12
13
  };
13
- declare type EventProperties = {
14
+ type EventProperties = {
14
15
  type?: ConnectionType;
15
16
  downlink?: number;
16
17
  effectiveType?: string;
@@ -1,8 +1,8 @@
1
1
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
2
2
  import type { PageTargeting } from './build-page-targeting';
3
3
  declare const consentlessTargetingKeys: readonly ["ab", "at", "bl", "bp", "br", "cc", "ct", "dcre", "edition", "k", "rp", "s", "se", "sens", "sh", "si", "skinsize", "su", "tn", "url", "urlkw"];
4
- declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
5
- declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
4
+ type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
5
+ type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
6
6
  /**
7
7
  * Call buildPageTargeting then filter out the keys that are not needed for
8
8
  * consentless targeting.
@@ -4,11 +4,11 @@ import type { CountryCode } from '@guardian/libs';
4
4
  import type { False, True } from '../types';
5
5
  import type { AdManagerGroup, Frequency } from './personalised';
6
6
  import type { SharedTargeting } from './shared';
7
- declare type PartialWithNulls<T> = {
7
+ type PartialWithNulls<T> = {
8
8
  [P in keyof T]?: T[P] | null;
9
9
  };
10
- declare type TrueOrFalse = True | False;
11
- declare type PageTargeting = PartialWithNulls<{
10
+ type TrueOrFalse = True | False;
11
+ type PageTargeting = PartialWithNulls<{
12
12
  ab: string[];
13
13
  af: 't';
14
14
  amtgrp: AdManagerGroup;
@@ -35,7 +35,7 @@ declare type PageTargeting = PartialWithNulls<{
35
35
  [_: string]: string | string[];
36
36
  } & SharedTargeting>;
37
37
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
38
- declare type BuildPageTargetingParams = {
38
+ type BuildPageTargetingParams = {
39
39
  adFree: boolean;
40
40
  clientSideParticipations: Participations;
41
41
  consentState: ConsentState;
@@ -12,7 +12,7 @@ declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180
12
12
  * - a surge in page views per minute
13
13
  *
14
14
  */
15
- declare type ContentTargeting = {
15
+ type ContentTargeting = {
16
16
  /**
17
17
  * **D**ot**c**om-**r**endering **E**ligible - [see on Ad Manager][gam]
18
18
  *
@@ -58,7 +58,7 @@ declare type ContentTargeting = {
58
58
  */
59
59
  vl: null | typeof videoLengths[number];
60
60
  };
61
- declare type Content = {
61
+ type Content = {
62
62
  eligibleForDCR: boolean;
63
63
  path: SharedTargeting['url'];
64
64
  renderingPlatform: ContentTargeting['rp'];
@@ -2,16 +2,16 @@ import type { ConsentState } from '@guardian/consent-management-platform/dist/ty
2
2
  import type { TCEventStatusCode } from '@guardian/consent-management-platform/dist/types/tcfv2';
3
3
  import type { False, NotApplicable, True } from '../types';
4
4
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
5
- declare type Frequency = typeof frequency[number];
5
+ type Frequency = typeof frequency[number];
6
6
  declare const adManagerGroups: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
7
- declare type AdManagerGroup = typeof adManagerGroups[number];
7
+ type AdManagerGroup = typeof adManagerGroups[number];
8
8
  /**
9
9
  * Personalised Targeting requires user consent
10
10
  *
11
11
  * It allows or prevents personalised advertising, restrict data processing
12
12
  * and handles access to cookies and local storage
13
13
  */
14
- declare type PersonalisedTargeting = {
14
+ type PersonalisedTargeting = {
15
15
  /**
16
16
  * **A**d **M**anager **T**argeting **Gr**ou**p** – [see on Ad Manager][gam]
17
17
  *
@@ -75,7 +75,7 @@ declare type PersonalisedTargeting = {
75
75
  */
76
76
  rdp: True | False | NotApplicable;
77
77
  };
78
- declare type Personalised = {
78
+ type Personalised = {
79
79
  state: ConsentState;
80
80
  youtube: boolean;
81
81
  };
@@ -1,5 +1,5 @@
1
1
  import type { ConditionalExcept } from 'type-fest';
2
- declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
2
+ type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
3
3
  /**
4
4
  * Picks only keys with targeting values from an object.
5
5
  * A targeting values is defined as either:
@@ -22,7 +22,7 @@ declare const referrers: readonly [{
22
22
  * These values identify a browser session are either generated client-side,
23
23
  * read from a cookie or passed down from the server.
24
24
  */
25
- declare type SessionTargeting = {
25
+ type SessionTargeting = {
26
26
  /**
27
27
  * **AB** Tests – [see on Ad Manager][gam]
28
28
  *
@@ -90,7 +90,7 @@ declare type SessionTargeting = {
90
90
  */
91
91
  si: True | False;
92
92
  };
93
- declare type AllParticipations = {
93
+ type AllParticipations = {
94
94
  clientSideParticipations: Participations;
95
95
  serverSideParticipations: {
96
96
  [key: `${string}Control`]: 'control';
@@ -98,7 +98,7 @@ declare type AllParticipations = {
98
98
  };
99
99
  };
100
100
  declare const experimentsTargeting: ({ clientSideParticipations, serverSideParticipations, }: AllParticipations) => SessionTargeting['ab'];
101
- declare type Session = {
101
+ type Session = {
102
102
  adTest: SessionTargeting['at'];
103
103
  countryCode: CountryCode;
104
104
  isSignedIn: boolean;
@@ -34,7 +34,7 @@ declare const surges: {
34
34
  *
35
35
  *
36
36
  */
37
- declare type SharedTargeting = {
37
+ type SharedTargeting = {
38
38
  /**
39
39
  * **Bl**og tags – [see on Ad Manager][gam]
40
40
  *
@@ -7,7 +7,7 @@ import type { False, True } from '../types';
7
7
  * - whether a CMP banner will show
8
8
  * - size of page skin
9
9
  */
10
- declare type ViewportTargeting = {
10
+ type ViewportTargeting = {
11
11
  /**
12
12
  * **B**reak**p**oint – [see on Ad Manager][gam]
13
13
  *
@@ -39,7 +39,7 @@ declare type ViewportTargeting = {
39
39
  */
40
40
  skinsize: 'l' | 's';
41
41
  };
42
- declare type Viewport = {
42
+ type Viewport = {
43
43
  viewPortWidth: number;
44
44
  cmpBannerWillShow: boolean;
45
45
  };
@@ -1,7 +1,7 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
3
  import type { CustomParams } from '../types';
4
- declare type BuildImaAdTagUrl = {
4
+ type BuildImaAdTagUrl = {
5
5
  adUnit: string;
6
6
  customParams: CustomParams;
7
7
  consentState: ConsentState;
@@ -2,7 +2,7 @@ import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
3
  import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
4
4
  declare const disabledAds: AdsConfigDisabled;
5
- declare type BuildAdsConfigWithConsent = {
5
+ type BuildAdsConfigWithConsent = {
6
6
  isAdFreeUser: boolean;
7
7
  adUnit: string;
8
8
  customParams: CustomParams;
@@ -1,9 +1,15 @@
1
1
  import type { VendorName } from '@guardian/consent-management-platform/dist/types';
2
- export declare type TagAttribute = {
2
+ export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
3
+ export interface NetworkInformation extends EventTarget {
4
+ readonly type?: ConnectionType;
5
+ readonly downlink?: number;
6
+ readonly effectiveType?: string;
7
+ }
8
+ export type TagAttribute = {
3
9
  name: string;
4
10
  value: string;
5
11
  };
6
- export declare type ThirdPartyTag = {
12
+ export type ThirdPartyTag = {
7
13
  async?: boolean;
8
14
  attrs?: TagAttribute[];
9
15
  beforeLoad?: () => void;
@@ -15,14 +21,14 @@ export declare type ThirdPartyTag = {
15
21
  url?: string;
16
22
  useImage?: boolean;
17
23
  };
18
- export declare type GetThirdPartyTag = (arg0: {
24
+ export type GetThirdPartyTag = (arg0: {
19
25
  shouldRun: boolean;
20
26
  }) => ThirdPartyTag;
21
- export declare type GuardianAnalyticsConfig = {
27
+ export type GuardianAnalyticsConfig = {
22
28
  trackers: Record<string, string>;
23
29
  };
24
- export declare type Edition = 'UK' | 'AU' | 'US';
25
- export declare type GuardianWindowConfig = {
30
+ export type Edition = 'UK' | 'AU' | 'US';
31
+ export type GuardianWindowConfig = {
26
32
  googleAnalytics?: GuardianAnalyticsConfig;
27
33
  isDotcomRendering: boolean;
28
34
  ophan: {
@@ -42,27 +48,27 @@ export declare type GuardianWindowConfig = {
42
48
  [key: `${string}Variant`]: 'variant';
43
49
  };
44
50
  };
45
- export declare type GoogleTagParams = unknown;
46
- export declare type GoogleTrackConversionObject = {
51
+ export type GoogleTagParams = unknown;
52
+ export type GoogleTrackConversionObject = {
47
53
  google_conversion_id: number;
48
54
  google_custom_params: GoogleTagParams;
49
55
  google_remarketing_only: boolean;
50
56
  };
51
- export declare type MaybeArray<T> = T | T[];
52
- export declare type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
53
- export declare type AdsConfigDisabled = {
57
+ export type MaybeArray<T> = T | T[];
58
+ export type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
59
+ export type AdsConfigDisabled = {
54
60
  disableAds: true;
55
61
  };
56
- export declare type AdsConfigBasic = {
62
+ export type AdsConfigBasic = {
57
63
  adTagParameters: {
58
64
  iu: string;
59
65
  cust_params: string;
60
66
  };
61
67
  };
62
- export declare type AdsConfigCCPAorAus = AdsConfigBasic & {
68
+ export type AdsConfigCCPAorAus = AdsConfigBasic & {
63
69
  restrictedDataProcessor: boolean;
64
70
  };
65
- export declare type AdsConfigTCFV2 = AdsConfigBasic & {
71
+ export type AdsConfigTCFV2 = AdsConfigBasic & {
66
72
  adTagParameters: {
67
73
  cmpGdpr: number;
68
74
  cmpVcd: string;
@@ -70,9 +76,9 @@ export declare type AdsConfigTCFV2 = AdsConfigBasic & {
70
76
  };
71
77
  nonPersonalizedAd: boolean;
72
78
  };
73
- export declare type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
74
- export declare type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
75
- export declare type AdTargetingBuilder = () => Promise<AdsConfig>;
76
- export declare type True = 't';
77
- export declare type False = 'f';
78
- export declare type NotApplicable = 'na';
79
+ export type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
80
+ export type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
81
+ export type AdTargetingBuilder = () => Promise<AdsConfig>;
82
+ export type True = 't';
83
+ export type False = 'f';
84
+ export type NotApplicable = 'na';
@@ -1,5 +1,5 @@
1
1
  import type { Breakpoint } from './lib/breakpoint';
2
- declare type AdSizeString = 'fluid' | `${number},${number}`;
2
+ type AdSizeString = 'fluid' | `${number},${number}`;
3
3
  /**
4
4
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
5
5
  * more semantic `width`/`height` properties and keep things readonly.
@@ -27,10 +27,10 @@ declare class AdSize extends Array<number> {
27
27
  get width(): number;
28
28
  get height(): number;
29
29
  }
30
- declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'cascade';
31
- declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky' | 'crossword-banner';
32
- declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
33
- declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
30
+ type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'cascade';
31
+ type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'merchandising-high-lucky' | 'survey' | 'im' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky' | 'crossword-banner' | 'exclusion';
32
+ type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
33
+ type SlotSizeMappings = Record<SlotName, SizeMapping>;
34
34
  declare const createAdSize: (width: number, height: number) => AdSize;
35
35
  declare const standardAdSizes: {
36
36
  '970x250': AdSize;
@@ -265,6 +265,11 @@ const slotSizeMappings = {
265
265
  tablet: [adSizes.outOfPage, adSizes.empty, adSizes.leaderboard],
266
266
  phablet: [adSizes.outOfPage, adSizes.empty, adSizes.leaderboard],
267
267
  },
268
+ exclusion: {
269
+ mobile: [adSizes.empty],
270
+ phablet: [adSizes.empty],
271
+ desktop: [adSizes.empty],
272
+ },
268
273
  };
269
274
  const getAdSize = (size) => adSizes[size];
270
275
  // Export for testing
@@ -1,6 +1,6 @@
1
1
  import type { SizeMapping } from './ad-sizes';
2
- declare type SlotName = 'im' | 'high-merch' | 'high-merch-lucky' | 'high-merch-paid' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
3
- declare type CreateSlotOptions = {
2
+ type SlotName = 'im' | 'high-merch' | 'high-merch-lucky' | 'high-merch-paid' | 'inline' | 'mostpop' | 'comments' | 'top-above-nav' | 'carrot' | 'epic' | 'mobile-sticky';
3
+ type CreateSlotOptions = {
4
4
  classes?: string;
5
5
  name?: string;
6
6
  };
@@ -1,3 +1,4 @@
1
+ import type { ConnectionType } from './types';
1
2
  declare class Event {
2
3
  name: string;
3
4
  ts: DOMHighResTimeStamp;
@@ -6,6 +6,47 @@ class Event {
6
6
  }
7
7
  }
8
8
  class EventTimer {
9
+ /**
10
+ * Initialise the EventTimer class on page.
11
+ * Returns the singleton instance of the EventTimer class and binds
12
+ * to window.guardian.commercialTimer. If it's been previously
13
+ * initialised and bound it returns the original instance
14
+ * Note: We save to window.guardian.commercialTimer because
15
+ * different bundles (DCR / DCP) can use commercial core, and we want
16
+ * all timer events saved to a single instance per-page
17
+ * @returns {EventTimer} Instance of EventTimer
18
+ */
19
+ static init() {
20
+ var _a;
21
+ return ((_a = window.guardian).commercialTimer || (_a.commercialTimer = new EventTimer()));
22
+ }
23
+ /**
24
+ * Just a helper method to access the singleton instance of EventTimer.
25
+ * Typical use case is EventTimer.get().trigger
26
+ */
27
+ static get() {
28
+ return this.init();
29
+ }
30
+ /**
31
+ * Returns all commercial timers. CMP-related timers are not tracked
32
+ * by EventTimer so they need to be concatenated to EventTimer's private events array.
33
+ */
34
+ get events() {
35
+ return typeof window.performance !== 'undefined' &&
36
+ 'getEntriesByName' in window.performance
37
+ ? [
38
+ ...this._events,
39
+ ...EventTimer._externallyDefinedEventNames
40
+ .map((eventName) => {
41
+ const entry = window.performance.getEntriesByName(eventName)[0];
42
+ return entry
43
+ ? new Event(eventName, entry)
44
+ : undefined;
45
+ })
46
+ .filter((entry) => entry instanceof Event),
47
+ ]
48
+ : this._events;
49
+ }
9
50
  constructor() {
10
51
  this._events = [];
11
52
  this.startTS = window.performance.now();
@@ -64,47 +105,6 @@ class EventTimer {
64
105
  }
65
106
  : {};
66
107
  }
67
- /**
68
- * Initialise the EventTimer class on page.
69
- * Returns the singleton instance of the EventTimer class and binds
70
- * to window.guardian.commercialTimer. If it's been previously
71
- * initialised and bound it returns the original instance
72
- * Note: We save to window.guardian.commercialTimer because
73
- * different bundles (DCR / DCP) can use commercial core, and we want
74
- * all timer events saved to a single instance per-page
75
- * @returns {EventTimer} Instance of EventTimer
76
- */
77
- static init() {
78
- var _a;
79
- return ((_a = window.guardian).commercialTimer || (_a.commercialTimer = new EventTimer()));
80
- }
81
- /**
82
- * Just a helper method to access the singleton instance of EventTimer.
83
- * Typical use case is EventTimer.get().trigger
84
- */
85
- static get() {
86
- return this.init();
87
- }
88
- /**
89
- * Returns all commercial timers. CMP-related timers are not tracked
90
- * by EventTimer so they need to be concatenated to EventTimer's private events array.
91
- */
92
- get events() {
93
- return typeof window.performance !== 'undefined' &&
94
- 'getEntriesByName' in window.performance
95
- ? [
96
- ...this._events,
97
- ...EventTimer._externallyDefinedEventNames
98
- .map((eventName) => {
99
- const entry = window.performance.getEntriesByName(eventName)[0];
100
- return entry
101
- ? new Event(eventName, entry)
102
- : undefined;
103
- })
104
- .filter((entry) => entry instanceof Event),
105
- ]
106
- : this._events;
107
- }
108
108
  /**
109
109
  * Adds an event timer property
110
110
  *
@@ -1,13 +1,7 @@
1
1
  /// <reference types="google.analytics" />
2
- import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig } from './types';
2
+ import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig, NetworkInformation } from './types';
3
3
  import type { EventTimer } from '.';
4
4
  declare global {
5
- type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
6
- interface NetworkInformation extends EventTarget {
7
- readonly type?: ConnectionType;
8
- readonly downlink?: number;
9
- readonly effectiveType?: string;
10
- }
11
5
  interface Navigator {
12
6
  readonly connection: NetworkInformation;
13
7
  }
@@ -1,4 +1,4 @@
1
- declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
1
+ type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
2
2
  declare const isBreakpoint: (s: string) => s is Breakpoint;
3
3
  export type { Breakpoint };
4
4
  export { isBreakpoint };
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * The type of iframe messages we accept
3
3
  */
4
- declare type MessageType = 'background' | 'click' | 'disable-refresh' | 'get-page-targeting' | 'get-page-url' | 'get-styles' | 'measure-ad-load' | 'passback' | 'resize' | 'set-ad-height' | 'scroll' | 'type' | 'viewport';
4
+ type MessageType = 'background' | 'click' | 'disable-refresh' | 'get-page-targeting' | 'get-page-url' | 'get-styles' | 'measure-ad-load' | 'passback' | 'resize' | 'set-ad-height' | 'scroll' | 'type' | 'viewport';
5
5
  /**
6
6
  * Callbacks that can be registered to fire when receiving messages from an iframe
7
7
  */
8
- declare type ListenerCallback = (
8
+ type ListenerCallback = (
9
9
  /**
10
10
  * The data payload sent by an iframe, and has type `unknown` because we can't
11
11
  * predict what the iframe will send. It is the responsibility of the callback
@@ -22,7 +22,7 @@ ret: unknown,
22
22
  * Reference to the iframe that is the source of the message
23
23
  */
24
24
  iframe?: HTMLIFrameElement) => unknown;
25
- declare type RespondProxy = (error: {
25
+ type RespondProxy = (error: {
26
26
  message: string;
27
27
  } | null, result: unknown) => void;
28
28
  /**
@@ -34,28 +34,28 @@ declare type RespondProxy = (error: {
34
34
  *
35
35
  * This is useful for listeners such as viewport or scroll where the values change over time
36
36
  */
37
- declare type PersistentListenerCallback = (respondProxy: RespondProxy, specs: unknown,
37
+ type PersistentListenerCallback = (respondProxy: RespondProxy, specs: unknown,
38
38
  /**
39
39
  * Reference to the iframe that is the source of the message
40
40
  */
41
41
  iframe?: HTMLIFrameElement) => void;
42
- declare type ListenerOptions = {
42
+ type ListenerOptions = {
43
43
  window?: WindowProxy;
44
44
  };
45
- declare type MessengerErrorHandler = (err: Error, features: Record<string, string>) => void;
45
+ type MessengerErrorHandler = (err: Error, features: Record<string, string>) => void;
46
46
  /**
47
47
  * Types of functions to register a listener for a given type of iframe message
48
48
  */
49
- declare type RegisterListener = (type: MessageType, callback: ListenerCallback, options?: ListenerOptions) => void;
49
+ type RegisterListener = (type: MessageType, callback: ListenerCallback, options?: ListenerOptions) => void;
50
50
  /**
51
51
  * Types of functions to register a persistent listener for a given type of iframe message
52
52
  */
53
- declare type RegisterPersistentListener = (type: MessageType, callback: PersistentListenerCallback, options?: ListenerOptions) => void;
53
+ type RegisterPersistentListener = (type: MessageType, callback: PersistentListenerCallback, options?: ListenerOptions) => void;
54
54
  /**
55
55
  * Types of functions to unregister a listener for a given type of iframe message
56
56
  *
57
57
  */
58
- declare type UnregisterListener = (type: MessageType, callback?: ListenerCallback, options?: ListenerOptions) => void;
58
+ type UnregisterListener = (type: MessageType, callback?: ListenerCallback, options?: ListenerOptions) => void;
59
59
  /**
60
60
  * Register a listener for a given type of iframe message
61
61
  *
@@ -1,16 +1,17 @@
1
- declare type Metric = {
1
+ import type { ConnectionType } from './types';
2
+ type Metric = {
2
3
  name: string;
3
4
  value: number;
4
5
  };
5
- declare type Property = {
6
+ type Property = {
6
7
  name: string;
7
8
  value: string;
8
9
  };
9
- declare type TimedEvent = {
10
+ type TimedEvent = {
10
11
  name: string;
11
12
  ts: number;
12
13
  };
13
- declare type EventProperties = {
14
+ type EventProperties = {
14
15
  type?: ConnectionType;
15
16
  downlink?: number;
16
17
  effectiveType?: string;
@@ -1,8 +1,8 @@
1
1
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
2
2
  import type { PageTargeting } from './build-page-targeting';
3
3
  declare const consentlessTargetingKeys: readonly ["ab", "at", "bl", "bp", "br", "cc", "ct", "dcre", "edition", "k", "rp", "s", "se", "sens", "sh", "si", "skinsize", "su", "tn", "url", "urlkw"];
4
- declare type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
5
- declare type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
4
+ type ConsentlessTargetingKeys = typeof consentlessTargetingKeys[number];
5
+ type ConsentlessPageTargeting = Partial<Pick<PageTargeting, ConsentlessTargetingKeys>>;
6
6
  /**
7
7
  * Call buildPageTargeting then filter out the keys that are not needed for
8
8
  * consentless targeting.
@@ -4,11 +4,11 @@ import type { CountryCode } from '@guardian/libs';
4
4
  import type { False, True } from '../types';
5
5
  import type { AdManagerGroup, Frequency } from './personalised';
6
6
  import type { SharedTargeting } from './shared';
7
- declare type PartialWithNulls<T> = {
7
+ type PartialWithNulls<T> = {
8
8
  [P in keyof T]?: T[P] | null;
9
9
  };
10
- declare type TrueOrFalse = True | False;
11
- declare type PageTargeting = PartialWithNulls<{
10
+ type TrueOrFalse = True | False;
11
+ type PageTargeting = PartialWithNulls<{
12
12
  ab: string[];
13
13
  af: 't';
14
14
  amtgrp: AdManagerGroup;
@@ -35,7 +35,7 @@ declare type PageTargeting = PartialWithNulls<{
35
35
  [_: string]: string | string[];
36
36
  } & SharedTargeting>;
37
37
  declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
38
- declare type BuildPageTargetingParams = {
38
+ type BuildPageTargetingParams = {
39
39
  adFree: boolean;
40
40
  clientSideParticipations: Participations;
41
41
  consentState: ConsentState;
@@ -12,7 +12,7 @@ declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180
12
12
  * - a surge in page views per minute
13
13
  *
14
14
  */
15
- declare type ContentTargeting = {
15
+ type ContentTargeting = {
16
16
  /**
17
17
  * **D**ot**c**om-**r**endering **E**ligible - [see on Ad Manager][gam]
18
18
  *
@@ -58,7 +58,7 @@ declare type ContentTargeting = {
58
58
  */
59
59
  vl: null | typeof videoLengths[number];
60
60
  };
61
- declare type Content = {
61
+ type Content = {
62
62
  eligibleForDCR: boolean;
63
63
  path: SharedTargeting['url'];
64
64
  renderingPlatform: ContentTargeting['rp'];
@@ -2,16 +2,16 @@ import type { ConsentState } from '@guardian/consent-management-platform/dist/ty
2
2
  import type { TCEventStatusCode } from '@guardian/consent-management-platform/dist/types/tcfv2';
3
3
  import type { False, NotApplicable, True } from '../types';
4
4
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
5
- declare type Frequency = typeof frequency[number];
5
+ type Frequency = typeof frequency[number];
6
6
  declare const adManagerGroups: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
7
- declare type AdManagerGroup = typeof adManagerGroups[number];
7
+ type AdManagerGroup = typeof adManagerGroups[number];
8
8
  /**
9
9
  * Personalised Targeting requires user consent
10
10
  *
11
11
  * It allows or prevents personalised advertising, restrict data processing
12
12
  * and handles access to cookies and local storage
13
13
  */
14
- declare type PersonalisedTargeting = {
14
+ type PersonalisedTargeting = {
15
15
  /**
16
16
  * **A**d **M**anager **T**argeting **Gr**ou**p** – [see on Ad Manager][gam]
17
17
  *
@@ -75,7 +75,7 @@ declare type PersonalisedTargeting = {
75
75
  */
76
76
  rdp: True | False | NotApplicable;
77
77
  };
78
- declare type Personalised = {
78
+ type Personalised = {
79
79
  state: ConsentState;
80
80
  youtube: boolean;
81
81
  };
@@ -1,5 +1,5 @@
1
1
  import type { ConditionalExcept } from 'type-fest';
2
- declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
2
+ type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
3
3
  /**
4
4
  * Picks only keys with targeting values from an object.
5
5
  * A targeting values is defined as either:
@@ -22,7 +22,7 @@ declare const referrers: readonly [{
22
22
  * These values identify a browser session are either generated client-side,
23
23
  * read from a cookie or passed down from the server.
24
24
  */
25
- declare type SessionTargeting = {
25
+ type SessionTargeting = {
26
26
  /**
27
27
  * **AB** Tests – [see on Ad Manager][gam]
28
28
  *
@@ -90,7 +90,7 @@ declare type SessionTargeting = {
90
90
  */
91
91
  si: True | False;
92
92
  };
93
- declare type AllParticipations = {
93
+ type AllParticipations = {
94
94
  clientSideParticipations: Participations;
95
95
  serverSideParticipations: {
96
96
  [key: `${string}Control`]: 'control';
@@ -98,7 +98,7 @@ declare type AllParticipations = {
98
98
  };
99
99
  };
100
100
  declare const experimentsTargeting: ({ clientSideParticipations, serverSideParticipations, }: AllParticipations) => SessionTargeting['ab'];
101
- declare type Session = {
101
+ type Session = {
102
102
  adTest: SessionTargeting['at'];
103
103
  countryCode: CountryCode;
104
104
  isSignedIn: boolean;
@@ -34,7 +34,7 @@ declare const surges: {
34
34
  *
35
35
  *
36
36
  */
37
- declare type SharedTargeting = {
37
+ type SharedTargeting = {
38
38
  /**
39
39
  * **Bl**og tags – [see on Ad Manager][gam]
40
40
  *
@@ -7,7 +7,7 @@ import type { False, True } from '../types';
7
7
  * - whether a CMP banner will show
8
8
  * - size of page skin
9
9
  */
10
- declare type ViewportTargeting = {
10
+ type ViewportTargeting = {
11
11
  /**
12
12
  * **B**reak**p**oint – [see on Ad Manager][gam]
13
13
  *
@@ -39,7 +39,7 @@ declare type ViewportTargeting = {
39
39
  */
40
40
  skinsize: 'l' | 's';
41
41
  };
42
- declare type Viewport = {
42
+ type Viewport = {
43
43
  viewPortWidth: number;
44
44
  cmpBannerWillShow: boolean;
45
45
  };
@@ -1,7 +1,7 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
3
  import type { CustomParams } from '../types';
4
- declare type BuildImaAdTagUrl = {
4
+ type BuildImaAdTagUrl = {
5
5
  adUnit: string;
6
6
  customParams: CustomParams;
7
7
  consentState: ConsentState;
@@ -2,7 +2,7 @@ import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/consent-management-platform/dist/types';
3
3
  import type { AdsConfig, AdsConfigDisabled, CustomParams } from '../types';
4
4
  declare const disabledAds: AdsConfigDisabled;
5
- declare type BuildAdsConfigWithConsent = {
5
+ type BuildAdsConfigWithConsent = {
6
6
  isAdFreeUser: boolean;
7
7
  adUnit: string;
8
8
  customParams: CustomParams;
@@ -1,9 +1,15 @@
1
1
  import type { VendorName } from '@guardian/consent-management-platform/dist/types';
2
- export declare type TagAttribute = {
2
+ export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
3
+ export interface NetworkInformation extends EventTarget {
4
+ readonly type?: ConnectionType;
5
+ readonly downlink?: number;
6
+ readonly effectiveType?: string;
7
+ }
8
+ export type TagAttribute = {
3
9
  name: string;
4
10
  value: string;
5
11
  };
6
- export declare type ThirdPartyTag = {
12
+ export type ThirdPartyTag = {
7
13
  async?: boolean;
8
14
  attrs?: TagAttribute[];
9
15
  beforeLoad?: () => void;
@@ -15,14 +21,14 @@ export declare type ThirdPartyTag = {
15
21
  url?: string;
16
22
  useImage?: boolean;
17
23
  };
18
- export declare type GetThirdPartyTag = (arg0: {
24
+ export type GetThirdPartyTag = (arg0: {
19
25
  shouldRun: boolean;
20
26
  }) => ThirdPartyTag;
21
- export declare type GuardianAnalyticsConfig = {
27
+ export type GuardianAnalyticsConfig = {
22
28
  trackers: Record<string, string>;
23
29
  };
24
- export declare type Edition = 'UK' | 'AU' | 'US';
25
- export declare type GuardianWindowConfig = {
30
+ export type Edition = 'UK' | 'AU' | 'US';
31
+ export type GuardianWindowConfig = {
26
32
  googleAnalytics?: GuardianAnalyticsConfig;
27
33
  isDotcomRendering: boolean;
28
34
  ophan: {
@@ -42,27 +48,27 @@ export declare type GuardianWindowConfig = {
42
48
  [key: `${string}Variant`]: 'variant';
43
49
  };
44
50
  };
45
- export declare type GoogleTagParams = unknown;
46
- export declare type GoogleTrackConversionObject = {
51
+ export type GoogleTagParams = unknown;
52
+ export type GoogleTrackConversionObject = {
47
53
  google_conversion_id: number;
48
54
  google_custom_params: GoogleTagParams;
49
55
  google_remarketing_only: boolean;
50
56
  };
51
- export declare type MaybeArray<T> = T | T[];
52
- export declare type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
53
- export declare type AdsConfigDisabled = {
57
+ export type MaybeArray<T> = T | T[];
58
+ export type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
59
+ export type AdsConfigDisabled = {
54
60
  disableAds: true;
55
61
  };
56
- export declare type AdsConfigBasic = {
62
+ export type AdsConfigBasic = {
57
63
  adTagParameters: {
58
64
  iu: string;
59
65
  cust_params: string;
60
66
  };
61
67
  };
62
- export declare type AdsConfigCCPAorAus = AdsConfigBasic & {
68
+ export type AdsConfigCCPAorAus = AdsConfigBasic & {
63
69
  restrictedDataProcessor: boolean;
64
70
  };
65
- export declare type AdsConfigTCFV2 = AdsConfigBasic & {
71
+ export type AdsConfigTCFV2 = AdsConfigBasic & {
66
72
  adTagParameters: {
67
73
  cmpGdpr: number;
68
74
  cmpVcd: string;
@@ -70,9 +76,9 @@ export declare type AdsConfigTCFV2 = AdsConfigBasic & {
70
76
  };
71
77
  nonPersonalizedAd: boolean;
72
78
  };
73
- export declare type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
74
- export declare type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
75
- export declare type AdTargetingBuilder = () => Promise<AdsConfig>;
76
- export declare type True = 't';
77
- export declare type False = 'f';
78
- export declare type NotApplicable = 'na';
79
+ export type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
80
+ export type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
81
+ export type AdTargetingBuilder = () => Promise<AdsConfig>;
82
+ export type True = 't';
83
+ export type False = 'f';
84
+ export type NotApplicable = 'na';
package/package.json CHANGED
@@ -1,87 +1,96 @@
1
1
  {
2
- "name": "@guardian/commercial-core",
3
- "version": "4.25.0",
4
- "description": "Guardian advertising business logic",
5
- "homepage": "https://github.com/guardian/commercial-core#readme",
6
- "bugs": {
7
- "url": "https://github.com/guardian/commercial-core/issues"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/guardian/commercial-core.git"
12
- },
13
- "license": "Apache-2.0",
14
- "main": "dist/cjs/index.js",
15
- "module": "dist/esm/index.js",
16
- "files": [
17
- "dist"
18
- ],
19
- "scripts": {
20
- "build": "npm-run-all clean --parallel compile:*",
21
- "clean": "rm -rf dist",
22
- "commit": "cz",
23
- "compile:common": "tsc --project ./tsconfig.build.json --outDir ./dist/cjs --module CommonJS",
24
- "compile:esm": "tsc --project ./tsconfig.build.json --outDir ./dist/esm",
25
- "lint": "eslint .",
26
- "precommit:lint": "lint-staged",
27
- "prepush:test": "jest --verbose --runInBand --onlyChanged",
28
- "test": "jest",
29
- "test:watch": "jest --watch",
30
- "test:ci": "jest --coverage --ci",
31
- "tsc": "tsc --noEmit",
32
- "validate": "npm-run-all tsc lint test build",
33
- "prepare": "husky install"
34
- },
35
- "commitlint": {
36
- "extends": [
37
- "@commitlint/config-conventional"
38
- ]
39
- },
40
- "lint-staged": {
41
- "*.js|*.ts": "eslint --fix"
42
- },
43
- "prettier": "@guardian/prettier",
44
- "devDependencies": {
45
- "@commitlint/cli": "^17.0.3",
46
- "@commitlint/config-conventional": "^17.0.0",
47
- "@guardian/ab-core": "^2.0.0",
48
- "@guardian/consent-management-platform": "^10.6.0",
49
- "@guardian/eslint-config-typescript": "^1.0.0",
50
- "@guardian/libs": "^7.1.3",
51
- "@guardian/prettier": "^2.1.1",
52
- "@octokit/core": "^4.0.5",
53
- "@semantic-release/github": "^8.0.2",
54
- "@types/google.analytics": "^0.0.42",
55
- "@types/googletag": "^2.0.0",
56
- "@types/jest": "^27.0.3",
57
- "@typescript-eslint/eslint-plugin": "^5.5.0",
58
- "@typescript-eslint/parser": "^5.5.0",
59
- "commitizen": "^4.2.4",
60
- "conventional-changelog-conventionalcommits": "^5.0.0",
61
- "cz-conventional-changelog": "^3.3.0",
62
- "eslint": "^8.4.1",
63
- "eslint-config-prettier": "^8.3.0",
64
- "eslint-plugin-eslint-comments": "^3.2.0",
65
- "eslint-plugin-import": "^2.25.3",
66
- "eslint-plugin-jest": "^26.1.5",
67
- "eslint-plugin-prettier": "^4.0.0",
68
- "husky": "^8.0.1",
69
- "jest": "^27.4.1",
70
- "lint-staged": "^13.0.3",
71
- "mockdate": "^3.0.5",
72
- "npm-run-all": "^4.1.5",
73
- "prettier": "^2.5.0",
74
- "semantic-release": "^19.0.2",
75
- "ts-jest": "^27.0.7",
76
- "type-fest": "^2.8.0",
77
- "typescript": "^4.5.2",
78
- "web-vitals": "^2.1.2"
79
- },
80
- "publishConfig": {
81
- "access": "public"
82
- },
83
- "peerDependencies": {
84
- "@guardian/ab-core": "^2.0.0",
85
- "@guardian/libs": ">6"
86
- }
2
+ "name": "@guardian/commercial-core",
3
+ "version": "5.0.1",
4
+ "description": "Guardian advertising business logic",
5
+ "homepage": "https://github.com/guardian/commercial-core#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/guardian/commercial-core/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/guardian/commercial-core.git"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "main": "dist/cjs/index.js",
15
+ "module": "dist/esm/index.js",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "npm-run-all clean --parallel compile:*",
21
+ "clean": "rm -rf dist",
22
+ "commit": "cz",
23
+ "compile:common": "tsc --project ./tsconfig.build.json --outDir ./dist/cjs --module CommonJS",
24
+ "compile:esm": "tsc --project ./tsconfig.build.json --outDir ./dist/esm",
25
+ "lint": "eslint .",
26
+ "prettier:check": "prettier . --check --cache",
27
+ "prettier:fix": "prettier . --write --cache",
28
+ "precommit:lint": "lint-staged",
29
+ "prepush:test": "jest --verbose --runInBand --onlyChanged",
30
+ "test": "jest",
31
+ "test:watch": "jest --watch",
32
+ "test:ci": "jest --coverage --ci",
33
+ "tsc": "tsc --noEmit",
34
+ "validate": "npm-run-all tsc lint test build",
35
+ "prepare": "husky install"
36
+ },
37
+ "commitlint": {
38
+ "extends": [
39
+ "@commitlint/config-conventional"
40
+ ]
41
+ },
42
+ "lint-staged": {
43
+ "*.js|*.ts": [
44
+ "eslint --fix",
45
+ "yarn prettier:fix"
46
+ ]
47
+ },
48
+ "prettier": "@guardian/prettier",
49
+ "dependencies": {
50
+ "type-fest": "2.12.2"
51
+ },
52
+ "devDependencies": {
53
+ "@commitlint/cli": "^17.0.3",
54
+ "@commitlint/config-conventional": "^17.0.0",
55
+ "@guardian/ab-core": "2.0.0",
56
+ "@guardian/consent-management-platform": "11.0.0",
57
+ "@guardian/eslint-config-typescript": "^1.0.0",
58
+ "@guardian/libs": "10.0.0",
59
+ "@guardian/prettier": "^2.1.1",
60
+ "@octokit/core": "^4.0.5",
61
+ "@semantic-release/github": "^8.0.2",
62
+ "@types/google.analytics": "^0.0.42",
63
+ "@types/googletag": "^2.0.0",
64
+ "@types/jest": "^27.0.3",
65
+ "@types/node": "^18.11.9",
66
+ "@typescript-eslint/eslint-plugin": "^5.5.0",
67
+ "@typescript-eslint/parser": "^5.5.0",
68
+ "commitizen": "^4.2.4",
69
+ "conventional-changelog-conventionalcommits": "^5.0.0",
70
+ "cz-conventional-changelog": "^3.3.0",
71
+ "eslint": "^8.4.1",
72
+ "eslint-config-prettier": "^8.3.0",
73
+ "eslint-plugin-eslint-comments": "^3.2.0",
74
+ "eslint-plugin-import": "^2.25.3",
75
+ "eslint-plugin-jest": "^26.1.5",
76
+ "eslint-plugin-prettier": "^4.0.0",
77
+ "husky": "^8.0.1",
78
+ "jest": "^27.4.1",
79
+ "lint-staged": "^13.0.3",
80
+ "mockdate": "^3.0.5",
81
+ "npm-run-all": "^4.1.5",
82
+ "prettier": "^2.5.0",
83
+ "semantic-release": "^19.0.2",
84
+ "ts-jest": "^27.0.7",
85
+ "tslib": "^2.4.0",
86
+ "typescript": "^4.5.2"
87
+ },
88
+ "peerDependencies": {
89
+ "@guardian/ab-core": "^2.0.0",
90
+ "@guardian/consent-management-platform": "^11.0.0",
91
+ "@guardian/libs": "^10.0.0"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
95
+ }
87
96
  }