@mjhls/mjh-framework 1.0.204 → 1.0.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/AD-e2479b7c.js +31 -0
- package/dist/cjs/DeckContent.js +430 -0
- package/dist/cjs/DeckQueue.js +366 -0
- package/dist/cjs/Dfp-d94f7f73.js +97 -0
- package/dist/cjs/GridContent.js +613 -0
- package/dist/cjs/GroupDeck.js +156 -0
- package/dist/cjs/IssueContentDeck.js +81 -0
- package/dist/cjs/IssueDeck.js +144 -0
- package/dist/cjs/MasterDeck.js +340 -0
- package/dist/cjs/Normal-7dd8c339.js +2374 -0
- package/dist/cjs/PublicationDeck.js +81 -0
- package/dist/cjs/QueueDeckExpanded.js +559 -0
- package/dist/cjs/TaxonomyCard-7b5b4298.js +1045 -0
- package/dist/cjs/TaxonomyCard.js +18 -0
- package/dist/cjs/TemplateNormal.js +29 -0
- package/dist/cjs/ThumbnailCard.js +58 -0
- package/dist/cjs/Ustream-0d3dd953.js +122 -0
- package/dist/cjs/Ustream.js +10 -0
- package/dist/cjs/VideoSeriesListing.js +248 -0
- package/dist/cjs/YoutubeGroup-f7707ceb.js +228 -0
- package/dist/cjs/YoutubeGroup.js +13 -0
- package/dist/cjs/_babelHelpers-f321c258.js +119 -0
- package/dist/cjs/_commonjsHelpers-3fc1f64e.js +20 -0
- package/dist/cjs/debounce-286eb3fb.js +279 -0
- package/dist/cjs/entities-3e0b4a16.js +506 -0
- package/dist/cjs/get-06aac51b.js +992 -0
- package/dist/cjs/index-0d0efcfa.js +610 -0
- package/dist/cjs/index-a4c53ff4.js +551 -0
- package/dist/cjs/index.es-2289df51.js +5028 -0
- package/dist/cjs/index.esm-340d3792.js +113 -0
- package/dist/cjs/index.js +12044 -0
- package/dist/cjs/isSymbol-311eb805.js +209 -0
- package/dist/cjs/main-58839f4e.js +858 -0
- package/dist/cjs/visibility-sensor-5c5a7302.js +2251 -0
- package/dist/esm/AD-1b2a3dd3.js +26 -0
- package/dist/esm/DeckContent.js +424 -0
- package/dist/esm/DeckQueue.js +360 -0
- package/dist/esm/Dfp-ab7941d3.js +92 -0
- package/dist/esm/GridContent.js +607 -0
- package/dist/esm/GroupDeck.js +151 -0
- package/dist/esm/IssueContentDeck.js +76 -0
- package/dist/esm/IssueDeck.js +139 -0
- package/dist/esm/MasterDeck.js +334 -0
- package/dist/esm/Normal-403c5666.js +2354 -0
- package/dist/esm/PublicationDeck.js +76 -0
- package/dist/esm/QueueDeckExpanded.js +553 -0
- package/dist/esm/TaxonomyCard-f9c93953.js +1039 -0
- package/dist/esm/TaxonomyCard.js +12 -0
- package/dist/esm/TemplateNormal.js +23 -0
- package/dist/esm/ThumbnailCard.js +53 -0
- package/dist/esm/Ustream-6bb45fe7.js +116 -0
- package/dist/esm/Ustream.js +4 -0
- package/dist/esm/VideoSeriesListing.js +242 -0
- package/dist/esm/YoutubeGroup-06df4923.js +222 -0
- package/dist/esm/YoutubeGroup.js +7 -0
- package/dist/esm/_babelHelpers-67c05996.js +111 -0
- package/dist/esm/_commonjsHelpers-ae1b5db5.js +15 -0
- package/dist/esm/debounce-a0242b4a.js +277 -0
- package/dist/esm/entities-e85d3a4a.js +503 -0
- package/dist/esm/get-b684ff61.js +990 -0
- package/dist/esm/index-3c1ee9ab.js +605 -0
- package/dist/esm/index-ca4ff5cb.js +548 -0
- package/dist/esm/index.es-f369b3e8.js +5022 -0
- package/dist/esm/index.esm-536609db.js +103 -0
- package/dist/esm/index.js +11991 -0
- package/dist/esm/isSymbol-c2b7d05a.js +203 -0
- package/dist/esm/main-dea495b7.js +851 -0
- package/dist/esm/visibility-sensor-3cfe6713.js +2243 -0
- package/package.json +8 -7
- package/dist/index.es.js +0 -30261
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -30320
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,2251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var React__default = _interopDefault(React);
|
|
7
|
+
var _commonjsHelpers = require('./_commonjsHelpers-3fc1f64e.js');
|
|
8
|
+
var PropTypes = _interopDefault(require('prop-types'));
|
|
9
|
+
var reactDom = _interopDefault(require('react-dom'));
|
|
10
|
+
|
|
11
|
+
var domain;
|
|
12
|
+
|
|
13
|
+
// This constructor is used to store event handlers. Instantiating this is
|
|
14
|
+
// faster than explicitly calling `Object.create(null)` to get a "clean" empty
|
|
15
|
+
// object (tested with v8 v4.9).
|
|
16
|
+
function EventHandlers() {}
|
|
17
|
+
EventHandlers.prototype = Object.create(null);
|
|
18
|
+
|
|
19
|
+
function EventEmitter() {
|
|
20
|
+
EventEmitter.init.call(this);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// nodejs oddity
|
|
24
|
+
// require('events') === require('events').EventEmitter
|
|
25
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
26
|
+
|
|
27
|
+
EventEmitter.usingDomains = false;
|
|
28
|
+
|
|
29
|
+
EventEmitter.prototype.domain = undefined;
|
|
30
|
+
EventEmitter.prototype._events = undefined;
|
|
31
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
32
|
+
|
|
33
|
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
34
|
+
// added to it. This is a useful default which helps finding memory leaks.
|
|
35
|
+
EventEmitter.defaultMaxListeners = 10;
|
|
36
|
+
|
|
37
|
+
EventEmitter.init = function() {
|
|
38
|
+
this.domain = null;
|
|
39
|
+
if (EventEmitter.usingDomains) {
|
|
40
|
+
// if there is an active domain, then attach to it.
|
|
41
|
+
if (domain.active ) ;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
|
|
45
|
+
this._events = new EventHandlers();
|
|
46
|
+
this._eventsCount = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Obviously not all Emitters should be limited to 10. This function allows
|
|
53
|
+
// that to be increased. Set to zero for unlimited.
|
|
54
|
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
55
|
+
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
|
56
|
+
throw new TypeError('"n" argument must be a positive number');
|
|
57
|
+
this._maxListeners = n;
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function $getMaxListeners(that) {
|
|
62
|
+
if (that._maxListeners === undefined)
|
|
63
|
+
return EventEmitter.defaultMaxListeners;
|
|
64
|
+
return that._maxListeners;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
|
68
|
+
return $getMaxListeners(this);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// These standalone emit* functions are used to optimize calling of event
|
|
72
|
+
// handlers for fast cases because emit() itself often has a variable number of
|
|
73
|
+
// arguments and can be deoptimized because of that. These functions always have
|
|
74
|
+
// the same number of arguments and thus do not get deoptimized, so the code
|
|
75
|
+
// inside them can execute faster.
|
|
76
|
+
function emitNone(handler, isFn, self) {
|
|
77
|
+
if (isFn)
|
|
78
|
+
handler.call(self);
|
|
79
|
+
else {
|
|
80
|
+
var len = handler.length;
|
|
81
|
+
var listeners = arrayClone(handler, len);
|
|
82
|
+
for (var i = 0; i < len; ++i)
|
|
83
|
+
listeners[i].call(self);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function emitOne(handler, isFn, self, arg1) {
|
|
87
|
+
if (isFn)
|
|
88
|
+
handler.call(self, arg1);
|
|
89
|
+
else {
|
|
90
|
+
var len = handler.length;
|
|
91
|
+
var listeners = arrayClone(handler, len);
|
|
92
|
+
for (var i = 0; i < len; ++i)
|
|
93
|
+
listeners[i].call(self, arg1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function emitTwo(handler, isFn, self, arg1, arg2) {
|
|
97
|
+
if (isFn)
|
|
98
|
+
handler.call(self, arg1, arg2);
|
|
99
|
+
else {
|
|
100
|
+
var len = handler.length;
|
|
101
|
+
var listeners = arrayClone(handler, len);
|
|
102
|
+
for (var i = 0; i < len; ++i)
|
|
103
|
+
listeners[i].call(self, arg1, arg2);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
|
|
107
|
+
if (isFn)
|
|
108
|
+
handler.call(self, arg1, arg2, arg3);
|
|
109
|
+
else {
|
|
110
|
+
var len = handler.length;
|
|
111
|
+
var listeners = arrayClone(handler, len);
|
|
112
|
+
for (var i = 0; i < len; ++i)
|
|
113
|
+
listeners[i].call(self, arg1, arg2, arg3);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function emitMany(handler, isFn, self, args) {
|
|
118
|
+
if (isFn)
|
|
119
|
+
handler.apply(self, args);
|
|
120
|
+
else {
|
|
121
|
+
var len = handler.length;
|
|
122
|
+
var listeners = arrayClone(handler, len);
|
|
123
|
+
for (var i = 0; i < len; ++i)
|
|
124
|
+
listeners[i].apply(self, args);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
EventEmitter.prototype.emit = function emit(type) {
|
|
129
|
+
var er, handler, len, args, i, events, domain;
|
|
130
|
+
var doError = (type === 'error');
|
|
131
|
+
|
|
132
|
+
events = this._events;
|
|
133
|
+
if (events)
|
|
134
|
+
doError = (doError && events.error == null);
|
|
135
|
+
else if (!doError)
|
|
136
|
+
return false;
|
|
137
|
+
|
|
138
|
+
domain = this.domain;
|
|
139
|
+
|
|
140
|
+
// If there is no 'error' event listener then throw.
|
|
141
|
+
if (doError) {
|
|
142
|
+
er = arguments[1];
|
|
143
|
+
if (domain) {
|
|
144
|
+
if (!er)
|
|
145
|
+
er = new Error('Uncaught, unspecified "error" event');
|
|
146
|
+
er.domainEmitter = this;
|
|
147
|
+
er.domain = domain;
|
|
148
|
+
er.domainThrown = false;
|
|
149
|
+
domain.emit('error', er);
|
|
150
|
+
} else if (er instanceof Error) {
|
|
151
|
+
throw er; // Unhandled 'error' event
|
|
152
|
+
} else {
|
|
153
|
+
// At least give some kind of context to the user
|
|
154
|
+
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
|
155
|
+
err.context = er;
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
handler = events[type];
|
|
162
|
+
|
|
163
|
+
if (!handler)
|
|
164
|
+
return false;
|
|
165
|
+
|
|
166
|
+
var isFn = typeof handler === 'function';
|
|
167
|
+
len = arguments.length;
|
|
168
|
+
switch (len) {
|
|
169
|
+
// fast cases
|
|
170
|
+
case 1:
|
|
171
|
+
emitNone(handler, isFn, this);
|
|
172
|
+
break;
|
|
173
|
+
case 2:
|
|
174
|
+
emitOne(handler, isFn, this, arguments[1]);
|
|
175
|
+
break;
|
|
176
|
+
case 3:
|
|
177
|
+
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
|
178
|
+
break;
|
|
179
|
+
case 4:
|
|
180
|
+
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
|
181
|
+
break;
|
|
182
|
+
// slower
|
|
183
|
+
default:
|
|
184
|
+
args = new Array(len - 1);
|
|
185
|
+
for (i = 1; i < len; i++)
|
|
186
|
+
args[i - 1] = arguments[i];
|
|
187
|
+
emitMany(handler, isFn, this, args);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return true;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
function _addListener(target, type, listener, prepend) {
|
|
194
|
+
var m;
|
|
195
|
+
var events;
|
|
196
|
+
var existing;
|
|
197
|
+
|
|
198
|
+
if (typeof listener !== 'function')
|
|
199
|
+
throw new TypeError('"listener" argument must be a function');
|
|
200
|
+
|
|
201
|
+
events = target._events;
|
|
202
|
+
if (!events) {
|
|
203
|
+
events = target._events = new EventHandlers();
|
|
204
|
+
target._eventsCount = 0;
|
|
205
|
+
} else {
|
|
206
|
+
// To avoid recursion in the case that type === "newListener"! Before
|
|
207
|
+
// adding it to the listeners, first emit "newListener".
|
|
208
|
+
if (events.newListener) {
|
|
209
|
+
target.emit('newListener', type,
|
|
210
|
+
listener.listener ? listener.listener : listener);
|
|
211
|
+
|
|
212
|
+
// Re-assign `events` because a newListener handler could have caused the
|
|
213
|
+
// this._events to be assigned to a new object
|
|
214
|
+
events = target._events;
|
|
215
|
+
}
|
|
216
|
+
existing = events[type];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!existing) {
|
|
220
|
+
// Optimize the case of one listener. Don't need the extra array object.
|
|
221
|
+
existing = events[type] = listener;
|
|
222
|
+
++target._eventsCount;
|
|
223
|
+
} else {
|
|
224
|
+
if (typeof existing === 'function') {
|
|
225
|
+
// Adding the second element, need to change to array.
|
|
226
|
+
existing = events[type] = prepend ? [listener, existing] :
|
|
227
|
+
[existing, listener];
|
|
228
|
+
} else {
|
|
229
|
+
// If we've already got an array, just append.
|
|
230
|
+
if (prepend) {
|
|
231
|
+
existing.unshift(listener);
|
|
232
|
+
} else {
|
|
233
|
+
existing.push(listener);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Check for listener leak
|
|
238
|
+
if (!existing.warned) {
|
|
239
|
+
m = $getMaxListeners(target);
|
|
240
|
+
if (m && m > 0 && existing.length > m) {
|
|
241
|
+
existing.warned = true;
|
|
242
|
+
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
|
243
|
+
existing.length + ' ' + type + ' listeners added. ' +
|
|
244
|
+
'Use emitter.setMaxListeners() to increase limit');
|
|
245
|
+
w.name = 'MaxListenersExceededWarning';
|
|
246
|
+
w.emitter = target;
|
|
247
|
+
w.type = type;
|
|
248
|
+
w.count = existing.length;
|
|
249
|
+
emitWarning(w);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return target;
|
|
255
|
+
}
|
|
256
|
+
function emitWarning(e) {
|
|
257
|
+
typeof console.warn === 'function' ? console.warn(e) : console.log(e);
|
|
258
|
+
}
|
|
259
|
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
260
|
+
return _addListener(this, type, listener, false);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
264
|
+
|
|
265
|
+
EventEmitter.prototype.prependListener =
|
|
266
|
+
function prependListener(type, listener) {
|
|
267
|
+
return _addListener(this, type, listener, true);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
function _onceWrap(target, type, listener) {
|
|
271
|
+
var fired = false;
|
|
272
|
+
function g() {
|
|
273
|
+
target.removeListener(type, g);
|
|
274
|
+
if (!fired) {
|
|
275
|
+
fired = true;
|
|
276
|
+
listener.apply(target, arguments);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
g.listener = listener;
|
|
280
|
+
return g;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
EventEmitter.prototype.once = function once(type, listener) {
|
|
284
|
+
if (typeof listener !== 'function')
|
|
285
|
+
throw new TypeError('"listener" argument must be a function');
|
|
286
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
287
|
+
return this;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
EventEmitter.prototype.prependOnceListener =
|
|
291
|
+
function prependOnceListener(type, listener) {
|
|
292
|
+
if (typeof listener !== 'function')
|
|
293
|
+
throw new TypeError('"listener" argument must be a function');
|
|
294
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
295
|
+
return this;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// emits a 'removeListener' event iff the listener was removed
|
|
299
|
+
EventEmitter.prototype.removeListener =
|
|
300
|
+
function removeListener(type, listener) {
|
|
301
|
+
var list, events, position, i, originalListener;
|
|
302
|
+
|
|
303
|
+
if (typeof listener !== 'function')
|
|
304
|
+
throw new TypeError('"listener" argument must be a function');
|
|
305
|
+
|
|
306
|
+
events = this._events;
|
|
307
|
+
if (!events)
|
|
308
|
+
return this;
|
|
309
|
+
|
|
310
|
+
list = events[type];
|
|
311
|
+
if (!list)
|
|
312
|
+
return this;
|
|
313
|
+
|
|
314
|
+
if (list === listener || (list.listener && list.listener === listener)) {
|
|
315
|
+
if (--this._eventsCount === 0)
|
|
316
|
+
this._events = new EventHandlers();
|
|
317
|
+
else {
|
|
318
|
+
delete events[type];
|
|
319
|
+
if (events.removeListener)
|
|
320
|
+
this.emit('removeListener', type, list.listener || listener);
|
|
321
|
+
}
|
|
322
|
+
} else if (typeof list !== 'function') {
|
|
323
|
+
position = -1;
|
|
324
|
+
|
|
325
|
+
for (i = list.length; i-- > 0;) {
|
|
326
|
+
if (list[i] === listener ||
|
|
327
|
+
(list[i].listener && list[i].listener === listener)) {
|
|
328
|
+
originalListener = list[i].listener;
|
|
329
|
+
position = i;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (position < 0)
|
|
335
|
+
return this;
|
|
336
|
+
|
|
337
|
+
if (list.length === 1) {
|
|
338
|
+
list[0] = undefined;
|
|
339
|
+
if (--this._eventsCount === 0) {
|
|
340
|
+
this._events = new EventHandlers();
|
|
341
|
+
return this;
|
|
342
|
+
} else {
|
|
343
|
+
delete events[type];
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
spliceOne(list, position);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (events.removeListener)
|
|
350
|
+
this.emit('removeListener', type, originalListener || listener);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return this;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
EventEmitter.prototype.removeAllListeners =
|
|
357
|
+
function removeAllListeners(type) {
|
|
358
|
+
var listeners, events;
|
|
359
|
+
|
|
360
|
+
events = this._events;
|
|
361
|
+
if (!events)
|
|
362
|
+
return this;
|
|
363
|
+
|
|
364
|
+
// not listening for removeListener, no need to emit
|
|
365
|
+
if (!events.removeListener) {
|
|
366
|
+
if (arguments.length === 0) {
|
|
367
|
+
this._events = new EventHandlers();
|
|
368
|
+
this._eventsCount = 0;
|
|
369
|
+
} else if (events[type]) {
|
|
370
|
+
if (--this._eventsCount === 0)
|
|
371
|
+
this._events = new EventHandlers();
|
|
372
|
+
else
|
|
373
|
+
delete events[type];
|
|
374
|
+
}
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// emit removeListener for all listeners on all events
|
|
379
|
+
if (arguments.length === 0) {
|
|
380
|
+
var keys = Object.keys(events);
|
|
381
|
+
for (var i = 0, key; i < keys.length; ++i) {
|
|
382
|
+
key = keys[i];
|
|
383
|
+
if (key === 'removeListener') continue;
|
|
384
|
+
this.removeAllListeners(key);
|
|
385
|
+
}
|
|
386
|
+
this.removeAllListeners('removeListener');
|
|
387
|
+
this._events = new EventHandlers();
|
|
388
|
+
this._eventsCount = 0;
|
|
389
|
+
return this;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
listeners = events[type];
|
|
393
|
+
|
|
394
|
+
if (typeof listeners === 'function') {
|
|
395
|
+
this.removeListener(type, listeners);
|
|
396
|
+
} else if (listeners) {
|
|
397
|
+
// LIFO order
|
|
398
|
+
do {
|
|
399
|
+
this.removeListener(type, listeners[listeners.length - 1]);
|
|
400
|
+
} while (listeners[0]);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return this;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
EventEmitter.prototype.listeners = function listeners(type) {
|
|
407
|
+
var evlistener;
|
|
408
|
+
var ret;
|
|
409
|
+
var events = this._events;
|
|
410
|
+
|
|
411
|
+
if (!events)
|
|
412
|
+
ret = [];
|
|
413
|
+
else {
|
|
414
|
+
evlistener = events[type];
|
|
415
|
+
if (!evlistener)
|
|
416
|
+
ret = [];
|
|
417
|
+
else if (typeof evlistener === 'function')
|
|
418
|
+
ret = [evlistener.listener || evlistener];
|
|
419
|
+
else
|
|
420
|
+
ret = unwrapListeners(evlistener);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return ret;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
427
|
+
if (typeof emitter.listenerCount === 'function') {
|
|
428
|
+
return emitter.listenerCount(type);
|
|
429
|
+
} else {
|
|
430
|
+
return listenerCount.call(emitter, type);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
EventEmitter.prototype.listenerCount = listenerCount;
|
|
435
|
+
function listenerCount(type) {
|
|
436
|
+
var events = this._events;
|
|
437
|
+
|
|
438
|
+
if (events) {
|
|
439
|
+
var evlistener = events[type];
|
|
440
|
+
|
|
441
|
+
if (typeof evlistener === 'function') {
|
|
442
|
+
return 1;
|
|
443
|
+
} else if (evlistener) {
|
|
444
|
+
return evlistener.length;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return 0;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
452
|
+
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// About 1.5x faster than the two-arg version of Array#splice().
|
|
456
|
+
function spliceOne(list, index) {
|
|
457
|
+
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
|
|
458
|
+
list[i] = list[k];
|
|
459
|
+
list.pop();
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function arrayClone(arr, i) {
|
|
463
|
+
var copy = new Array(i);
|
|
464
|
+
while (i--)
|
|
465
|
+
copy[i] = arr[i];
|
|
466
|
+
return copy;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function unwrapListeners(arr) {
|
|
470
|
+
var ret = new Array(arr.length);
|
|
471
|
+
for (var i = 0; i < ret.length; ++i) {
|
|
472
|
+
ret[i] = arr[i].listener || arr[i];
|
|
473
|
+
}
|
|
474
|
+
return ret;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
var utils = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
478
|
+
|
|
479
|
+
Object.defineProperty(exports, "__esModule", {
|
|
480
|
+
value: true
|
|
481
|
+
});
|
|
482
|
+
exports.loadGPTScript = loadGPTScript;
|
|
483
|
+
|
|
484
|
+
function doloadGPTScript(resolve, reject) {
|
|
485
|
+
window.googletag = window.googletag || {};
|
|
486
|
+
window.googletag.cmd = window.googletag.cmd || [];
|
|
487
|
+
var scriptTag = document.createElement('script');
|
|
488
|
+
scriptTag.src = "".concat(document.location.protocol, "//securepubads.g.doubleclick.net/tag/js/gpt.js");
|
|
489
|
+
scriptTag.async = true;
|
|
490
|
+
scriptTag.type = 'text/javascript';
|
|
491
|
+
|
|
492
|
+
scriptTag.onerror = function scriptTagOnError(errs) {
|
|
493
|
+
reject(errs);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
scriptTag.onload = function scriptTagOnLoad() {
|
|
497
|
+
resolve(window.googletag);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
document.getElementsByTagName('head')[0].appendChild(scriptTag);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function loadGPTScript() {
|
|
504
|
+
return new Promise(function (resolve, reject) {
|
|
505
|
+
doloadGPTScript(resolve, reject);
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
_commonjsHelpers.unwrapExports(utils);
|
|
511
|
+
var utils_1 = utils.loadGPTScript;
|
|
512
|
+
|
|
513
|
+
var manager = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
514
|
+
|
|
515
|
+
Object.defineProperty(exports, "__esModule", {
|
|
516
|
+
value: true
|
|
517
|
+
});
|
|
518
|
+
exports.default = void 0;
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
var Utils = _interopRequireWildcard(utils);
|
|
523
|
+
|
|
524
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
525
|
+
|
|
526
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
527
|
+
|
|
528
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
529
|
+
|
|
530
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
531
|
+
|
|
532
|
+
var loadPromise = null;
|
|
533
|
+
var googleGPTScriptLoadPromise = null;
|
|
534
|
+
var singleRequestEnabled = true;
|
|
535
|
+
var disableInitialLoadEnabled = false;
|
|
536
|
+
var lazyLoadEnabled = false;
|
|
537
|
+
var lazyLoadConfig = null;
|
|
538
|
+
var servePersonalizedAds = true;
|
|
539
|
+
var registeredSlots = {};
|
|
540
|
+
var managerAlreadyInitialized = false;
|
|
541
|
+
var globalTargetingArguments = {};
|
|
542
|
+
var globalAdSenseAttributes = {};
|
|
543
|
+
var DFPManager = Object.assign(new EventEmitter.EventEmitter().setMaxListeners(0), {
|
|
544
|
+
singleRequestIsEnabled: function singleRequestIsEnabled() {
|
|
545
|
+
return singleRequestEnabled;
|
|
546
|
+
},
|
|
547
|
+
configureSingleRequest: function configureSingleRequest(value) {
|
|
548
|
+
singleRequestEnabled = !!value;
|
|
549
|
+
},
|
|
550
|
+
disableInitialLoadIsEnabled: function disableInitialLoadIsEnabled() {
|
|
551
|
+
return disableInitialLoadEnabled;
|
|
552
|
+
},
|
|
553
|
+
configureDisableInitialLoad: function configureDisableInitialLoad(value) {
|
|
554
|
+
disableInitialLoadEnabled = !!value;
|
|
555
|
+
},
|
|
556
|
+
configureLazyLoad: function configureLazyLoad() {
|
|
557
|
+
var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
558
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
559
|
+
var conf = null;
|
|
560
|
+
|
|
561
|
+
if (config !== null && _typeof(config) === 'object') {
|
|
562
|
+
conf = _objectSpread({}, config);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
lazyLoadEnabled = !!enable;
|
|
566
|
+
lazyLoadConfig = conf;
|
|
567
|
+
},
|
|
568
|
+
lazyLoadIsEnabled: function lazyLoadIsEnabled() {
|
|
569
|
+
return lazyLoadEnabled;
|
|
570
|
+
},
|
|
571
|
+
getLazyLoadConfig: function getLazyLoadConfig() {
|
|
572
|
+
return lazyLoadConfig;
|
|
573
|
+
},
|
|
574
|
+
getAdSenseAttribute: function getAdSenseAttribute(key) {
|
|
575
|
+
return globalAdSenseAttributes[key];
|
|
576
|
+
},
|
|
577
|
+
configurePersonalizedAds: function configurePersonalizedAds(value) {
|
|
578
|
+
servePersonalizedAds = value;
|
|
579
|
+
},
|
|
580
|
+
personalizedAdsEnabled: function personalizedAdsEnabled() {
|
|
581
|
+
return servePersonalizedAds;
|
|
582
|
+
},
|
|
583
|
+
setAdSenseAttribute: function setAdSenseAttribute(key, value) {
|
|
584
|
+
this.setAdSenseAttributes(_defineProperty({}, key, value));
|
|
585
|
+
},
|
|
586
|
+
getAdSenseAttributes: function getAdSenseAttributes() {
|
|
587
|
+
return _objectSpread({}, globalAdSenseAttributes);
|
|
588
|
+
},
|
|
589
|
+
setAdSenseAttributes: function setAdSenseAttributes(attrs) {
|
|
590
|
+
Object.assign(globalAdSenseAttributes, attrs);
|
|
591
|
+
|
|
592
|
+
if (managerAlreadyInitialized === true) {
|
|
593
|
+
this.getGoogletag().then(function (googletag) {
|
|
594
|
+
googletag.cmd.push(function () {
|
|
595
|
+
var pubadsService = googletag.pubads();
|
|
596
|
+
Object.keys(globalAdSenseAttributes).forEach(function (key) {
|
|
597
|
+
pubadsService.set(key, globalTargetingArguments[key]);
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
setTargetingArguments: function setTargetingArguments(data) {
|
|
604
|
+
Object.assign(globalTargetingArguments, data);
|
|
605
|
+
|
|
606
|
+
if (managerAlreadyInitialized === true) {
|
|
607
|
+
this.getGoogletag().then(function (googletag) {
|
|
608
|
+
googletag.cmd.push(function () {
|
|
609
|
+
var pubadsService = googletag.pubads();
|
|
610
|
+
Object.keys(globalTargetingArguments).forEach(function (varName) {
|
|
611
|
+
if (pubadsService) {
|
|
612
|
+
pubadsService.setTargeting(varName, globalTargetingArguments[varName]);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
getTargetingArguments: function getTargetingArguments() {
|
|
620
|
+
return _objectSpread({}, globalTargetingArguments);
|
|
621
|
+
},
|
|
622
|
+
getSlotProperty: function getSlotProperty(slotId, propName) {
|
|
623
|
+
var slot = this.getRegisteredSlots()[slotId];
|
|
624
|
+
var ret = null;
|
|
625
|
+
|
|
626
|
+
if (slot !== undefined) {
|
|
627
|
+
ret = slot[propName] || ret;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
return ret;
|
|
631
|
+
},
|
|
632
|
+
getSlotTargetingArguments: function getSlotTargetingArguments(slotId) {
|
|
633
|
+
var propValue = this.getSlotProperty(slotId, 'targetingArguments');
|
|
634
|
+
return propValue ? _objectSpread({}, propValue) : null;
|
|
635
|
+
},
|
|
636
|
+
getSlotAdSenseAttributes: function getSlotAdSenseAttributes(slotId) {
|
|
637
|
+
var propValue = this.getSlotProperty(slotId, 'adSenseAttributes');
|
|
638
|
+
return propValue ? _objectSpread({}, propValue) : null;
|
|
639
|
+
},
|
|
640
|
+
init: function init() {
|
|
641
|
+
var _this = this;
|
|
642
|
+
|
|
643
|
+
if (managerAlreadyInitialized === false) {
|
|
644
|
+
managerAlreadyInitialized = true;
|
|
645
|
+
this.getGoogletag().then(function (googletag) {
|
|
646
|
+
googletag.cmd.push(function () {
|
|
647
|
+
var pubadsService = googletag.pubads();
|
|
648
|
+
pubadsService.addEventListener('slotRenderEnded', function (event) {
|
|
649
|
+
var slotId = event.slot.getSlotElementId();
|
|
650
|
+
|
|
651
|
+
_this.emit('slotRenderEnded', {
|
|
652
|
+
slotId: slotId,
|
|
653
|
+
event: event
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
pubadsService.addEventListener('impressionViewable', function (event) {
|
|
657
|
+
var slotId = event.slot.getSlotElementId();
|
|
658
|
+
|
|
659
|
+
_this.emit('impressionViewable', {
|
|
660
|
+
slotId: slotId,
|
|
661
|
+
event: event
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
pubadsService.addEventListener('slotVisibilityChanged', function (event) {
|
|
665
|
+
var slotId = event.slot.getSlotElementId();
|
|
666
|
+
|
|
667
|
+
_this.emit('slotVisibilityChanged', {
|
|
668
|
+
slotId: slotId,
|
|
669
|
+
event: event
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
pubadsService.setRequestNonPersonalizedAds(_this.personalizedAdsEnabled() ? 0 : 1);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
getGoogletag: function getGoogletag() {
|
|
678
|
+
if (googleGPTScriptLoadPromise === null) {
|
|
679
|
+
googleGPTScriptLoadPromise = Utils.loadGPTScript();
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return googleGPTScriptLoadPromise;
|
|
683
|
+
},
|
|
684
|
+
setCollapseEmptyDivs: function setCollapseEmptyDivs(collapse) {
|
|
685
|
+
this.collapseEmptyDivs = collapse;
|
|
686
|
+
},
|
|
687
|
+
load: function load() {
|
|
688
|
+
var _this2 = this;
|
|
689
|
+
|
|
690
|
+
for (var _len = arguments.length, slots = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
691
|
+
slots[_key] = arguments[_key];
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (loadPromise === null) {
|
|
695
|
+
loadPromise = this.doLoad.apply(this, slots);
|
|
696
|
+
} else {
|
|
697
|
+
loadPromise = loadPromise.then(function () {
|
|
698
|
+
return _this2.doLoad.apply(_this2, slots);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
doLoad: function doLoad() {
|
|
703
|
+
this.init();
|
|
704
|
+
var availableSlots = {};
|
|
705
|
+
|
|
706
|
+
for (var _len2 = arguments.length, slots = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
707
|
+
slots[_key2] = arguments[_key2];
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (slots.length > 0) {
|
|
711
|
+
availableSlots = slots.filter(function (slotId) {
|
|
712
|
+
return Object.prototype.hasOwnProperty.call(registeredSlots, slotId);
|
|
713
|
+
});
|
|
714
|
+
} else {
|
|
715
|
+
availableSlots = Object.keys(registeredSlots);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
availableSlots = availableSlots.filter(function (id) {
|
|
719
|
+
return !registeredSlots[id].loading && !registeredSlots[id].gptSlot;
|
|
720
|
+
});
|
|
721
|
+
availableSlots.forEach(function (slotId) {
|
|
722
|
+
registeredSlots[slotId].loading = true;
|
|
723
|
+
});
|
|
724
|
+
return this.gptLoadAds(availableSlots);
|
|
725
|
+
},
|
|
726
|
+
gptLoadAds: function gptLoadAds(slotsToInitialize) {
|
|
727
|
+
var _this3 = this;
|
|
728
|
+
|
|
729
|
+
return new Promise(function (resolve) {
|
|
730
|
+
_this3.getGoogletag().then(function (googletag) {
|
|
731
|
+
_this3.configureInitialOptions(googletag);
|
|
732
|
+
|
|
733
|
+
slotsToInitialize.forEach(function (currentSlotId) {
|
|
734
|
+
registeredSlots[currentSlotId].loading = false;
|
|
735
|
+
googletag.cmd.push(function () {
|
|
736
|
+
var slot = registeredSlots[currentSlotId];
|
|
737
|
+
var gptSlot;
|
|
738
|
+
var adUnit = "".concat(slot.dfpNetworkId, "/").concat(slot.adUnit);
|
|
739
|
+
|
|
740
|
+
if (slot.renderOutOfThePage === true) {
|
|
741
|
+
gptSlot = googletag.defineOutOfPageSlot(adUnit, currentSlotId);
|
|
742
|
+
} else {
|
|
743
|
+
gptSlot = googletag.defineSlot(adUnit, slot.sizes, currentSlotId);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (gptSlot !== null) {
|
|
747
|
+
slot.gptSlot = gptSlot;
|
|
748
|
+
|
|
749
|
+
var slotTargetingArguments = _this3.getSlotTargetingArguments(currentSlotId);
|
|
750
|
+
|
|
751
|
+
if (slotTargetingArguments !== null) {
|
|
752
|
+
Object.keys(slotTargetingArguments).forEach(function (varName) {
|
|
753
|
+
if (slot && slot.gptSlot) {
|
|
754
|
+
slot.gptSlot.setTargeting(varName, slotTargetingArguments[varName]);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
var slotAdSenseAttributes = _this3.getSlotAdSenseAttributes(currentSlotId);
|
|
760
|
+
|
|
761
|
+
if (slotAdSenseAttributes !== null) {
|
|
762
|
+
Object.keys(slotAdSenseAttributes).forEach(function (varName) {
|
|
763
|
+
slot.gptSlot.set(varName, slotAdSenseAttributes[varName]);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
slot.gptSlot.addService(googletag.pubads());
|
|
768
|
+
|
|
769
|
+
if (slot.sizeMapping) {
|
|
770
|
+
var smbuilder = googletag.sizeMapping();
|
|
771
|
+
slot.sizeMapping.forEach(function (mapping) {
|
|
772
|
+
smbuilder = smbuilder.addSize(mapping.viewport, mapping.sizes);
|
|
773
|
+
});
|
|
774
|
+
slot.gptSlot.defineSizeMapping(smbuilder.build());
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
_this3.configureOptions(googletag);
|
|
781
|
+
|
|
782
|
+
googletag.cmd.push(function () {
|
|
783
|
+
googletag.enableServices();
|
|
784
|
+
|
|
785
|
+
if (!_this3.disableInitialLoadIsEnabled()) {
|
|
786
|
+
slotsToInitialize.forEach(function (theSlotId) {
|
|
787
|
+
googletag.display(theSlotId);
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
resolve();
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
},
|
|
796
|
+
// configure those gpt parameters that need to be set before pubsads service
|
|
797
|
+
// initialization.
|
|
798
|
+
configureInitialOptions: function configureInitialOptions(googletag) {
|
|
799
|
+
var _this4 = this;
|
|
800
|
+
|
|
801
|
+
googletag.cmd.push(function () {
|
|
802
|
+
if (_this4.disableInitialLoadIsEnabled()) {
|
|
803
|
+
googletag.pubads().disableInitialLoad();
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
},
|
|
807
|
+
configureOptions: function configureOptions(googletag) {
|
|
808
|
+
var _this5 = this;
|
|
809
|
+
|
|
810
|
+
googletag.cmd.push(function () {
|
|
811
|
+
var pubadsService = googletag.pubads();
|
|
812
|
+
pubadsService.setRequestNonPersonalizedAds(_this5.personalizedAdsEnabled() ? 0 : 1);
|
|
813
|
+
|
|
814
|
+
var targetingArguments = _this5.getTargetingArguments(); // set global targetting arguments
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
Object.keys(targetingArguments).forEach(function (varName) {
|
|
818
|
+
if (pubadsService) {
|
|
819
|
+
pubadsService.setTargeting(varName, targetingArguments[varName]);
|
|
820
|
+
}
|
|
821
|
+
}); // set global adSense attributes
|
|
822
|
+
|
|
823
|
+
var adSenseAttributes = _this5.getAdSenseAttributes();
|
|
824
|
+
|
|
825
|
+
Object.keys(adSenseAttributes).forEach(function (key) {
|
|
826
|
+
pubadsService.set(key, adSenseAttributes[key]);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
if (_this5.lazyLoadIsEnabled()) {
|
|
830
|
+
var args = [];
|
|
831
|
+
|
|
832
|
+
var config = _this5.getLazyLoadConfig();
|
|
833
|
+
|
|
834
|
+
if (config !== null) {
|
|
835
|
+
args.push(config);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
pubadsService.enableLazyLoad.call(args);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
if (_this5.singleRequestIsEnabled()) {
|
|
842
|
+
pubadsService.enableSingleRequest();
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (_this5.collapseEmptyDivs === true || _this5.collapseEmptyDivs === false) {
|
|
846
|
+
pubadsService.collapseEmptyDivs(_this5.collapseEmptyDivs);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
},
|
|
850
|
+
getRefreshableSlots: function getRefreshableSlots() {
|
|
851
|
+
var slots = {};
|
|
852
|
+
|
|
853
|
+
for (var _len3 = arguments.length, slotsArray = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
854
|
+
slotsArray[_key3] = arguments[_key3];
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
if (slotsArray.length === 0) {
|
|
858
|
+
var slotsToRefresh = Object.keys(registeredSlots).map(function (k) {
|
|
859
|
+
return registeredSlots[k];
|
|
860
|
+
});
|
|
861
|
+
return slotsToRefresh.reduce(function (last, slot) {
|
|
862
|
+
if (slot.slotShouldRefresh() === true) {
|
|
863
|
+
slots[slot.slotId] = slot;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
return slots;
|
|
867
|
+
}, slots);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
return slotsArray.reduce(function (last, slotId) {
|
|
871
|
+
var slot = registeredSlots[slotId];
|
|
872
|
+
|
|
873
|
+
if (typeof slot !== 'undefined') {
|
|
874
|
+
slots[slotId] = slot;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return slots;
|
|
878
|
+
}, slots);
|
|
879
|
+
},
|
|
880
|
+
refresh: function refresh() {
|
|
881
|
+
if (loadPromise === null) {
|
|
882
|
+
this.load();
|
|
883
|
+
} else {
|
|
884
|
+
this.gptRefreshAds(Object.keys(this.getRefreshableSlots.apply(this, arguments)));
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
gptRefreshAds: function gptRefreshAds(slots) {
|
|
888
|
+
var _this6 = this;
|
|
889
|
+
|
|
890
|
+
return this.getGoogletag().then(function (googletag) {
|
|
891
|
+
_this6.configureOptions(googletag);
|
|
892
|
+
|
|
893
|
+
googletag.cmd.push(function () {
|
|
894
|
+
var pubadsService = googletag.pubads();
|
|
895
|
+
pubadsService.refresh(slots.map(function (slotId) {
|
|
896
|
+
return registeredSlots[slotId].gptSlot;
|
|
897
|
+
}));
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
},
|
|
901
|
+
reload: function reload() {
|
|
902
|
+
var _this7 = this;
|
|
903
|
+
|
|
904
|
+
return this.destroyGPTSlots.apply(this, arguments).then(function () {
|
|
905
|
+
return _this7.load();
|
|
906
|
+
});
|
|
907
|
+
},
|
|
908
|
+
destroyGPTSlots: function destroyGPTSlots() {
|
|
909
|
+
var _this8 = this;
|
|
910
|
+
|
|
911
|
+
for (var _len4 = arguments.length, slotsToDestroy = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
912
|
+
slotsToDestroy[_key4] = arguments[_key4];
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
if (slotsToDestroy.length === 0) {
|
|
916
|
+
// eslint-disable-next-line no-param-reassign
|
|
917
|
+
slotsToDestroy = Object.keys(registeredSlots);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
return new Promise(function (resolve) {
|
|
921
|
+
var slots = []; // eslint-disable-next-line guard-for-in,no-restricted-syntax
|
|
922
|
+
|
|
923
|
+
for (var idx in slotsToDestroy) {
|
|
924
|
+
var slotId = slotsToDestroy[idx];
|
|
925
|
+
var slot = registeredSlots[slotId];
|
|
926
|
+
slots.push(slot);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
_this8.getGoogletag().then(function (googletag) {
|
|
930
|
+
googletag.cmd.push(function () {
|
|
931
|
+
if (managerAlreadyInitialized === true) {
|
|
932
|
+
if (slotsToDestroy.length > 0) {
|
|
933
|
+
// eslint-disable-next-line guard-for-in,no-restricted-syntax
|
|
934
|
+
for (var _idx in slots) {
|
|
935
|
+
var _slot = slots[_idx];
|
|
936
|
+
slots.push(_slot.gptSlot);
|
|
937
|
+
delete _slot.gptSlot;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
googletag.destroySlots(slots);
|
|
941
|
+
} else {
|
|
942
|
+
googletag.destroySlots();
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
resolve(slotsToDestroy);
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
},
|
|
951
|
+
registerSlot: function registerSlot(_ref) {
|
|
952
|
+
var _this9 = this;
|
|
953
|
+
|
|
954
|
+
var slotId = _ref.slotId,
|
|
955
|
+
dfpNetworkId = _ref.dfpNetworkId,
|
|
956
|
+
adUnit = _ref.adUnit,
|
|
957
|
+
sizes = _ref.sizes,
|
|
958
|
+
renderOutOfThePage = _ref.renderOutOfThePage,
|
|
959
|
+
sizeMapping = _ref.sizeMapping,
|
|
960
|
+
adSenseAttributes = _ref.adSenseAttributes,
|
|
961
|
+
targetingArguments = _ref.targetingArguments,
|
|
962
|
+
slotShouldRefresh = _ref.slotShouldRefresh;
|
|
963
|
+
var autoLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
964
|
+
|
|
965
|
+
if (!Object.prototype.hasOwnProperty.call(registeredSlots, slotId)) {
|
|
966
|
+
registeredSlots[slotId] = {
|
|
967
|
+
slotId: slotId,
|
|
968
|
+
sizes: sizes,
|
|
969
|
+
renderOutOfThePage: renderOutOfThePage,
|
|
970
|
+
dfpNetworkId: dfpNetworkId,
|
|
971
|
+
adUnit: adUnit,
|
|
972
|
+
adSenseAttributes: adSenseAttributes,
|
|
973
|
+
targetingArguments: targetingArguments,
|
|
974
|
+
sizeMapping: sizeMapping,
|
|
975
|
+
slotShouldRefresh: slotShouldRefresh,
|
|
976
|
+
loading: false
|
|
977
|
+
};
|
|
978
|
+
this.emit('slotRegistered', {
|
|
979
|
+
slotId: slotId
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
if (autoLoad === true && loadPromise !== null) {
|
|
983
|
+
loadPromise = loadPromise.catch().then(function () {
|
|
984
|
+
var slot = registeredSlots[slotId];
|
|
985
|
+
|
|
986
|
+
if (typeof slot !== 'undefined') {
|
|
987
|
+
var loading = slot.loading,
|
|
988
|
+
gptSlot = slot.gptSlot;
|
|
989
|
+
|
|
990
|
+
if (loading === false && !gptSlot) {
|
|
991
|
+
_this9.load(slotId);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
},
|
|
998
|
+
unregisterSlot: function unregisterSlot(_ref2) {
|
|
999
|
+
var slotId = _ref2.slotId;
|
|
1000
|
+
this.destroyGPTSlots(slotId);
|
|
1001
|
+
delete registeredSlots[slotId];
|
|
1002
|
+
},
|
|
1003
|
+
getRegisteredSlots: function getRegisteredSlots() {
|
|
1004
|
+
return registeredSlots;
|
|
1005
|
+
},
|
|
1006
|
+
attachSlotRenderEnded: function attachSlotRenderEnded(cb) {
|
|
1007
|
+
this.on('slotRenderEnded', cb);
|
|
1008
|
+
},
|
|
1009
|
+
detachSlotRenderEnded: function detachSlotRenderEnded(cb) {
|
|
1010
|
+
this.removeListener('slotRenderEnded', cb);
|
|
1011
|
+
},
|
|
1012
|
+
attachSlotVisibilityChanged: function attachSlotVisibilityChanged(cb) {
|
|
1013
|
+
this.on('slotVisibilityChanged', cb);
|
|
1014
|
+
},
|
|
1015
|
+
detachSlotVisibilityChanged: function detachSlotVisibilityChanged(cb) {
|
|
1016
|
+
this.removeListener('slotVisibilityChanged', cb);
|
|
1017
|
+
},
|
|
1018
|
+
attachSlotIsViewable: function attachSlotIsViewable(cb) {
|
|
1019
|
+
this.on('impressionViewable', cb);
|
|
1020
|
+
},
|
|
1021
|
+
detachSlotIsViewable: function detachSlotIsViewable(cb) {
|
|
1022
|
+
this.removeListener('impressionViewable', cb);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
var _default = DFPManager;
|
|
1026
|
+
exports.default = _default;
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
_commonjsHelpers.unwrapExports(manager);
|
|
1030
|
+
|
|
1031
|
+
var dfpslotsprovider = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
1032
|
+
|
|
1033
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1034
|
+
value: true
|
|
1035
|
+
});
|
|
1036
|
+
exports.default = exports.Context = void 0;
|
|
1037
|
+
|
|
1038
|
+
var _react = _interopRequireDefault(React__default);
|
|
1039
|
+
|
|
1040
|
+
var _propTypes = _interopRequireDefault(PropTypes);
|
|
1041
|
+
|
|
1042
|
+
var _manager = _interopRequireDefault(manager);
|
|
1043
|
+
|
|
1044
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1045
|
+
|
|
1046
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
1047
|
+
|
|
1048
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1049
|
+
|
|
1050
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1051
|
+
|
|
1052
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1053
|
+
|
|
1054
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1055
|
+
|
|
1056
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1057
|
+
|
|
1058
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1059
|
+
|
|
1060
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1061
|
+
|
|
1062
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1063
|
+
|
|
1064
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1065
|
+
|
|
1066
|
+
// React.createContext is undefined for React < 16.3
|
|
1067
|
+
var Context = _react.default.createContext ? _react.default.createContext({
|
|
1068
|
+
dfpNetworkId: null,
|
|
1069
|
+
dfpAdUnit: null,
|
|
1070
|
+
dfpSizeMapping: null,
|
|
1071
|
+
dfpTargetingArguments: null,
|
|
1072
|
+
newSlotCallback: null
|
|
1073
|
+
}) : null;
|
|
1074
|
+
exports.Context = Context;
|
|
1075
|
+
|
|
1076
|
+
var DFPSlotsProvider =
|
|
1077
|
+
/*#__PURE__*/
|
|
1078
|
+
function (_React$Component) {
|
|
1079
|
+
_inherits(DFPSlotsProvider, _React$Component);
|
|
1080
|
+
|
|
1081
|
+
function DFPSlotsProvider(props) {
|
|
1082
|
+
var _this;
|
|
1083
|
+
|
|
1084
|
+
_classCallCheck(this, DFPSlotsProvider);
|
|
1085
|
+
|
|
1086
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(DFPSlotsProvider).call(this, props));
|
|
1087
|
+
_this.loadAdsIfPossible = _this.loadAdsIfPossible.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1088
|
+
_this.newSlotCallback = _this.newSlotCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1089
|
+
_this.applyConfigs = _this.applyConfigs.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1090
|
+
_this.shouldReloadConfig = _this.shouldReloadConfig.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1091
|
+
_this.attachLoadCallback = _this.attachLoadCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1092
|
+
_this.getContextValue = _this.getContextValue.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1093
|
+
_this.loadAlreadyCalled = false;
|
|
1094
|
+
_this.loadCallbackAttached = false;
|
|
1095
|
+
_this.shouldReloadAds = false;
|
|
1096
|
+
_this.totalSlots = 0;
|
|
1097
|
+
_this.contextValue = {};
|
|
1098
|
+
|
|
1099
|
+
if (Context === null) {
|
|
1100
|
+
_this.getChildContext = function () {
|
|
1101
|
+
return _this.getContextValue();
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
return _this;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
_createClass(DFPSlotsProvider, [{
|
|
1109
|
+
key: "componentDidMount",
|
|
1110
|
+
value: function componentDidMount() {
|
|
1111
|
+
this.applyConfigs();
|
|
1112
|
+
|
|
1113
|
+
if (this.props.autoLoad && !this.loadAdsIfPossible()) {
|
|
1114
|
+
this.attachLoadCallback();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}, {
|
|
1118
|
+
key: "shouldComponentUpdate",
|
|
1119
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
1120
|
+
this.shouldReloadAds = this.shouldReloadConfig(nextProps);
|
|
1121
|
+
|
|
1122
|
+
if (nextProps.children !== this.props.children) {
|
|
1123
|
+
return true;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (nextProps.autoLoad && !this.props.autoLoad) {
|
|
1127
|
+
return true;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return this.shouldReloadAds;
|
|
1131
|
+
}
|
|
1132
|
+
}, {
|
|
1133
|
+
key: "componentDidUpdate",
|
|
1134
|
+
value: function componentDidUpdate() {
|
|
1135
|
+
this.applyConfigs();
|
|
1136
|
+
|
|
1137
|
+
if (this.props.autoLoad) {
|
|
1138
|
+
if (this.loadAlreadyCalled) {
|
|
1139
|
+
if (this.shouldReloadAds) {
|
|
1140
|
+
_manager.default.reload();
|
|
1141
|
+
}
|
|
1142
|
+
} else if (!this.loadAdsIfPossible()) {
|
|
1143
|
+
this.attachLoadCallback();
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
this.shouldReloadAds = false;
|
|
1148
|
+
}
|
|
1149
|
+
}, {
|
|
1150
|
+
key: "getContextValue",
|
|
1151
|
+
value: function getContextValue() {
|
|
1152
|
+
var _this$props = this.props,
|
|
1153
|
+
dfpNetworkId = _this$props.dfpNetworkId,
|
|
1154
|
+
dfpAdUnit = _this$props.adUnit,
|
|
1155
|
+
dfpSizeMapping = _this$props.sizeMapping,
|
|
1156
|
+
dfpTargetingArguments = _this$props.targetingArguments,
|
|
1157
|
+
_this$contextValue = this.contextValue,
|
|
1158
|
+
ctxDfpNetworkId = _this$contextValue.dfpNetworkId,
|
|
1159
|
+
ctxDfpAdUnit = _this$contextValue.adUnit,
|
|
1160
|
+
ctxDfpSizeMapping = _this$contextValue.sizeMapping,
|
|
1161
|
+
ctxDfpTargetingArguments = _this$contextValue.targetingArguments; // performance: update context value object only when any of its
|
|
1162
|
+
// props is updated.
|
|
1163
|
+
|
|
1164
|
+
if (dfpNetworkId !== ctxDfpNetworkId || dfpAdUnit !== ctxDfpAdUnit || dfpSizeMapping !== ctxDfpSizeMapping || dfpTargetingArguments !== ctxDfpTargetingArguments) {
|
|
1165
|
+
this.contextValue = {
|
|
1166
|
+
dfpNetworkId: dfpNetworkId,
|
|
1167
|
+
dfpAdUnit: dfpAdUnit,
|
|
1168
|
+
dfpSizeMapping: dfpSizeMapping,
|
|
1169
|
+
dfpTargetingArguments: dfpTargetingArguments,
|
|
1170
|
+
newSlotCallback: this.newSlotCallback
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
return this.contextValue;
|
|
1175
|
+
}
|
|
1176
|
+
}, {
|
|
1177
|
+
key: "applyConfigs",
|
|
1178
|
+
value: function applyConfigs() {
|
|
1179
|
+
_manager.default.configurePersonalizedAds(this.props.personalizedAds);
|
|
1180
|
+
|
|
1181
|
+
_manager.default.configureSingleRequest(this.props.singleRequest);
|
|
1182
|
+
|
|
1183
|
+
_manager.default.configureDisableInitialLoad(this.props.disableInitialLoad);
|
|
1184
|
+
|
|
1185
|
+
_manager.default.configureLazyLoad(!!this.props.lazyLoad, typeof this.props.lazyLoad === 'boolean' ? null : this.props.lazyLoad);
|
|
1186
|
+
|
|
1187
|
+
_manager.default.setAdSenseAttributes(this.props.adSenseAttributes);
|
|
1188
|
+
|
|
1189
|
+
_manager.default.setCollapseEmptyDivs(this.props.collapseEmptyDivs);
|
|
1190
|
+
}
|
|
1191
|
+
}, {
|
|
1192
|
+
key: "attachLoadCallback",
|
|
1193
|
+
value: function attachLoadCallback() {
|
|
1194
|
+
if (this.loadCallbackAttached === false) {
|
|
1195
|
+
_manager.default.on('slotRegistered', this.loadAdsIfPossible);
|
|
1196
|
+
|
|
1197
|
+
this.loadCallbackAttached = true;
|
|
1198
|
+
return true;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
return false;
|
|
1202
|
+
} // pretty strait-forward interface that children ad slots use to register
|
|
1203
|
+
// with their DFPSlotProvider parent node.
|
|
1204
|
+
|
|
1205
|
+
}, {
|
|
1206
|
+
key: "newSlotCallback",
|
|
1207
|
+
value: function newSlotCallback() {
|
|
1208
|
+
this.totalSlots++;
|
|
1209
|
+
} // Checks all the mounted children ads have been already registered
|
|
1210
|
+
// in the DFPManager before trying to call the gpt load scripts.
|
|
1211
|
+
// This is helpful when trying to fetch ads with a single request.
|
|
1212
|
+
|
|
1213
|
+
}, {
|
|
1214
|
+
key: "loadAdsIfPossible",
|
|
1215
|
+
value: function loadAdsIfPossible() {
|
|
1216
|
+
var r = false;
|
|
1217
|
+
|
|
1218
|
+
if (Object.keys(_manager.default.getRegisteredSlots()).length >= this.totalSlots) {
|
|
1219
|
+
_manager.default.removeListener('slotRegistered', this.loadAdsIfPossible);
|
|
1220
|
+
|
|
1221
|
+
_manager.default.load();
|
|
1222
|
+
|
|
1223
|
+
this.loadAlreadyCalled = true;
|
|
1224
|
+
this.loadCallbackAttached = false;
|
|
1225
|
+
r = true;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
return r;
|
|
1229
|
+
}
|
|
1230
|
+
}, {
|
|
1231
|
+
key: "shouldReloadConfig",
|
|
1232
|
+
value: function shouldReloadConfig(nextProps) {
|
|
1233
|
+
var reloadConfig = nextProps.autoReload || this.props.autoReload;
|
|
1234
|
+
|
|
1235
|
+
if (this.props.autoLoad || nextProps.autoLoad) {
|
|
1236
|
+
if (_typeof(reloadConfig) === 'object') {
|
|
1237
|
+
var attrs = Object.keys(reloadConfig); // eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
1238
|
+
|
|
1239
|
+
for (var i in attrs) {
|
|
1240
|
+
var propName = attrs[i]; // eslint-disable-next-line
|
|
1241
|
+
|
|
1242
|
+
if (reloadConfig[propName] === true && this.props[propName] !== nextProps[propName]) {
|
|
1243
|
+
return true;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
return false;
|
|
1250
|
+
}
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "render",
|
|
1253
|
+
value: function render() {
|
|
1254
|
+
var children = this.props.children;
|
|
1255
|
+
|
|
1256
|
+
if (Context === null) {
|
|
1257
|
+
return children;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
return _react.default.createElement(Context.Provider, {
|
|
1261
|
+
value: this.getContextValue()
|
|
1262
|
+
}, children);
|
|
1263
|
+
}
|
|
1264
|
+
}]);
|
|
1265
|
+
|
|
1266
|
+
return DFPSlotsProvider;
|
|
1267
|
+
}(_react.default.Component);
|
|
1268
|
+
|
|
1269
|
+
exports.default = DFPSlotsProvider;
|
|
1270
|
+
|
|
1271
|
+
_defineProperty(DFPSlotsProvider, "propTypes", {
|
|
1272
|
+
children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.array]).isRequired,
|
|
1273
|
+
autoLoad: _propTypes.default.bool,
|
|
1274
|
+
autoReload: _propTypes.default.shape({
|
|
1275
|
+
dfpNetworkId: _propTypes.default.bool,
|
|
1276
|
+
personalizedAds: _propTypes.default.bool,
|
|
1277
|
+
singleRequest: _propTypes.default.bool,
|
|
1278
|
+
disableInitialLoad: _propTypes.default.bool,
|
|
1279
|
+
adUnit: _propTypes.default.bool,
|
|
1280
|
+
sizeMapping: _propTypes.default.bool,
|
|
1281
|
+
adSenseAttributes: _propTypes.default.bool,
|
|
1282
|
+
targetingArguments: _propTypes.default.bool,
|
|
1283
|
+
collapseEmptyDivs: _propTypes.default.bool,
|
|
1284
|
+
lazyLoad: _propTypes.default.bool
|
|
1285
|
+
}),
|
|
1286
|
+
dfpNetworkId: _propTypes.default.string.isRequired,
|
|
1287
|
+
personalizedAds: _propTypes.default.bool,
|
|
1288
|
+
singleRequest: _propTypes.default.bool,
|
|
1289
|
+
disableInitialLoad: _propTypes.default.bool,
|
|
1290
|
+
adUnit: _propTypes.default.string,
|
|
1291
|
+
sizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
1292
|
+
adSenseAttributes: _propTypes.default.object,
|
|
1293
|
+
targetingArguments: _propTypes.default.object,
|
|
1294
|
+
collapseEmptyDivs: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
|
|
1295
|
+
adSenseAttrs: _propTypes.default.object,
|
|
1296
|
+
lazyLoad: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.shape({
|
|
1297
|
+
fetchMarginPercent: _propTypes.default.number,
|
|
1298
|
+
renderMarginPercent: _propTypes.default.number,
|
|
1299
|
+
mobileScaling: _propTypes.default.number
|
|
1300
|
+
})])
|
|
1301
|
+
});
|
|
1302
|
+
|
|
1303
|
+
_defineProperty(DFPSlotsProvider, "defaultProps", {
|
|
1304
|
+
autoLoad: true,
|
|
1305
|
+
autoReload: {
|
|
1306
|
+
dfpNetworkId: false,
|
|
1307
|
+
personalizedAds: false,
|
|
1308
|
+
singleRequest: false,
|
|
1309
|
+
disableInitialLoad: false,
|
|
1310
|
+
adUnit: false,
|
|
1311
|
+
sizeMapping: false,
|
|
1312
|
+
adSenseAttributes: false,
|
|
1313
|
+
targetingArguments: false,
|
|
1314
|
+
collapseEmptyDivs: false,
|
|
1315
|
+
lazyLoad: false
|
|
1316
|
+
},
|
|
1317
|
+
personalizedAds: true,
|
|
1318
|
+
singleRequest: true,
|
|
1319
|
+
disableInitialLoad: false,
|
|
1320
|
+
collapseEmptyDivs: null,
|
|
1321
|
+
lazyLoad: false
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
if (Context === null) {
|
|
1325
|
+
// React < 16.3
|
|
1326
|
+
DFPSlotsProvider.childContextTypes = {
|
|
1327
|
+
dfpNetworkId: _propTypes.default.string,
|
|
1328
|
+
dfpAdUnit: _propTypes.default.string,
|
|
1329
|
+
dfpSizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
1330
|
+
dfpTargetingArguments: _propTypes.default.object,
|
|
1331
|
+
newSlotCallback: _propTypes.default.func
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
|
|
1336
|
+
_commonjsHelpers.unwrapExports(dfpslotsprovider);
|
|
1337
|
+
var dfpslotsprovider_1 = dfpslotsprovider.Context;
|
|
1338
|
+
|
|
1339
|
+
var adslot = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
1340
|
+
|
|
1341
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1342
|
+
value: true
|
|
1343
|
+
});
|
|
1344
|
+
exports.default = exports.AdSlot = void 0;
|
|
1345
|
+
|
|
1346
|
+
var _react = _interopRequireDefault(React__default);
|
|
1347
|
+
|
|
1348
|
+
var _propTypes = _interopRequireDefault(PropTypes);
|
|
1349
|
+
|
|
1350
|
+
var _manager = _interopRequireDefault(manager);
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1355
|
+
|
|
1356
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
1357
|
+
|
|
1358
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1359
|
+
|
|
1360
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
1361
|
+
|
|
1362
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1363
|
+
|
|
1364
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1365
|
+
|
|
1366
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1367
|
+
|
|
1368
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1369
|
+
|
|
1370
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1371
|
+
|
|
1372
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1373
|
+
|
|
1374
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1375
|
+
|
|
1376
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1377
|
+
|
|
1378
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1379
|
+
|
|
1380
|
+
var dynamicAdCount = 0;
|
|
1381
|
+
|
|
1382
|
+
var AdSlot =
|
|
1383
|
+
/*#__PURE__*/
|
|
1384
|
+
function (_React$Component) {
|
|
1385
|
+
_inherits(AdSlot, _React$Component);
|
|
1386
|
+
|
|
1387
|
+
function AdSlot(props) {
|
|
1388
|
+
var _this;
|
|
1389
|
+
|
|
1390
|
+
_classCallCheck(this, AdSlot);
|
|
1391
|
+
|
|
1392
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AdSlot).call(this, props));
|
|
1393
|
+
_this.doRegisterSlot = _this.doRegisterSlot.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1394
|
+
_this.generateSlotId = _this.generateSlotId.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1395
|
+
_this.getSlotId = _this.getSlotId.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1396
|
+
_this.mapContextToAdSlotProps = _this.mapContextToAdSlotProps.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1397
|
+
_this.slotShouldRefresh = _this.slotShouldRefresh.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1398
|
+
_this.slotRenderEnded = _this.slotRenderEnded.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1399
|
+
_this.slotRegisterCallback = _this.slotRegisterCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1400
|
+
_this.slotIsViewable = _this.slotIsViewable.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1401
|
+
_this.slotVisibilityChanged = _this.slotVisibilityChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1402
|
+
_this.getClasses = _this.getClasses.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
1403
|
+
_this.state = {
|
|
1404
|
+
slotId: _this.props.slotId || null,
|
|
1405
|
+
className: _this.props.className || ''
|
|
1406
|
+
};
|
|
1407
|
+
_this.adElementRef = _react.default.createRef ? _react.default.createRef() : function (element) {
|
|
1408
|
+
_this.adElementRef = element;
|
|
1409
|
+
};
|
|
1410
|
+
return _this;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
_createClass(AdSlot, [{
|
|
1414
|
+
key: "componentDidMount",
|
|
1415
|
+
value: function componentDidMount() {
|
|
1416
|
+
// register this ad-unit in the <DFPSlotProvider>, when available.
|
|
1417
|
+
if (this.context !== undefined && this.context.newSlotCallback) {
|
|
1418
|
+
this.context.newSlotCallback();
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
this.registerSlot();
|
|
1422
|
+
}
|
|
1423
|
+
}, {
|
|
1424
|
+
key: "componentWillUnmount",
|
|
1425
|
+
value: function componentWillUnmount() {
|
|
1426
|
+
this.unregisterSlot();
|
|
1427
|
+
}
|
|
1428
|
+
}, {
|
|
1429
|
+
key: "getSlotId",
|
|
1430
|
+
value: function getSlotId() {
|
|
1431
|
+
return this.props.slotId || this.state.slotId;
|
|
1432
|
+
}
|
|
1433
|
+
}, {
|
|
1434
|
+
key: "getClasses",
|
|
1435
|
+
value: function getClasses() {
|
|
1436
|
+
var baseClass = 'adunitContainer';
|
|
1437
|
+
var extraClasses = this.state.className.split(' ');
|
|
1438
|
+
extraClasses.push(baseClass);
|
|
1439
|
+
return extraClasses;
|
|
1440
|
+
}
|
|
1441
|
+
}, {
|
|
1442
|
+
key: "generateSlotId",
|
|
1443
|
+
value: function generateSlotId() {
|
|
1444
|
+
return "adSlot-".concat(dynamicAdCount++);
|
|
1445
|
+
}
|
|
1446
|
+
}, {
|
|
1447
|
+
key: "mapContextToAdSlotProps",
|
|
1448
|
+
value: function mapContextToAdSlotProps() {
|
|
1449
|
+
var context = this.context;
|
|
1450
|
+
var mappedProps = {};
|
|
1451
|
+
|
|
1452
|
+
if (context.dfpNetworkId !== undefined) {
|
|
1453
|
+
mappedProps.dfpNetworkId = context.dfpNetworkId;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
if (context.dfpAdUnit !== undefined) {
|
|
1457
|
+
mappedProps.adUnit = context.dfpAdUnit;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
if (context.dfpSizeMapping !== undefined) {
|
|
1461
|
+
mappedProps.sizeMapping = context.dfpSizeMapping;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
if (context.dfpTargetingArguments !== undefined) {
|
|
1465
|
+
mappedProps.targetingArguments = context.dfpTargetingArguments;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
return mappedProps;
|
|
1469
|
+
}
|
|
1470
|
+
}, {
|
|
1471
|
+
key: "doRegisterSlot",
|
|
1472
|
+
value: function doRegisterSlot() {
|
|
1473
|
+
_manager.default.registerSlot(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, this.state, {
|
|
1474
|
+
slotShouldRefresh: this.slotShouldRefresh
|
|
1475
|
+
}));
|
|
1476
|
+
|
|
1477
|
+
if (this.props.fetchNow === true) {
|
|
1478
|
+
_manager.default.load(this.getSlotId());
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
_manager.default.attachSlotRenderEnded(this.slotRenderEnded);
|
|
1482
|
+
|
|
1483
|
+
_manager.default.attachSlotIsViewable(this.slotIsViewable);
|
|
1484
|
+
|
|
1485
|
+
_manager.default.attachSlotVisibilityChanged(this.slotVisibilityChanged);
|
|
1486
|
+
|
|
1487
|
+
this.slotRegisterCallback();
|
|
1488
|
+
}
|
|
1489
|
+
}, {
|
|
1490
|
+
key: "registerSlot",
|
|
1491
|
+
value: function registerSlot() {
|
|
1492
|
+
if (this.state.slotId === null) {
|
|
1493
|
+
this.setState({
|
|
1494
|
+
slotId: this.generateSlotId()
|
|
1495
|
+
}, this.doRegisterSlot);
|
|
1496
|
+
} else {
|
|
1497
|
+
this.doRegisterSlot();
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
}, {
|
|
1501
|
+
key: "unregisterSlot",
|
|
1502
|
+
value: function unregisterSlot() {
|
|
1503
|
+
_manager.default.unregisterSlot(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, this.state));
|
|
1504
|
+
|
|
1505
|
+
_manager.default.detachSlotRenderEnded(this.slotRenderEnded);
|
|
1506
|
+
|
|
1507
|
+
_manager.default.detachSlotIsViewable(this.slotIsViewable);
|
|
1508
|
+
|
|
1509
|
+
_manager.default.detachSlotVisibilityChanged(this.slotVisibilityChanged);
|
|
1510
|
+
}
|
|
1511
|
+
}, {
|
|
1512
|
+
key: "slotRenderEnded",
|
|
1513
|
+
value: function slotRenderEnded(eventData) {
|
|
1514
|
+
if (eventData.slotId === this.getSlotId()) {
|
|
1515
|
+
if (this.props.onSlotRender !== undefined) {
|
|
1516
|
+
// now that slot has rendered we have access to the ref
|
|
1517
|
+
var params = _objectSpread({}, eventData, {
|
|
1518
|
+
adElementRef: this.adElementRef
|
|
1519
|
+
});
|
|
1520
|
+
|
|
1521
|
+
this.props.onSlotRender(params);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}, {
|
|
1526
|
+
key: "slotRegisterCallback",
|
|
1527
|
+
value: function slotRegisterCallback() {
|
|
1528
|
+
if (typeof this.props.onSlotRegister === 'function') {
|
|
1529
|
+
this.props.onSlotRegister({
|
|
1530
|
+
slotId: this.getSlotId(),
|
|
1531
|
+
sizes: this.props.sizes,
|
|
1532
|
+
slotCount: dynamicAdCount,
|
|
1533
|
+
adElementRef: this.adElementRef
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}, {
|
|
1538
|
+
key: "slotIsViewable",
|
|
1539
|
+
value: function slotIsViewable(eventData) {
|
|
1540
|
+
if (eventData.slotId === this.getSlotId()) {
|
|
1541
|
+
if (this.props.onSlotIsViewable !== undefined) {
|
|
1542
|
+
this.props.onSlotIsViewable(eventData);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}, {
|
|
1547
|
+
key: "slotVisibilityChanged",
|
|
1548
|
+
value: function slotVisibilityChanged(eventData) {
|
|
1549
|
+
if (eventData.slotId === this.getSlotId()) {
|
|
1550
|
+
if (this.props.onSlotVisibilityChanged !== undefined) {
|
|
1551
|
+
this.props.onSlotVisibilityChanged(eventData);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}, {
|
|
1556
|
+
key: "slotShouldRefresh",
|
|
1557
|
+
value: function slotShouldRefresh() {
|
|
1558
|
+
var r = true;
|
|
1559
|
+
|
|
1560
|
+
if (this.props.shouldRefresh !== undefined) {
|
|
1561
|
+
r = this.props.shouldRefresh(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, {
|
|
1562
|
+
slotId: this.getSlotId()
|
|
1563
|
+
}));
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
return r;
|
|
1567
|
+
}
|
|
1568
|
+
}, {
|
|
1569
|
+
key: "render",
|
|
1570
|
+
value: function render() {
|
|
1571
|
+
var slotId = this.state.slotId;
|
|
1572
|
+
var props = {
|
|
1573
|
+
className: 'adBox'
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
if (slotId !== null) {
|
|
1577
|
+
props.id = slotId;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
return _react.default.createElement("div", {
|
|
1581
|
+
className: this.getClasses().join(' ').trim()
|
|
1582
|
+
}, _react.default.createElement("div", _extends({
|
|
1583
|
+
ref: this.adElementRef
|
|
1584
|
+
}, props)));
|
|
1585
|
+
}
|
|
1586
|
+
}]);
|
|
1587
|
+
|
|
1588
|
+
return AdSlot;
|
|
1589
|
+
}(_react.default.Component);
|
|
1590
|
+
|
|
1591
|
+
exports.AdSlot = AdSlot;
|
|
1592
|
+
|
|
1593
|
+
_defineProperty(AdSlot, "propTypes", {
|
|
1594
|
+
dfpNetworkId: _propTypes.default.string,
|
|
1595
|
+
adUnit: _propTypes.default.string,
|
|
1596
|
+
sizes: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.number), _propTypes.default.string])),
|
|
1597
|
+
renderOutOfThePage: _propTypes.default.bool,
|
|
1598
|
+
sizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
1599
|
+
fetchNow: _propTypes.default.bool,
|
|
1600
|
+
adSenseAttributes: _propTypes.default.object,
|
|
1601
|
+
targetingArguments: _propTypes.default.object,
|
|
1602
|
+
onSlotRender: _propTypes.default.func,
|
|
1603
|
+
onSlotRegister: _propTypes.default.func,
|
|
1604
|
+
onSlotIsViewable: _propTypes.default.func,
|
|
1605
|
+
onSlotVisibilityChanged: _propTypes.default.func,
|
|
1606
|
+
shouldRefresh: _propTypes.default.func,
|
|
1607
|
+
slotId: _propTypes.default.string,
|
|
1608
|
+
className: _propTypes.default.string
|
|
1609
|
+
});
|
|
1610
|
+
|
|
1611
|
+
_defineProperty(AdSlot, "defaultProps", {
|
|
1612
|
+
fetchNow: false
|
|
1613
|
+
});
|
|
1614
|
+
|
|
1615
|
+
if (dfpslotsprovider.Context === null) {
|
|
1616
|
+
// React < 16.3
|
|
1617
|
+
AdSlot.contextTypes = {
|
|
1618
|
+
dfpNetworkId: _propTypes.default.string,
|
|
1619
|
+
dfpAdUnit: _propTypes.default.string,
|
|
1620
|
+
dfpSizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
1621
|
+
dfpTargetingArguments: _propTypes.default.object,
|
|
1622
|
+
newSlotCallback: _propTypes.default.func
|
|
1623
|
+
};
|
|
1624
|
+
} else {
|
|
1625
|
+
AdSlot.contextType = dfpslotsprovider.Context;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
var _default = AdSlot;
|
|
1629
|
+
exports.default = _default;
|
|
1630
|
+
});
|
|
1631
|
+
|
|
1632
|
+
_commonjsHelpers.unwrapExports(adslot);
|
|
1633
|
+
var adslot_1 = adslot.AdSlot;
|
|
1634
|
+
|
|
1635
|
+
var lib = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
1636
|
+
|
|
1637
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1638
|
+
value: true
|
|
1639
|
+
});
|
|
1640
|
+
exports.DFPSlotsProvider = exports.AdSlot = exports.DFPManager = void 0;
|
|
1641
|
+
|
|
1642
|
+
var _manager = _interopRequireDefault(manager);
|
|
1643
|
+
|
|
1644
|
+
var _adslot = _interopRequireDefault(adslot);
|
|
1645
|
+
|
|
1646
|
+
var _dfpslotsprovider = _interopRequireDefault(dfpslotsprovider);
|
|
1647
|
+
|
|
1648
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1649
|
+
|
|
1650
|
+
var DFPManager = _manager.default;
|
|
1651
|
+
exports.DFPManager = DFPManager;
|
|
1652
|
+
var AdSlot = _adslot.default;
|
|
1653
|
+
exports.AdSlot = AdSlot;
|
|
1654
|
+
var DFPSlotsProvider = _dfpslotsprovider.default;
|
|
1655
|
+
exports.DFPSlotsProvider = DFPSlotsProvider;
|
|
1656
|
+
});
|
|
1657
|
+
|
|
1658
|
+
_commonjsHelpers.unwrapExports(lib);
|
|
1659
|
+
var lib_1 = lib.DFPSlotsProvider;
|
|
1660
|
+
var lib_2 = lib.AdSlot;
|
|
1661
|
+
var lib_3 = lib.DFPManager;
|
|
1662
|
+
|
|
1663
|
+
var visibilitySensor = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
1664
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
1665
|
+
module.exports = factory(React__default, reactDom);
|
|
1666
|
+
})(_commonjsHelpers.commonjsGlobal, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__2__) {
|
|
1667
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
1668
|
+
/******/ // The module cache
|
|
1669
|
+
/******/ var installedModules = {};
|
|
1670
|
+
/******/
|
|
1671
|
+
/******/ // The require function
|
|
1672
|
+
/******/ function __webpack_require__(moduleId) {
|
|
1673
|
+
/******/
|
|
1674
|
+
/******/ // Check if module is in cache
|
|
1675
|
+
/******/ if(installedModules[moduleId]) {
|
|
1676
|
+
/******/ return installedModules[moduleId].exports;
|
|
1677
|
+
/******/ }
|
|
1678
|
+
/******/ // Create a new module (and put it into the cache)
|
|
1679
|
+
/******/ var module = installedModules[moduleId] = {
|
|
1680
|
+
/******/ i: moduleId,
|
|
1681
|
+
/******/ l: false,
|
|
1682
|
+
/******/ exports: {}
|
|
1683
|
+
/******/ };
|
|
1684
|
+
/******/
|
|
1685
|
+
/******/ // Execute the module function
|
|
1686
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1687
|
+
/******/
|
|
1688
|
+
/******/ // Flag the module as loaded
|
|
1689
|
+
/******/ module.l = true;
|
|
1690
|
+
/******/
|
|
1691
|
+
/******/ // Return the exports of the module
|
|
1692
|
+
/******/ return module.exports;
|
|
1693
|
+
/******/ }
|
|
1694
|
+
/******/
|
|
1695
|
+
/******/
|
|
1696
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
1697
|
+
/******/ __webpack_require__.m = modules;
|
|
1698
|
+
/******/
|
|
1699
|
+
/******/ // expose the module cache
|
|
1700
|
+
/******/ __webpack_require__.c = installedModules;
|
|
1701
|
+
/******/
|
|
1702
|
+
/******/ // define getter function for harmony exports
|
|
1703
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
1704
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
1705
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
1706
|
+
/******/ }
|
|
1707
|
+
/******/ };
|
|
1708
|
+
/******/
|
|
1709
|
+
/******/ // define __esModule on exports
|
|
1710
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
1711
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
1712
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1713
|
+
/******/ }
|
|
1714
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
1715
|
+
/******/ };
|
|
1716
|
+
/******/
|
|
1717
|
+
/******/ // create a fake namespace object
|
|
1718
|
+
/******/ // mode & 1: value is a module id, require it
|
|
1719
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
1720
|
+
/******/ // mode & 4: return value when already ns object
|
|
1721
|
+
/******/ // mode & 8|1: behave like require
|
|
1722
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
1723
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
1724
|
+
/******/ if(mode & 8) return value;
|
|
1725
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
1726
|
+
/******/ var ns = Object.create(null);
|
|
1727
|
+
/******/ __webpack_require__.r(ns);
|
|
1728
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
1729
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
1730
|
+
/******/ return ns;
|
|
1731
|
+
/******/ };
|
|
1732
|
+
/******/
|
|
1733
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
1734
|
+
/******/ __webpack_require__.n = function(module) {
|
|
1735
|
+
/******/ var getter = module && module.__esModule ?
|
|
1736
|
+
/******/ function getDefault() { return module['default']; } :
|
|
1737
|
+
/******/ function getModuleExports() { return module; };
|
|
1738
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
1739
|
+
/******/ return getter;
|
|
1740
|
+
/******/ };
|
|
1741
|
+
/******/
|
|
1742
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
1743
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
1744
|
+
/******/
|
|
1745
|
+
/******/ // __webpack_public_path__
|
|
1746
|
+
/******/ __webpack_require__.p = "";
|
|
1747
|
+
/******/
|
|
1748
|
+
/******/
|
|
1749
|
+
/******/ // Load entry module and return exports
|
|
1750
|
+
/******/ return __webpack_require__(__webpack_require__.s = 4);
|
|
1751
|
+
/******/ })
|
|
1752
|
+
/************************************************************************/
|
|
1753
|
+
/******/ ([
|
|
1754
|
+
/* 0 */
|
|
1755
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1759
|
+
*
|
|
1760
|
+
* This source code is licensed under the MIT license found in the
|
|
1761
|
+
* LICENSE file in the root directory of this source tree.
|
|
1762
|
+
*/
|
|
1763
|
+
|
|
1764
|
+
{
|
|
1765
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1766
|
+
// http://fb.me/prop-types-in-prod
|
|
1767
|
+
module.exports = __webpack_require__(5)();
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
/***/ }),
|
|
1772
|
+
/* 1 */
|
|
1773
|
+
/***/ (function(module, exports) {
|
|
1774
|
+
|
|
1775
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
|
|
1776
|
+
|
|
1777
|
+
/***/ }),
|
|
1778
|
+
/* 2 */
|
|
1779
|
+
/***/ (function(module, exports) {
|
|
1780
|
+
|
|
1781
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
|
|
1782
|
+
|
|
1783
|
+
/***/ }),
|
|
1784
|
+
/* 3 */
|
|
1785
|
+
/***/ (function(module, exports) {
|
|
1786
|
+
|
|
1787
|
+
// Tell whether the rect is visible, given an offset
|
|
1788
|
+
//
|
|
1789
|
+
// return: boolean
|
|
1790
|
+
module.exports = function (offset, rect, containmentRect) {
|
|
1791
|
+
var offsetDir = offset.direction;
|
|
1792
|
+
var offsetVal = offset.value; // Rules for checking different kind of offsets. In example if the element is
|
|
1793
|
+
// 90px below viewport and offsetTop is 100, it is considered visible.
|
|
1794
|
+
|
|
1795
|
+
switch (offsetDir) {
|
|
1796
|
+
case 'top':
|
|
1797
|
+
return containmentRect.top + offsetVal < rect.top && containmentRect.bottom > rect.bottom && containmentRect.left < rect.left && containmentRect.right > rect.right;
|
|
1798
|
+
|
|
1799
|
+
case 'left':
|
|
1800
|
+
return containmentRect.left + offsetVal < rect.left && containmentRect.bottom > rect.bottom && containmentRect.top < rect.top && containmentRect.right > rect.right;
|
|
1801
|
+
|
|
1802
|
+
case 'bottom':
|
|
1803
|
+
return containmentRect.bottom - offsetVal > rect.bottom && containmentRect.left < rect.left && containmentRect.right > rect.right && containmentRect.top < rect.top;
|
|
1804
|
+
|
|
1805
|
+
case 'right':
|
|
1806
|
+
return containmentRect.right - offsetVal > rect.right && containmentRect.left < rect.left && containmentRect.top < rect.top && containmentRect.bottom > rect.bottom;
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
/***/ }),
|
|
1811
|
+
/* 4 */
|
|
1812
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1813
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1814
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return VisibilitySensor; });
|
|
1815
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
1816
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1817
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
1818
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1819
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
|
|
1820
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
|
|
1821
|
+
/* harmony import */ var _lib_is_visible_with_offset__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
|
|
1822
|
+
/* harmony import */ var _lib_is_visible_with_offset__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_lib_is_visible_with_offset__WEBPACK_IMPORTED_MODULE_3__);
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
1826
|
+
|
|
1827
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1828
|
+
|
|
1829
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1830
|
+
|
|
1831
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1832
|
+
|
|
1833
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1834
|
+
|
|
1835
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1836
|
+
|
|
1837
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1838
|
+
|
|
1839
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1840
|
+
|
|
1841
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1842
|
+
|
|
1843
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
function normalizeRect(rect) {
|
|
1851
|
+
if (rect.width === undefined) {
|
|
1852
|
+
rect.width = rect.right - rect.left;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
if (rect.height === undefined) {
|
|
1856
|
+
rect.height = rect.bottom - rect.top;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
return rect;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
var VisibilitySensor =
|
|
1863
|
+
/*#__PURE__*/
|
|
1864
|
+
function (_React$Component) {
|
|
1865
|
+
_inherits(VisibilitySensor, _React$Component);
|
|
1866
|
+
|
|
1867
|
+
function VisibilitySensor(props) {
|
|
1868
|
+
var _this;
|
|
1869
|
+
|
|
1870
|
+
_classCallCheck(this, VisibilitySensor);
|
|
1871
|
+
|
|
1872
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(VisibilitySensor).call(this, props));
|
|
1873
|
+
|
|
1874
|
+
_defineProperty(_assertThisInitialized(_this), "getContainer", function () {
|
|
1875
|
+
return _this.props.containment || window;
|
|
1876
|
+
});
|
|
1877
|
+
|
|
1878
|
+
_defineProperty(_assertThisInitialized(_this), "addEventListener", function (target, event, delay, throttle) {
|
|
1879
|
+
if (!_this.debounceCheck) {
|
|
1880
|
+
_this.debounceCheck = {};
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
var timeout;
|
|
1884
|
+
var func;
|
|
1885
|
+
|
|
1886
|
+
var later = function later() {
|
|
1887
|
+
timeout = null;
|
|
1888
|
+
|
|
1889
|
+
_this.check();
|
|
1890
|
+
};
|
|
1891
|
+
|
|
1892
|
+
if (throttle > -1) {
|
|
1893
|
+
func = function func() {
|
|
1894
|
+
if (!timeout) {
|
|
1895
|
+
timeout = setTimeout(later, throttle || 0);
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
} else {
|
|
1899
|
+
func = function func() {
|
|
1900
|
+
clearTimeout(timeout);
|
|
1901
|
+
timeout = setTimeout(later, delay || 0);
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
var info = {
|
|
1906
|
+
target: target,
|
|
1907
|
+
fn: func,
|
|
1908
|
+
getLastTimeout: function getLastTimeout() {
|
|
1909
|
+
return timeout;
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1912
|
+
target.addEventListener(event, info.fn);
|
|
1913
|
+
_this.debounceCheck[event] = info;
|
|
1914
|
+
});
|
|
1915
|
+
|
|
1916
|
+
_defineProperty(_assertThisInitialized(_this), "startWatching", function () {
|
|
1917
|
+
if (_this.debounceCheck || _this.interval) {
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
if (_this.props.intervalCheck) {
|
|
1922
|
+
_this.interval = setInterval(_this.check, _this.props.intervalDelay);
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
if (_this.props.scrollCheck) {
|
|
1926
|
+
_this.addEventListener(_this.getContainer(), "scroll", _this.props.scrollDelay, _this.props.scrollThrottle);
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
if (_this.props.resizeCheck) {
|
|
1930
|
+
_this.addEventListener(window, "resize", _this.props.resizeDelay, _this.props.resizeThrottle);
|
|
1931
|
+
} // if dont need delayed call, check on load ( before the first interval fires )
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
!_this.props.delayedCall && _this.check();
|
|
1935
|
+
});
|
|
1936
|
+
|
|
1937
|
+
_defineProperty(_assertThisInitialized(_this), "stopWatching", function () {
|
|
1938
|
+
if (_this.debounceCheck) {
|
|
1939
|
+
// clean up event listeners and their debounce callers
|
|
1940
|
+
for (var debounceEvent in _this.debounceCheck) {
|
|
1941
|
+
if (_this.debounceCheck.hasOwnProperty(debounceEvent)) {
|
|
1942
|
+
var debounceInfo = _this.debounceCheck[debounceEvent];
|
|
1943
|
+
clearTimeout(debounceInfo.getLastTimeout());
|
|
1944
|
+
debounceInfo.target.removeEventListener(debounceEvent, debounceInfo.fn);
|
|
1945
|
+
_this.debounceCheck[debounceEvent] = null;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
_this.debounceCheck = null;
|
|
1951
|
+
|
|
1952
|
+
if (_this.interval) {
|
|
1953
|
+
_this.interval = clearInterval(_this.interval);
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
_defineProperty(_assertThisInitialized(_this), "check", function () {
|
|
1958
|
+
var el = _this.node;
|
|
1959
|
+
var rect;
|
|
1960
|
+
var containmentRect; // if the component has rendered to null, dont update visibility
|
|
1961
|
+
|
|
1962
|
+
if (!el) {
|
|
1963
|
+
return _this.state;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
rect = normalizeRect(_this.roundRectDown(el.getBoundingClientRect()));
|
|
1967
|
+
|
|
1968
|
+
if (_this.props.containment) {
|
|
1969
|
+
var containmentDOMRect = _this.props.containment.getBoundingClientRect();
|
|
1970
|
+
|
|
1971
|
+
containmentRect = {
|
|
1972
|
+
top: containmentDOMRect.top,
|
|
1973
|
+
left: containmentDOMRect.left,
|
|
1974
|
+
bottom: containmentDOMRect.bottom,
|
|
1975
|
+
right: containmentDOMRect.right
|
|
1976
|
+
};
|
|
1977
|
+
} else {
|
|
1978
|
+
containmentRect = {
|
|
1979
|
+
top: 0,
|
|
1980
|
+
left: 0,
|
|
1981
|
+
bottom: window.innerHeight || document.documentElement.clientHeight,
|
|
1982
|
+
right: window.innerWidth || document.documentElement.clientWidth
|
|
1983
|
+
};
|
|
1984
|
+
} // Check if visibility is wanted via offset?
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
var offset = _this.props.offset || {};
|
|
1988
|
+
var hasValidOffset = _typeof(offset) === "object";
|
|
1989
|
+
|
|
1990
|
+
if (hasValidOffset) {
|
|
1991
|
+
containmentRect.top += offset.top || 0;
|
|
1992
|
+
containmentRect.left += offset.left || 0;
|
|
1993
|
+
containmentRect.bottom -= offset.bottom || 0;
|
|
1994
|
+
containmentRect.right -= offset.right || 0;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
var visibilityRect = {
|
|
1998
|
+
top: rect.top >= containmentRect.top,
|
|
1999
|
+
left: rect.left >= containmentRect.left,
|
|
2000
|
+
bottom: rect.bottom <= containmentRect.bottom,
|
|
2001
|
+
right: rect.right <= containmentRect.right
|
|
2002
|
+
}; // https://github.com/joshwnj/react-visibility-sensor/pull/114
|
|
2003
|
+
|
|
2004
|
+
var hasSize = rect.height > 0 && rect.width > 0;
|
|
2005
|
+
var isVisible = hasSize && visibilityRect.top && visibilityRect.left && visibilityRect.bottom && visibilityRect.right; // check for partial visibility
|
|
2006
|
+
|
|
2007
|
+
if (hasSize && _this.props.partialVisibility) {
|
|
2008
|
+
var partialVisible = rect.top <= containmentRect.bottom && rect.bottom >= containmentRect.top && rect.left <= containmentRect.right && rect.right >= containmentRect.left; // account for partial visibility on a single edge
|
|
2009
|
+
|
|
2010
|
+
if (typeof _this.props.partialVisibility === "string") {
|
|
2011
|
+
partialVisible = visibilityRect[_this.props.partialVisibility];
|
|
2012
|
+
} // if we have minimum top visibility set by props, lets check, if it meets the passed value
|
|
2013
|
+
// so if for instance element is at least 200px in viewport, then show it.
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
isVisible = _this.props.minTopValue ? partialVisible && rect.top <= containmentRect.bottom - _this.props.minTopValue : partialVisible;
|
|
2017
|
+
} // Deprecated options for calculating offset.
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
if (typeof offset.direction === "string" && typeof offset.value === "number") {
|
|
2021
|
+
console.warn("[notice] offset.direction and offset.value have been deprecated. They still work for now, but will be removed in next major version. Please upgrade to the new syntax: { %s: %d }", offset.direction, offset.value);
|
|
2022
|
+
isVisible = _lib_is_visible_with_offset__WEBPACK_IMPORTED_MODULE_3___default()(offset, rect, containmentRect);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
var state = _this.state; // notify the parent when the value changes
|
|
2026
|
+
|
|
2027
|
+
if (_this.state.isVisible !== isVisible) {
|
|
2028
|
+
state = {
|
|
2029
|
+
isVisible: isVisible,
|
|
2030
|
+
visibilityRect: visibilityRect
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
_this.setState(state);
|
|
2034
|
+
|
|
2035
|
+
if (_this.props.onChange) _this.props.onChange(isVisible);
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
return state;
|
|
2039
|
+
});
|
|
2040
|
+
|
|
2041
|
+
_this.state = {
|
|
2042
|
+
isVisible: null,
|
|
2043
|
+
visibilityRect: {}
|
|
2044
|
+
};
|
|
2045
|
+
return _this;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
_createClass(VisibilitySensor, [{
|
|
2049
|
+
key: "componentDidMount",
|
|
2050
|
+
value: function componentDidMount() {
|
|
2051
|
+
this.node = react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this);
|
|
2052
|
+
|
|
2053
|
+
if (this.props.active) {
|
|
2054
|
+
this.startWatching();
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}, {
|
|
2058
|
+
key: "componentWillUnmount",
|
|
2059
|
+
value: function componentWillUnmount() {
|
|
2060
|
+
this.stopWatching();
|
|
2061
|
+
}
|
|
2062
|
+
}, {
|
|
2063
|
+
key: "componentDidUpdate",
|
|
2064
|
+
value: function componentDidUpdate(prevProps) {
|
|
2065
|
+
// re-register node in componentDidUpdate if children diffs [#103]
|
|
2066
|
+
this.node = react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.findDOMNode(this);
|
|
2067
|
+
|
|
2068
|
+
if (this.props.active && !prevProps.active) {
|
|
2069
|
+
this.setState({
|
|
2070
|
+
isVisible: null,
|
|
2071
|
+
visibilityRect: {}
|
|
2072
|
+
});
|
|
2073
|
+
this.startWatching();
|
|
2074
|
+
} else if (!this.props.active) {
|
|
2075
|
+
this.stopWatching();
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}, {
|
|
2079
|
+
key: "roundRectDown",
|
|
2080
|
+
value: function roundRectDown(rect) {
|
|
2081
|
+
return {
|
|
2082
|
+
top: Math.floor(rect.top),
|
|
2083
|
+
left: Math.floor(rect.left),
|
|
2084
|
+
bottom: Math.floor(rect.bottom),
|
|
2085
|
+
right: Math.floor(rect.right)
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Check if the element is within the visible viewport
|
|
2090
|
+
*/
|
|
2091
|
+
|
|
2092
|
+
}, {
|
|
2093
|
+
key: "render",
|
|
2094
|
+
value: function render() {
|
|
2095
|
+
if (this.props.children instanceof Function) {
|
|
2096
|
+
return this.props.children({
|
|
2097
|
+
isVisible: this.state.isVisible,
|
|
2098
|
+
visibilityRect: this.state.visibilityRect
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
return react__WEBPACK_IMPORTED_MODULE_0___default.a.Children.only(this.props.children);
|
|
2103
|
+
}
|
|
2104
|
+
}]);
|
|
2105
|
+
|
|
2106
|
+
return VisibilitySensor;
|
|
2107
|
+
}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);
|
|
2108
|
+
|
|
2109
|
+
_defineProperty(VisibilitySensor, "defaultProps", {
|
|
2110
|
+
active: true,
|
|
2111
|
+
partialVisibility: false,
|
|
2112
|
+
minTopValue: 0,
|
|
2113
|
+
scrollCheck: false,
|
|
2114
|
+
scrollDelay: 250,
|
|
2115
|
+
scrollThrottle: -1,
|
|
2116
|
+
resizeCheck: false,
|
|
2117
|
+
resizeDelay: 250,
|
|
2118
|
+
resizeThrottle: -1,
|
|
2119
|
+
intervalCheck: true,
|
|
2120
|
+
intervalDelay: 100,
|
|
2121
|
+
delayedCall: false,
|
|
2122
|
+
offset: {},
|
|
2123
|
+
containment: null,
|
|
2124
|
+
children: react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null)
|
|
2125
|
+
});
|
|
2126
|
+
|
|
2127
|
+
_defineProperty(VisibilitySensor, "propTypes", {
|
|
2128
|
+
onChange: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.func,
|
|
2129
|
+
active: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2130
|
+
partialVisibility: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOf(["top", "right", "bottom", "left"])]),
|
|
2131
|
+
delayedCall: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2132
|
+
offset: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.shape({
|
|
2133
|
+
top: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2134
|
+
left: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2135
|
+
bottom: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2136
|
+
right: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number
|
|
2137
|
+
}), // deprecated offset property
|
|
2138
|
+
prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.shape({
|
|
2139
|
+
direction: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOf(["top", "right", "bottom", "left"]),
|
|
2140
|
+
value: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number
|
|
2141
|
+
})]),
|
|
2142
|
+
scrollCheck: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2143
|
+
scrollDelay: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2144
|
+
scrollThrottle: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2145
|
+
resizeCheck: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2146
|
+
resizeDelay: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2147
|
+
resizeThrottle: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2148
|
+
intervalCheck: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2149
|
+
intervalDelay: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2150
|
+
containment: typeof window !== "undefined" ? prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.instanceOf(window.Element) : prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.any,
|
|
2151
|
+
children: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.element, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.func]),
|
|
2152
|
+
minTopValue: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number
|
|
2153
|
+
});
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
/***/ }),
|
|
2158
|
+
/* 5 */
|
|
2159
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
2160
|
+
/**
|
|
2161
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2162
|
+
*
|
|
2163
|
+
* This source code is licensed under the MIT license found in the
|
|
2164
|
+
* LICENSE file in the root directory of this source tree.
|
|
2165
|
+
*/
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
var ReactPropTypesSecret = __webpack_require__(6);
|
|
2170
|
+
|
|
2171
|
+
function emptyFunction() {}
|
|
2172
|
+
function emptyFunctionWithReset() {}
|
|
2173
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
2174
|
+
|
|
2175
|
+
module.exports = function() {
|
|
2176
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
2177
|
+
if (secret === ReactPropTypesSecret) {
|
|
2178
|
+
// It is still safe when called from React.
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
var err = new Error(
|
|
2182
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
2183
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
2184
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
2185
|
+
);
|
|
2186
|
+
err.name = 'Invariant Violation';
|
|
2187
|
+
throw err;
|
|
2188
|
+
} shim.isRequired = shim;
|
|
2189
|
+
function getShim() {
|
|
2190
|
+
return shim;
|
|
2191
|
+
} // Important!
|
|
2192
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
2193
|
+
var ReactPropTypes = {
|
|
2194
|
+
array: shim,
|
|
2195
|
+
bool: shim,
|
|
2196
|
+
func: shim,
|
|
2197
|
+
number: shim,
|
|
2198
|
+
object: shim,
|
|
2199
|
+
string: shim,
|
|
2200
|
+
symbol: shim,
|
|
2201
|
+
|
|
2202
|
+
any: shim,
|
|
2203
|
+
arrayOf: getShim,
|
|
2204
|
+
element: shim,
|
|
2205
|
+
elementType: shim,
|
|
2206
|
+
instanceOf: getShim,
|
|
2207
|
+
node: shim,
|
|
2208
|
+
objectOf: getShim,
|
|
2209
|
+
oneOf: getShim,
|
|
2210
|
+
oneOfType: getShim,
|
|
2211
|
+
shape: getShim,
|
|
2212
|
+
exact: getShim,
|
|
2213
|
+
|
|
2214
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
2215
|
+
resetWarningCache: emptyFunction
|
|
2216
|
+
};
|
|
2217
|
+
|
|
2218
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
2219
|
+
|
|
2220
|
+
return ReactPropTypes;
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
|
|
2224
|
+
/***/ }),
|
|
2225
|
+
/* 6 */
|
|
2226
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
2227
|
+
/**
|
|
2228
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2229
|
+
*
|
|
2230
|
+
* This source code is licensed under the MIT license found in the
|
|
2231
|
+
* LICENSE file in the root directory of this source tree.
|
|
2232
|
+
*/
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
2237
|
+
|
|
2238
|
+
module.exports = ReactPropTypesSecret;
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
/***/ })
|
|
2242
|
+
/******/ ]);
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2245
|
+
|
|
2246
|
+
var VisibilitySensor = _commonjsHelpers.unwrapExports(visibilitySensor);
|
|
2247
|
+
|
|
2248
|
+
exports.VisibilitySensor = VisibilitySensor;
|
|
2249
|
+
exports.lib_1 = lib_1;
|
|
2250
|
+
exports.lib_2 = lib_2;
|
|
2251
|
+
exports.lib_3 = lib_3;
|