@guardian/commercial-core 0.35.0 → 0.37.2
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/cjs/EventTimer.d.ts +1 -1
- package/dist/cjs/EventTimer.js +12 -10
- package/dist/cjs/ad-sizes.d.ts +2 -1
- package/dist/cjs/ad-sizes.js +25 -23
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/targeting/pick-targeting-values.d.ts +2 -2
- package/dist/esm/EventTimer.d.ts +1 -1
- package/dist/esm/EventTimer.js +12 -10
- package/dist/esm/ad-sizes.d.ts +2 -1
- package/dist/esm/ad-sizes.js +23 -22
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/targeting/pick-targeting-values.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/EventTimer.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class EventTimer {
|
|
|
57
57
|
* by EventTimer so they need to be concatenated to EventTimer's private events array.
|
|
58
58
|
*/
|
|
59
59
|
get events(): Event[];
|
|
60
|
-
constructor();
|
|
60
|
+
private constructor();
|
|
61
61
|
/**
|
|
62
62
|
* Creates a new performance mark
|
|
63
63
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/cjs/EventTimer.js
CHANGED
|
@@ -96,9 +96,13 @@ class EventTimer {
|
|
|
96
96
|
? [
|
|
97
97
|
...this._events,
|
|
98
98
|
...EventTimer._externallyDefinedEventNames
|
|
99
|
-
.
|
|
100
|
-
.
|
|
101
|
-
|
|
99
|
+
.map((eventName) => {
|
|
100
|
+
const entry = window.performance.getEntriesByName(eventName)[0];
|
|
101
|
+
return entry
|
|
102
|
+
? new Event(eventName, entry)
|
|
103
|
+
: undefined;
|
|
104
|
+
})
|
|
105
|
+
.filter((entry) => entry instanceof Event),
|
|
102
106
|
]
|
|
103
107
|
: this._events;
|
|
104
108
|
}
|
|
@@ -137,13 +141,11 @@ class EventTimer {
|
|
|
137
141
|
mark(name) {
|
|
138
142
|
const longName = `gu.commercial.${name}`;
|
|
139
143
|
if (typeof window.performance !== 'undefined' &&
|
|
140
|
-
'mark' in window.performance
|
|
141
|
-
window.performance.mark
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.slice(-1)[0];
|
|
146
|
-
if (typeof mark !== 'undefined') {
|
|
144
|
+
'mark' in window.performance &&
|
|
145
|
+
typeof window.performance.mark === 'function') {
|
|
146
|
+
const mark = window.performance.mark(longName);
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- browser support is patchy
|
|
148
|
+
if (typeof mark?.startTime === 'number') {
|
|
147
149
|
this._events.push(new Event(name, mark));
|
|
148
150
|
}
|
|
149
151
|
}
|
package/dist/cjs/ad-sizes.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare type AdSize = Readonly<{
|
|
|
6
6
|
}>;
|
|
7
7
|
export declare type SizeKeys = 'billboard' | 'leaderboard' | 'mpu' | 'halfPage' | 'portrait' | 'skyscraper' | 'mobilesticky' | 'fluid' | 'outOfPage' | 'googleCard' | 'video' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'merchandisingHighAdFeature' | 'merchandisingHigh' | 'merchandising' | 'inlineMerchandising' | 'fabric' | 'empty' | '970x250' | '728x90' | '300x250' | '300x600' | '300x1050' | '160x600';
|
|
8
8
|
export declare const adSizes: Record<SizeKeys, AdSize>;
|
|
9
|
+
export declare const getAdSize: (size: SizeKeys) => AdSize;
|
|
9
10
|
export declare const _: {
|
|
10
|
-
|
|
11
|
+
createAdSize: (width: number, height: number) => AdSize;
|
|
11
12
|
};
|
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._ = exports.adSizes = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports._ = exports.getAdSize = exports.adSizes = void 0;
|
|
4
|
+
const createAdSize = (width, height) => {
|
|
5
5
|
const toString = () => width === 0 && height === 0 ? 'fluid' : `${width},${height}`;
|
|
6
6
|
return Object.freeze({
|
|
7
7
|
width,
|
|
@@ -11,28 +11,28 @@ const getAdSize = (width, height) => {
|
|
|
11
11
|
};
|
|
12
12
|
const adSizesPartial = {
|
|
13
13
|
// standard ad sizes
|
|
14
|
-
billboard:
|
|
15
|
-
leaderboard:
|
|
16
|
-
mpu:
|
|
17
|
-
halfPage:
|
|
18
|
-
portrait:
|
|
19
|
-
skyscraper:
|
|
20
|
-
mobilesticky:
|
|
14
|
+
billboard: createAdSize(970, 250),
|
|
15
|
+
leaderboard: createAdSize(728, 90),
|
|
16
|
+
mpu: createAdSize(300, 250),
|
|
17
|
+
halfPage: createAdSize(300, 600),
|
|
18
|
+
portrait: createAdSize(300, 1050),
|
|
19
|
+
skyscraper: createAdSize(160, 600),
|
|
20
|
+
mobilesticky: createAdSize(320, 50),
|
|
21
21
|
// dfp proprietary ad sizes
|
|
22
|
-
fluid:
|
|
23
|
-
outOfPage:
|
|
24
|
-
googleCard:
|
|
22
|
+
fluid: createAdSize(0, 0),
|
|
23
|
+
outOfPage: createAdSize(1, 1),
|
|
24
|
+
googleCard: createAdSize(300, 274),
|
|
25
25
|
// guardian proprietary ad sizes
|
|
26
|
-
video:
|
|
27
|
-
outstreamDesktop:
|
|
28
|
-
outstreamGoogleDesktop:
|
|
29
|
-
outstreamMobile:
|
|
30
|
-
merchandisingHighAdFeature:
|
|
31
|
-
merchandisingHigh:
|
|
32
|
-
merchandising:
|
|
33
|
-
inlineMerchandising:
|
|
34
|
-
fabric:
|
|
35
|
-
empty:
|
|
26
|
+
video: createAdSize(620, 1),
|
|
27
|
+
outstreamDesktop: createAdSize(620, 350),
|
|
28
|
+
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
29
|
+
outstreamMobile: createAdSize(300, 197),
|
|
30
|
+
merchandisingHighAdFeature: createAdSize(88, 89),
|
|
31
|
+
merchandisingHigh: createAdSize(88, 87),
|
|
32
|
+
merchandising: createAdSize(88, 88),
|
|
33
|
+
inlineMerchandising: createAdSize(88, 85),
|
|
34
|
+
fabric: createAdSize(88, 71),
|
|
35
|
+
empty: createAdSize(2, 2),
|
|
36
36
|
};
|
|
37
37
|
exports.adSizes = {
|
|
38
38
|
...adSizesPartial,
|
|
@@ -43,5 +43,7 @@ exports.adSizes = {
|
|
|
43
43
|
'300x1050': adSizesPartial.portrait,
|
|
44
44
|
'160x600': adSizesPartial.skyscraper,
|
|
45
45
|
};
|
|
46
|
+
const getAdSize = (size) => exports.adSizes[size];
|
|
47
|
+
exports.getAdSize = getAdSize;
|
|
46
48
|
// Export for testing
|
|
47
|
-
exports._ = {
|
|
49
|
+
exports._ = { createAdSize };
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { remarketing } from './third-party-tags/remarketing';
|
|
|
7
7
|
export { EventTimer } from './EventTimer';
|
|
8
8
|
export { sendCommercialMetrics } from './sendCommercialMetrics';
|
|
9
9
|
export type { ThirdPartyTag } from './types';
|
|
10
|
-
export { adSizes } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize } from './ad-sizes';
|
|
11
11
|
export type { SizeKeys, AdSizeString, AdSize } from './ad-sizes';
|
|
12
12
|
export { isAdBlockInUse } from './detectAdBlocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
return result;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.adSizes = exports.sendCommercialMetrics = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
23
|
+
exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.getAdSize = exports.adSizes = exports.sendCommercialMetrics = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
24
24
|
var ias_1 = require("./third-party-tags/ias");
|
|
25
25
|
Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
|
|
26
26
|
var permutive_1 = require("./third-party-tags/permutive");
|
|
@@ -39,6 +39,7 @@ var sendCommercialMetrics_1 = require("./sendCommercialMetrics");
|
|
|
39
39
|
Object.defineProperty(exports, "sendCommercialMetrics", { enumerable: true, get: function () { return sendCommercialMetrics_1.sendCommercialMetrics; } });
|
|
40
40
|
var ad_sizes_1 = require("./ad-sizes");
|
|
41
41
|
Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
|
|
42
|
+
Object.defineProperty(exports, "getAdSize", { enumerable: true, get: function () { return ad_sizes_1.getAdSize; } });
|
|
42
43
|
var detectAdBlocker_1 = require("./detectAdBlocker");
|
|
43
44
|
Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detectAdBlocker_1.isAdBlockInUse; } });
|
|
44
45
|
var permutive_2 = require("./permutive");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConditionalExcept } from 'type-fest';
|
|
2
|
-
declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
|
|
2
|
+
declare 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:
|
|
@@ -21,5 +21,5 @@ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefin
|
|
|
21
21
|
* clean.invalid
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
24
|
+
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | never[] | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
25
25
|
export {};
|
package/dist/esm/EventTimer.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class EventTimer {
|
|
|
57
57
|
* by EventTimer so they need to be concatenated to EventTimer's private events array.
|
|
58
58
|
*/
|
|
59
59
|
get events(): Event[];
|
|
60
|
-
constructor();
|
|
60
|
+
private constructor();
|
|
61
61
|
/**
|
|
62
62
|
* Creates a new performance mark
|
|
63
63
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/esm/EventTimer.js
CHANGED
|
@@ -93,9 +93,13 @@ export class EventTimer {
|
|
|
93
93
|
? [
|
|
94
94
|
...this._events,
|
|
95
95
|
...EventTimer._externallyDefinedEventNames
|
|
96
|
-
.
|
|
97
|
-
.
|
|
98
|
-
|
|
96
|
+
.map((eventName) => {
|
|
97
|
+
const entry = window.performance.getEntriesByName(eventName)[0];
|
|
98
|
+
return entry
|
|
99
|
+
? new Event(eventName, entry)
|
|
100
|
+
: undefined;
|
|
101
|
+
})
|
|
102
|
+
.filter((entry) => entry instanceof Event),
|
|
99
103
|
]
|
|
100
104
|
: this._events;
|
|
101
105
|
}
|
|
@@ -134,13 +138,11 @@ export class EventTimer {
|
|
|
134
138
|
mark(name) {
|
|
135
139
|
const longName = `gu.commercial.${name}`;
|
|
136
140
|
if (typeof window.performance !== 'undefined' &&
|
|
137
|
-
'mark' in window.performance
|
|
138
|
-
window.performance.mark
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.slice(-1)[0];
|
|
143
|
-
if (typeof mark !== 'undefined') {
|
|
141
|
+
'mark' in window.performance &&
|
|
142
|
+
typeof window.performance.mark === 'function') {
|
|
143
|
+
const mark = window.performance.mark(longName);
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- browser support is patchy
|
|
145
|
+
if (typeof mark?.startTime === 'number') {
|
|
144
146
|
this._events.push(new Event(name, mark));
|
|
145
147
|
}
|
|
146
148
|
}
|
package/dist/esm/ad-sizes.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare type AdSize = Readonly<{
|
|
|
6
6
|
}>;
|
|
7
7
|
export declare type SizeKeys = 'billboard' | 'leaderboard' | 'mpu' | 'halfPage' | 'portrait' | 'skyscraper' | 'mobilesticky' | 'fluid' | 'outOfPage' | 'googleCard' | 'video' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'merchandisingHighAdFeature' | 'merchandisingHigh' | 'merchandising' | 'inlineMerchandising' | 'fabric' | 'empty' | '970x250' | '728x90' | '300x250' | '300x600' | '300x1050' | '160x600';
|
|
8
8
|
export declare const adSizes: Record<SizeKeys, AdSize>;
|
|
9
|
+
export declare const getAdSize: (size: SizeKeys) => AdSize;
|
|
9
10
|
export declare const _: {
|
|
10
|
-
|
|
11
|
+
createAdSize: (width: number, height: number) => AdSize;
|
|
11
12
|
};
|
package/dist/esm/ad-sizes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const createAdSize = (width, height) => {
|
|
2
2
|
const toString = () => width === 0 && height === 0 ? 'fluid' : `${width},${height}`;
|
|
3
3
|
return Object.freeze({
|
|
4
4
|
width,
|
|
@@ -8,28 +8,28 @@ const getAdSize = (width, height) => {
|
|
|
8
8
|
};
|
|
9
9
|
const adSizesPartial = {
|
|
10
10
|
// standard ad sizes
|
|
11
|
-
billboard:
|
|
12
|
-
leaderboard:
|
|
13
|
-
mpu:
|
|
14
|
-
halfPage:
|
|
15
|
-
portrait:
|
|
16
|
-
skyscraper:
|
|
17
|
-
mobilesticky:
|
|
11
|
+
billboard: createAdSize(970, 250),
|
|
12
|
+
leaderboard: createAdSize(728, 90),
|
|
13
|
+
mpu: createAdSize(300, 250),
|
|
14
|
+
halfPage: createAdSize(300, 600),
|
|
15
|
+
portrait: createAdSize(300, 1050),
|
|
16
|
+
skyscraper: createAdSize(160, 600),
|
|
17
|
+
mobilesticky: createAdSize(320, 50),
|
|
18
18
|
// dfp proprietary ad sizes
|
|
19
|
-
fluid:
|
|
20
|
-
outOfPage:
|
|
21
|
-
googleCard:
|
|
19
|
+
fluid: createAdSize(0, 0),
|
|
20
|
+
outOfPage: createAdSize(1, 1),
|
|
21
|
+
googleCard: createAdSize(300, 274),
|
|
22
22
|
// guardian proprietary ad sizes
|
|
23
|
-
video:
|
|
24
|
-
outstreamDesktop:
|
|
25
|
-
outstreamGoogleDesktop:
|
|
26
|
-
outstreamMobile:
|
|
27
|
-
merchandisingHighAdFeature:
|
|
28
|
-
merchandisingHigh:
|
|
29
|
-
merchandising:
|
|
30
|
-
inlineMerchandising:
|
|
31
|
-
fabric:
|
|
32
|
-
empty:
|
|
23
|
+
video: createAdSize(620, 1),
|
|
24
|
+
outstreamDesktop: createAdSize(620, 350),
|
|
25
|
+
outstreamGoogleDesktop: createAdSize(550, 310),
|
|
26
|
+
outstreamMobile: createAdSize(300, 197),
|
|
27
|
+
merchandisingHighAdFeature: createAdSize(88, 89),
|
|
28
|
+
merchandisingHigh: createAdSize(88, 87),
|
|
29
|
+
merchandising: createAdSize(88, 88),
|
|
30
|
+
inlineMerchandising: createAdSize(88, 85),
|
|
31
|
+
fabric: createAdSize(88, 71),
|
|
32
|
+
empty: createAdSize(2, 2),
|
|
33
33
|
};
|
|
34
34
|
export const adSizes = {
|
|
35
35
|
...adSizesPartial,
|
|
@@ -40,5 +40,6 @@ export const adSizes = {
|
|
|
40
40
|
'300x1050': adSizesPartial.portrait,
|
|
41
41
|
'160x600': adSizesPartial.skyscraper,
|
|
42
42
|
};
|
|
43
|
+
export const getAdSize = (size) => adSizes[size];
|
|
43
44
|
// Export for testing
|
|
44
|
-
export const _ = {
|
|
45
|
+
export const _ = { createAdSize };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { remarketing } from './third-party-tags/remarketing';
|
|
|
7
7
|
export { EventTimer } from './EventTimer';
|
|
8
8
|
export { sendCommercialMetrics } from './sendCommercialMetrics';
|
|
9
9
|
export type { ThirdPartyTag } from './types';
|
|
10
|
-
export { adSizes } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize } from './ad-sizes';
|
|
11
11
|
export type { SizeKeys, AdSizeString, AdSize } from './ad-sizes';
|
|
12
12
|
export { isAdBlockInUse } from './detectAdBlocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
package/dist/esm/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { inizio } from './third-party-tags/inizio';
|
|
|
7
7
|
export { remarketing } from './third-party-tags/remarketing';
|
|
8
8
|
export { EventTimer } from './EventTimer';
|
|
9
9
|
export { sendCommercialMetrics } from './sendCommercialMetrics';
|
|
10
|
-
export { adSizes } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize } from './ad-sizes';
|
|
11
11
|
export { isAdBlockInUse } from './detectAdBlocker';
|
|
12
12
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
13
13
|
export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConditionalExcept } from 'type-fest';
|
|
2
|
-
declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
|
|
2
|
+
declare 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:
|
|
@@ -21,5 +21,5 @@ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefin
|
|
|
21
21
|
* clean.invalid
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
24
|
+
export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | never[] | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
|
|
25
25
|
export {};
|