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

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.
@@ -9978,7 +9978,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
9978
9978
  const SESSION_RESPONSE = 'multiplayer-debug-session-response';
9979
9979
  const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
9980
9980
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
9981
- const PACKAGE_VERSION_EXPORT = "1.2.32" || 0;
9981
+ const PACKAGE_VERSION_EXPORT = "1.2.34" || 0;
9982
9982
  // Regex patterns for OpenTelemetry ignore URLs
9983
9983
  const OTEL_IGNORE_URLS = [
9984
9984
  // Traces endpoint
package/dist/index.js CHANGED
@@ -24143,7 +24143,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
24143
24143
  const SESSION_RESPONSE = 'multiplayer-debug-session-response';
24144
24144
  const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24145
24145
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24146
- const PACKAGE_VERSION_EXPORT = "1.2.32" || 0;
24146
+ const PACKAGE_VERSION_EXPORT = "1.2.34" || 0;
24147
24147
  // Regex patterns for OpenTelemetry ignore URLs
24148
24148
  const OTEL_IGNORE_URLS = [
24149
24149
  // Traces endpoint
@@ -26561,41 +26561,75 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
26561
26561
  * Register session widget event listeners for controlling session actions
26562
26562
  */
26563
26563
  _registerWidgetEvents() {
26564
- this._sessionWidget.on('toggle', (state, comment) => {
26564
+ this._sessionWidget.on('start', () => {
26565
26565
  this.error = '';
26566
- if (state) {
26567
- this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.MANUAL);
26568
- }
26569
- else {
26570
- this.stop(comment === null || comment === void 0 ? void 0 : comment.trim());
26571
- }
26566
+ this._handleStart();
26567
+ });
26568
+ this._sessionWidget.on('stop', (comment) => {
26569
+ this.error = '';
26570
+ this._handleStop(comment);
26572
26571
  });
26573
26572
  this._sessionWidget.on('pause', () => {
26574
26573
  this.error = '';
26575
- this.pause();
26574
+ this._handlePause();
26576
26575
  });
26577
26576
  this._sessionWidget.on('resume', () => {
26578
26577
  this.error = '';
26579
- this.resume();
26578
+ this._handleResume();
26580
26579
  });
26581
26580
  this._sessionWidget.on('cancel', () => {
26582
26581
  this.error = '';
26583
- this.cancel();
26582
+ this._handleCancel();
26584
26583
  });
26585
26584
  this._sessionWidget.on('continuous-debugging', (enabled) => {
26586
26585
  this.error = '';
26587
26586
  if (enabled) {
26588
- this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.CONTINUOUS);
26587
+ this._handleContinuousDebugging();
26589
26588
  }
26590
26589
  else {
26591
- this.stop();
26590
+ this._handleStop();
26592
26591
  }
26593
26592
  });
26594
26593
  this._sessionWidget.on('save', () => {
26595
26594
  this.error = '';
26596
- this.save();
26595
+ this._handleSave();
26597
26596
  });
26598
26597
  }
26598
+ _handleStart() {
26599
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped) {
26600
+ this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.MANUAL);
26601
+ }
26602
+ }
26603
+ _handleStop(comment) {
26604
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started || this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
26605
+ this.stop(comment);
26606
+ }
26607
+ }
26608
+ _handlePause() {
26609
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started) {
26610
+ this.pause();
26611
+ }
26612
+ }
26613
+ _handleResume() {
26614
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
26615
+ this.resume();
26616
+ }
26617
+ }
26618
+ _handleCancel() {
26619
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started || this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
26620
+ this.cancel();
26621
+ }
26622
+ }
26623
+ _handleSave() {
26624
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started && this.continuousRecording) {
26625
+ this.save();
26626
+ }
26627
+ }
26628
+ _handleContinuousDebugging() {
26629
+ if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped) {
26630
+ this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.CONTINUOUS);
26631
+ }
26632
+ }
26599
26633
  /**
26600
26634
  * Register session limit reaching listeners for controlling session end
26601
26635
  */
@@ -26652,6 +26686,7 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
26652
26686
  }
26653
26687
  catch (error) {
26654
26688
  this.error = error.message;
26689
+ this.sessionState = _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped;
26655
26690
  if (this.continuousRecording) {
26656
26691
  this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.MANUAL;
26657
26692
  }
@@ -27091,6 +27126,7 @@ class DragManager {
27091
27126
  this.isDragging = false;
27092
27127
  this.dragStarted = false;
27093
27128
  this.isOnLeftHalfOfScreen = false;
27129
+ this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
27094
27130
  this.recorderButton = recorderButton;
27095
27131
  this.recorderPlacement = recorderPlacement;
27096
27132
  this.onDragEnd = onDragEnd;
@@ -27098,10 +27134,14 @@ class DragManager {
27098
27134
  this.onRecordingButtonClick = onRecordingButtonClick;
27099
27135
  }
27100
27136
  init() {
27137
+ if (!this.isBrowser)
27138
+ return;
27101
27139
  this.loadStoredPosition();
27102
27140
  this.setupDragListeners();
27103
27141
  }
27104
27142
  loadStoredPosition() {
27143
+ if (!this.isBrowser || typeof window === 'undefined' || typeof localStorage === 'undefined')
27144
+ return;
27105
27145
  const savedPosition = localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_0__.POSITION_STATE_KEY);
27106
27146
  if (!savedPosition) {
27107
27147
  return;
@@ -27132,11 +27172,15 @@ class DragManager {
27132
27172
  });
27133
27173
  }
27134
27174
  savePosition(r, b) {
27175
+ if (!this.isBrowser || typeof window === 'undefined' || typeof localStorage === 'undefined')
27176
+ return;
27135
27177
  const right = (r / window.innerWidth) * 100;
27136
27178
  const bottom = (b / window.innerHeight) * 100;
27137
27179
  localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_0__.POSITION_STATE_KEY, JSON.stringify({ right, bottom }));
27138
27180
  }
27139
27181
  setupDragListeners() {
27182
+ if (!this.isBrowser || typeof document === 'undefined' || typeof window === 'undefined')
27183
+ return;
27140
27184
  this.recorderButton.addEventListener('mousedown', (e) => {
27141
27185
  const onMouseUp = () => {
27142
27186
  const isDraggable = !this.recorderButton.classList.contains('no-draggable');
@@ -27230,29 +27274,37 @@ class DragManager {
27230
27274
 
27231
27275
  class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observable {
27232
27276
  set buttonState(newState) {
27277
+ var _a, _b;
27233
27278
  this._buttonState = newState;
27279
+ if (!this.isBrowser)
27280
+ return;
27234
27281
  const { icon, tooltip, classes, excludeClasses } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.buttonStates[newState];
27235
27282
  if (newState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL) {
27236
- this.buttonDraggabilityObserver.observe(this.recorderButton, {
27283
+ (_a = this.buttonDraggabilityObserver) === null || _a === void 0 ? void 0 : _a.observe(this.recorderButton, {
27237
27284
  attributes: true,
27238
27285
  attributeOldValue: true,
27239
27286
  attributeFilter: ['class'],
27240
27287
  });
27241
27288
  }
27242
27289
  else {
27243
- this.buttonDraggabilityObserver.disconnect();
27290
+ (_b = this.buttonDraggabilityObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
27244
27291
  }
27292
+ this.uiManager.setPopoverLoadingState(newState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING);
27245
27293
  this.updateButton(icon, tooltip, excludeClasses, classes);
27246
27294
  }
27247
27295
  set initialPopoverVisible(v) {
27248
27296
  var _a;
27249
27297
  this._initialPopoverVisible = v;
27250
- (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27298
+ if (this.isBrowser) {
27299
+ (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27300
+ }
27251
27301
  }
27252
27302
  set finalPopoverVisible(v) {
27253
27303
  var _a;
27254
27304
  this._finalPopoverVisible = v;
27255
- (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27305
+ if (this.isBrowser) {
27306
+ (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27307
+ }
27256
27308
  }
27257
27309
  get error() {
27258
27310
  return this._error;
@@ -27271,6 +27323,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27271
27323
  }
27272
27324
  set isStarted(v) {
27273
27325
  this._isStarted = v;
27326
+ if (!this.isBrowser)
27327
+ return;
27274
27328
  if (!this.showRecorderButton && v && !this._continuousRecording) {
27275
27329
  this.overlay.classList.remove('hidden');
27276
27330
  this.makeOverlayDraggable();
@@ -27290,7 +27344,6 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27290
27344
  else {
27291
27345
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CONTINUOUS_DEBUGGING;
27292
27346
  }
27293
- this.uiManager.setPopoverLoadingState(false);
27294
27347
  }
27295
27348
  else {
27296
27349
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
@@ -27298,6 +27351,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27298
27351
  }
27299
27352
  set isPaused(v) {
27300
27353
  this._isPaused = v;
27354
+ if (!this.isBrowser)
27355
+ return;
27301
27356
  if (this._isInitialized && !this.showRecorderButton && v && !this._continuousRecording) {
27302
27357
  this.overlay.classList.add('hidden');
27303
27358
  this.submitSessionDialog.classList.remove('hidden');
@@ -27341,6 +27396,18 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27341
27396
  }
27342
27397
  }
27343
27398
  };
27399
+ this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
27400
+ if (!this.isBrowser) {
27401
+ // Create dummy elements for SSR to prevent crashes
27402
+ this.recorderButton = {};
27403
+ this.initialPopover = {};
27404
+ this.finalPopover = {};
27405
+ this.overlay = {};
27406
+ this.toast = {};
27407
+ this.submitSessionDialog = {};
27408
+ this.uiManager = {};
27409
+ return;
27410
+ }
27344
27411
  this.recorderButton = document.createElement('button');
27345
27412
  this.initialPopover = document.createElement('div');
27346
27413
  this.finalPopover = document.createElement('div');
@@ -27379,6 +27446,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27379
27446
  }
27380
27447
  }
27381
27448
  updateContinuousRecordingState(checked, disabled = false) {
27449
+ if (!this.isBrowser)
27450
+ return;
27382
27451
  const toggleCheckbox = this.initialPopover.querySelector('#mp-session-debugger-continuous-debugging-checkbox');
27383
27452
  if (toggleCheckbox) {
27384
27453
  toggleCheckbox.checked = checked;
@@ -27386,6 +27455,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27386
27455
  }
27387
27456
  }
27388
27457
  updateSaveContinuousDebugSessionState(state) {
27458
+ if (!this.isBrowser)
27459
+ return;
27389
27460
  const saveButton = this.initialPopover.querySelector('#mp-save-continuous-debug-session');
27390
27461
  if (saveButton) {
27391
27462
  const { textContent, disabled } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.continuousRecordingSaveButtonStates[state];
@@ -27399,15 +27470,21 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27399
27470
  * @param duration - Duration in milliseconds to show the toast (default: 10000ms)
27400
27471
  */
27401
27472
  showToast(config, duration = 10000) {
27473
+ if (!this.isBrowser)
27474
+ return;
27402
27475
  this.uiManager.showToast(config, duration);
27403
27476
  }
27404
27477
  /**
27405
27478
  * Hides the currently displayed toast message
27406
27479
  */
27407
27480
  hideToast() {
27481
+ if (!this.isBrowser)
27482
+ return;
27408
27483
  this.uiManager.hideToast();
27409
27484
  }
27410
27485
  observeButtonDraggableMode() {
27486
+ if (!this.isBrowser)
27487
+ return;
27411
27488
  this.buttonDraggabilityObserver = new MutationObserver((mutationsList) => {
27412
27489
  for (const mutation of mutationsList) {
27413
27490
  if (mutation.type === 'attributes' &&
@@ -27429,6 +27506,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27429
27506
  init(options) {
27430
27507
  if (this._isInitialized)
27431
27508
  return;
27509
+ if (!this.isBrowser)
27510
+ return;
27432
27511
  this._isInitialized = true;
27433
27512
  this.showRecorderButton = options.showWidget;
27434
27513
  this._showContinuousRecording = options.showContinuousRecording;
@@ -27468,6 +27547,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27468
27547
  this.addEventListeners();
27469
27548
  }
27470
27549
  appendElements(elements) {
27550
+ if (!this.isBrowser || typeof document === 'undefined')
27551
+ return;
27471
27552
  const rootWrapper = document.createElement('mp-root');
27472
27553
  rootWrapper.classList.add('mp-root-wrapper');
27473
27554
  rootWrapper.setAttribute('data-rr-ignore', 'true');
@@ -27475,6 +27556,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27475
27556
  document.body.appendChild(rootWrapper);
27476
27557
  }
27477
27558
  addRecorderDragFunctionality() {
27559
+ if (!this.isBrowser)
27560
+ return;
27478
27561
  this.dragManager = new _dragManager__WEBPACK_IMPORTED_MODULE_2__.DragManager(this.recorderButton, this._recorderPlacement, () => {
27479
27562
  if (this._isPaused) {
27480
27563
  this.finalPopoverVisible = true;
@@ -27483,6 +27566,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27483
27566
  this.dragManager.init();
27484
27567
  }
27485
27568
  updatePopoverPosition() {
27569
+ if (!this.isBrowser || typeof window === 'undefined')
27570
+ return;
27486
27571
  const { top, right, bottom, left } = this.recorderButton.getBoundingClientRect();
27487
27572
  const isDraggable = !this.recorderButton.classList.contains('no-draggable');
27488
27573
  const POPOVER_HEIGHT = this._isStarted ? 400 : 300;
@@ -27519,6 +27604,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27519
27604
  });
27520
27605
  }
27521
27606
  addEventListeners() {
27607
+ if (!this.isBrowser)
27608
+ return;
27522
27609
  const events = [];
27523
27610
  if (this.showRecorderButton) {
27524
27611
  events.push({
@@ -27576,34 +27663,47 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27576
27663
  });
27577
27664
  }
27578
27665
  handleStopRecording() {
27666
+ if (!this.isBrowser)
27667
+ return;
27579
27668
  this.onStop();
27580
27669
  this.handleUIReseting();
27581
27670
  }
27582
27671
  handleUIReseting() {
27672
+ if (!this.isBrowser)
27673
+ return;
27583
27674
  this.finalPopoverVisible = false;
27584
27675
  this.resetRecordingButton();
27585
27676
  }
27586
27677
  handleCloseInitialPopover() {
27678
+ if (!this.isBrowser)
27679
+ return;
27587
27680
  if (this._buttonState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING) {
27588
27681
  this.onCancel();
27589
- this.uiManager.setPopoverLoadingState(false);
27590
27682
  }
27591
27683
  this.initialPopoverVisible = false;
27592
27684
  this.buttonState = this._continuousRecording
27593
27685
  ? _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CONTINUOUS_DEBUGGING
27594
27686
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
27595
- document.removeEventListener('click', this.handleClickOutside);
27687
+ if (typeof document !== 'undefined') {
27688
+ document.removeEventListener('click', this.handleClickOutside);
27689
+ }
27596
27690
  }
27597
27691
  handleCloseFinalPopover() {
27598
27692
  this.onResume();
27599
27693
  }
27600
27694
  onRequestError() {
27695
+ if (!this.isBrowser)
27696
+ return;
27601
27697
  this.initialPopoverVisible = false;
27602
27698
  this.finalPopoverVisible = false;
27603
27699
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
27604
- document.removeEventListener('click', this.handleClickOutside);
27700
+ if (typeof document !== 'undefined') {
27701
+ document.removeEventListener('click', this.handleClickOutside);
27702
+ }
27605
27703
  }
27606
27704
  handleDismissRecording() {
27705
+ if (!this.isBrowser)
27706
+ return;
27607
27707
  this.onCancel();
27608
27708
  this.finalPopoverVisible = !this._finalPopoverVisible;
27609
27709
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
@@ -27622,6 +27722,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27622
27722
  (_a = element === null || element === void 0 ? void 0 : element.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.addEventListener(event, handler);
27623
27723
  }
27624
27724
  onRecordingButtonClick(e) {
27725
+ if (!this.isBrowser)
27726
+ return;
27625
27727
  if (this.buttonClickExternalHandler) {
27626
27728
  const shouldPropagate = this.buttonClickExternalHandler();
27627
27729
  if (shouldPropagate === false) {
@@ -27653,15 +27755,17 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27653
27755
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL;
27654
27756
  this.initialPopoverVisible = !this._initialPopoverVisible;
27655
27757
  }
27656
- if (this._initialPopoverVisible || this._finalPopoverVisible) {
27657
- document.addEventListener('click', this.handleClickOutside);
27658
- }
27659
- else {
27660
- document.removeEventListener('click', this.handleClickOutside);
27758
+ if (typeof document !== 'undefined') {
27759
+ if (this._initialPopoverVisible || this._finalPopoverVisible) {
27760
+ document.addEventListener('click', this.handleClickOutside);
27761
+ }
27762
+ else {
27763
+ document.removeEventListener('click', this.handleClickOutside);
27764
+ }
27661
27765
  }
27662
27766
  }
27663
27767
  updateButton(innerHTML, tooltip, excludeClasses, classes) {
27664
- if (!this.recorderButton)
27768
+ if (!this.isBrowser || !this.recorderButton)
27665
27769
  return;
27666
27770
  (0,_utils__WEBPACK_IMPORTED_MODULE_0__.insertTrustedHTML)(this.recorderButton, `${innerHTML}`);
27667
27771
  this.recorderButton.dataset['tooltip'] = tooltip;
@@ -27683,15 +27787,16 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27683
27787
  }
27684
27788
  startRecording() {
27685
27789
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING;
27686
- this.uiManager.setPopoverLoadingState(true);
27687
27790
  this.onStart();
27688
27791
  }
27689
27792
  onStart() {
27690
27793
  if (!this.recorderButton)
27691
27794
  return;
27692
- this.emit('toggle', [true]);
27795
+ this.emit('start', []);
27693
27796
  }
27694
27797
  onStop() {
27798
+ if (!this.isBrowser)
27799
+ return;
27695
27800
  if (this.showRecorderButton && !this.recorderButton)
27696
27801
  return;
27697
27802
  this.submitSessionDialog.classList.add('hidden');
@@ -27699,16 +27804,18 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27699
27804
  ? this.commentTextarea
27700
27805
  : this.submitSessionDialog.querySelector('#mp-recording-comment');
27701
27806
  if (commentElement) {
27702
- this.emit('toggle', [false, commentElement.value]);
27807
+ this.emit('stop', [commentElement.value]);
27703
27808
  commentElement.value = '';
27704
27809
  return;
27705
27810
  }
27706
- this.emit('toggle', [false, '']);
27811
+ this.emit('stop', []);
27707
27812
  }
27708
27813
  onPause() {
27709
27814
  this.emit('pause', []);
27710
27815
  }
27711
27816
  onResume() {
27817
+ if (!this.isBrowser)
27818
+ return;
27712
27819
  this.finalPopoverVisible = false;
27713
27820
  if (!this._continuousRecording) {
27714
27821
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.RECORDING;
@@ -27719,28 +27826,35 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27719
27826
  }
27720
27827
  }
27721
27828
  onCancel() {
27829
+ if (!this.isBrowser)
27830
+ return;
27722
27831
  this.submitSessionDialog.classList.add('hidden');
27723
27832
  this.emit('cancel', []);
27724
27833
  }
27725
27834
  enable() {
27726
- if (!this.recorderButton)
27835
+ if (!this.isBrowser || !this.recorderButton)
27727
27836
  return;
27728
27837
  this.recorderButton.disabled = false;
27729
27838
  this.recorderButton.style.opacity = '1';
27730
27839
  }
27731
27840
  disable() {
27732
- if (!this.recorderButton)
27841
+ if (!this.isBrowser || !this.recorderButton)
27733
27842
  return;
27734
27843
  this.recorderButton.disabled = true;
27735
27844
  this.recorderButton.style.opacity = '0.5';
27736
27845
  }
27737
27846
  destroy() {
27738
- if (!this.recorderButton)
27847
+ if (!this.isBrowser || !this.recorderButton || typeof document === 'undefined')
27739
27848
  return;
27740
- document.body.removeChild(this.recorderButton);
27849
+ const rootWrapper = document.querySelector('.mp-root-wrapper');
27850
+ if (rootWrapper && rootWrapper.contains(this.recorderButton)) {
27851
+ document.body.removeChild(rootWrapper);
27852
+ }
27741
27853
  document.removeEventListener('click', this.handleClickOutside);
27742
27854
  }
27743
27855
  startTimer() {
27856
+ if (!this.isBrowser)
27857
+ return;
27744
27858
  if (this.timerInterval) {
27745
27859
  clearInterval(this.timerInterval);
27746
27860
  this.timerInterval = null;
@@ -27759,6 +27873,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27759
27873
  }
27760
27874
  }
27761
27875
  makeOverlayDraggable() {
27876
+ if (!this.isBrowser || typeof document === 'undefined')
27877
+ return;
27762
27878
  const element = this.overlay;
27763
27879
  const dragHandle = element.querySelector('.mp-drag-handle');
27764
27880
  if (!dragHandle)