@pendo/agent 2.290.1 → 2.290.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dom.esm.js CHANGED
@@ -5283,16 +5283,6 @@ function isElementShadowRoot(elem, _win) {
5283
5283
  function getParent(elem, _win) {
5284
5284
  return isElementShadowRoot(elem, _win) ? elem.host : elem.parentNode;
5285
5285
  }
5286
- function contains(context, elem, _win) {
5287
- var parent = elem;
5288
- while (parent) {
5289
- if (parent === context) {
5290
- return true;
5291
- }
5292
- parent = getParent(parent, _win);
5293
- }
5294
- return false;
5295
- }
5296
5286
 
5297
5287
  var shadowAPI = (function () {
5298
5288
  function isShadowSelector(selector) {
@@ -5325,19 +5315,10 @@ var shadowAPI = (function () {
5325
5315
  isElementShadowRoot: isElementShadowRoot,
5326
5316
  getParent: getParent,
5327
5317
  isShadowSelector: isShadowSelector,
5328
- wrapSizzle: function (Sizzle, shadowDomManager) {
5318
+ wrapSizzle: function (Sizzle) {
5329
5319
  Sizzle.intercept(function (Sizzle, selection, context, results, seed) {
5330
5320
  if (!isShadowSelector(selection)) {
5331
- var queryResults_1 = Sizzle(selection, context, results, seed);
5332
- if (shadowDomManager.cache.size > 0) {
5333
- // eslint-disable-next-line agent-eslint-rules/no-array-foreach
5334
- shadowDomManager.cache.forEach(function (shadowRoot) {
5335
- if (!context || context === document || contains(context, shadowRoot)) {
5336
- queryResults_1.push.apply(queryResults_1, Sizzle(selection, shadowRoot, results, seed));
5337
- }
5338
- });
5339
- }
5340
- return queryResults_1;
5321
+ return Sizzle(selection, context, results, seed);
5341
5322
  }
5342
5323
  if (!_.isFunction(document.documentElement.attachShadow)) {
5343
5324
  return Sizzle(selection.replace(shadowAPI.PSEUDO_REGEX, ''), context, results, seed);
@@ -7311,7 +7292,7 @@ function getScreenPosition(element) {
7311
7292
  };
7312
7293
  }
7313
7294
 
7314
- var VERSION = '2.290.1_';
7295
+ var VERSION = '2.290.2_';
7315
7296
 
7316
7297
  var decodeURIComponent = _.isFunction(window.decodeURIComponent) ? window.decodeURIComponent : _.identity;
7317
7298
 
@@ -3903,8 +3903,8 @@ var SERVER = '';
3903
3903
  var ASSET_HOST = '';
3904
3904
  var ASSET_PATH = '';
3905
3905
  var DESIGNER_SERVER = '';
3906
- var VERSION = '2.290.1_';
3907
- var PACKAGE_VERSION = '2.290.1';
3906
+ var VERSION = '2.290.2_';
3907
+ var PACKAGE_VERSION = '2.290.2';
3908
3908
  var LOADER = 'xhr';
3909
3909
  /* eslint-enable agent-eslint-rules/no-gulp-env-references */
3910
3910
  /**
@@ -6131,16 +6131,6 @@ function isElementShadowRoot(elem, _win) {
6131
6131
  function getParent(elem, _win) {
6132
6132
  return isElementShadowRoot(elem, _win) ? elem.host : elem.parentNode;
6133
6133
  }
6134
- function contains(context, elem, _win) {
6135
- let parent = elem;
6136
- while (parent) {
6137
- if (parent === context) {
6138
- return true;
6139
- }
6140
- parent = getParent(parent, _win);
6141
- }
6142
- return false;
6143
- }
6144
6134
 
6145
6135
  var shadowAPI = (function () {
6146
6136
  function isShadowSelector(selector) {
@@ -6173,19 +6163,10 @@ var shadowAPI = (function () {
6173
6163
  isElementShadowRoot: isElementShadowRoot,
6174
6164
  getParent: getParent,
6175
6165
  isShadowSelector,
6176
- wrapSizzle(Sizzle, shadowDomManager) {
6166
+ wrapSizzle(Sizzle) {
6177
6167
  Sizzle.intercept(function (Sizzle, selection, context, results, seed) {
6178
6168
  if (!isShadowSelector(selection)) {
6179
- const queryResults = Sizzle(selection, context, results, seed);
6180
- if (shadowDomManager.cache.size > 0) {
6181
- // eslint-disable-next-line agent-eslint-rules/no-array-foreach
6182
- shadowDomManager.cache.forEach(shadowRoot => {
6183
- if (!context || context === document || contains(context, shadowRoot)) {
6184
- queryResults.push(...Sizzle(selection, shadowRoot, results, seed));
6185
- }
6186
- });
6187
- }
6188
- return queryResults;
6169
+ return Sizzle(selection, context, results, seed);
6189
6170
  }
6190
6171
  if (!_.isFunction(document.documentElement.attachShadow)) {
6191
6172
  return Sizzle(selection.replace(shadowAPI.PSEUDO_REGEX, ''), context, results, seed);
@@ -25597,7 +25578,7 @@ function securityPolicyViolationFn(evt) {
25597
25578
  * @example
25598
25579
  * pendo.initGuides()
25599
25580
  */
25600
- var initGuides = function (observer) {
25581
+ var initGuides = function () {
25601
25582
  const teardownFns = [];
25602
25583
  teardownFns.push(initGuideAnalytics({
25603
25584
  localStorageUnload: ConfigReader.get('analytics.localStorageUnload')
@@ -25661,8 +25642,8 @@ var initGuides = function (observer) {
25661
25642
  teardownFns.push(attachEventInternal(window, 'gestureend', adjustGuidesOnGestureEnd, true));
25662
25643
  teardownFns.push(attachEventInternal(window, 'securitypolicyviolation', securityPolicyViolationFn));
25663
25644
  teardownFns.push(createVideoFullScreenListeners());
25664
- if (observer.observing) {
25665
- var updateGuide = function () {
25645
+ if (ConfigReader.get('preferMutationObserver') && sniffer.MutationObserver) {
25646
+ var updateGuide = function (event) {
25666
25647
  store.dispatch('guideUpdate/documentChanged');
25667
25648
  };
25668
25649
  const debouncedUpdate = _.debounce(updateGuide, 50);
@@ -25670,8 +25651,10 @@ var initGuides = function (observer) {
25670
25651
  teardownFns.push(attachEvent(window, 'animationend', debouncedUpdate));
25671
25652
  teardownFns.push(attachEvent(window, 'transitionend', debouncedUpdate));
25672
25653
  teardownFns.push(attachEvent(window, 'mouseover', debouncedUpdate));
25673
- store.commit('guideUpdate/setObserver', observer);
25674
25654
  store.commit('guideUpdate/setUseObserver');
25655
+ if (ConfigReader.get('observeShadowRoots')) {
25656
+ store.commit('guideUpdate/setObserveShadowRoots');
25657
+ }
25675
25658
  teardownFns.push(() => store.dispatch('guideUpdate/stopObserver'));
25676
25659
  }
25677
25660
  /**
@@ -27052,159 +27035,6 @@ const isReady = (pendoObj) => {
27052
27035
  return pendoObj.doesExist(pendoObj.apiKey);
27053
27036
  };
27054
27037
 
27055
- class ShadowDomManager extends EventTarget {
27056
- constructor() {
27057
- super();
27058
- this.cache = new Set();
27059
- this.foundShadowRoots = false;
27060
- this.stoppedSearchEarly = false;
27061
- }
27062
- updateCache() {
27063
- // eslint-disable-next-line agent-eslint-rules/no-array-foreach
27064
- this.cache.forEach(shadowRoot => {
27065
- if (!isInDocument(shadowRoot)) {
27066
- this.cache.delete(shadowRoot);
27067
- this.dispatchEvent({
27068
- type: 'detachShadow',
27069
- shadowRoot
27070
- });
27071
- }
27072
- });
27073
- }
27074
- patchAttachShadow(Element) {
27075
- const original = Element.prototype.attachShadow;
27076
- const self = this;
27077
- Element.prototype.attachShadow = function (options) {
27078
- const shadowRoot = original.call(this, options);
27079
- if (this.shadowRoot) {
27080
- self.triggerAttachShadow(this.shadowRoot);
27081
- }
27082
- return shadowRoot;
27083
- };
27084
- Element.prototype.attachShadow.toString = function () {
27085
- return original.toString();
27086
- };
27087
- return () => {
27088
- Element.prototype.attachShadow = original;
27089
- };
27090
- }
27091
- initialize() {
27092
- this.unpatchAttachShadow = this.patchAttachShadow(Element);
27093
- this.findShadowRoots(document);
27094
- }
27095
- triggerAttachShadow(shadowRoot) {
27096
- this.cache.add(shadowRoot);
27097
- this.dispatchEvent({
27098
- type: 'attachShadow',
27099
- shadowRoot
27100
- });
27101
- }
27102
- findShadowRoots(document, maxPerSearch = 5000) {
27103
- if (!_.isFunction(document.createNodeIterator))
27104
- return;
27105
- let nodesChecked = 0;
27106
- let queue = [getBody(document)];
27107
- let currentNode;
27108
- function eachShadowRoot(iterator) {
27109
- do {
27110
- if (!iterator) {
27111
- iterator = document.createNodeIterator(queue.pop(), NodeFilter.SHOW_ELEMENT);
27112
- }
27113
- if (!iterator || !iterator.nextNode)
27114
- break;
27115
- while ((currentNode = iterator.nextNode())) {
27116
- nodesChecked++;
27117
- if (currentNode && currentNode.shadowRoot) {
27118
- this.triggerAttachShadow(currentNode.shadowRoot);
27119
- queue.push(currentNode.shadowRoot);
27120
- this.foundShadowRoots = true;
27121
- }
27122
- if (nodesChecked % maxPerSearch === 0)
27123
- break;
27124
- }
27125
- if (currentNode)
27126
- break;
27127
- iterator = null;
27128
- } while (queue.length);
27129
- if (currentNode && this.foundShadowRoots) {
27130
- this.findTimeout = setTimeout$1(() => {
27131
- this.findTimeout = null;
27132
- eachShadowRoot.call(this, iterator);
27133
- }, 50);
27134
- }
27135
- if (nodesChecked === maxPerSearch && !this.foundShadowRoots) {
27136
- this.stoppedSearchEarly = true;
27137
- }
27138
- }
27139
- eachShadowRoot.call(this);
27140
- }
27141
- teardown() {
27142
- this.cache.clear();
27143
- if (_.isFunction(this.unpatchAttachShadow)) {
27144
- this.unpatchAttachShadow();
27145
- this.unpatchAttachShadow = null;
27146
- }
27147
- if (this.findTimeout) {
27148
- clearTimeout(this.findTimeout);
27149
- this.findTimeout = null;
27150
- }
27151
- }
27152
- }
27153
-
27154
- class UberMutationObserver extends EventTarget {
27155
- constructor(observerClass = getZoneSafeMethod('MutationObserver')) {
27156
- super();
27157
- this.ObserverClass = observerClass;
27158
- this.observing = false;
27159
- this.observers = new Map();
27160
- this.shadowDom = new ShadowDomManager();
27161
- this.shadowDom.addEventListener('attachShadow', _.bind(this.handleAttachShadow, this));
27162
- this.shadowDom.addEventListener('detachShadow', _.bind(this.handleDetachShadow, this));
27163
- this.addEventListener('mutation', () => {
27164
- this.shadowDom.updateCache();
27165
- });
27166
- }
27167
- initialize(pendo, PluginAPI) {
27168
- const configReader = PluginAPI.ConfigReader;
27169
- if (!configReader.get('preferMutationObserver') || !pendo.sniffer.MutationObserver) {
27170
- return;
27171
- }
27172
- this.observeShadowRoots = configReader.get('observeShadowRoots');
27173
- this.startObserver(document.documentElement);
27174
- this.observing = true;
27175
- if (this.observeShadowRoots) {
27176
- this.shadowDom.initialize();
27177
- }
27178
- }
27179
- startObserver(target) {
27180
- const observer = new this.ObserverClass(_.bind(this.triggerMutation, this));
27181
- this.observers.set(target, observer);
27182
- observer.observe(target, {
27183
- subtree: true,
27184
- attributes: true,
27185
- childList: true,
27186
- characterData: true
27187
- });
27188
- }
27189
- teardown() {
27190
- this.observers.clear();
27191
- this.shadowDom.teardown();
27192
- }
27193
- triggerMutation(mutation) {
27194
- this.dispatchEvent({
27195
- type: 'mutation',
27196
- mutation
27197
- });
27198
- }
27199
- handleAttachShadow({ shadowRoot }) {
27200
- this.startObserver(shadowRoot);
27201
- }
27202
- handleDetachShadow({ shadowRoot }) {
27203
- this.observers.delete(shadowRoot);
27204
- }
27205
- }
27206
- var observer = new UberMutationObserver();
27207
-
27208
27038
  // ---------------------------------------------------------------------------
27209
27039
  function registerEventHandlers({ events = [] }) {
27210
27040
  _.each(events, (callback, eventName) => {
@@ -27315,9 +27145,6 @@ const initialize = makeSafe(function (options) {
27315
27145
  teardownFns.push(initializeEventBuffer({
27316
27146
  localStorageUnload: localStorageUnloadEnabled
27317
27147
  }));
27318
- // needs to happen before initGuides
27319
- observer.initialize(pendo$1, PluginAPI);
27320
- teardownFns.push(() => observer.teardown());
27321
27148
  if (pendoCore) {
27322
27149
  /**
27323
27150
  * Current visitor id for pendo installation, either anonymous or identified. Used to determine
@@ -27371,7 +27198,7 @@ const initialize = makeSafe(function (options) {
27371
27198
  // Register handlers passed through pendo_options
27372
27199
  teardownFns.push(forwardInternalEvents(Events));
27373
27200
  registerEventHandlers(options);
27374
- teardownFns.push(initGuides(observer)); // this is safe. loadGuides actually does the loading.
27201
+ teardownFns.push(initGuides()); // this is safe. loadGuides actually does the loading.
27375
27202
  initIdentityEvents(); // setup identify and meta event listeners
27376
27203
  teardownFns.push(wirePage());
27377
27204
  teardownFns.push(initializePlugins());
@@ -32317,6 +32144,75 @@ function updateMasterGuideList(state) {
32317
32144
  }
32318
32145
  }
32319
32146
 
32147
+ function addShadowObserver(shadowRoot, observerCallback) {
32148
+ const MutationObserver = getZoneSafeMethod('MutationObserver');
32149
+ const shadowObserver = new MutationObserver(observerCallback);
32150
+ shadowObserver.observe(shadowRoot, {
32151
+ subtree: true,
32152
+ attributes: true,
32153
+ childList: true,
32154
+ characterData: true
32155
+ });
32156
+ }
32157
+ function patchAttachShadow(observerCallback) {
32158
+ const original = Element.prototype.attachShadow;
32159
+ Element.prototype.attachShadow = function (options) {
32160
+ const shadowRoot = original.call(this, options);
32161
+ if (this.shadowRoot) {
32162
+ addShadowObserver(this.shadowRoot, observerCallback);
32163
+ }
32164
+ return shadowRoot;
32165
+ };
32166
+ Element.prototype.attachShadow.toString = function () {
32167
+ return original.toString();
32168
+ };
32169
+ }
32170
+ function startObserver(observerCallback) {
32171
+ patchAttachShadow(observerCallback);
32172
+ if (!_.isFunction(document.createNodeIterator))
32173
+ return;
32174
+ const maxPerSearch = 5000;
32175
+ let nodesChecked = 0;
32176
+ let queue = [getBody()];
32177
+ let currentNode;
32178
+ function eachShadowRoot(iterator) {
32179
+ do {
32180
+ if (!iterator) {
32181
+ iterator = document.createNodeIterator(queue.pop(), NodeFilter.SHOW_ELEMENT);
32182
+ }
32183
+ if (!iterator || !iterator.nextNode)
32184
+ break;
32185
+ while ((currentNode = iterator.nextNode())) {
32186
+ nodesChecked++;
32187
+ if (currentNode && currentNode.shadowRoot) {
32188
+ addShadowObserver(currentNode.shadowRoot, observerCallback);
32189
+ queue.push(currentNode.shadowRoot);
32190
+ shadowDomManager.foundShadowRoots = true;
32191
+ }
32192
+ if (nodesChecked % maxPerSearch === 0)
32193
+ break;
32194
+ }
32195
+ if (currentNode)
32196
+ break;
32197
+ iterator = null;
32198
+ } while (queue.length);
32199
+ if (currentNode && shadowDomManager.foundShadowRoots) {
32200
+ setTimeout$1(() => {
32201
+ eachShadowRoot(iterator);
32202
+ }, 50);
32203
+ }
32204
+ if (nodesChecked === maxPerSearch && !shadowDomManager.foundShadowRoots) {
32205
+ shadowDomManager.stoppedSearchEarly = true;
32206
+ }
32207
+ }
32208
+ eachShadowRoot();
32209
+ }
32210
+ const shadowDomManager = {
32211
+ startObserver,
32212
+ foundShadowRoots: false,
32213
+ stoppedSearchEarly: false
32214
+ };
32215
+
32320
32216
  var GuideUpdateModule = (function () {
32321
32217
  var observer;
32322
32218
  function observerCallback() {
@@ -32327,6 +32223,7 @@ var GuideUpdateModule = (function () {
32327
32223
  }
32328
32224
  var state = {
32329
32225
  useObserver: false,
32226
+ observeShadowRoots: false,
32330
32227
  observing: false,
32331
32228
  needsUpdate: false,
32332
32229
  scheduledUpdate: null,
@@ -32357,31 +32254,43 @@ var GuideUpdateModule = (function () {
32357
32254
  context.commit('setScheduledUpdate', null);
32358
32255
  }
32359
32256
  },
32360
- startObserverIfNeeded(context) {
32257
+ startObserverIfNeeded(context, observerClass) {
32361
32258
  if (context.state.useObserver) {
32259
+ var observerInstance = context.getters.observer();
32260
+ if (!observerInstance) {
32261
+ observerInstance = new (observerClass || getZoneSafeMethod('MutationObserver'))(observerCallback);
32262
+ observer = observerInstance;
32263
+ }
32362
32264
  if (!context.state.observing) {
32363
- const observer = context.getters.observer();
32364
- observer.addEventListener('mutation', observerCallback);
32265
+ observerInstance.observe(document.documentElement, {
32266
+ subtree: true,
32267
+ attributes: true,
32268
+ childList: true,
32269
+ characterData: true
32270
+ });
32271
+ if (context.state.observeShadowRoots) {
32272
+ shadowDomManager.startObserver(observerCallback);
32273
+ }
32365
32274
  context.commit('setObserving', true);
32366
32275
  }
32367
32276
  }
32368
32277
  },
32369
32278
  stopObserver(context) {
32370
- const observer = context.getters.observer();
32371
- if (observer) {
32372
- observer.removeEventListener('mutation', observerCallback);
32279
+ var observerInstance = context.getters.observer();
32280
+ if (observerInstance && _.isFunction(observerInstance.disconnect)) {
32281
+ observerInstance.disconnect();
32373
32282
  }
32374
32283
  context.commit('setObserving', false);
32375
32284
  context.dispatch('stopScheduledUpdate');
32376
32285
  }
32377
32286
  };
32378
32287
  var mutations = {
32379
- setObserver(state, _observer) {
32380
- observer = _observer;
32381
- },
32382
32288
  setUseObserver(state) {
32383
32289
  state.useObserver = true;
32384
32290
  },
32291
+ setObserveShadowRoots(state) {
32292
+ state.observeShadowRoots = true;
32293
+ },
32385
32294
  setObserving(state, observing) {
32386
32295
  state.observing = observing;
32387
32296
  },
@@ -36296,8 +36205,7 @@ function debuggerExports() {
36296
36205
  isStagingServer,
36297
36206
  AutoDisplay,
36298
36207
  isLeader,
36299
- Events,
36300
- observer
36208
+ Events
36301
36209
  };
36302
36210
  }
36303
36211
  function startDebuggingModuleIfEnabled() {
@@ -38676,7 +38584,7 @@ function initAgent(pendo, PendoConfig) {
38676
38584
  AsyncContent.reset();
38677
38585
  store.dispatch('frames/init');
38678
38586
  logPublic.init();
38679
- shadowAPI.wrapSizzle(SizzleProxy, observer.shadowDom);
38587
+ shadowAPI.wrapSizzle(SizzleProxy);
38680
38588
  SizzleProxy.intercept(sizzleAttachPointInterceptor);
38681
38589
  populatePendoObject(pendo);
38682
38590
  log.addEventListener('log', _.partial(store.dispatch, 'errorLog/write'));