@guardian/commercial-core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ad-sizes.d.ts +37 -22
- package/dist/cjs/ad-sizes.js +42 -7
- package/dist/cjs/create-ad-slot.js +5 -12
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -1
- package/dist/esm/ad-sizes.d.ts +37 -22
- package/dist/esm/ad-sizes.js +41 -7
- package/dist/esm/create-ad-slot.js +5 -12
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
package/dist/cjs/ad-sizes.d.ts
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
declare type AdSizeString = 'fluid' | `${number},${number}`;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Store ad sizes in a way that is compatible with google-tag but also accessible via
|
|
4
|
+
* more semantic `width`/`height` properties and keep things readonly.
|
|
5
|
+
*
|
|
6
|
+
* example:
|
|
7
|
+
* const size = new AdSize([300, 250]);
|
|
8
|
+
*
|
|
9
|
+
* size.width === 300; // true
|
|
10
|
+
* size[0] === 300; // true
|
|
11
|
+
*
|
|
12
|
+
* size.height === 250; // true
|
|
13
|
+
* size[1] === 250; // true
|
|
14
|
+
*
|
|
15
|
+
* size[0] = 200; // throws error
|
|
16
|
+
* size.width = 200; // throws error
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
declare class AdSize extends Array<number> {
|
|
20
|
+
readonly [0]: number;
|
|
21
|
+
readonly [1]: number;
|
|
22
|
+
constructor([width, height]: [number, number]);
|
|
23
|
+
toString(): AdSizeString;
|
|
24
|
+
get width(): number;
|
|
25
|
+
get height(): number;
|
|
22
26
|
}
|
|
27
|
+
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';
|
|
28
|
+
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'survey';
|
|
29
|
+
declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
|
|
30
|
+
declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
|
|
31
|
+
declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
|
|
32
|
+
declare const createAdSize: (width: number, height: number) => AdSize;
|
|
23
33
|
declare const adSizes: Record<SizeKeys, AdSize>;
|
|
34
|
+
/**
|
|
35
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
36
|
+
* Some of these may or may not need to be synced for with the sizes in ./create-ad-slot.ts
|
|
37
|
+
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
38
|
+
**/
|
|
24
39
|
declare const slotSizeMappings: SlotSizeMappings;
|
|
25
40
|
declare const getAdSize: (size: SizeKeys) => AdSize;
|
|
26
41
|
export declare const _: {
|
|
27
42
|
createAdSize: (width: number, height: number) => AdSize;
|
|
28
43
|
};
|
|
29
|
-
export type { AdSizeString, AdSize, SizeKeys, SizeMapping };
|
|
30
|
-
export { adSizes, getAdSize, slotSizeMappings };
|
|
44
|
+
export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
|
|
45
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize };
|
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports._ = void 0;
|
|
3
|
+
exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports._ = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Store ad sizes in a way that is compatible with google-tag but also accessible via
|
|
6
|
+
* more semantic `width`/`height` properties and keep things readonly.
|
|
7
|
+
*
|
|
8
|
+
* example:
|
|
9
|
+
* const size = new AdSize([300, 250]);
|
|
10
|
+
*
|
|
11
|
+
* size.width === 300; // true
|
|
12
|
+
* size[0] === 300; // true
|
|
13
|
+
*
|
|
14
|
+
* size.height === 250; // true
|
|
15
|
+
* size[1] === 250; // true
|
|
16
|
+
*
|
|
17
|
+
* size[0] = 200; // throws error
|
|
18
|
+
* size.width = 200; // throws error
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
class AdSize extends Array {
|
|
22
|
+
constructor([width, height]) {
|
|
23
|
+
super();
|
|
24
|
+
this.push(width, height);
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return this.width === 0 && this.height === 0
|
|
28
|
+
? 'fluid'
|
|
29
|
+
: `${this.width},${this.height}`;
|
|
30
|
+
}
|
|
31
|
+
get width() {
|
|
32
|
+
return this[0];
|
|
33
|
+
}
|
|
34
|
+
get height() {
|
|
35
|
+
return this[1];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
4
38
|
const createAdSize = (width, height) => {
|
|
5
|
-
|
|
6
|
-
return Object.freeze({
|
|
7
|
-
width,
|
|
8
|
-
height,
|
|
9
|
-
toString,
|
|
10
|
-
});
|
|
39
|
+
return new AdSize([width, height]);
|
|
11
40
|
};
|
|
41
|
+
exports.createAdSize = createAdSize;
|
|
12
42
|
const adSizesPartial = {
|
|
13
43
|
// standard ad sizes
|
|
14
44
|
billboard: createAdSize(970, 250),
|
|
@@ -43,6 +73,11 @@ const adSizes = {
|
|
|
43
73
|
'160x600': adSizesPartial.skyscraper,
|
|
44
74
|
};
|
|
45
75
|
exports.adSizes = adSizes;
|
|
76
|
+
/**
|
|
77
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
78
|
+
* Some of these may or may not need to be synced for with the sizes in ./create-ad-slot.ts
|
|
79
|
+
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
80
|
+
**/
|
|
46
81
|
const slotSizeMappings = {
|
|
47
82
|
right: {
|
|
48
83
|
mobile: [
|
|
@@ -28,18 +28,11 @@ const commonSizeMappings = {
|
|
|
28
28
|
ad_sizes_1.adSizes.fluid,
|
|
29
29
|
],
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
dotcom-rendering.
|
|
37
|
-
|
|
38
|
-
If/when this file is modified, please make sure that updates, if any, are reported to DCR.
|
|
39
|
-
|
|
40
|
-
TODO use a map type??
|
|
41
|
-
want to assert that values are of type AdSlotConfig
|
|
42
|
-
*/
|
|
31
|
+
/**
|
|
32
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
33
|
+
* Some of these may or may not need to be synced for with the sizes in ./ad-sizes.ts
|
|
34
|
+
* these were originally from frontend, ad-sizes.ts ones were in DCR.
|
|
35
|
+
**/
|
|
43
36
|
const adSlotConfigs = {
|
|
44
37
|
im: {
|
|
45
38
|
label: false,
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export { remarketing } from './third-party-tags/remarketing';
|
|
|
7
7
|
export { EventTimer } from './event-timer';
|
|
8
8
|
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
|
|
9
9
|
export type { ThirdPartyTag } from './types';
|
|
10
|
-
export { adSizes, getAdSize, slotSizeMappings } from './ad-sizes';
|
|
11
|
-
export type { SizeKeys, AdSizeString, AdSize } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
|
|
11
|
+
export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, SlotName, } from './ad-sizes';
|
|
12
12
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
14
14
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
27
|
+
exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
28
28
|
var ias_1 = require("./third-party-tags/ias");
|
|
29
29
|
Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
|
|
30
30
|
var permutive_1 = require("./third-party-tags/permutive");
|
|
@@ -46,6 +46,7 @@ var ad_sizes_1 = require("./ad-sizes");
|
|
|
46
46
|
Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
|
|
47
47
|
Object.defineProperty(exports, "getAdSize", { enumerable: true, get: function () { return ad_sizes_1.getAdSize; } });
|
|
48
48
|
Object.defineProperty(exports, "slotSizeMappings", { enumerable: true, get: function () { return ad_sizes_1.slotSizeMappings; } });
|
|
49
|
+
Object.defineProperty(exports, "createAdSize", { enumerable: true, get: function () { return ad_sizes_1.createAdSize; } });
|
|
49
50
|
var detect_ad_blocker_1 = require("./detect-ad-blocker");
|
|
50
51
|
Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detect_ad_blocker_1.isAdBlockInUse; } });
|
|
51
52
|
var permutive_2 = require("./permutive");
|
package/dist/esm/ad-sizes.d.ts
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
declare type AdSizeString = 'fluid' | `${number},${number}`;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Store ad sizes in a way that is compatible with google-tag but also accessible via
|
|
4
|
+
* more semantic `width`/`height` properties and keep things readonly.
|
|
5
|
+
*
|
|
6
|
+
* example:
|
|
7
|
+
* const size = new AdSize([300, 250]);
|
|
8
|
+
*
|
|
9
|
+
* size.width === 300; // true
|
|
10
|
+
* size[0] === 300; // true
|
|
11
|
+
*
|
|
12
|
+
* size.height === 250; // true
|
|
13
|
+
* size[1] === 250; // true
|
|
14
|
+
*
|
|
15
|
+
* size[0] = 200; // throws error
|
|
16
|
+
* size.width = 200; // throws error
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
declare class AdSize extends Array<number> {
|
|
20
|
+
readonly [0]: number;
|
|
21
|
+
readonly [1]: number;
|
|
22
|
+
constructor([width, height]: [number, number]);
|
|
23
|
+
toString(): AdSizeString;
|
|
24
|
+
get width(): number;
|
|
25
|
+
get height(): number;
|
|
22
26
|
}
|
|
27
|
+
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';
|
|
28
|
+
declare type SlotName = 'right' | 'comments' | 'top-above-nav' | 'mostpop' | 'merchandising' | 'merchandising-high' | 'survey';
|
|
29
|
+
declare type Breakpoint = 'mobile' | 'desktop' | 'phablet' | 'tablet';
|
|
30
|
+
declare type SizeMapping = Partial<Record<Breakpoint, AdSize[]>>;
|
|
31
|
+
declare type SlotSizeMappings = Record<SlotName, SizeMapping>;
|
|
32
|
+
declare const createAdSize: (width: number, height: number) => AdSize;
|
|
23
33
|
declare const adSizes: Record<SizeKeys, AdSize>;
|
|
34
|
+
/**
|
|
35
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
36
|
+
* Some of these may or may not need to be synced for with the sizes in ./create-ad-slot.ts
|
|
37
|
+
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
38
|
+
**/
|
|
24
39
|
declare const slotSizeMappings: SlotSizeMappings;
|
|
25
40
|
declare const getAdSize: (size: SizeKeys) => AdSize;
|
|
26
41
|
export declare const _: {
|
|
27
42
|
createAdSize: (width: number, height: number) => AdSize;
|
|
28
43
|
};
|
|
29
|
-
export type { AdSizeString, AdSize, SizeKeys, SizeMapping };
|
|
30
|
-
export { adSizes, getAdSize, slotSizeMappings };
|
|
44
|
+
export type { AdSizeString, AdSize, SizeKeys, SizeMapping, SlotSizeMappings, SlotName, };
|
|
45
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize };
|
package/dist/esm/ad-sizes.js
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store ad sizes in a way that is compatible with google-tag but also accessible via
|
|
3
|
+
* more semantic `width`/`height` properties and keep things readonly.
|
|
4
|
+
*
|
|
5
|
+
* example:
|
|
6
|
+
* const size = new AdSize([300, 250]);
|
|
7
|
+
*
|
|
8
|
+
* size.width === 300; // true
|
|
9
|
+
* size[0] === 300; // true
|
|
10
|
+
*
|
|
11
|
+
* size.height === 250; // true
|
|
12
|
+
* size[1] === 250; // true
|
|
13
|
+
*
|
|
14
|
+
* size[0] = 200; // throws error
|
|
15
|
+
* size.width = 200; // throws error
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
class AdSize extends Array {
|
|
19
|
+
constructor([width, height]) {
|
|
20
|
+
super();
|
|
21
|
+
this.push(width, height);
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return this.width === 0 && this.height === 0
|
|
25
|
+
? 'fluid'
|
|
26
|
+
: `${this.width},${this.height}`;
|
|
27
|
+
}
|
|
28
|
+
get width() {
|
|
29
|
+
return this[0];
|
|
30
|
+
}
|
|
31
|
+
get height() {
|
|
32
|
+
return this[1];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
1
35
|
const createAdSize = (width, height) => {
|
|
2
|
-
|
|
3
|
-
return Object.freeze({
|
|
4
|
-
width,
|
|
5
|
-
height,
|
|
6
|
-
toString,
|
|
7
|
-
});
|
|
36
|
+
return new AdSize([width, height]);
|
|
8
37
|
};
|
|
9
38
|
const adSizesPartial = {
|
|
10
39
|
// standard ad sizes
|
|
@@ -39,6 +68,11 @@ const adSizes = {
|
|
|
39
68
|
'300x1050': adSizesPartial.portrait,
|
|
40
69
|
'160x600': adSizesPartial.skyscraper,
|
|
41
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
73
|
+
* Some of these may or may not need to be synced for with the sizes in ./create-ad-slot.ts
|
|
74
|
+
* these were originally from DCR, create-ad-slot.ts ones were in frontend.
|
|
75
|
+
**/
|
|
42
76
|
const slotSizeMappings = {
|
|
43
77
|
right: {
|
|
44
78
|
mobile: [
|
|
@@ -155,4 +189,4 @@ const slotSizeMappings = {
|
|
|
155
189
|
const getAdSize = (size) => adSizes[size];
|
|
156
190
|
// Export for testing
|
|
157
191
|
export const _ = { createAdSize };
|
|
158
|
-
export { adSizes, getAdSize, slotSizeMappings };
|
|
192
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize };
|
|
@@ -25,18 +25,11 @@ const commonSizeMappings = {
|
|
|
25
25
|
adSizes.fluid,
|
|
26
26
|
],
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
dotcom-rendering.
|
|
34
|
-
|
|
35
|
-
If/when this file is modified, please make sure that updates, if any, are reported to DCR.
|
|
36
|
-
|
|
37
|
-
TODO use a map type??
|
|
38
|
-
want to assert that values are of type AdSlotConfig
|
|
39
|
-
*/
|
|
28
|
+
/**
|
|
29
|
+
* mark: 432b3a46-90c1-4573-90d3-2400b51af8d0
|
|
30
|
+
* Some of these may or may not need to be synced for with the sizes in ./ad-sizes.ts
|
|
31
|
+
* these were originally from frontend, ad-sizes.ts ones were in DCR.
|
|
32
|
+
**/
|
|
40
33
|
const adSlotConfigs = {
|
|
41
34
|
im: {
|
|
42
35
|
label: false,
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export { remarketing } from './third-party-tags/remarketing';
|
|
|
7
7
|
export { EventTimer } from './event-timer';
|
|
8
8
|
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
|
|
9
9
|
export type { ThirdPartyTag } from './types';
|
|
10
|
-
export { adSizes, getAdSize, slotSizeMappings } from './ad-sizes';
|
|
11
|
-
export type { SizeKeys, AdSizeString, AdSize } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
|
|
11
|
+
export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, SlotName, } from './ad-sizes';
|
|
12
12
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
14
14
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
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 './event-timer';
|
|
9
9
|
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
|
|
10
|
-
export { adSizes, getAdSize, slotSizeMappings } from './ad-sizes';
|
|
10
|
+
export { adSizes, getAdSize, slotSizeMappings, createAdSize } from './ad-sizes';
|
|
11
11
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
12
12
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
13
13
|
export { initTrackScrollDepth } from './track-scroll-depth';
|