@guardian/commercial-core 7.1.0 → 27.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.
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 +129 -38
  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 +403 -63
  39. package/dist/cjs/types.js +11 -0
  40. package/dist/esm/ad-sizes.d.ts +150 -8
  41. package/dist/esm/ad-sizes.js +127 -38
  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 +403 -63
  76. package/dist/esm/types.js +11 -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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,56 +1,45 @@
1
1
  # @guardian/commercial-core
2
2
 
3
- [![npm (scoped)](https://img.shields.io/npm/v/@guardian/commercial-core)](https://www.npmjs.com/package/@guardian/commercial-core)
4
- [![ES version](https://badgen.net/badge/ES/2020/cyan)](https://tc39.es/ecma262/2020/)
5
- [![npm type definitions](https://img.shields.io/npm/types/@guardian/commercial-core)](https://www.typescriptlang.org/)
6
-
7
- > Guardian advertising business logic
8
-
9
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
10
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
11
- ## Table of contents
12
-
13
- - [Installation](#installation)
14
- - [Bundling](#bundling)
15
- - [Development](#development)
16
- - [Requirements](#requirements)
17
- - [Releasing](#releasing)
18
-
19
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
3
+ This directory contains the modules that are published as the `@guardian/commercial-core` npm package.
20
4
 
21
5
  ## Installation
22
6
 
23
- [![Generic badge](https://img.shields.io/badge/google-chat-259082.svg)](https://chat.google.com/room/AAAAPL2MBvE)
7
+ To install the npm package, install with your favourite package manager:
24
8
 
25
9
  ```bash
10
+ pnpm i @guardian/commercial-core
26
11
  yarn add @guardian/commercial-core
12
+ npm i @guardian/commercial-core
27
13
  ```
28
14
 
29
- ### Bundling
30
-
31
- This package uses `ES2020`.
15
+ ## Development
32
16
 
33
- If your target environment does not support that, make sure you transpile this package when bundling your application.
17
+ build the package with:
34
18
 
35
- ## Development
19
+ ```bash
20
+ pnpm build
21
+ ```
36
22
 
37
- ### Requirements
23
+ This will build the package into the `dist` directory, which is what is published to npm.
38
24
 
39
- 1. [Node 16](https://nodejs.org/en/download/) ([fnm][] recommended)
40
- 2. [Yarn](https://classic.yarnpkg.com/en/docs/install/)
25
+ #### Beta Releases
26
+ 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.
41
27
 
42
- [fnm]: https://github.com/Schniz/fnm
28
+ 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.
43
29
 
44
- ### Releasing
30
+ 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.
45
31
 
46
- Changes are automatically released to NPM.
32
+ ## Releasing to NPM
33
+ This repository uses changesets for version management.
47
34
 
48
- The `main` branch on GitHub is analysed by [semantic-release](https://semantic-release.gitbook.io/) after every push.
35
+ To release a new version with your changes, run:
49
36
 
50
- If a commit message follows the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0), semantic-release can determine what types of changes are included in that commit.
37
+ ```bash
38
+ pnpm changeset add
39
+ ```
51
40
 
52
- If necessary, it will then automatically release a new, [semver](https://semver.org/)-compliant version of the package to NPM.
41
+ and follow the prompts. This will create a new changeset file in the `.changeset` directory. Commit this file with your PR.
53
42
 
54
- #### Pull requests
43
+ When your PR is merged, changeset will analyse the changes and create a PR to release the new version.
55
44
 
56
- Try to write PR titles in the conventional commit format, and [squash and merge](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges#squash-and-merge-your-pull-request-commits) when merging. That way your PR will trigger a release when you merge it (if necessary).
45
+ if you are part of the `commercial` team, you can merge the changeset PR to release the new version. If you are not part of the `commercial` team, you will need to ask someone who is to merge the PR for you.
@@ -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' | 'fronts-banner' | '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, };