@guardian/commercial-core 0.0.0-beta-20251030174934 → 0.0.0-beta-20251113115216

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 (48) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/ad-sizes.d.ts +1 -1
  3. package/dist/cjs/ad-sizes.js +1 -1
  4. package/dist/cjs/constants/index.d.ts +3 -3
  5. package/dist/cjs/constants/index.js +3 -3
  6. package/dist/cjs/event-timer.d.ts +1 -1
  7. package/dist/cjs/geo/geo-utils.js +1 -1
  8. package/dist/cjs/global.d.ts +2 -2
  9. package/dist/cjs/index.d.ts +14 -14
  10. package/dist/cjs/index.js +11 -11
  11. package/dist/cjs/send-commercial-metrics.d.ts +1 -1
  12. package/dist/cjs/send-commercial-metrics.js +1 -1
  13. package/dist/cjs/targeting/build-page-targeting.d.ts +4 -4
  14. package/dist/cjs/targeting/build-page-targeting.js +7 -7
  15. package/dist/cjs/targeting/content.d.ts +2 -2
  16. package/dist/cjs/targeting/personalised.d.ts +1 -1
  17. package/dist/cjs/targeting/personalised.js +1 -1
  18. package/dist/cjs/targeting/session.d.ts +1 -1
  19. package/dist/cjs/targeting/shared.js +1 -1
  20. package/dist/cjs/targeting/viewport.d.ts +1 -1
  21. package/dist/cjs/targeting/youtube-ima.d.ts +1 -1
  22. package/dist/cjs/targeting/youtube-ima.js +1 -1
  23. package/dist/cjs/types.d.ts +2 -2
  24. package/dist/esm/ad-sizes.d.ts +1 -1
  25. package/dist/esm/ad-sizes.js +1 -1
  26. package/dist/esm/constants/index.d.ts +3 -3
  27. package/dist/esm/constants/index.js +3 -3
  28. package/dist/esm/event-timer.d.ts +1 -1
  29. package/dist/esm/geo/geo-utils.js +1 -1
  30. package/dist/esm/global.d.ts +2 -2
  31. package/dist/esm/global.js +1 -0
  32. package/dist/esm/index.d.ts +14 -14
  33. package/dist/esm/index.js +11 -11
  34. package/dist/esm/send-commercial-metrics.d.ts +1 -1
  35. package/dist/esm/send-commercial-metrics.js +1 -1
  36. package/dist/esm/targeting/build-page-targeting.d.ts +4 -4
  37. package/dist/esm/targeting/build-page-targeting.js +7 -7
  38. package/dist/esm/targeting/content.d.ts +2 -2
  39. package/dist/esm/targeting/personalised.d.ts +1 -1
  40. package/dist/esm/targeting/personalised.js +1 -1
  41. package/dist/esm/targeting/session.d.ts +1 -1
  42. package/dist/esm/targeting/shared.js +1 -1
  43. package/dist/esm/targeting/types.js +1 -0
  44. package/dist/esm/targeting/viewport.d.ts +1 -1
  45. package/dist/esm/targeting/youtube-ima.d.ts +1 -1
  46. package/dist/esm/targeting/youtube-ima.js +1 -1
  47. package/dist/esm/types.d.ts +2 -2
  48. package/package.json +5 -3
package/README.md CHANGED
@@ -23,6 +23,7 @@ pnpm build
23
23
  This will build the package into the `dist` directory, which is what is published to npm.
24
24
 
25
25
  #### Beta Releases
26
+
26
27
  You can add the [beta] @guardian/commercial-core label to your pull request, this will release a beta version of the bundle to NPM, the exact version will be commented on your PR.
27
28
 
28
29
  In order to do this, run `pnpm changeset`. This will create a new changeset file in the .changeset directory. Commit this file with your PR.
@@ -30,6 +31,7 @@ In order to do this, run `pnpm changeset`. This will create a new changeset file
30
31
  Note: Once the beta version is released, the label will be removed from the PR, so you will need to add it again if you want to release subsequent new versions.
31
32
 
32
33
  ## Releasing to NPM
34
+
33
35
  This repository uses changesets for version management.
34
36
 
35
37
  To release a new version with your changes, run:
@@ -1,4 +1,4 @@
1
- import type { Breakpoint } from './breakpoint';
1
+ import type { Breakpoint } from './breakpoint.js';
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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findAppliedSizesForBreakpoint = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.outstreamSizes = exports.standardAdSizes = exports.adSizes = exports.AdSize = exports._ = void 0;
4
- const breakpoint_1 = require("./breakpoint");
4
+ const breakpoint_1 = require("./breakpoint.js");
5
5
  /**
6
6
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
7
7
  * more semantic `width`/`height` properties and keep things readonly.
@@ -1,3 +1,3 @@
1
- export { AD_LABEL_HEIGHT } from './ad-label-height';
2
- export { PREBID_TIMEOUT } from './prebid-timeout';
3
- export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
1
+ export { AD_LABEL_HEIGHT } from './ad-label-height.js';
2
+ export { PREBID_TIMEOUT } from './prebid-timeout.js';
3
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height.js';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = exports.AD_LABEL_HEIGHT = void 0;
4
- var ad_label_height_1 = require("./ad-label-height");
4
+ var ad_label_height_1 = require("./ad-label-height.js");
5
5
  Object.defineProperty(exports, "AD_LABEL_HEIGHT", { enumerable: true, get: function () { return ad_label_height_1.AD_LABEL_HEIGHT; } });
6
- var prebid_timeout_1 = require("./prebid-timeout");
6
+ var prebid_timeout_1 = require("./prebid-timeout.js");
7
7
  Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebid_timeout_1.PREBID_TIMEOUT; } });
8
- var top_above_nav_height_1 = require("./top-above-nav-height");
8
+ var top_above_nav_height_1 = require("./top-above-nav-height.js");
9
9
  Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return top_above_nav_height_1.TOP_ABOVE_NAV_HEIGHT; } });
@@ -1,4 +1,4 @@
1
- import type { ConnectionType } from './types';
1
+ import type { ConnectionType } from './types.js';
2
2
  declare const supportsPerformanceAPI: () => boolean;
3
3
  interface EventTimerProperties {
4
4
  type?: ConnectionType;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._ = exports.isInRow = exports.isInAuOrNz = exports.isInUsOrCa = exports.isInNewZealand = exports.isInAustralia = exports.isInCanada = exports.isInUsa = exports.isInUk = void 0;
4
- const country_code_1 = require("./country-code");
4
+ const country_code_1 = require("./country-code.js");
5
5
  // cache the users location so we only have to look it up once
6
6
  let geo;
7
7
  const currentGeoLocation = () => {
@@ -1,5 +1,5 @@
1
- import type { EventTimer } from './event-timer';
2
- import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types';
1
+ import type { EventTimer } from './event-timer.js';
2
+ import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types.js';
3
3
  declare global {
4
4
  interface Navigator {
5
5
  readonly connection?: NetworkInformation;
@@ -1,14 +1,14 @@
1
- export { isAdBlockInUse } from './detect-ad-blocker';
2
- export { EventTimer } from './event-timer';
3
- export { adSizes } from './ad-sizes';
4
- export * as constants from './constants';
5
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
6
- export { buildPageTargeting } from './targeting/build-page-targeting';
7
- export { postMessage } from './messenger/post-message';
8
- export { buildImaAdTagUrl } from './targeting/youtube-ima';
9
- export { getPermutivePFPSegments } from './permutive';
10
- export { isEligibleForTeads } from './targeting/teads-eligibility';
11
- export { hashEmail } from './email-hash';
12
- export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
13
- export type { PageTargeting } from './targeting/build-page-targeting';
14
- export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
1
+ export { isAdBlockInUse } from './detect-ad-blocker.js';
2
+ export { EventTimer } from './event-timer.js';
3
+ export { adSizes } from './ad-sizes.js';
4
+ export * as constants from './constants/index.js';
5
+ export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics.js';
6
+ export { buildPageTargeting } from './targeting/build-page-targeting.js';
7
+ export { postMessage } from './messenger/post-message.js';
8
+ export { buildImaAdTagUrl } from './targeting/youtube-ima.js';
9
+ export { getPermutivePFPSegments } from './permutive.js';
10
+ export { isEligibleForTeads } from './targeting/teads-eligibility.js';
11
+ export { hashEmail } from './email-hash.js';
12
+ export type { AdSize, SizeMapping, SlotName } from './ad-sizes.js';
13
+ export type { PageTargeting } from './targeting/build-page-targeting.js';
14
+ export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types.js';
package/dist/cjs/index.js CHANGED
@@ -34,25 +34,25 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.hashEmail = exports.isEligibleForTeads = exports.getPermutivePFPSegments = exports.buildImaAdTagUrl = exports.buildPageTargeting = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.constants = exports.adSizes = exports.EventTimer = exports.isAdBlockInUse = void 0;
37
- var detect_ad_blocker_1 = require("./detect-ad-blocker");
37
+ var detect_ad_blocker_1 = require("./detect-ad-blocker.js");
38
38
  Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detect_ad_blocker_1.isAdBlockInUse; } });
39
- var event_timer_1 = require("./event-timer");
39
+ var event_timer_1 = require("./event-timer.js");
40
40
  Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return event_timer_1.EventTimer; } });
41
- var ad_sizes_1 = require("./ad-sizes");
41
+ var ad_sizes_1 = require("./ad-sizes.js");
42
42
  Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
43
- exports.constants = __importStar(require("./constants"));
44
- var send_commercial_metrics_1 = require("./send-commercial-metrics");
43
+ exports.constants = __importStar(require("./constants/index.js"));
44
+ var send_commercial_metrics_1 = require("./send-commercial-metrics.js");
45
45
  Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return send_commercial_metrics_1.bypassCommercialMetricsSampling; } });
46
46
  Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return send_commercial_metrics_1.initCommercialMetrics; } });
47
- var build_page_targeting_1 = require("./targeting/build-page-targeting");
47
+ var build_page_targeting_1 = require("./targeting/build-page-targeting.js");
48
48
  Object.defineProperty(exports, "buildPageTargeting", { enumerable: true, get: function () { return build_page_targeting_1.buildPageTargeting; } });
49
- var post_message_1 = require("./messenger/post-message");
49
+ var post_message_1 = require("./messenger/post-message.js");
50
50
  Object.defineProperty(exports, "postMessage", { enumerable: true, get: function () { return post_message_1.postMessage; } });
51
- var youtube_ima_1 = require("./targeting/youtube-ima");
51
+ var youtube_ima_1 = require("./targeting/youtube-ima.js");
52
52
  Object.defineProperty(exports, "buildImaAdTagUrl", { enumerable: true, get: function () { return youtube_ima_1.buildImaAdTagUrl; } });
53
- var permutive_1 = require("./permutive");
53
+ var permutive_1 = require("./permutive.js");
54
54
  Object.defineProperty(exports, "getPermutivePFPSegments", { enumerable: true, get: function () { return permutive_1.getPermutivePFPSegments; } });
55
- var teads_eligibility_1 = require("./targeting/teads-eligibility");
55
+ var teads_eligibility_1 = require("./targeting/teads-eligibility.js");
56
56
  Object.defineProperty(exports, "isEligibleForTeads", { enumerable: true, get: function () { return teads_eligibility_1.isEligibleForTeads; } });
57
- var email_hash_1 = require("./email-hash");
57
+ var email_hash_1 = require("./email-hash.js");
58
58
  Object.defineProperty(exports, "hashEmail", { enumerable: true, get: function () { return email_hash_1.hashEmail; } });
@@ -1,4 +1,4 @@
1
- import type { ConnectionType } from './types';
1
+ import type { ConnectionType } from './types.js';
2
2
  type Metric = {
3
3
  name: string;
4
4
  value: number;
@@ -4,7 +4,7 @@ exports.checkConsent = exports._ = void 0;
4
4
  exports.bypassCommercialMetricsSampling = bypassCommercialMetricsSampling;
5
5
  exports.initCommercialMetrics = initCommercialMetrics;
6
6
  const libs_1 = require("@guardian/libs");
7
- const event_timer_1 = require("./event-timer");
7
+ const event_timer_1 = require("./event-timer.js");
8
8
  var Endpoints;
9
9
  (function (Endpoints) {
10
10
  Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
@@ -1,9 +1,9 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState, CountryCode } from '@guardian/libs';
3
- import type { AdManagerGroup, Frequency } from './personalised';
4
- import type { SharedTargeting } from './shared';
5
- import { getLocalHour } from './shared';
6
- import type { TrueOrFalse } from './types';
3
+ import type { AdManagerGroup, Frequency } from './personalised.js';
4
+ import type { SharedTargeting } from './shared.js';
5
+ import { getLocalHour } from './shared.js';
6
+ import type { TrueOrFalse } from './types.js';
7
7
  type PartialWithNulls<T> = {
8
8
  [P in keyof T]?: T[P] | null;
9
9
  };
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalHour = exports.filterValues = exports.buildPageTargeting = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const event_timer_1 = require("../event-timer");
6
- const get_locale_1 = require("../geo/get-locale");
7
- const content_1 = require("./content");
8
- const personalised_1 = require("./personalised");
9
- const session_1 = require("./session");
10
- const shared_1 = require("./shared");
5
+ const event_timer_1 = require("../event-timer.js");
6
+ const get_locale_1 = require("../geo/get-locale.js");
7
+ const content_1 = require("./content.js");
8
+ const personalised_1 = require("./personalised.js");
9
+ const session_1 = require("./session.js");
10
+ const shared_1 = require("./shared.js");
11
11
  Object.defineProperty(exports, "getLocalHour", { enumerable: true, get: function () { return shared_1.getLocalHour; } });
12
- const viewport_1 = require("./viewport");
12
+ const viewport_1 = require("./viewport.js");
13
13
  const filterValues = (pageTargets) => {
14
14
  const filtered = {};
15
15
  for (const key in pageTargets) {
@@ -1,5 +1,5 @@
1
- import type { SharedTargeting } from './shared';
2
- import type { False, True } from './types';
1
+ import type { SharedTargeting } from './shared.js';
2
+ import type { False, True } from './types.js';
3
3
  declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180", "210", "240", "270", "300"];
4
4
  /**
5
5
  * Content Targeting comes from the server
@@ -1,5 +1,5 @@
1
1
  import type { ConsentState, TCEventStatusCode } from '@guardian/libs';
2
- import type { False, NotApplicable, True } from './types';
2
+ import type { False, NotApplicable, True } from './types.js';
3
3
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
4
4
  type Frequency = (typeof frequency)[number];
5
5
  declare const adManagerGroups: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPersonalisedTargeting = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const permutive_1 = require("../permutive");
5
+ const permutive_1 = require("../permutive.js");
6
6
  /* -- Types -- */
7
7
  const frequency = [
8
8
  '0',
@@ -1,6 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { CountryCode } from '@guardian/libs';
3
- import type { False, True } from './types';
3
+ import type { False, True } from './types.js';
4
4
  declare const referrers: readonly [{
5
5
  readonly id: "facebook";
6
6
  readonly match: "facebook.com";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalHour = exports.getSharedTargeting = exports._ = void 0;
4
- const pick_targeting_values_1 = require("./pick-targeting-values");
4
+ const pick_targeting_values_1 = require("./pick-targeting-values.js");
5
5
  const surges = {
6
6
  0: '0',
7
7
  50: '5',
@@ -1,4 +1,4 @@
1
- import type { False, True } from './types';
1
+ import type { False, True } from './types.js';
2
2
  /**
3
3
  * Viewport Targeting
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/libs';
3
- import type { CustomParams } from './types';
3
+ import type { CustomParams } from './types.js';
4
4
  type BuildImaAdTagUrl = {
5
5
  adUnit: string;
6
6
  customParams: CustomParams;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildImaAdTagUrl = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const build_page_targeting_1 = require("./build-page-targeting");
5
+ const build_page_targeting_1 = require("./build-page-targeting.js");
6
6
  /**
7
7
  * @param {Record<string, MaybeArray<string|number|boolean>>
8
8
  * Follows https://support.google.com/admanager/answer/1080597
@@ -1,6 +1,6 @@
1
1
  import type { EventPayload } from '@guardian/ophan-tracker-js';
2
- import type { AdSize, SizeMapping } from './ad-sizes';
3
- import type { PageTargeting } from './targeting/build-page-targeting';
2
+ import type { AdSize, SizeMapping } from './ad-sizes.js';
3
+ import type { PageTargeting } from './targeting/build-page-targeting.js';
4
4
  import 'googletag';
5
5
  type HeaderBiddingSize = AdSize;
6
6
  interface Advert {
@@ -1,4 +1,4 @@
1
- import type { Breakpoint } from './breakpoint';
1
+ import type { Breakpoint } from './breakpoint.js';
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
@@ -1,4 +1,4 @@
1
- import { breakpoints, isBreakpoint } from './breakpoint';
1
+ import { breakpoints, isBreakpoint } from './breakpoint.js';
2
2
  /**
3
3
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
4
4
  * more semantic `width`/`height` properties and keep things readonly.
@@ -1,3 +1,3 @@
1
- export { AD_LABEL_HEIGHT } from './ad-label-height';
2
- export { PREBID_TIMEOUT } from './prebid-timeout';
3
- export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
1
+ export { AD_LABEL_HEIGHT } from './ad-label-height.js';
2
+ export { PREBID_TIMEOUT } from './prebid-timeout.js';
3
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height.js';
@@ -1,3 +1,3 @@
1
- export { AD_LABEL_HEIGHT } from './ad-label-height';
2
- export { PREBID_TIMEOUT } from './prebid-timeout';
3
- export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
1
+ export { AD_LABEL_HEIGHT } from './ad-label-height.js';
2
+ export { PREBID_TIMEOUT } from './prebid-timeout.js';
3
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height.js';
@@ -1,4 +1,4 @@
1
- import type { ConnectionType } from './types';
1
+ import type { ConnectionType } from './types.js';
2
2
  declare const supportsPerformanceAPI: () => boolean;
3
3
  interface EventTimerProperties {
4
4
  type?: ConnectionType;
@@ -1,4 +1,4 @@
1
- import { getCountryCode } from './country-code';
1
+ import { getCountryCode } from './country-code.js';
2
2
  // cache the users location so we only have to look it up once
3
3
  let geo;
4
4
  const currentGeoLocation = () => {
@@ -1,5 +1,5 @@
1
- import type { EventTimer } from './event-timer';
2
- import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types';
1
+ import type { EventTimer } from './event-timer.js';
2
+ import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types.js';
3
3
  declare global {
4
4
  interface Navigator {
5
5
  readonly connection?: NetworkInformation;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,14 @@
1
- export { isAdBlockInUse } from './detect-ad-blocker';
2
- export { EventTimer } from './event-timer';
3
- export { adSizes } from './ad-sizes';
4
- export * as constants from './constants';
5
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
6
- export { buildPageTargeting } from './targeting/build-page-targeting';
7
- export { postMessage } from './messenger/post-message';
8
- export { buildImaAdTagUrl } from './targeting/youtube-ima';
9
- export { getPermutivePFPSegments } from './permutive';
10
- export { isEligibleForTeads } from './targeting/teads-eligibility';
11
- export { hashEmail } from './email-hash';
12
- export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
13
- export type { PageTargeting } from './targeting/build-page-targeting';
14
- export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
1
+ export { isAdBlockInUse } from './detect-ad-blocker.js';
2
+ export { EventTimer } from './event-timer.js';
3
+ export { adSizes } from './ad-sizes.js';
4
+ export * as constants from './constants/index.js';
5
+ export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics.js';
6
+ export { buildPageTargeting } from './targeting/build-page-targeting.js';
7
+ export { postMessage } from './messenger/post-message.js';
8
+ export { buildImaAdTagUrl } from './targeting/youtube-ima.js';
9
+ export { getPermutivePFPSegments } from './permutive.js';
10
+ export { isEligibleForTeads } from './targeting/teads-eligibility.js';
11
+ export { hashEmail } from './email-hash.js';
12
+ export type { AdSize, SizeMapping, SlotName } from './ad-sizes.js';
13
+ export type { PageTargeting } from './targeting/build-page-targeting.js';
14
+ export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types.js';
package/dist/esm/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export { isAdBlockInUse } from './detect-ad-blocker';
2
- export { EventTimer } from './event-timer';
3
- export { adSizes } from './ad-sizes';
4
- export * as constants from './constants';
5
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
6
- export { buildPageTargeting } from './targeting/build-page-targeting';
7
- export { postMessage } from './messenger/post-message';
8
- export { buildImaAdTagUrl } from './targeting/youtube-ima';
9
- export { getPermutivePFPSegments } from './permutive';
10
- export { isEligibleForTeads } from './targeting/teads-eligibility';
11
- export { hashEmail } from './email-hash';
1
+ export { isAdBlockInUse } from './detect-ad-blocker.js';
2
+ export { EventTimer } from './event-timer.js';
3
+ export { adSizes } from './ad-sizes.js';
4
+ export * as constants from './constants/index.js';
5
+ export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics.js';
6
+ export { buildPageTargeting } from './targeting/build-page-targeting.js';
7
+ export { postMessage } from './messenger/post-message.js';
8
+ export { buildImaAdTagUrl } from './targeting/youtube-ima.js';
9
+ export { getPermutivePFPSegments } from './permutive.js';
10
+ export { isEligibleForTeads } from './targeting/teads-eligibility.js';
11
+ export { hashEmail } from './email-hash.js';
@@ -1,4 +1,4 @@
1
- import type { ConnectionType } from './types';
1
+ import type { ConnectionType } from './types.js';
2
2
  type Metric = {
3
3
  name: string;
4
4
  value: number;
@@ -1,5 +1,5 @@
1
1
  import { getMeasures, isNonNullable, log, onConsent } from '@guardian/libs';
2
- import { EventTimer } from './event-timer';
2
+ import { EventTimer } from './event-timer.js';
3
3
  var Endpoints;
4
4
  (function (Endpoints) {
5
5
  Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
@@ -1,9 +1,9 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState, CountryCode } from '@guardian/libs';
3
- import type { AdManagerGroup, Frequency } from './personalised';
4
- import type { SharedTargeting } from './shared';
5
- import { getLocalHour } from './shared';
6
- import type { TrueOrFalse } from './types';
3
+ import type { AdManagerGroup, Frequency } from './personalised.js';
4
+ import type { SharedTargeting } from './shared.js';
5
+ import { getLocalHour } from './shared.js';
6
+ import type { TrueOrFalse } from './types.js';
7
7
  type PartialWithNulls<T> = {
8
8
  [P in keyof T]?: T[P] | null;
9
9
  };
@@ -1,11 +1,11 @@
1
1
  import { cmp, getConsentFor, getCookie, isString } from '@guardian/libs';
2
- import { supportsPerformanceAPI } from '../event-timer';
3
- import { getLocale } from '../geo/get-locale';
4
- import { getContentTargeting } from './content';
5
- import { getPersonalisedTargeting } from './personalised';
6
- import { getSessionTargeting } from './session';
7
- import { getLocalHour, getSharedTargeting } from './shared';
8
- import { getViewportTargeting } from './viewport';
2
+ import { supportsPerformanceAPI } from '../event-timer.js';
3
+ import { getLocale } from '../geo/get-locale.js';
4
+ import { getContentTargeting } from './content.js';
5
+ import { getPersonalisedTargeting } from './personalised.js';
6
+ import { getSessionTargeting } from './session.js';
7
+ import { getLocalHour, getSharedTargeting } from './shared.js';
8
+ import { getViewportTargeting } from './viewport.js';
9
9
  const filterValues = (pageTargets) => {
10
10
  const filtered = {};
11
11
  for (const key in pageTargets) {
@@ -1,5 +1,5 @@
1
- import type { SharedTargeting } from './shared';
2
- import type { False, True } from './types';
1
+ import type { SharedTargeting } from './shared.js';
2
+ import type { False, True } from './types.js';
3
3
  declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180", "210", "240", "270", "300"];
4
4
  /**
5
5
  * Content Targeting comes from the server
@@ -1,5 +1,5 @@
1
1
  import type { ConsentState, TCEventStatusCode } from '@guardian/libs';
2
- import type { False, NotApplicable, True } from './types';
2
+ import type { False, NotApplicable, True } from './types.js';
3
3
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
4
4
  type Frequency = (typeof frequency)[number];
5
5
  declare const adManagerGroups: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
@@ -1,5 +1,5 @@
1
1
  import { storage } from '@guardian/libs';
2
- import { clearPermutiveSegments, getPermutivePFPSegments, getPermutiveSegments, } from '../permutive';
2
+ import { clearPermutiveSegments, getPermutivePFPSegments, getPermutiveSegments, } from '../permutive.js';
3
3
  /* -- Types -- */
4
4
  const frequency = [
5
5
  '0',
@@ -1,6 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { CountryCode } from '@guardian/libs';
3
- import type { False, True } from './types';
3
+ import type { False, True } from './types.js';
4
4
  declare const referrers: readonly [{
5
5
  readonly id: "facebook";
6
6
  readonly match: "facebook.com";
@@ -1,4 +1,4 @@
1
- import { pickTargetingValues } from './pick-targeting-values';
1
+ import { pickTargetingValues } from './pick-targeting-values.js';
2
2
  const surges = {
3
3
  0: '0',
4
4
  50: '5',
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { False, True } from './types';
1
+ import type { False, True } from './types.js';
2
2
  /**
3
3
  * Viewport Targeting
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import type { Participations } from '@guardian/ab-core';
2
2
  import type { ConsentState } from '@guardian/libs';
3
- import type { CustomParams } from './types';
3
+ import type { CustomParams } from './types.js';
4
4
  type BuildImaAdTagUrl = {
5
5
  adUnit: string;
6
6
  customParams: CustomParams;
@@ -1,5 +1,5 @@
1
1
  import { log } from '@guardian/libs';
2
- import { buildPageTargeting, filterValues } from './build-page-targeting';
2
+ import { buildPageTargeting, filterValues } from './build-page-targeting.js';
3
3
  /**
4
4
  * @param {Record<string, MaybeArray<string|number|boolean>>
5
5
  * Follows https://support.google.com/admanager/answer/1080597
@@ -1,6 +1,6 @@
1
1
  import type { EventPayload } from '@guardian/ophan-tracker-js';
2
- import type { AdSize, SizeMapping } from './ad-sizes';
3
- import type { PageTargeting } from './targeting/build-page-targeting';
2
+ import type { AdSize, SizeMapping } from './ad-sizes.js';
3
+ import type { PageTargeting } from './targeting/build-page-targeting.js';
4
4
  import 'googletag';
5
5
  type HeaderBiddingSize = AdSize;
6
6
  interface Advert {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "0.0.0-beta-20251030174934",
3
+ "version": "0.0.0-beta-20251113115216",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial#readme",
6
6
  "bugs": {
@@ -17,6 +17,7 @@
17
17
  ],
18
18
  "main": "dist/cjs/index.js",
19
19
  "module": "dist/esm/index.js",
20
+ "type": "module",
20
21
  "exports": {
21
22
  ".": {
22
23
  "import": "./dist/esm/index.js",
@@ -40,13 +41,14 @@
40
41
  },
41
42
  "devDependencies": {
42
43
  "@guardian/ophan-tracker-js": "2.6.1",
44
+ "@types/google-publisher-tag": "~1.20250811.1",
43
45
  "@types/jest": "30.0.0",
44
46
  "@types/node": "24.7.2",
45
- "@types/google-publisher-tag": "~1.20250811.1",
46
47
  "jest": "^30.2.0",
47
48
  "jest-environment-jsdom": "^30.2.0",
48
49
  "jest-environment-jsdom-global": "~4.0.0",
49
50
  "ts-jest": "^29.4.4",
51
+ "tsc-alias": "1.8.16",
50
52
  "type-fest": "^4.41.0",
51
53
  "typescript": "5.9.3"
52
54
  },
@@ -56,7 +58,7 @@
56
58
  "scripts": {
57
59
  "build": "pnpm run --parallel --aggregate-output /^build:.*/",
58
60
  "clean": "rm -rf dist",
59
- "build:esm": "tsc --outDir ./dist/esm --project ./tsconfig.esm.json",
61
+ "build:esm": "tsc --outDir ./dist/esm --project ./tsconfig.esm.json && tsc-alias --project ./tsconfig.esm.json",
60
62
  "build:cjs": "tsc --outDir ./dist/cjs --project ./tsconfig.cjs.json",
61
63
  "lint": "eslint .",
62
64
  "prettier:check": "prettier . --check --cache",