@lvce-editor/renderer-process 30.36.0 → 30.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10475,6 +10475,18 @@ const flushPendingData = state => {
10475
10475
  }
10476
10476
  pendingData.length = 0;
10477
10477
  };
10478
+ const focusIfConnected = state => {
10479
+ const {
10480
+ $Viewlet,
10481
+ pendingFocus,
10482
+ terminal
10483
+ } = state;
10484
+ if (!pendingFocus || !terminal || !$Viewlet.isConnected) {
10485
+ return;
10486
+ }
10487
+ state.pendingFocus = false;
10488
+ terminal.focus();
10489
+ };
10478
10490
  const mountTerminal = async (state, uid) => {
10479
10491
  const {
10480
10492
  fitAddon,
@@ -10499,6 +10511,7 @@ const mountTerminal = async (state, uid) => {
10499
10511
  terminal.open(state.$Viewlet);
10500
10512
  const resizeObserver = new ResizeObserver(() => {
10501
10513
  fitAddon.fit();
10514
+ focusIfConnected(state);
10502
10515
  });
10503
10516
  resizeObserver.observe(state.$Viewlet);
10504
10517
  state.fitAddon = fitAddon;
@@ -10507,10 +10520,7 @@ const mountTerminal = async (state, uid) => {
10507
10520
  state.disposables = [inputDisposable, resizeDisposable];
10508
10521
  fitAddon.fit();
10509
10522
  flushPendingData(state);
10510
- if (state.pendingFocus) {
10511
- state.pendingFocus = false;
10512
- terminal.focus();
10513
- }
10523
+ focusIfConnected(state);
10514
10524
  };
10515
10525
  const create = () => {
10516
10526
  const $Viewlet = document.createElement('div');
@@ -10554,7 +10564,7 @@ const focus = state => {
10554
10564
  const {
10555
10565
  terminal
10556
10566
  } = state;
10557
- if (!terminal) {
10567
+ if (!terminal || !state.$Viewlet.isConnected) {
10558
10568
  state.pendingFocus = true;
10559
10569
  return;
10560
10570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.36.0",
3
+ "version": "30.36.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"