@multiplayer-app/session-recorder-browser 1.2.32 → 1.2.33

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.
@@ -25094,7 +25094,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
25094
25094
  const SESSION_RESPONSE = 'multiplayer-debug-session-response';
25095
25095
  const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
25096
25096
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
25097
- const PACKAGE_VERSION_EXPORT = "1.2.32" || 0;
25097
+ const PACKAGE_VERSION_EXPORT = "1.2.33" || 0;
25098
25098
  // Regex patterns for OpenTelemetry ignore URLs
25099
25099
  const OTEL_IGNORE_URLS = [
25100
25100
  // Traces endpoint
@@ -28249,29 +28249,36 @@ __webpack_require__.r(__webpack_exports__);
28249
28249
 
28250
28250
  class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observable {
28251
28251
  set buttonState(newState) {
28252
+ var _a, _b;
28252
28253
  this._buttonState = newState;
28254
+ if (!this.isBrowser)
28255
+ return;
28253
28256
  const { icon, tooltip, classes, excludeClasses } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.buttonStates[newState];
28254
28257
  if (newState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL) {
28255
- this.buttonDraggabilityObserver.observe(this.recorderButton, {
28258
+ (_a = this.buttonDraggabilityObserver) === null || _a === void 0 ? void 0 : _a.observe(this.recorderButton, {
28256
28259
  attributes: true,
28257
28260
  attributeOldValue: true,
28258
28261
  attributeFilter: ['class'],
28259
28262
  });
28260
28263
  }
28261
28264
  else {
28262
- this.buttonDraggabilityObserver.disconnect();
28265
+ (_b = this.buttonDraggabilityObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
28263
28266
  }
28264
28267
  this.updateButton(icon, tooltip, excludeClasses, classes);
28265
28268
  }
28266
28269
  set initialPopoverVisible(v) {
28267
28270
  var _a;
28268
28271
  this._initialPopoverVisible = v;
28269
- (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
28272
+ if (this.isBrowser) {
28273
+ (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
28274
+ }
28270
28275
  }
28271
28276
  set finalPopoverVisible(v) {
28272
28277
  var _a;
28273
28278
  this._finalPopoverVisible = v;
28274
- (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
28279
+ if (this.isBrowser) {
28280
+ (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
28281
+ }
28275
28282
  }
28276
28283
  get error() {
28277
28284
  return this._error;
@@ -28290,6 +28297,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28290
28297
  }
28291
28298
  set isStarted(v) {
28292
28299
  this._isStarted = v;
28300
+ if (!this.isBrowser)
28301
+ return;
28293
28302
  if (!this.showRecorderButton && v && !this._continuousRecording) {
28294
28303
  this.overlay.classList.remove('hidden');
28295
28304
  this.makeOverlayDraggable();
@@ -28317,6 +28326,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28317
28326
  }
28318
28327
  set isPaused(v) {
28319
28328
  this._isPaused = v;
28329
+ if (!this.isBrowser)
28330
+ return;
28320
28331
  if (this._isInitialized && !this.showRecorderButton && v && !this._continuousRecording) {
28321
28332
  this.overlay.classList.add('hidden');
28322
28333
  this.submitSessionDialog.classList.remove('hidden');
@@ -28360,6 +28371,18 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28360
28371
  }
28361
28372
  }
28362
28373
  };
28374
+ this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
28375
+ if (!this.isBrowser) {
28376
+ // Create dummy elements for SSR to prevent crashes
28377
+ this.recorderButton = {};
28378
+ this.initialPopover = {};
28379
+ this.finalPopover = {};
28380
+ this.overlay = {};
28381
+ this.toast = {};
28382
+ this.submitSessionDialog = {};
28383
+ this.uiManager = {};
28384
+ return;
28385
+ }
28363
28386
  this.recorderButton = document.createElement('button');
28364
28387
  this.initialPopover = document.createElement('div');
28365
28388
  this.finalPopover = document.createElement('div');
@@ -28398,6 +28421,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28398
28421
  }
28399
28422
  }
28400
28423
  updateContinuousRecordingState(checked, disabled = false) {
28424
+ if (!this.isBrowser)
28425
+ return;
28401
28426
  const toggleCheckbox = this.initialPopover.querySelector('#mp-session-debugger-continuous-debugging-checkbox');
28402
28427
  if (toggleCheckbox) {
28403
28428
  toggleCheckbox.checked = checked;
@@ -28405,6 +28430,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28405
28430
  }
28406
28431
  }
28407
28432
  updateSaveContinuousDebugSessionState(state) {
28433
+ if (!this.isBrowser)
28434
+ return;
28408
28435
  const saveButton = this.initialPopover.querySelector('#mp-save-continuous-debug-session');
28409
28436
  if (saveButton) {
28410
28437
  const { textContent, disabled } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.continuousRecordingSaveButtonStates[state];
@@ -28418,15 +28445,21 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28418
28445
  * @param duration - Duration in milliseconds to show the toast (default: 10000ms)
28419
28446
  */
28420
28447
  showToast(config, duration = 10000) {
28448
+ if (!this.isBrowser)
28449
+ return;
28421
28450
  this.uiManager.showToast(config, duration);
28422
28451
  }
28423
28452
  /**
28424
28453
  * Hides the currently displayed toast message
28425
28454
  */
28426
28455
  hideToast() {
28456
+ if (!this.isBrowser)
28457
+ return;
28427
28458
  this.uiManager.hideToast();
28428
28459
  }
28429
28460
  observeButtonDraggableMode() {
28461
+ if (!this.isBrowser)
28462
+ return;
28430
28463
  this.buttonDraggabilityObserver = new MutationObserver((mutationsList) => {
28431
28464
  for (const mutation of mutationsList) {
28432
28465
  if (mutation.type === 'attributes' &&
@@ -28448,6 +28481,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28448
28481
  init(options) {
28449
28482
  if (this._isInitialized)
28450
28483
  return;
28484
+ if (!this.isBrowser)
28485
+ return;
28451
28486
  this._isInitialized = true;
28452
28487
  this.showRecorderButton = options.showWidget;
28453
28488
  this._showContinuousRecording = options.showContinuousRecording;
@@ -28487,6 +28522,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28487
28522
  this.addEventListeners();
28488
28523
  }
28489
28524
  appendElements(elements) {
28525
+ if (!this.isBrowser || typeof document === 'undefined')
28526
+ return;
28490
28527
  const rootWrapper = document.createElement('mp-root');
28491
28528
  rootWrapper.classList.add('mp-root-wrapper');
28492
28529
  rootWrapper.setAttribute('data-rr-ignore', 'true');
@@ -28494,6 +28531,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28494
28531
  document.body.appendChild(rootWrapper);
28495
28532
  }
28496
28533
  addRecorderDragFunctionality() {
28534
+ if (!this.isBrowser)
28535
+ return;
28497
28536
  this.dragManager = new _dragManager__WEBPACK_IMPORTED_MODULE_2__.DragManager(this.recorderButton, this._recorderPlacement, () => {
28498
28537
  if (this._isPaused) {
28499
28538
  this.finalPopoverVisible = true;
@@ -28502,6 +28541,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28502
28541
  this.dragManager.init();
28503
28542
  }
28504
28543
  updatePopoverPosition() {
28544
+ if (!this.isBrowser || typeof window === 'undefined')
28545
+ return;
28505
28546
  const { top, right, bottom, left } = this.recorderButton.getBoundingClientRect();
28506
28547
  const isDraggable = !this.recorderButton.classList.contains('no-draggable');
28507
28548
  const POPOVER_HEIGHT = this._isStarted ? 400 : 300;
@@ -28538,6 +28579,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28538
28579
  });
28539
28580
  }
28540
28581
  addEventListeners() {
28582
+ if (!this.isBrowser)
28583
+ return;
28541
28584
  const events = [];
28542
28585
  if (this.showRecorderButton) {
28543
28586
  events.push({
@@ -28595,14 +28638,20 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28595
28638
  });
28596
28639
  }
28597
28640
  handleStopRecording() {
28641
+ if (!this.isBrowser)
28642
+ return;
28598
28643
  this.onStop();
28599
28644
  this.handleUIReseting();
28600
28645
  }
28601
28646
  handleUIReseting() {
28647
+ if (!this.isBrowser)
28648
+ return;
28602
28649
  this.finalPopoverVisible = false;
28603
28650
  this.resetRecordingButton();
28604
28651
  }
28605
28652
  handleCloseInitialPopover() {
28653
+ if (!this.isBrowser)
28654
+ return;
28606
28655
  if (this._buttonState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING) {
28607
28656
  this.onCancel();
28608
28657
  this.uiManager.setPopoverLoadingState(false);
@@ -28611,18 +28660,26 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28611
28660
  this.buttonState = this._continuousRecording
28612
28661
  ? _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CONTINUOUS_DEBUGGING
28613
28662
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
28614
- document.removeEventListener('click', this.handleClickOutside);
28663
+ if (typeof document !== 'undefined') {
28664
+ document.removeEventListener('click', this.handleClickOutside);
28665
+ }
28615
28666
  }
28616
28667
  handleCloseFinalPopover() {
28617
28668
  this.onResume();
28618
28669
  }
28619
28670
  onRequestError() {
28671
+ if (!this.isBrowser)
28672
+ return;
28620
28673
  this.initialPopoverVisible = false;
28621
28674
  this.finalPopoverVisible = false;
28622
28675
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
28623
- document.removeEventListener('click', this.handleClickOutside);
28676
+ if (typeof document !== 'undefined') {
28677
+ document.removeEventListener('click', this.handleClickOutside);
28678
+ }
28624
28679
  }
28625
28680
  handleDismissRecording() {
28681
+ if (!this.isBrowser)
28682
+ return;
28626
28683
  this.onCancel();
28627
28684
  this.finalPopoverVisible = !this._finalPopoverVisible;
28628
28685
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
@@ -28641,6 +28698,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28641
28698
  (_a = element === null || element === void 0 ? void 0 : element.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.addEventListener(event, handler);
28642
28699
  }
28643
28700
  onRecordingButtonClick(e) {
28701
+ if (!this.isBrowser)
28702
+ return;
28644
28703
  if (this.buttonClickExternalHandler) {
28645
28704
  const shouldPropagate = this.buttonClickExternalHandler();
28646
28705
  if (shouldPropagate === false) {
@@ -28672,15 +28731,17 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28672
28731
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL;
28673
28732
  this.initialPopoverVisible = !this._initialPopoverVisible;
28674
28733
  }
28675
- if (this._initialPopoverVisible || this._finalPopoverVisible) {
28676
- document.addEventListener('click', this.handleClickOutside);
28677
- }
28678
- else {
28679
- document.removeEventListener('click', this.handleClickOutside);
28734
+ if (typeof document !== 'undefined') {
28735
+ if (this._initialPopoverVisible || this._finalPopoverVisible) {
28736
+ document.addEventListener('click', this.handleClickOutside);
28737
+ }
28738
+ else {
28739
+ document.removeEventListener('click', this.handleClickOutside);
28740
+ }
28680
28741
  }
28681
28742
  }
28682
28743
  updateButton(innerHTML, tooltip, excludeClasses, classes) {
28683
- if (!this.recorderButton)
28744
+ if (!this.isBrowser || !this.recorderButton)
28684
28745
  return;
28685
28746
  (0,_utils__WEBPACK_IMPORTED_MODULE_0__.insertTrustedHTML)(this.recorderButton, `${innerHTML}`);
28686
28747
  this.recorderButton.dataset['tooltip'] = tooltip;
@@ -28711,6 +28772,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28711
28772
  this.emit('toggle', [true]);
28712
28773
  }
28713
28774
  onStop() {
28775
+ if (!this.isBrowser)
28776
+ return;
28714
28777
  if (this.showRecorderButton && !this.recorderButton)
28715
28778
  return;
28716
28779
  this.submitSessionDialog.classList.add('hidden');
@@ -28728,6 +28791,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28728
28791
  this.emit('pause', []);
28729
28792
  }
28730
28793
  onResume() {
28794
+ if (!this.isBrowser)
28795
+ return;
28731
28796
  this.finalPopoverVisible = false;
28732
28797
  if (!this._continuousRecording) {
28733
28798
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.RECORDING;
@@ -28738,28 +28803,35 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28738
28803
  }
28739
28804
  }
28740
28805
  onCancel() {
28806
+ if (!this.isBrowser)
28807
+ return;
28741
28808
  this.submitSessionDialog.classList.add('hidden');
28742
28809
  this.emit('cancel', []);
28743
28810
  }
28744
28811
  enable() {
28745
- if (!this.recorderButton)
28812
+ if (!this.isBrowser || !this.recorderButton)
28746
28813
  return;
28747
28814
  this.recorderButton.disabled = false;
28748
28815
  this.recorderButton.style.opacity = '1';
28749
28816
  }
28750
28817
  disable() {
28751
- if (!this.recorderButton)
28818
+ if (!this.isBrowser || !this.recorderButton)
28752
28819
  return;
28753
28820
  this.recorderButton.disabled = true;
28754
28821
  this.recorderButton.style.opacity = '0.5';
28755
28822
  }
28756
28823
  destroy() {
28757
- if (!this.recorderButton)
28824
+ if (!this.isBrowser || !this.recorderButton || typeof document === 'undefined')
28758
28825
  return;
28759
- document.body.removeChild(this.recorderButton);
28826
+ const rootWrapper = document.querySelector('.mp-root-wrapper');
28827
+ if (rootWrapper && rootWrapper.contains(this.recorderButton)) {
28828
+ document.body.removeChild(rootWrapper);
28829
+ }
28760
28830
  document.removeEventListener('click', this.handleClickOutside);
28761
28831
  }
28762
28832
  startTimer() {
28833
+ if (!this.isBrowser)
28834
+ return;
28763
28835
  if (this.timerInterval) {
28764
28836
  clearInterval(this.timerInterval);
28765
28837
  this.timerInterval = null;
@@ -28778,6 +28850,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
28778
28850
  }
28779
28851
  }
28780
28852
  makeOverlayDraggable() {
28853
+ if (!this.isBrowser || typeof document === 'undefined')
28854
+ return;
28781
28855
  const element = this.overlay;
28782
28856
  const dragHandle = element.querySelector('.mp-drag-handle');
28783
28857
  if (!dragHandle)