@guardian/commercial-core 7.0.0 → 27.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.
Files changed (173) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -34
  3. package/dist/cjs/ad-sizes.d.ts +150 -8
  4. package/dist/cjs/ad-sizes.js +137 -37
  5. package/dist/cjs/breakpoint.d.ts +8 -0
  6. package/dist/cjs/breakpoint.js +10 -0
  7. package/dist/cjs/constants/index.d.ts +1 -1
  8. package/dist/cjs/constants/index.js +2 -2
  9. package/dist/cjs/detect-ad-blocker.js +1 -2
  10. package/dist/cjs/event-timer.d.ts +60 -48
  11. package/dist/cjs/event-timer.js +149 -115
  12. package/dist/cjs/geo/country-code.d.ts +3 -0
  13. package/dist/cjs/geo/country-code.js +34 -0
  14. package/dist/cjs/geo/geo-utils.d.ts +11 -0
  15. package/dist/cjs/geo/geo-utils.js +31 -0
  16. package/dist/cjs/global.d.ts +58 -10
  17. package/dist/cjs/index.d.ts +9 -39
  18. package/dist/cjs/index.js +12 -67
  19. package/dist/cjs/send-commercial-metrics.d.ts +8 -2
  20. package/dist/cjs/send-commercial-metrics.js +51 -27
  21. package/dist/cjs/targeting/build-page-targeting.d.ts +4 -5
  22. package/dist/cjs/targeting/build-page-targeting.js +35 -7
  23. package/dist/cjs/targeting/content.d.ts +1 -1
  24. package/dist/cjs/targeting/content.js +1 -1
  25. package/dist/cjs/targeting/personalised.d.ts +2 -3
  26. package/dist/cjs/targeting/personalised.js +3 -3
  27. package/dist/cjs/targeting/pick-targeting-values.d.ts +1 -1
  28. package/dist/cjs/targeting/session.d.ts +2 -2
  29. package/dist/cjs/targeting/shared.d.ts +31 -20
  30. package/dist/cjs/targeting/shared.js +0 -30
  31. package/dist/cjs/targeting/teads-eligibility.d.ts +2 -0
  32. package/dist/cjs/targeting/teads-eligibility.js +20 -0
  33. package/dist/cjs/targeting/types.d.ts +6 -0
  34. package/dist/cjs/targeting/types.js +2 -0
  35. package/dist/cjs/targeting/viewport.d.ts +1 -1
  36. package/dist/cjs/targeting/youtube-ima.d.ts +4 -3
  37. package/dist/cjs/targeting/youtube-ima.js +7 -4
  38. package/dist/cjs/types.d.ts +399 -63
  39. package/dist/cjs/types.js +10 -0
  40. package/dist/esm/ad-sizes.d.ts +150 -8
  41. package/dist/esm/ad-sizes.js +135 -37
  42. package/dist/esm/breakpoint.d.ts +8 -0
  43. package/dist/esm/breakpoint.js +6 -0
  44. package/dist/esm/constants/index.d.ts +1 -1
  45. package/dist/esm/constants/index.js +1 -1
  46. package/dist/esm/event-timer.d.ts +60 -48
  47. package/dist/esm/event-timer.js +147 -115
  48. package/dist/esm/geo/country-code.d.ts +3 -0
  49. package/dist/esm/geo/country-code.js +31 -0
  50. package/dist/esm/geo/geo-utils.d.ts +11 -0
  51. package/dist/esm/geo/geo-utils.js +20 -0
  52. package/dist/esm/global.d.ts +58 -10
  53. package/dist/esm/global.js +0 -1
  54. package/dist/esm/index.d.ts +9 -39
  55. package/dist/esm/index.js +6 -31
  56. package/dist/esm/send-commercial-metrics.d.ts +8 -2
  57. package/dist/esm/send-commercial-metrics.js +48 -25
  58. package/dist/esm/targeting/build-page-targeting.d.ts +4 -5
  59. package/dist/esm/targeting/build-page-targeting.js +35 -7
  60. package/dist/esm/targeting/content.d.ts +1 -1
  61. package/dist/esm/targeting/content.js +1 -1
  62. package/dist/esm/targeting/personalised.d.ts +2 -3
  63. package/dist/esm/targeting/personalised.js +3 -3
  64. package/dist/esm/targeting/pick-targeting-values.d.ts +1 -1
  65. package/dist/esm/targeting/session.d.ts +2 -2
  66. package/dist/esm/targeting/shared.d.ts +31 -20
  67. package/dist/esm/targeting/shared.js +0 -30
  68. package/dist/esm/targeting/teads-eligibility.d.ts +2 -0
  69. package/dist/esm/targeting/teads-eligibility.js +17 -0
  70. package/dist/esm/targeting/types.d.ts +6 -0
  71. package/dist/esm/targeting/types.js +0 -0
  72. package/dist/esm/targeting/viewport.d.ts +1 -1
  73. package/dist/esm/targeting/youtube-ima.d.ts +4 -3
  74. package/dist/esm/targeting/youtube-ima.js +7 -4
  75. package/dist/esm/types.d.ts +399 -63
  76. package/dist/esm/types.js +10 -1
  77. package/package.json +64 -83
  78. package/dist/cjs/__vendor/a9-apstag.d.ts +0 -1
  79. package/dist/cjs/__vendor/a9-apstag.js +0 -34
  80. package/dist/cjs/__vendor/ipsos-mori.d.ts +0 -1
  81. package/dist/cjs/__vendor/ipsos-mori.js +0 -18
  82. package/dist/cjs/__vendor/launchpad.d.ts +0 -1
  83. package/dist/cjs/__vendor/launchpad.js +0 -25
  84. package/dist/cjs/__vendor/pubmatic.d.ts +0 -1
  85. package/dist/cjs/__vendor/pubmatic.js +0 -49
  86. package/dist/cjs/__vendor/twitter-script.d.ts +0 -1
  87. package/dist/cjs/__vendor/twitter-script.js +0 -26
  88. package/dist/cjs/create-ad-slot.d.ts +0 -17
  89. package/dist/cjs/create-ad-slot.js +0 -107
  90. package/dist/cjs/google-analytics.d.ts +0 -1
  91. package/dist/cjs/google-analytics.js +0 -14
  92. package/dist/cjs/lib/ab-localstorage.d.ts +0 -2
  93. package/dist/cjs/lib/ab-localstorage.js +0 -14
  94. package/dist/cjs/lib/breakpoint.d.ts +0 -4
  95. package/dist/cjs/lib/breakpoint.js +0 -5
  96. package/dist/cjs/lib/can-use-dom.d.ts +0 -2
  97. package/dist/cjs/lib/can-use-dom.js +0 -9
  98. package/dist/cjs/lib/construct-query.d.ts +0 -3
  99. package/dist/cjs/lib/construct-query.js +0 -12
  100. package/dist/cjs/messenger.d.ts +0 -97
  101. package/dist/cjs/messenger.js +0 -281
  102. package/dist/cjs/targeting/build-page-targeting-consentless.d.ts +0 -15
  103. package/dist/cjs/targeting/build-page-targeting-consentless.js +0 -46
  104. package/dist/cjs/targeting/youtube.d.ts +0 -13
  105. package/dist/cjs/targeting/youtube.js +0 -64
  106. package/dist/cjs/third-party-tags/ias.d.ts +0 -7
  107. package/dist/cjs/third-party-tags/ias.js +0 -14
  108. package/dist/cjs/third-party-tags/inizio.d.ts +0 -13
  109. package/dist/cjs/third-party-tags/inizio.js +0 -39
  110. package/dist/cjs/third-party-tags/permutive.d.ts +0 -6
  111. package/dist/cjs/third-party-tags/permutive.js +0 -13
  112. package/dist/cjs/third-party-tags/remarketing.d.ts +0 -7
  113. package/dist/cjs/third-party-tags/remarketing.js +0 -22
  114. package/dist/cjs/third-party-tags/twitter-uwt.d.ts +0 -7
  115. package/dist/cjs/third-party-tags/twitter-uwt.js +0 -15
  116. package/dist/cjs/track-gpc-signal.d.ts +0 -7
  117. package/dist/cjs/track-gpc-signal.js +0 -17
  118. package/dist/cjs/track-labs-container.d.ts +0 -7
  119. package/dist/cjs/track-labs-container.js +0 -35
  120. package/dist/cjs/track-scroll-depth.d.ts +0 -8
  121. package/dist/cjs/track-scroll-depth.js +0 -41
  122. package/dist/esm/__vendor/a9-apstag.d.ts +0 -1
  123. package/dist/esm/__vendor/a9-apstag.js +0 -30
  124. package/dist/esm/__vendor/ipsos-mori.d.ts +0 -1
  125. package/dist/esm/__vendor/ipsos-mori.js +0 -14
  126. package/dist/esm/__vendor/launchpad.d.ts +0 -1
  127. package/dist/esm/__vendor/launchpad.js +0 -21
  128. package/dist/esm/__vendor/pubmatic.d.ts +0 -1
  129. package/dist/esm/__vendor/pubmatic.js +0 -45
  130. package/dist/esm/__vendor/twitter-script.d.ts +0 -1
  131. package/dist/esm/__vendor/twitter-script.js +0 -22
  132. package/dist/esm/create-ad-slot.d.ts +0 -17
  133. package/dist/esm/create-ad-slot.js +0 -103
  134. package/dist/esm/google-analytics.d.ts +0 -1
  135. package/dist/esm/google-analytics.js +0 -10
  136. package/dist/esm/lib/ab-localstorage.d.ts +0 -2
  137. package/dist/esm/lib/ab-localstorage.js +0 -10
  138. package/dist/esm/lib/breakpoint.d.ts +0 -4
  139. package/dist/esm/lib/breakpoint.js +0 -2
  140. package/dist/esm/lib/can-use-dom.d.ts +0 -2
  141. package/dist/esm/lib/can-use-dom.js +0 -6
  142. package/dist/esm/lib/construct-query.d.ts +0 -3
  143. package/dist/esm/lib/construct-query.js +0 -9
  144. package/dist/esm/messenger.d.ts +0 -97
  145. package/dist/esm/messenger.js +0 -274
  146. package/dist/esm/targeting/build-page-targeting-consentless.d.ts +0 -15
  147. package/dist/esm/targeting/build-page-targeting-consentless.js +0 -43
  148. package/dist/esm/targeting/youtube.d.ts +0 -13
  149. package/dist/esm/targeting/youtube.js +0 -60
  150. package/dist/esm/third-party-tags/ias.d.ts +0 -7
  151. package/dist/esm/third-party-tags/ias.js +0 -10
  152. package/dist/esm/third-party-tags/inizio.d.ts +0 -13
  153. package/dist/esm/third-party-tags/inizio.js +0 -35
  154. package/dist/esm/third-party-tags/permutive.d.ts +0 -6
  155. package/dist/esm/third-party-tags/permutive.js +0 -9
  156. package/dist/esm/third-party-tags/remarketing.d.ts +0 -7
  157. package/dist/esm/third-party-tags/remarketing.js +0 -18
  158. package/dist/esm/third-party-tags/twitter-uwt.d.ts +0 -7
  159. package/dist/esm/third-party-tags/twitter-uwt.js +0 -11
  160. package/dist/esm/track-gpc-signal.d.ts +0 -7
  161. package/dist/esm/track-gpc-signal.js +0 -14
  162. package/dist/esm/track-labs-container.d.ts +0 -7
  163. package/dist/esm/track-labs-container.js +0 -32
  164. package/dist/esm/track-scroll-depth.d.ts +0 -8
  165. package/dist/esm/track-scroll-depth.js +0 -38
  166. /package/dist/cjs/constants/{adLabelHeight.d.ts → ad-label-height.d.ts} +0 -0
  167. /package/dist/cjs/constants/{adLabelHeight.js → ad-label-height.js} +0 -0
  168. /package/dist/cjs/{lib → geo}/get-locale.d.ts +0 -0
  169. /package/dist/cjs/{lib → geo}/get-locale.js +0 -0
  170. /package/dist/esm/constants/{adLabelHeight.d.ts → ad-label-height.d.ts} +0 -0
  171. /package/dist/esm/constants/{adLabelHeight.js → ad-label-height.js} +0 -0
  172. /package/dist/esm/{lib → geo}/get-locale.d.ts +0 -0
  173. /package/dist/esm/{lib → geo}/get-locale.js +0 -0
@@ -1,87 +1,423 @@
1
- import type { VendorName } from '@guardian/consent-management-platform/dist/types';
2
- export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
3
- export interface NetworkInformation extends EventTarget {
1
+ import type { AdSize, SizeMapping } from './ad-sizes';
2
+ import type { PageTargeting } from './targeting/build-page-targeting';
3
+ type HeaderBiddingSize = AdSize;
4
+ interface Advert {
5
+ id: string;
6
+ node: HTMLElement;
7
+ prebidAdUnit: string;
8
+ sizes: SizeMapping;
9
+ headerBiddingSizes: HeaderBiddingSize[] | null;
10
+ size: AdSize | 'fluid' | null;
11
+ slot: googletag.Slot;
12
+ isEmpty: boolean | null;
13
+ isRendered: boolean;
14
+ shouldRefresh: boolean;
15
+ whenSlotReady: Promise<void>;
16
+ extraNodeClasses: string[];
17
+ hasPrebidSize: boolean;
18
+ headerBiddingBidRequest: Promise<unknown> | null;
19
+ lineItemId: number | null;
20
+ creativeId: number | null;
21
+ creativeTemplateId: number | null;
22
+ testgroup: string | undefined;
23
+ finishedRendering(isRendered: boolean): void;
24
+ updateExtraSlotClasses(...newClasses: string[]): Promise<void>;
25
+ generateSizeMapping(additionalSizeMapping: SizeMapping): SizeMapping;
26
+ updateSizeMapping(additionalSizeMapping: SizeMapping): void;
27
+ }
28
+ interface DfpEnv {
29
+ renderStartTime: number;
30
+ adSlotSelector: string;
31
+ lazyLoadEnabled: boolean;
32
+ lazyLoadObserve: boolean;
33
+ advertsToLoad: Advert[];
34
+ adverts: Map<Advert['id'], Advert>;
35
+ shouldLazyLoad: () => boolean;
36
+ }
37
+ type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
38
+ interface NetworkInformation extends EventTarget {
4
39
  readonly type?: ConnectionType;
5
40
  readonly downlink?: number;
6
41
  readonly effectiveType?: string;
7
42
  }
8
- export type TagAttribute = {
9
- name: string;
10
- value: string;
43
+ type OphanRecordFunction = (event: Record<string, unknown> & {
44
+ /**
45
+ * the experiences key will override previously set values.
46
+ * Use `recordExperiences` instead.
47
+ */
48
+ experiences?: never;
49
+ }, callback?: () => void) => void;
50
+ /**
51
+ * Generates a type which represents possible indices of this array
52
+ *
53
+ * Example usage:
54
+ * const list = ['foo', 'bar', 'baz'] as const;
55
+ * type Test = Indices<typeof list>
56
+ */
57
+ type Indices<T extends readonly unknown[]> = Exclude<Partial<T>['length'], T['length']>;
58
+ type Edition = 'UK' | 'AU' | 'US';
59
+ type AdsConfigDisabled = {
60
+ disableAds: true;
61
+ };
62
+ type AdsConfigBasic = {
63
+ adTagParameters: {
64
+ iu: string;
65
+ cust_params: string;
66
+ };
67
+ };
68
+ type AdsConfigUSNATorAus = AdsConfigBasic & {
69
+ restrictedDataProcessor: boolean;
11
70
  };
12
- export type ThirdPartyTag = {
13
- async?: boolean;
14
- attrs?: TagAttribute[];
15
- beforeLoad?: () => void;
16
- insertSnippet?: () => void;
17
- loaded?: boolean;
18
- onLoad?: () => void;
19
- shouldRun: boolean;
20
- name?: VendorName;
21
- url?: string;
22
- useImage?: boolean;
71
+ type AdsConfigTCFV2 = AdsConfigBasic & {
72
+ adTagParameters: {
73
+ cmpGdpr: number;
74
+ cmpVcd: string;
75
+ cmpGvcd: string;
76
+ };
77
+ nonPersonalizedAd: boolean;
23
78
  };
24
- export type GetThirdPartyTag = (arg0: {
25
- shouldRun: boolean;
26
- }) => ThirdPartyTag;
27
- export type GuardianAnalyticsConfig = {
28
- trackers: Record<string, string>;
79
+ interface Ophan {
80
+ trackComponentAttention: (name: string, el: Element, visiblityThreshold: number) => void;
81
+ record: OphanRecordFunction;
82
+ viewId: string;
83
+ pageViewId: string;
84
+ }
85
+ type PrebidBreakpoint = 'D' | 'T' | 'M';
86
+ type PrebidIndexSite = {
87
+ bp: PrebidBreakpoint;
88
+ id: number;
29
89
  };
30
- export type Edition = 'UK' | 'AU' | 'US';
31
- export type GuardianWindowConfig = {
32
- googleAnalytics?: GuardianAnalyticsConfig;
90
+ interface CommercialPageConfig {
91
+ pbIndexSites: PrebidIndexSite[];
92
+ adUnit: string;
93
+ appNexusPageTargeting?: string;
94
+ sharedAdTargeting?: Record<string, string | string[]>;
95
+ shouldHideAdverts: boolean;
96
+ pageAdTargeting?: PageTargeting;
97
+ dfpAccountId: string;
98
+ ipsosTag?: string;
99
+ a9PublisherId: string;
100
+ libs?: {
101
+ googletag?: string;
102
+ };
103
+ }
104
+ interface PageConfig extends CommercialPageConfig {
105
+ ajaxUrl?: string;
106
+ assetsPath: string;
107
+ author: string;
108
+ authorIds: string;
109
+ blogIds: string;
110
+ commentable: boolean;
111
+ contentType: string;
112
+ dcrCouldRender: boolean;
113
+ edition: Edition;
114
+ frontendAssetsFullURL?: string;
115
+ hasPageSkin: boolean;
116
+ hasShowcaseMainElement: boolean;
117
+ hasYouTubeAtom: boolean;
118
+ headline: string;
119
+ host: string;
120
+ idApiUrl?: string;
121
+ idUrl?: string;
122
+ isbn?: string;
123
+ isDev: boolean;
124
+ isFront: boolean;
125
+ isHosted: boolean;
126
+ isImmersive?: boolean;
127
+ isLiveBlog?: boolean;
128
+ isPaidContent: boolean;
129
+ isPreview: boolean;
130
+ isProd: boolean;
131
+ isSensitive: boolean;
132
+ isMinuteArticle: boolean;
133
+ keywordIds: string;
134
+ keywords: string;
135
+ lightboxImages?: {
136
+ images: Array<{
137
+ src: string;
138
+ }>;
139
+ };
140
+ pageId: string;
141
+ publication: string;
142
+ revisionNumber: string;
143
+ section: string;
144
+ sectionName: string;
145
+ sentryHost: string;
146
+ sentryPublicApiKey: string;
147
+ series: string;
148
+ seriesId: string;
149
+ sharedAdTargeting?: Record<string, string | string[]>;
150
+ shouldHideReaderRevenue?: boolean;
151
+ showNewRecipeDesign?: boolean;
152
+ showRelatedContent?: boolean;
153
+ source: string;
154
+ sponsorshipType: string;
155
+ toneIds: string;
156
+ tones: string;
157
+ videoDuration: number;
158
+ webPublicationDate: number;
159
+ userAttributesApiUrl?: string;
160
+ }
161
+ type Stage = 'DEV' | 'CODE' | 'PROD';
162
+ interface UserConfig {
163
+ accountCreatedDate: number;
164
+ displayName: string;
165
+ emailVerified: boolean;
166
+ id: string;
167
+ rawResponse: string;
168
+ }
169
+ interface Config {
170
+ commercialMetricsInitialised?: boolean;
171
+ frontendAssetsFullURL?: string;
33
172
  isDotcomRendering: boolean;
34
173
  ophan: {
35
174
  browserId?: string;
36
175
  pageViewId: string;
37
176
  };
38
- page: {
39
- dcrCouldRender: boolean;
40
- edition: Edition;
41
- isPreview: boolean;
42
- isSensitive: boolean;
43
- pageId: string;
44
- section: string;
45
- sharedAdTargeting?: Record<string, string | string[]>;
46
- videoDuration: number;
47
- webPublicationDate: number;
48
- };
177
+ page: PageConfig;
178
+ shouldSendCommercialMetrics?: boolean;
179
+ stage: Stage;
180
+ switches: Record<string, boolean | undefined>;
49
181
  tests?: {
50
182
  [key: `${string}Control`]: 'control';
51
183
  [key: `${string}Variant`]: 'variant';
52
184
  };
185
+ user?: UserConfig;
186
+ }
187
+ type AdBlockers = {
188
+ active: boolean | undefined;
189
+ onDetect: Array<(value: boolean | PromiseLike<boolean>) => void>;
53
190
  };
54
- export type GoogleTagParams = unknown;
55
- export type GoogleTrackConversionObject = {
56
- google_conversion_id: number;
57
- google_custom_params: GoogleTagParams;
58
- google_remarketing_only: boolean;
191
+ type TagCounts = Record<string, number>;
192
+ type WeeklyArticleLog = {
193
+ week: number;
194
+ count: number;
195
+ tags?: TagCounts;
59
196
  };
60
- export type MaybeArray<T> = T | T[];
61
- export type CustomParams = Record<string, MaybeArray<string | number | boolean>>;
62
- export type AdsConfigDisabled = {
63
- disableAds: true;
197
+ type WeeklyArticleHistory = WeeklyArticleLog[];
198
+ interface DailyArticleCount {
199
+ day: number;
200
+ count: number;
201
+ }
202
+ type DailyArticleHistory = DailyArticleCount[];
203
+ interface ArticleCounts {
204
+ weeklyArticleHistory: WeeklyArticleHistory;
205
+ dailyArticleHistory: DailyArticleHistory;
206
+ }
207
+ type FetchBidSizes = {
208
+ adSizes: `${number}x${number}`;
64
209
  };
65
- export type AdsConfigBasic = {
66
- adTagParameters: {
67
- iu: string;
68
- cust_params: string;
210
+ type FetchBidResponse = {
211
+ amznbid: string;
212
+ amzniid: string;
213
+ amznp: string;
214
+ amznsz: FetchBidSizes;
215
+ size: FetchBidSizes;
216
+ slotID: string;
217
+ };
218
+ interface HeaderNotification {
219
+ id: string;
220
+ target: string;
221
+ message: string;
222
+ ophanLabel: string;
223
+ logImpression: () => void;
224
+ }
225
+ interface OptOutInitializeOptions {
226
+ publisher: number;
227
+ onlyNoConsent?: 0 | 1;
228
+ alwaysNoConsent?: 0 | 1;
229
+ consentTimeOutMS?: 5000;
230
+ noLogging?: 0 | 1;
231
+ lazyLoading?: {
232
+ fractionInView?: number;
233
+ viewPortMargin?: string;
69
234
  };
235
+ noRequestsOnPageLoad?: 0 | 1;
236
+ frequencyScript?: string;
237
+ timeoutFrequencyCappingMS?: number;
238
+ debug_forceCap?: number;
239
+ }
240
+ interface OptOutResponse {
241
+ adSlot: string;
242
+ width: number;
243
+ height: number;
244
+ ad: string;
245
+ creativeId: string;
246
+ meta: {
247
+ networkId: string;
248
+ networkName: string;
249
+ agencyId: string;
250
+ agencyName: string;
251
+ advertiserId: string;
252
+ advertiserName: string;
253
+ advertiserDomains: string[];
254
+ };
255
+ optOutExt: {
256
+ noSafeFrame: boolean;
257
+ tags: string[];
258
+ };
259
+ }
260
+ type OptOutFilledCallback = (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
261
+ interface OptOutAdSlot {
262
+ adSlot: string;
263
+ targetId: string;
264
+ id: string;
265
+ filledCallback?: OptOutFilledCallback;
266
+ emptyCallback?: (adSlot: OptOutAdSlot) => void;
267
+ adShownCallback?: (adSlot: OptOutAdSlot, response: OptOutResponse) => void;
268
+ }
269
+ interface ImpressionsDfpObject {
270
+ s: string;
271
+ ad: string;
272
+ c: string;
273
+ I: string;
274
+ o: string;
275
+ A: string;
276
+ y: string;
277
+ co: string;
278
+ }
279
+ declare enum BlockingType {
280
+ Manual = 1,// Deprecated
281
+ Creative = 2,// Creative-based detection
282
+ ProviderSecurity = 3,// Domain-based detection for unsafe domains
283
+ BannedDomain = 4,// Domain-based detection for banned domains
284
+ ProviderIbv = 5,// Domain-based detection for in-banner-video
285
+ UnsafeJS = 6,// JavaScript-based detection for unsafe ads
286
+ Hrap = 7
287
+ }
288
+ type ConfiantCallback = (blockingType: BlockingType, blockingId: string, isBlocked: boolean, wrapperId: string, tagId: string, impressionsData?: {
289
+ prebid?: {
290
+ adId?: string | null;
291
+ cpm?: number | null;
292
+ s?: string;
293
+ };
294
+ dfp?: ImpressionsDfpObject;
295
+ }) => void;
296
+ interface Confiant extends Record<string, unknown> {
297
+ settings: {
298
+ callback: ConfiantCallback;
299
+ [key: string]: unknown;
300
+ };
301
+ }
302
+ interface Permutive {
303
+ config?: {
304
+ projectId?: string;
305
+ apiKey?: string;
306
+ environment?: string;
307
+ };
308
+ q?: Array<{
309
+ functionName: string;
310
+ arguments: unknown[];
311
+ }>;
312
+ addon?: (name: string, props: Record<string, unknown>) => void;
313
+ identify?: (user: Array<{
314
+ id: string;
315
+ tag: string;
316
+ }>) => void;
317
+ track?: (name: string, props: Record<string, unknown>) => void;
318
+ }
319
+ type ApstagInitConfig = {
320
+ pubID: string;
321
+ adServer?: string;
322
+ bidTimeout?: number;
323
+ blockedBidders?: string[];
70
324
  };
71
- export type AdsConfigCCPAorAus = AdsConfigBasic & {
72
- restrictedDataProcessor: boolean;
325
+ interface A9AdUnitInterface {
326
+ slotID: string;
327
+ slotName?: string;
328
+ sizes: number[][];
329
+ }
330
+ type FetchBidsBidConfig = {
331
+ slots: A9AdUnitInterface[];
73
332
  };
74
- export type AdsConfigTCFV2 = AdsConfigBasic & {
75
- adTagParameters: {
76
- cmpGdpr: number;
77
- cmpVcd: string;
78
- cmpGvcd: string;
333
+ type Apstag = {
334
+ init: (arg0: ApstagInitConfig) => void;
335
+ fetchBids: (arg0: FetchBidsBidConfig, callback: (res: FetchBidResponse[]) => void) => void;
336
+ setDisplayBids: () => void;
337
+ };
338
+ type ComscoreGlobals = {
339
+ c1: string;
340
+ c2: string;
341
+ cs_ucfr: string;
342
+ comscorekw?: string;
343
+ options?: {
344
+ enableFirstPartyCookie?: boolean;
79
345
  };
80
- nonPersonalizedAd: boolean;
81
346
  };
82
- export type AdsConfigEnabled = AdsConfigBasic | AdsConfigCCPAorAus | AdsConfigTCFV2;
83
- export type AdsConfig = AdsConfigEnabled | AdsConfigDisabled;
84
- export type AdTargetingBuilder = () => Promise<AdsConfig>;
85
- export type True = 't';
86
- export type False = 'f';
87
- export type NotApplicable = 'na';
347
+ interface IasPETSlot {
348
+ adSlotId: string;
349
+ size: Array<[number, number]>;
350
+ adUnitPath: string;
351
+ }
352
+ interface IasPET {
353
+ queue?: Array<{
354
+ adSlots: IasPETSlot[];
355
+ dataHandler: (targetingJSON: string) => void;
356
+ }>;
357
+ pubId?: string;
358
+ }
359
+ interface TeadsAnalytics {
360
+ analytics_tag_id?: string;
361
+ share?: () => void;
362
+ shared_data?: unknown[];
363
+ }
364
+ /**
365
+ * Types for the IAB Safeframe API
366
+ *
367
+ * Note this type definition is incomplete.
368
+ * These types can be refined as/when they are required
369
+ */
370
+ interface SafeFrameAPI {
371
+ ver: string;
372
+ specVersion: string;
373
+ lib: {
374
+ lang: Record<string, unknown>;
375
+ dom: {
376
+ iframes: Record<string, unknown>;
377
+ msghost: Record<string, unknown>;
378
+ };
379
+ logger: Record<string, unknown>;
380
+ };
381
+ env: {
382
+ isIE: boolean;
383
+ ua: Record<string, unknown>;
384
+ };
385
+ info: {
386
+ errs: unknown[];
387
+ list: unknown[];
388
+ };
389
+ host: {
390
+ Config: {
391
+ new (o: {
392
+ renderFile: string;
393
+ positions: Record<string, unknown>;
394
+ }): unknown;
395
+ };
396
+ };
397
+ }
398
+ /**
399
+ * Types for IMR Worldwide
400
+ */
401
+ interface NSdkInstance {
402
+ ggPM: (type: string, dcrStaticMetadata: {
403
+ type: string;
404
+ assetid: unknown;
405
+ section: string;
406
+ }) => void;
407
+ ggInitialize: (nolggGlobalParams: {
408
+ sfcode: string;
409
+ apid: string;
410
+ apn: string;
411
+ }) => void;
412
+ }
413
+ interface Trac {
414
+ record: () => this;
415
+ post: () => this;
416
+ }
417
+ type GoogleTagParams = unknown;
418
+ type GoogleTrackConversionObject = {
419
+ google_conversion_id: number;
420
+ google_custom_params: GoogleTagParams;
421
+ google_remarketing_only: boolean;
422
+ };
423
+ export type { Advert, DfpEnv, ConnectionType, NetworkInformation, OphanRecordFunction, Indices, Edition, AdsConfigDisabled, AdsConfigBasic, AdsConfigUSNATorAus, AdsConfigTCFV2, Ophan, Config, AdBlockers, ArticleCounts, FetchBidResponse, HeaderNotification, OptOutInitializeOptions, OptOutAdSlot, Confiant, Permutive, Apstag, ComscoreGlobals, IasPET, TeadsAnalytics, SafeFrameAPI, NSdkInstance, Trac, GoogleTagParams, GoogleTrackConversionObject, };
package/dist/cjs/types.js CHANGED
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var BlockingType;
4
+ (function (BlockingType) {
5
+ BlockingType[BlockingType["Manual"] = 1] = "Manual";
6
+ BlockingType[BlockingType["Creative"] = 2] = "Creative";
7
+ BlockingType[BlockingType["ProviderSecurity"] = 3] = "ProviderSecurity";
8
+ BlockingType[BlockingType["BannedDomain"] = 4] = "BannedDomain";
9
+ BlockingType[BlockingType["ProviderIbv"] = 5] = "ProviderIbv";
10
+ BlockingType[BlockingType["UnsafeJS"] = 6] = "UnsafeJS";
11
+ BlockingType[BlockingType["Hrap"] = 7] = "Hrap";
12
+ })(BlockingType || (BlockingType = {}));
@@ -1,4 +1,4 @@
1
- import type { Breakpoint } from './lib/breakpoint';
1
+ import type { Breakpoint } from './breakpoint';
2
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
@@ -27,9 +27,9 @@ declare class AdSize extends Array<number> {
27
27
  get width(): number;
28
28
  get height(): number;
29
29
  }
30
- type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'cascade' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'portraitInterstitial' | 'skyscraper';
31
- type SlotName = 'carrot' | 'comments' | 'comments-expanded' | 'crossword-banner' | 'epic' | 'exclusion' | 'im' | 'inline' | 'merchandising-high-lucky' | 'merchandising-high' | 'merchandising' | 'mobile-sticky' | 'mostpop' | 'right' | 'survey' | 'top-above-nav';
32
- type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
30
+ type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'cascade' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'portraitInterstitial' | 'pubmaticInterscroller' | 'skyscraper' | 'sponsorLogo';
31
+ type SlotName = 'article-end' | 'carrot' | 'comments-expanded' | 'comments' | 'crossword-banner-mobile' | 'exclusion' | 'external' | 'fronts-banner' | 'inline' | 'liveblog-top' | 'merchandising-high' | 'merchandising' | 'mobile-sticky' | 'football-right' | 'mostpop' | 'right' | 'sponsor-logo' | 'survey' | 'top-above-nav' | 'interactive';
32
+ type SizeMapping = Partial<Record<Breakpoint, readonly AdSize[]>>;
33
33
  type SlotSizeMappings = Record<SlotName, SizeMapping>;
34
34
  declare const createAdSize: (width: number, height: number) => AdSize;
35
35
  declare const standardAdSizes: {
@@ -45,16 +45,158 @@ declare const outstreamSizes: {
45
45
  outstreamGoogleDesktop: AdSize;
46
46
  outstreamMobile: AdSize;
47
47
  };
48
- declare const adSizes: Record<SizeKeys, AdSize>;
48
+ declare const adSizes: {
49
+ readonly empty: AdSize;
50
+ readonly fabric: AdSize;
51
+ readonly merchandising: AdSize;
52
+ readonly merchandisingHigh: AdSize;
53
+ readonly merchandisingHighAdFeature: AdSize;
54
+ readonly sponsorLogo: AdSize;
55
+ readonly fluid: AdSize;
56
+ readonly googleCard: AdSize;
57
+ readonly outOfPage: AdSize;
58
+ readonly pubmaticInterscroller: AdSize;
59
+ readonly outstreamDesktop: AdSize;
60
+ readonly outstreamGoogleDesktop: AdSize;
61
+ readonly outstreamMobile: AdSize;
62
+ readonly '970x250': AdSize;
63
+ readonly '300x600': AdSize;
64
+ readonly '728x90': AdSize;
65
+ readonly '300x250': AdSize;
66
+ readonly '300x1050': AdSize;
67
+ readonly '160x600': AdSize;
68
+ readonly billboard: AdSize;
69
+ readonly halfPage: AdSize;
70
+ readonly leaderboard: AdSize;
71
+ readonly mobilesticky: AdSize;
72
+ readonly mpu: AdSize;
73
+ readonly portrait: AdSize;
74
+ readonly skyscraper: AdSize;
75
+ readonly cascade: AdSize;
76
+ readonly portraitInterstitial: AdSize;
77
+ };
49
78
  /**
50
79
  * mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
51
80
  * Some of these may or may not need to be synced for with the sizes in ./create-ad-slot.ts
52
81
  * these were originally from DCR, create-ad-slot.ts ones were in frontend.
82
+ *
83
+ * Note:
84
+ * If a breakpoint is not defined in a size mapping for a slot, that breakpoint will use the sizes
85
+ * of the next breakpoint down that has a size mapping. For example, if only "mobile" and "phablet" sizes
86
+ * are defined for a slot, all breakpoints larger than "phablet" will use the mapping for "phablet".
87
+ *
88
+ * In another example, if a slot has only "tablet" as a size mapping defined,
89
+ * then "desktop" will use the size mapping for "tablet". "mobile" and "phablet"
90
+ * will have no size mapping. This type of example may be used in cases where
91
+ * we only want the slot to appear on the "tablet" size or greater.
53
92
  **/
54
- declare const slotSizeMappings: SlotSizeMappings;
93
+ declare const slotSizeMappings: {
94
+ readonly inline: {
95
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
96
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
97
+ };
98
+ readonly right: {
99
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
100
+ };
101
+ readonly comments: {
102
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
103
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
104
+ };
105
+ readonly 'comments-expanded': {
106
+ readonly mobile: readonly [AdSize, AdSize];
107
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
108
+ };
109
+ readonly 'top-above-nav': {
110
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
111
+ readonly tablet: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
112
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
113
+ };
114
+ readonly 'fronts-banner': {
115
+ readonly tablet: readonly [AdSize, AdSize];
116
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
117
+ };
118
+ readonly mostpop: {
119
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
120
+ readonly phablet: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
121
+ readonly tablet: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
122
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize, AdSize];
123
+ };
124
+ readonly 'liveblog-top': {
125
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize];
126
+ readonly tablet: readonly [];
127
+ readonly desktop: readonly [];
128
+ };
129
+ readonly 'merchandising-high': {
130
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
131
+ readonly tablet: readonly [AdSize, AdSize, AdSize, AdSize];
132
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
133
+ };
134
+ readonly merchandising: {
135
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
136
+ readonly tablet: readonly [AdSize, AdSize, AdSize, AdSize];
137
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize, AdSize];
138
+ };
139
+ readonly survey: {
140
+ readonly desktop: readonly [AdSize];
141
+ };
142
+ readonly carrot: {
143
+ readonly mobile: readonly [AdSize];
144
+ };
145
+ readonly 'mobile-sticky': {
146
+ readonly mobile: readonly [AdSize, AdSize, AdSize];
147
+ };
148
+ readonly 'crossword-banner-mobile': {
149
+ readonly mobile: readonly [AdSize];
150
+ };
151
+ readonly 'football-right': {
152
+ readonly desktop: readonly [AdSize, AdSize, AdSize, AdSize];
153
+ };
154
+ readonly 'article-end': {
155
+ readonly mobile: readonly [];
156
+ };
157
+ readonly exclusion: {
158
+ readonly mobile: readonly [AdSize];
159
+ };
160
+ /**
161
+ * @deprecated Use `slotSizeMappings['sponsor-logo']` instead
162
+ */
163
+ readonly external: {
164
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize];
165
+ };
166
+ readonly 'sponsor-logo': {
167
+ readonly mobile: readonly [AdSize, AdSize, AdSize, AdSize];
168
+ };
169
+ readonly interactive: {
170
+ readonly mobile: readonly [AdSize, AdSize];
171
+ readonly tablet: readonly [AdSize, AdSize];
172
+ readonly desktop: readonly [AdSize, AdSize];
173
+ };
174
+ };
55
175
  declare const getAdSize: (size: SizeKeys) => AdSize;
176
+ /**
177
+ * Finds the ad sizes that will be used for a breakpoint given a size mapping
178
+ *
179
+ * If ad sizes are defined in the size mapping for the specified breakpoint, we use that.
180
+ * If no sizes are defined for the breakpoint, use the next smallest breakpoint with defined ad sizes.
181
+ * If no smaller breakpoints have defined ad sizes, return an empty array
182
+ *
183
+ * Example:
184
+ * For the following slotSizeMappings:
185
+ * inline: {
186
+ * phablet: [adSizes.mpu],
187
+ * desktop: [adSizes.billboard]
188
+ * }
189
+ * the applied sizes for each breakpoint for the "inline" slot will be:
190
+ * mobile: []
191
+ * phablet: [adSizes.mpu]
192
+ * tablet: [adSizes.mpu]
193
+ * desktop: [adSizes.billboard]
194
+ *
195
+ * See ad-sizes.test.ts for more examples
196
+ */
197
+ declare const findAppliedSizesForBreakpoint: (sizeMappings: SizeMapping, breakpoint: Breakpoint) => readonly AdSize[];
56
198
  export declare const _: {
57
199
  createAdSize: (width: number, height: number) => AdSize;
58
200
  };
59
- export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
60
- export { adSizes, standardAdSizes, outstreamSizes, getAdSize, slotSizeMappings, createAdSize, };
201
+ export type { AdSizeString, SizeKeys, SizeMapping, SlotSizeMappings, SlotName };
202
+ export { AdSize, adSizes, standardAdSizes, outstreamSizes, getAdSize, slotSizeMappings, createAdSize, findAppliedSizesForBreakpoint, };