@surfside/ads 3.6.0-327321ef.0 → 3.6.1

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 (86) hide show
  1. package/package.json +10 -10
  2. package/lib/cjs/BuildInfo.js +0 -9
  3. package/lib/cjs/BuildInfo.js.map +0 -1
  4. package/lib/cjs/Constants.js +0 -5
  5. package/lib/cjs/Constants.js.map +0 -1
  6. package/lib/cjs/Init.js +0 -130
  7. package/lib/cjs/Init.js.map +0 -1
  8. package/lib/cjs/components/Banner.js +0 -135
  9. package/lib/cjs/components/Banner.js.map +0 -1
  10. package/lib/cjs/components/Card.js +0 -162
  11. package/lib/cjs/components/Card.js.map +0 -1
  12. package/lib/cjs/components/Carousel.js +0 -241
  13. package/lib/cjs/components/Carousel.js.map +0 -1
  14. package/lib/cjs/components/Creative.js +0 -203
  15. package/lib/cjs/components/Creative.js.map +0 -1
  16. package/lib/cjs/components/Dynamic.js +0 -300
  17. package/lib/cjs/components/Dynamic.js.map +0 -1
  18. package/lib/cjs/components/SimpleCreative.js +0 -75
  19. package/lib/cjs/components/SimpleCreative.js.map +0 -1
  20. package/lib/cjs/components/Video.js +0 -134
  21. package/lib/cjs/components/Video.js.map +0 -1
  22. package/lib/cjs/demo/test.js +0 -7
  23. package/lib/cjs/demo/test.js.map +0 -1
  24. package/lib/cjs/index.module.js +0 -107
  25. package/lib/cjs/index.module.js.map +0 -1
  26. package/lib/cjs/index.script.js +0 -102
  27. package/lib/cjs/index.script.js.map +0 -1
  28. package/lib/cjs/index.script.mock.js +0 -154
  29. package/lib/cjs/index.script.mock.js.map +0 -1
  30. package/lib/cjs/service/Init.js +0 -3
  31. package/lib/cjs/service/Init.js.map +0 -1
  32. package/lib/cjs/util/Attributes.js +0 -93
  33. package/lib/cjs/util/Attributes.js.map +0 -1
  34. package/lib/cjs/util/Types.js +0 -3
  35. package/lib/cjs/util/Types.js.map +0 -1
  36. package/lib/esm/BuildInfo.js +0 -6
  37. package/lib/esm/BuildInfo.js.map +0 -1
  38. package/lib/esm/Constants.js +0 -2
  39. package/lib/esm/Constants.js.map +0 -1
  40. package/lib/esm/Init.js +0 -92
  41. package/lib/esm/Init.js.map +0 -1
  42. package/lib/esm/components/Banner.js +0 -131
  43. package/lib/esm/components/Banner.js.map +0 -1
  44. package/lib/esm/components/Card.js +0 -158
  45. package/lib/esm/components/Card.js.map +0 -1
  46. package/lib/esm/components/Carousel.js +0 -237
  47. package/lib/esm/components/Carousel.js.map +0 -1
  48. package/lib/esm/components/Creative.js +0 -198
  49. package/lib/esm/components/Creative.js.map +0 -1
  50. package/lib/esm/components/Dynamic.js +0 -296
  51. package/lib/esm/components/Dynamic.js.map +0 -1
  52. package/lib/esm/components/SimpleCreative.js +0 -69
  53. package/lib/esm/components/SimpleCreative.js.map +0 -1
  54. package/lib/esm/components/Video.js +0 -130
  55. package/lib/esm/components/Video.js.map +0 -1
  56. package/lib/esm/demo/test.js +0 -5
  57. package/lib/esm/demo/test.js.map +0 -1
  58. package/lib/esm/index.module.js +0 -67
  59. package/lib/esm/index.module.js.map +0 -1
  60. package/lib/esm/index.script.js +0 -100
  61. package/lib/esm/index.script.js.map +0 -1
  62. package/lib/esm/index.script.mock.js +0 -152
  63. package/lib/esm/index.script.mock.js.map +0 -1
  64. package/lib/esm/service/Init.js +0 -2
  65. package/lib/esm/service/Init.js.map +0 -1
  66. package/lib/esm/util/Attributes.js +0 -81
  67. package/lib/esm/util/Attributes.js.map +0 -1
  68. package/lib/esm/util/Types.js +0 -2
  69. package/lib/esm/util/Types.js.map +0 -1
  70. package/lib/types/BuildInfo.d.ts +0 -5
  71. package/lib/types/Constants.d.ts +0 -1
  72. package/lib/types/Init.d.ts +0 -31
  73. package/lib/types/components/Banner.d.ts +0 -18
  74. package/lib/types/components/Card.d.ts +0 -17
  75. package/lib/types/components/Carousel.d.ts +0 -31
  76. package/lib/types/components/Creative.d.ts +0 -65
  77. package/lib/types/components/Dynamic.d.ts +0 -23
  78. package/lib/types/components/SimpleCreative.d.ts +0 -19
  79. package/lib/types/components/Video.d.ts +0 -22
  80. package/lib/types/demo/test.d.ts +0 -1
  81. package/lib/types/index.module.d.ts +0 -12
  82. package/lib/types/index.script.d.ts +0 -1
  83. package/lib/types/index.script.mock.d.ts +0 -1
  84. package/lib/types/service/Init.d.ts +0 -1
  85. package/lib/types/util/Attributes.d.ts +0 -24
  86. package/lib/types/util/Types.d.ts +0 -3
@@ -1,300 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SurfsideDynamicZone = void 0;
4
- const ads_core_1 = require("@surfside/ads-core");
5
- const Constants_1 = require("../Constants");
6
- const Creative_1 = require("./Creative");
7
- const Carousel_1 = require("./Carousel");
8
- const SimpleCreative_1 = require("./SimpleCreative");
9
- class SurfsideDynamicZone extends Creative_1.CreativeComponent {
10
- _cancellationToken = new ads_core_1.CancellationToken();
11
- maxItems;
12
- cardMinWidth = Constants_1.DefaultMinCardWidth;
13
- strategy;
14
- recommend;
15
- nextType;
16
- _bounce;
17
- getComponentName() {
18
- return 'SurfsideDynamicZone';
19
- }
20
- static get observedAttributes() {
21
- return [
22
- ...Creative_1.CreativeComponent.observedBaseAttributes,
23
- 'max-items',
24
- 'card-min-width',
25
- 'next-type'
26
- ];
27
- }
28
- async attributeChangedCallback(name, oldValue, newValue) {
29
- const log = this.log?.with('attributeChangedCallback');
30
- log?.info('Carousel attribute changed');
31
- switch (name) {
32
- case 'max-items': {
33
- try {
34
- this.maxItems = (0, SimpleCreative_1.IntValOrThrow)(this, 'max-items', newValue);
35
- }
36
- catch (err) {
37
- log?.warn('Failed to parse. Got', err);
38
- }
39
- break;
40
- }
41
- case 'card-min-width': {
42
- try {
43
- this.cardMinWidth = (0, SimpleCreative_1.IntValOrThrow)(this, 'card-min-width', newValue);
44
- }
45
- catch (err) {
46
- log?.warn('Failed to parse. Got', err);
47
- }
48
- break;
49
- }
50
- case 'strategy': {
51
- const strategy = newValue?.toLowerCase();
52
- switch (strategy) {
53
- case Creative_1.ProductFeedStrategy.Sponsored:
54
- case Creative_1.ProductFeedStrategy.Hybrid:
55
- case Creative_1.ProductFeedStrategy.Recommended:
56
- this.strategy = strategy;
57
- break;
58
- default:
59
- log?.warn('Unrecognized or null strategy:', newValue);
60
- break;
61
- }
62
- break;
63
- }
64
- case 'recommend': {
65
- const recommend = newValue?.toLowerCase();
66
- switch (recommend) {
67
- case Creative_1.RecommenderTypeInputs.TopProducts:
68
- this.recommend = 'top-products';
69
- break;
70
- case Creative_1.RecommenderTypeInputs.ForYou:
71
- this.recommend = 'for-you';
72
- break;
73
- case Creative_1.RecommenderTypeInputs.PastPurchases:
74
- case Creative_1.RecommenderTypeInputs.BuyAgain:
75
- this.recommend = 'past-purchases';
76
- break;
77
- default:
78
- log?.warn('Unrecognized or null recommender type:', newValue);
79
- break;
80
- }
81
- break;
82
- }
83
- case 'next-type': {
84
- const nextType = newValue?.toLowerCase();
85
- switch (nextType) {
86
- case Carousel_1.NextType.Page:
87
- case Carousel_1.NextType.Product:
88
- this.nextType = nextType;
89
- break;
90
- default:
91
- log?.warn('Unrecognized or null next-type:', newValue);
92
- break;
93
- }
94
- break;
95
- }
96
- default: {
97
- const baseName = name;
98
- if (Creative_1.CreativeComponent.observedBaseAttributes.includes(baseName)) {
99
- await super.baseAttributeChangedCallback(baseName, oldValue, newValue, log);
100
- }
101
- break;
102
- }
103
- }
104
- const totem = crypto.randomUUID();
105
- this.totem = totem;
106
- if (!this.attributesLoaded()) {
107
- log?.debug('Attributes not ready yet...', this.accountId);
108
- return;
109
- }
110
- else {
111
- log?.debug('Attributes ready!');
112
- }
113
- await this.lazyLoadApi();
114
- if (this.totem !== totem) {
115
- log?.debug('Totem changed in between attribute callbacks. Waiting for final attribue to render dynamic');
116
- return;
117
- }
118
- if (this._bounce !== undefined) {
119
- globalThis.clearTimeout(this._bounce);
120
- }
121
- this._bounce = globalThis.setTimeout(() => this.render(), Creative_1.DEBOUNCE_THRESHOLD);
122
- }
123
- async render() {
124
- const log = this.log?.with('SurfsideDynamicZone', { zoneId: this.zoneId });
125
- log?.info('Rendering Dynamic Zone', this.api);
126
- const stopTimer = log?.time?.('render dynamic zone');
127
- this._cancellationToken.cancel();
128
- const token = new ads_core_1.CancellationToken();
129
- this._cancellationToken = token;
130
- const { getDynamicZone, buildDynamicZoneRequest } = this.api;
131
- const dynamicZoneRes = await getDynamicZone(this.zoneId);
132
- if (this._cancellationToken.cancelled === true) {
133
- log?.error('Dynamic zone request was cancelled');
134
- return;
135
- }
136
- else if (!dynamicZoneRes.ok) {
137
- log?.error('Dynamic zone failed to load', dynamicZoneRes.error);
138
- return;
139
- }
140
- const dynamicZone = dynamicZoneRes.value;
141
- const dynamicZoneRequestRes = buildDynamicZoneRequest(this.zoneId, dynamicZone, this.category);
142
- if (!dynamicZoneRequestRes.ok) {
143
- log?.error('Failed to build dynamic zone request', dynamicZoneRequestRes.error);
144
- return;
145
- }
146
- const dynamicZoneRequest = dynamicZoneRequestRes.value;
147
- await this.requestAndRender(dynamicZoneRequest);
148
- stopTimer?.();
149
- }
150
- async requestAndRender(dynamicZoneRequest) {
151
- const { buildDynamicResponse, renderBanner, renderVideo, renderCarousel, renderProductCard } = this.api;
152
- const log = this.log?.with('SurfsideDynamicZone', { zoneId: this.zoneId });
153
- const dynamicResponseRes = await buildDynamicResponse(dynamicZoneRequest);
154
- // Have to cast too boolean here because typescript is too stupid to understand that
155
- // cancellationtoken can be mutated between async calls and is trying to narrow the type to false
156
- // based on the last cancellation check
157
- if (this._cancellationToken.cancelled === true) {
158
- log?.error('Dynamic zone request was cancelled');
159
- return;
160
- }
161
- else if (!dynamicResponseRes.ok) {
162
- log?.error('Dynamic response failed', dynamicResponseRes);
163
- return;
164
- }
165
- const dynamicResponse = dynamicResponseRes.value;
166
- const finalRender = (element, reauctionEnabled) => {
167
- this.shadow.innerHTML = '';
168
- this.shadow.appendChild(element);
169
- if (this.api.configuration.settings.reauctionEnabled && reauctionEnabled) {
170
- switch (dynamicResponse.type) {
171
- case 'banner': {
172
- log?.info('Attempting re-auction for banner...');
173
- setTimeout(() => {
174
- log?.info('Re-auctioning banner...');
175
- const bannerImp = dynamicZoneRequest.request.imp.find(i => i.banner !== undefined);
176
- if (bannerImp === undefined) {
177
- log?.error('Failed to find original banner request for re-auction');
178
- return;
179
- }
180
- const partialRequest = {
181
- requestIds: dynamicZoneRequest.requestIds,
182
- request: {
183
- ...dynamicZoneRequest.request,
184
- id: crypto.randomUUID(),
185
- imp: [{
186
- ...bannerImp,
187
- id: crypto.randomUUID(),
188
- banner: {
189
- ...bannerImp.banner,
190
- w: dynamicResponse.dynamicBannerRequest.width,
191
- h: dynamicResponse.dynamicBannerRequest.height,
192
- format: [{
193
- w: dynamicResponse.dynamicBannerRequest.width,
194
- h: dynamicResponse.dynamicBannerRequest.height
195
- }]
196
- }
197
- }]
198
- }
199
- };
200
- log?.info('sending re-auction', partialRequest);
201
- this.requestAndRender(partialRequest);
202
- }, Math.max(this.api.configuration.settings.reauctionIntervalMs, 10_000));
203
- break;
204
- }
205
- case 'video': {
206
- log?.info('Attempting re-auction for video...');
207
- const video = element.shadowRoot?.querySelector('video');
208
- if (video === null || video === undefined) {
209
- log?.error('Failed to find video element for re-auction in dynamic zone!');
210
- return;
211
- }
212
- log?.info('Re-auctioning video...');
213
- video.addEventListener('ended', () => {
214
- log?.info('video ended');
215
- const videoImp = dynamicZoneRequest.request.imp.find(i => i.video !== undefined);
216
- if (videoImp === undefined) {
217
- log?.error('Failed to find original banner request for re-auction');
218
- return;
219
- }
220
- const partialRequest = {
221
- requestIds: dynamicZoneRequest.requestIds,
222
- request: {
223
- ...dynamicZoneRequest.request,
224
- id: crypto.randomUUID(),
225
- imp: [{
226
- ...videoImp,
227
- id: crypto.randomUUID(),
228
- video: {
229
- ...videoImp.video,
230
- w: dynamicResponse.dynamicVideoRequest.width,
231
- h: dynamicResponse.dynamicVideoRequest.height,
232
- minduration: dynamicResponse.dynamicVideoRequest.minDuration,
233
- maxduration: dynamicResponse.dynamicVideoRequest.maxDuration
234
- }
235
- }]
236
- }
237
- };
238
- log?.info('Sending re-auction for video', partialRequest);
239
- this.requestAndRender(partialRequest);
240
- });
241
- }
242
- }
243
- }
244
- return (0, ads_core_1.Ok)(true);
245
- };
246
- switch (dynamicResponse.type) {
247
- case 'banner': {
248
- log?.info('Banner response', dynamicResponse);
249
- const reauctionEnabled = dynamicResponse.bid.ext?.takeover !== true;
250
- const result = (0, ads_core_1.Pipe)(renderBanner(dynamicResponse))
251
- .then(r => finalRender(r, reauctionEnabled))
252
- .result();
253
- if (!result.ok) {
254
- log?.error('Failed to render banner', result.error);
255
- }
256
- break;
257
- }
258
- case 'video': {
259
- const reauction = dynamicResponse.bid.ext?.takeover !== true;
260
- const result = (0, ads_core_1.Pipe)(renderVideo(dynamicResponse))
261
- .then(r => finalRender(r, reauction))
262
- .result();
263
- if (!result.ok) {
264
- log?.error('Failed to render video', result.error);
265
- }
266
- break;
267
- }
268
- case 'carousel': {
269
- const request = dynamicResponse.dynamicCarouselRequest;
270
- const maxItems = this.maxItems ?? request.maxItems;
271
- const cardMinWidth = this.cardMinWidth ?? request.cardMinWidth;
272
- const nextType = this.nextType ?? request.nextType;
273
- const result = await renderCarousel(dynamicResponse, cardMinWidth, maxItems === undefined
274
- ? { type: 'infinite' }
275
- : { type: 'limited', limit: maxItems }, nextType);
276
- if (!result.ok) {
277
- log?.error('Failed to render carousel', result.error);
278
- break;
279
- }
280
- finalRender(result.value.element, false);
281
- result.value.init();
282
- break;
283
- }
284
- case 'product-card': {
285
- const result = (0, ads_core_1.Pipe)(renderProductCard(dynamicResponse))
286
- .then(r => finalRender(r, false))
287
- .result();
288
- if (!result.ok) {
289
- log?.error('Failed to render product card', result.error);
290
- }
291
- break;
292
- }
293
- default:
294
- log?.error('Invalid creative type returned from dynamic zone', dynamicResponse);
295
- break;
296
- }
297
- }
298
- }
299
- exports.SurfsideDynamicZone = SurfsideDynamicZone;
300
- //# sourceM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AW,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;qBAChC,MAAM,EAAE,CAAC;gBACd,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;oBACb,GAAG,EAAE,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC9D,CAAC;gBACD,MAAM;YACV,CAAC;YACD;gBACI,GAAG,EAAE,KAAK,CAAC,kDAAkD,EAAE,eAAe,CAAC,CAAC;gBAChF,MAAM;QACd,CAAC;IACL,CAAC;CACJ;AAjUD,kDAiUC"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleCreativeComponent = exports.IntValOr = exports.IntValOrThrow = void 0;
4
- const Creative_1 = require("./Creative");
5
- const Attributes_1 = require("../util/Attributes");
6
- const ads_core_1 = require("@surfside/ads-core");
7
- const NumberValOrThrow = (element, attribute, value) => {
8
- const strValue = (0, Creative_1.AttributeValOrThrow)(element, attribute, value);
9
- const numValue = Number(strValue);
10
- if (Number.isNaN(numValue)) {
11
- throw new Attributes_1.AttributeNotANumberError(element, attribute);
12
- }
13
- return numValue;
14
- };
15
- const IntValOrThrow = (element, attribute, value) => {
16
- const numValue = NumberValOrThrow(element, attribute, value);
17
- if (!Number.isInteger(numValue)) {
18
- throw new Attributes_1.AttributeNotIntError(element, attribute);
19
- }
20
- return numValue;
21
- };
22
- exports.IntValOrThrow = IntValOrThrow;
23
- const IntValOr = (element, attribute, value, or) => {
24
- try {
25
- return (0, exports.IntValOrThrow)(element, attribute, value);
26
- }
27
- catch {
28
- return or;
29
- }
30
- };
31
- exports.IntValOr = IntValOr;
32
- class SimpleCreativeComponent extends Creative_1.CreativeComponent {
33
- width;
34
- height;
35
- constructor(initApi, getUserId, logger) {
36
- super(initApi, getUserId, logger);
37
- }
38
- attributesLoaded() {
39
- return (super.attributesLoaded() &&
40
- this.width !== undefined &&
41
- this.height !== undefined &&
42
- this.width !== null &&
43
- this.height !== null);
44
- }
45
- static get observedSimpleAttributes() {
46
- return [...Creative_1.CreativeComponent.observedBaseAttributes, 'width', 'height'];
47
- }
48
- async simpleAttributeChangedCallback(name, oldValue, newValue, logger) {
49
- const log = logger?.with('simpleAttributeChangedCallback');
50
- log?.info('Simple attribute changed: ', name);
51
- if (Creative_1.CreativeComponent.observedBaseAttributes.includes(name)) {
52
- log?.info('Base attribute changed');
53
- const key = name;
54
- await this.baseAttributeChangedCallback(key, oldValue, newValue, log);
55
- return;
56
- }
57
- if (name === 'width' || name === 'height') {
58
- log?.debug('Before: width', this.width, 'height', this.height);
59
- try {
60
- this[name] = (0, exports.IntValOrThrow)(this, name, newValue);
61
- }
62
- catch (error) {
63
- log?.warn('Couldn\'t parse number attribute', error);
64
- }
65
- log?.debug('After: width', this.width, 'height', this.height);
66
- }
67
- }
68
- readSimpleAttributes() {
69
- this.readBaseAttributes();
70
- this.width = (0, ads_core_1.GetValue)((0, Attributes_1.ReadIntAttribute)(this, 'width')) ?? this.width;
71
- this.height = (0, ads_core_1.GetValue)((0, Attributes_1.ReadIntAttribute)(this, 'height')) ?? this.height;
72
- }
73
- }
74
- exports.SimpleCreativeComponent = SimpleCreativeComponent;
75
- //# sourceMappingURL=SimpleCreative.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleCreative.js","sourceRoot":"../@surfside-ads/","sources":["components/SimpleCreative.ts"],"names":[],"mappings":";;;AAAA,yCAMoB;AACpB,mDAAsG;AAEtG,iDAAiF;AASjF,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,SAAiB,EAAE,KAAoB,EAAE,EAAE;IACnF,MAAM,QAAQ,GAAG,IAAA,8BAAmB,EAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,qCAAwB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AAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,IAAA,mBAAQ,EAAC,IAAA,6BAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;IAC5E,CAAC;CACJ;AAxDD,0DAwDC"}
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SurfsideVideo = void 0;
4
- const ads_core_1 = require("@surfside/ads-core");
5
- const SimpleCreative_1 = require("./SimpleCreative");
6
- const Creative_1 = require("./Creative");
7
- class SurfsideVideo extends SimpleCreative_1.SimpleCreativeComponent {
8
- _cancellationToken = new ads_core_1.CancellationToken();
9
- minDuration;
10
- maxDuration;
11
- _bounce;
12
- static get observedAttributes() {
13
- return [...SimpleCreative_1.SimpleCreativeComponent.observedSimpleAttributes, 'min-duration', 'max-duration'];
14
- }
15
- constructor(initApi, getUserId, logger) {
16
- super(initApi, getUserId, logger);
17
- }
18
- getComponentName() {
19
- return 'SurfsideVideo';
20
- }
21
- attributesLoaded() {
22
- return (super.attributesLoaded() && this.minDuration !== undefined && this.maxDuration !== undefined
23
- && this.minDuration !== null && this.maxDuration !== null);
24
- }
25
- async attributeChangedCallback(name, oldValue, newValue) {
26
- const log = this.log?.with('attributeChangedCallback');
27
- log?.info('Attribute changed');
28
- if (name === 'min-duration') {
29
- try {
30
- this.minDuration = (0, SimpleCreative_1.IntValOrThrow)(this, 'min-duration', newValue);
31
- }
32
- catch (err) {
33
- log?.warn('Couldn\'t parse min-duration', err);
34
- }
35
- }
36
- else if (name === 'max-duration') {
37
- try {
38
- this.maxDuration = (0, SimpleCreative_1.IntValOrThrow)(this, 'max-duration', newValue);
39
- }
40
- catch (err) {
41
- log?.warn('Couldn\'t parse min-duration', err);
42
- }
43
- }
44
- else {
45
- this.simpleAttributeChangedCallback(name, oldValue, newValue, log);
46
- }
47
- const totem = crypto.randomUUID();
48
- this.totem = totem;
49
- log?.debug(name, 'totem', totem);
50
- if (!this.attributesLoaded()) {
51
- log?.debug('Attributes not ready yet...');
52
- return;
53
- }
54
- if (this.totem !== totem) {
55
- log?.debug('Totem changed. Deferring rendering of video until last attribute changed', totem, this.totem);
56
- return;
57
- }
58
- log?.debug(`Rendering video upon change of [${name}]`);
59
- if (this._bounce !== undefined) {
60
- globalThis.clearTimeout(this._bounce);
61
- }
62
- this._bounce = globalThis.setTimeout(() => this.render(), Creative_1.DEBOUNCE_THRESHOLD);
63
- }
64
- readVideoAttributes() {
65
- this.readSimpleAttributes();
66
- }
67
- async connectedCallback() {
68
- super.connectedCallback();
69
- this.readVideoAttributes();
70
- await this.initApi();
71
- const totem = crypto.randomUUID();
72
- this.totem = totem;
73
- if (this.attributesLoaded()) {
74
- await this.lazyLoadApi();
75
- if (this.totem !== totem) {
76
- this.log?.debug('Attributes changed after connectedCallback, waiting to render');
77
- return;
78
- }
79
- this.log?.debug('Rendering upon connectedCallback');
80
- await this.render();
81
- }
82
- else {
83
- this.log?.warn('ConnectedCallback called before attributes were all ready.');
84
- }
85
- }
86
- async render() {
87
- const log = this.log?.with('SurfsideVideo', { zoneId: this.zoneId });
88
- log?.info('rendering');
89
- log?.debug('width', this.width, 'height', this.height);
90
- const stopTimer = log?.time?.('render video');
91
- this._cancellationToken.cancel();
92
- const token = new ads_core_1.CancellationToken();
93
- this._cancellationToken = token;
94
- const { requestBids, startRequest, buildVideoResponse, renderVideo } = this.api;
95
- const bidResponseResult = await requestBids(startRequest(this.zoneId)
96
- .withSurfCategory(this.category)
97
- .withKeywords(this.keywords)
98
- .withVideo(this.width, this.height, this.minDuration, this.maxDuration)
99
- .build());
100
- if (token.cancelled) {
101
- return;
102
- }
103
- if (!bidResponseResult.ok) {
104
- log?.warn('Did not get any bid responses', bidResponseResult.error);
105
- return;
106
- }
107
- const bid = bidResponseResult.value.seatbid?.[0]?.bid?.[0];
108
- if (bid === undefined) {
109
- log?.error('Got a bid response, but it was malformed', bidResponseResult);
110
- return;
111
- }
112
- const responseResult = buildVideoResponse(bid);
113
- if (!responseResult.ok) {
114
- log?.error(responseResult.error);
115
- return;
116
- }
117
- const elementResult = renderVideo(responseResult.value);
118
- if (!elementResult.ok) {
119
- log?.error(elementResult.error);
120
- return;
121
- }
122
- if (!token.cancelled) {
123
- stopTimer?.();
124
- this.shadow.innerHTML = '';
125
- this.shadow.appendChild(elementResult.value);
126
- elementResult.value.classList.add(`surf-zone-${this.zoneId}`);
127
- if (this.api.configuration.settings.reauctionEnabled && bid.ext?.takeover !== true) {
128
- elementResult.value.onended = () => this.render();
129
- }
130
- }
131
- }
132
- }
133
- exports.SurfsideVideo = SurfsideVideo;
134
- //# sourceMappingURL=Video.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Video.js","sourceRoot":"../@surfside-ads/","sources":["components/Video.ts"],"names":[],"mappings":";;;AAAA,iDAI4B;AAC5B,qDAAkH;AAClH,yCAA8D;AAQ9D,MAAa,aAAc,SAAQ,wCAAuB;IAC9C,kBAAkB,GAAsB,IAAI,4BAAiB,EAAE,CAAC;IAE9D,WAAW,CAAiB;IAC5B,WAAW,CAAiB;IAE9B,OAAO,CAAwB;IAEhC,MAAM,KAAK,kBAAkB;QAChC,OAAO,CAAC,GAAG,wCAAuB,CAAC,wBAAwB,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IACjG,CAAC;IAED,YACI,OAAgB,EAChB,SAAsB,EACtB,MAAgB;QAEhB,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAEkB,gBAAgB;QAC/B,OAAO,eAAe,CAAC;IAC3B,CAAC;IAEkB,gBAAgB;QAC/B,OAAO,CACH,KAAK,CAAC,gBAAgB,EAAE,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;eACzF,IAAI,CAAC,WAAW,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,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AE,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,GAAG,EAAE,KAAK,CAAC,0CAA0C,EAAE,iBAAiB,CAAC,CAAC;YAC1E,OAAO;QACX,CAAC;QAED,MAAM,cAAc,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;YACrB,GAAG,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO;QACX,CAAC;QAED,MAAM,aAAa,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;YACpB,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACnB,SAAS,EAAE,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC7C,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACjF,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAlKD,sCAkKC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_module_1 = require("../index.module");
4
- window.onload = () => {
5
- (0, index_module_1.InitSurfAdsWebComponents)();
6
- };
7
- //# sourceMappingURL=test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.js","sourceRoot":"../@surfside-ads/","sources":["demo/test.ts"],"names":[],"mappings":";;AAAA,kDAA2D;AAE3D,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;IACjB,IAAA,uCAAwB,GAAE,CAAC;AAC/B,CAAC,CAAA"}