@lvce-editor/renderer-process 29.2.0 → 29.4.0

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.
@@ -99,7 +99,7 @@ const writeText = async text => {
99
99
  const toClipboardItem = options => {
100
100
  return new ClipboardItem(options);
101
101
  };
102
- const write$1 = async itemOptions => {
102
+ const write$2 = async itemOptions => {
103
103
  const items = itemOptions.map(toClipboardItem);
104
104
  await navigator.clipboard.write(items);
105
105
  };
@@ -1087,7 +1087,7 @@ const Quote = 93;
1087
1087
  const Star = 131;
1088
1088
  const Plus = 132;
1089
1089
 
1090
- const keyCodeMap = {
1090
+ const keyCodeMap$1 = {
1091
1091
  [Backquote$1]: Backquote,
1092
1092
  [Backquote2]: Backquote,
1093
1093
  [Backslash$1]: Backslash,
@@ -1180,7 +1180,7 @@ const keyCodeMap = {
1180
1180
  [UpArrow$1]: UpArrow
1181
1181
  };
1182
1182
  const getKeyCode = key => {
1183
- return keyCodeMap[key] || Unknown;
1183
+ return keyCodeMap$1[key] || Unknown;
1184
1184
  };
1185
1185
 
1186
1186
  const CtrlCmd = 1 << 11 >>> 0;
@@ -2315,7 +2315,7 @@ const fixElectronParameters = value => {
2315
2315
  transfer
2316
2316
  };
2317
2317
  };
2318
- const attachEvents$7 = that => {
2318
+ const attachEvents$8 = that => {
2319
2319
  const handleMessage = (...args) => {
2320
2320
  const data = that.getData(...args);
2321
2321
  that.dispatchEvent(new MessageEvent('message', {
@@ -2332,7 +2332,7 @@ class Ipc extends EventTarget {
2332
2332
  constructor(rawIpc) {
2333
2333
  super();
2334
2334
  this._rawIpc = rawIpc;
2335
- attachEvents$7(this);
2335
+ attachEvents$8(this);
2336
2336
  }
2337
2337
  }
2338
2338
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
@@ -3445,7 +3445,7 @@ const hydrate$3 = async () => {
3445
3445
  };
3446
3446
 
3447
3447
  // TODO needed?
3448
- const dispose$i = () => {
3448
+ const dispose$j = () => {
3449
3449
  if (state$7.rpc) {
3450
3450
  // @ts-expect-error
3451
3451
  state$7.rpc.dispose();
@@ -3470,7 +3470,7 @@ const invokeAndTransfer = (method, ...params) => {
3470
3470
 
3471
3471
  const RendererWorker = {
3472
3472
  __proto__: null,
3473
- dispose: dispose$i,
3473
+ dispose: dispose$j,
3474
3474
  hydrate: hydrate$3,
3475
3475
  invoke: invoke$1,
3476
3476
  invokeAndTransfer,
@@ -3645,7 +3645,7 @@ const createWithOptions = (type, message, options) => {
3645
3645
  const $Notification = create$NotificationWithOptions(message, options);
3646
3646
  append$1($Notification);
3647
3647
  };
3648
- const dispose$h = id => {
3648
+ const dispose$i = id => {
3649
3649
  // const $Notification = state.$Notifications
3650
3650
  };
3651
3651
 
@@ -3782,7 +3782,7 @@ const getElement = () => {
3782
3782
  return state$4.$PreviousFocusElement;
3783
3783
  };
3784
3784
 
3785
- const focus$d = $Element => {
3785
+ const focus$e = $Element => {
3786
3786
  if ($Element === document.activeElement) {
3787
3787
  return;
3788
3788
  }
@@ -3881,7 +3881,7 @@ const getLevel = $Menu => {
3881
3881
  // @ts-expect-error
3882
3882
  return state$3.$$Menus.indexOf($Menu);
3883
3883
  };
3884
- const handleMouseDown$3 = event => {
3884
+ const handleMouseDown$4 = event => {
3885
3885
  const $Target = event.target;
3886
3886
  const $Menu = $Target.closest('.Menu');
3887
3887
  const index = findIndex($Menu, $Target);
@@ -3958,7 +3958,7 @@ const create$Menu$1 = () => {
3958
3958
  $Menu.tabIndex = -1;
3959
3959
  // $ContextMenu.onmousedown = contextMenuHandleMouseDown
3960
3960
  // TODO mousedown vs click? (click is usually better but mousedown is faster, why wait 100ms?)
3961
- $Menu.addEventListener(MouseDown, handleMouseDown$3);
3961
+ $Menu.addEventListener(MouseDown, handleMouseDown$4);
3962
3962
  $Menu.addEventListener(MouseEnter, handleMouseEnter, {
3963
3963
  capture: true
3964
3964
  });
@@ -4031,7 +4031,7 @@ const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom = [],
4031
4031
  state$3.$$Menus.push($Menu);
4032
4032
  append$1($Menu);
4033
4033
  if (level === 0) {
4034
- focus$d($Menu);
4034
+ focus$e($Menu);
4035
4035
  send('Focus.setFocus', FocusMenu);
4036
4036
  }
4037
4037
  };
@@ -4430,7 +4430,7 @@ const performAction2 = async (locator, fnName, options) => {
4430
4430
  fn(element, options);
4431
4431
  };
4432
4432
 
4433
- const toHaveText$1 = locator => {
4433
+ const getElementText = locator => {
4434
4434
  const element = querySelectorOne(locator._parsed);
4435
4435
  if (!element) {
4436
4436
  return {
@@ -4443,6 +4443,12 @@ const toHaveText$1 = locator => {
4443
4443
  wasFound: true
4444
4444
  };
4445
4445
  };
4446
+ const toHaveText$1 = locator => {
4447
+ return getElementText(locator);
4448
+ };
4449
+ const toContainText$1 = locator => {
4450
+ return getElementText(locator);
4451
+ };
4446
4452
  const toHaveAttribute$1 = (locator, {
4447
4453
  key,
4448
4454
  value
@@ -4551,6 +4557,7 @@ const toHaveJSProperty$1 = (locator, {
4551
4557
  const ConditionValues = {
4552
4558
  __proto__: null,
4553
4559
  toBeFocused: toBeFocused$1,
4560
+ toContainText: toContainText$1,
4554
4561
  toHaveAttribute: toHaveAttribute$1,
4555
4562
  toHaveClass: toHaveClass$1,
4556
4563
  toHaveCount: toHaveCount$1,
@@ -4560,10 +4567,89 @@ const ConditionValues = {
4560
4567
  toHaveText: toHaveText$1
4561
4568
  };
4562
4569
 
4570
+ const keyCodeMap = {
4571
+ ' ': {
4572
+ code: 'Space',
4573
+ keyCode: 32
4574
+ },
4575
+ '.': {
4576
+ code: 'Period',
4577
+ keyCode: 190
4578
+ },
4579
+ '>': {
4580
+ code: 'Period',
4581
+ keyCode: 190,
4582
+ shiftKey: true
4583
+ },
4584
+ Enter: {
4585
+ code: 'Enter',
4586
+ keyCode: 13
4587
+ },
4588
+ Space: {
4589
+ code: 'Space',
4590
+ key: ' ',
4591
+ keyCode: 32
4592
+ }
4593
+ };
4594
+ const getKeyboardOptions = options => {
4595
+ const key = options.key || '';
4596
+ const normalizedKey = key === 'Space' ? ' ' : key;
4597
+ if (keyCodeMap[key]) {
4598
+ const mapped = keyCodeMap[key];
4599
+ const keyCode = mapped.keyCode;
4600
+ return {
4601
+ ...options,
4602
+ ...mapped,
4603
+ key: mapped.key || normalizedKey,
4604
+ which: keyCode
4605
+ };
4606
+ }
4607
+ if (normalizedKey.length === 1) {
4608
+ const upper = normalizedKey.toUpperCase();
4609
+ const keyCode = upper.codePointAt(0);
4610
+ const code = /[A-Z]/.test(upper) ? `Key${upper}` : `Digit${upper}`;
4611
+ return {
4612
+ ...options,
4613
+ code,
4614
+ key: normalizedKey,
4615
+ keyCode,
4616
+ which: keyCode
4617
+ };
4618
+ }
4619
+ return options;
4620
+ };
4621
+ const isXtermTextArea = element => {
4622
+ return element instanceof HTMLTextAreaElement && element.classList.contains('xterm-helper-textarea');
4623
+ };
4624
+ const getPrintableKey = options => {
4625
+ if (options.key === 'Space') {
4626
+ return ' ';
4627
+ }
4628
+ if (options.key?.length === 1) {
4629
+ return options.key;
4630
+ }
4631
+ return '';
4632
+ };
4563
4633
  const press = options => {
4564
4634
  const element = document.activeElement;
4565
- keyDown(element, options);
4566
- keyUp(element, options);
4635
+ if (!element) {
4636
+ return;
4637
+ }
4638
+ const text = getPrintableKey(options);
4639
+ if (isXtermTextArea(element) && text) {
4640
+ element.value = text;
4641
+ element.dispatchEvent(new InputEvent('input', {
4642
+ bubbles: true,
4643
+ cancelable: true,
4644
+ data: text,
4645
+ inputType: 'insertText'
4646
+ }));
4647
+ element.value = '';
4648
+ return;
4649
+ }
4650
+ const keyboardOptions = getKeyboardOptions(options);
4651
+ keyDown(element, keyboardOptions);
4652
+ keyUp(element, keyboardOptions);
4567
4653
  };
4568
4654
 
4569
4655
  const KeyboardActions = {
@@ -4808,7 +4894,7 @@ const transferToWebView = objectId => {
4808
4894
  }, targetOrigin, [port]);
4809
4895
  };
4810
4896
 
4811
- const attachEvents$6 = ($Node, eventMap) => {
4897
+ const attachEvents$7 = ($Node, eventMap) => {
4812
4898
  for (const [key, value] of Object.entries(eventMap)) {
4813
4899
  $Node.addEventListener(key, value);
4814
4900
  }
@@ -4908,14 +4994,14 @@ const create$t = (uri, top, left) => {
4908
4994
  const update = (state, uri) => {
4909
4995
  state.$ImagePreviewImage.uri = uri;
4910
4996
  };
4911
- const dispose$g = state => {
4997
+ const dispose$h = state => {
4912
4998
  remove$1(state.$ImagePreview);
4913
4999
  };
4914
5000
 
4915
5001
  const ImagePreview$1 = {
4916
5002
  __proto__: null,
4917
5003
  create: create$t,
4918
- dispose: dispose$g,
5004
+ dispose: dispose$h,
4919
5005
  showError,
4920
5006
  update
4921
5007
  };
@@ -4938,7 +5024,7 @@ const get$ItemFromEvent = event => {
4938
5024
  }
4939
5025
  return undefined;
4940
5026
  };
4941
- const handleMouseDown$2 = event => {
5027
+ const handleMouseDown$3 = event => {
4942
5028
  const {
4943
5029
  button,
4944
5030
  clientX,
@@ -4978,7 +5064,7 @@ const ViewletActivityBarEvents = {
4978
5064
  handleBlur: handleBlur$8,
4979
5065
  handleContextMenu: handleContextMenu$6,
4980
5066
  handleFocus: handleFocus$8,
4981
- handleMouseDown: handleMouseDown$2,
5067
+ handleMouseDown: handleMouseDown$3,
4982
5068
  returnValue: returnValue$8
4983
5069
  };
4984
5070
 
@@ -5061,7 +5147,7 @@ forwardViewletCommand('handleListBlur');
5061
5147
  forwardViewletCommand('handleListFocus');
5062
5148
  const handleMenuClick$1 = forwardViewletCommand('handleMenuClick');
5063
5149
  const handleMenuMouseOver$1 = forwardViewletCommand('handleMenuMouseOver');
5064
- const handleMouseDown$1 = forwardViewletCommand('handleMouseDown');
5150
+ const handleMouseDown$2 = forwardViewletCommand('handleMouseDown');
5065
5151
  forwardViewletCommand('handleMouseMove');
5066
5152
  const handleMouseOut$1 = forwardViewletCommand('handleMouseOut');
5067
5153
  const handleMouseOver$1 = forwardViewletCommand('handleMouseOver');
@@ -5101,6 +5187,7 @@ forwardViewletCommand('moveRectangleSelectionPx');
5101
5187
  forwardViewletCommand('moveSelectionPx');
5102
5188
  forwardViewletCommand('paste');
5103
5189
  forwardViewletCommand('replaceAll');
5190
+ const resize = forwardViewletCommand('resize');
5104
5191
  const selectIndex = forwardViewletCommand('selectIndex');
5105
5192
  forwardViewletCommand('setDelta');
5106
5193
  forwardViewletCommand('toggleMatchCase');
@@ -5146,7 +5233,7 @@ const create$s = () => {
5146
5233
  $Viewlet
5147
5234
  };
5148
5235
  };
5149
- const dispose$f = state => {};
5236
+ const dispose$g = state => {};
5150
5237
  const refresh$4 = () => {};
5151
5238
  const setTime = (state, time) => {
5152
5239
  object(state);
@@ -5157,7 +5244,7 @@ const setTime = (state, time) => {
5157
5244
  const ViewletClock = {
5158
5245
  __proto__: null,
5159
5246
  create: create$s,
5160
- dispose: dispose$f,
5247
+ dispose: dispose$g,
5161
5248
  refresh: refresh$4,
5162
5249
  setTime
5163
5250
  };
@@ -5353,7 +5440,7 @@ const setValue$2 = (state, value) => {
5353
5440
  const $Input = $Viewlet.querySelector(':scope input');
5354
5441
  $Input.value = value;
5355
5442
  };
5356
- const focus$c = state => {
5443
+ const focus$d = state => {
5357
5444
  const {
5358
5445
  $Viewlet
5359
5446
  } = state;
@@ -5364,7 +5451,7 @@ const focus$c = state => {
5364
5451
  const ViewletDefineKeyBinding = {
5365
5452
  __proto__: null,
5366
5453
  Events: ViewletDefineKeyBindingEvents,
5367
- focus: focus$c,
5454
+ focus: focus$d,
5368
5455
  setValue: setValue$2
5369
5456
  };
5370
5457
 
@@ -5751,10 +5838,10 @@ const appendWidget$5 = state => {
5751
5838
  } = state;
5752
5839
  append$1($Viewlet);
5753
5840
  };
5754
- const dispose$e = state => {
5841
+ const dispose$f = state => {
5755
5842
  remove$1(state.$Viewlet);
5756
5843
  };
5757
- const focus$b = (state, key, source) => {
5844
+ const focus$c = (state, key, source) => {
5758
5845
  if (!key) {
5759
5846
  return;
5760
5847
  }
@@ -5777,8 +5864,8 @@ const ViewletEditorCodeGenerator = {
5777
5864
  __proto__: null,
5778
5865
  Events: ViewletEditorCodeGeneratorEvents,
5779
5866
  appendWidget: appendWidget$5,
5780
- dispose: dispose$e,
5781
- focus: focus$b,
5867
+ dispose: dispose$f,
5868
+ focus: focus$c,
5782
5869
  setBounds: setBounds$9
5783
5870
  };
5784
5871
 
@@ -5919,17 +6006,17 @@ const create$n = () => {
5919
6006
  $Viewlet
5920
6007
  };
5921
6008
  };
5922
- const attachEvents$5 = state => {
6009
+ const attachEvents$6 = state => {
5923
6010
  const {
5924
6011
  $ListItems,
5925
6012
  $ScrollBar,
5926
6013
  $Viewlet
5927
6014
  } = state;
5928
6015
  $Viewlet.addEventListener(Wheel, handleWheel$1, Passive);
5929
- attachEvents$6($ListItems, {
6016
+ attachEvents$7($ListItems, {
5930
6017
  [MouseDown]: handleMousedown
5931
6018
  });
5932
- attachEvents$6($ScrollBar, {
6019
+ attachEvents$7($ScrollBar, {
5933
6020
  [PointerDown]: handleScrollBarPointerDown$1
5934
6021
  });
5935
6022
  };
@@ -5948,7 +6035,7 @@ const setDom$8 = (state, dom) => {
5948
6035
  // TODO recycle nodes
5949
6036
  // TODO set right aria attributes on $EditorInput
5950
6037
  };
5951
- const dispose$d = state => {
6038
+ const dispose$e = state => {
5952
6039
  remove$1(state.$Viewlet);
5953
6040
  // state.$EditorInput.removeAttribute('aria-activedescendant')
5954
6041
  };
@@ -5978,9 +6065,9 @@ const setBounds$8 = (state, x, y, width, height) => {
5978
6065
 
5979
6066
  const ViewletEditorCompletion = {
5980
6067
  __proto__: null,
5981
- attachEvents: attachEvents$5,
6068
+ attachEvents: attachEvents$6,
5982
6069
  create: create$n,
5983
- dispose: dispose$d,
6070
+ dispose: dispose$e,
5984
6071
  handleError: handleError$5,
5985
6072
  setBounds: setBounds$8,
5986
6073
  setContentHeight,
@@ -6010,7 +6097,7 @@ const create$m = () => {
6010
6097
  $Viewlet
6011
6098
  };
6012
6099
  };
6013
- const attachEvents$4 = state => {
6100
+ const attachEvents$5 = state => {
6014
6101
  // TODO
6015
6102
  };
6016
6103
  const setDom$7 = (state, dom) => {
@@ -6028,7 +6115,7 @@ const appendWidget$4 = state => {
6028
6115
  } = state;
6029
6116
  append$1($Viewlet);
6030
6117
  };
6031
- const dispose$c = state => {
6118
+ const dispose$d = state => {
6032
6119
  remove$1(state.$Viewlet);
6033
6120
  };
6034
6121
  const setBounds$7 = (state, x, y, width, height) => {
@@ -6042,9 +6129,9 @@ const ViewletEditorCompletionDetails = {
6042
6129
  __proto__: null,
6043
6130
  Events: ViewletEditorCompletionDetailsEvents,
6044
6131
  appendWidget: appendWidget$4,
6045
- attachEvents: attachEvents$4,
6132
+ attachEvents: attachEvents$5,
6046
6133
  create: create$m,
6047
- dispose: dispose$c,
6134
+ dispose: dispose$d,
6048
6135
  setBounds: setBounds$7,
6049
6136
  setDom: setDom$7
6050
6137
  };
@@ -6249,11 +6336,11 @@ const create$k = () => {
6249
6336
  $Viewlet
6250
6337
  };
6251
6338
  };
6252
- const attachEvents$3 = state => {
6339
+ const attachEvents$4 = state => {
6253
6340
  const {
6254
6341
  $Viewlet
6255
6342
  } = state;
6256
- attachEvents$6($Viewlet, {
6343
+ attachEvents$7($Viewlet, {
6257
6344
  [ContextMenu]: handleContextMenu$2,
6258
6345
  [FocusIn]: handleFocus$5,
6259
6346
  [PointerDown]: handlePointerDown$1,
@@ -6284,7 +6371,7 @@ const setDom$4 = (state, dom) => {
6284
6371
 
6285
6372
  const ViewletEditorImage = {
6286
6373
  __proto__: null,
6287
- attachEvents: attachEvents$3,
6374
+ attachEvents: attachEvents$4,
6288
6375
  create: create$k,
6289
6376
  setDom: setDom$4,
6290
6377
  setDragging,
@@ -6299,7 +6386,7 @@ const create$j = () => {
6299
6386
  $Viewlet
6300
6387
  };
6301
6388
  };
6302
- const dispose$b = state => {};
6389
+ const dispose$c = state => {};
6303
6390
  const refresh$3 = (state, context) => {
6304
6391
  object(state);
6305
6392
  string(context.content);
@@ -6309,7 +6396,7 @@ const refresh$3 = (state, context) => {
6309
6396
  const ViewletEditorPlainText = {
6310
6397
  __proto__: null,
6311
6398
  create: create$j,
6312
- dispose: dispose$b,
6399
+ dispose: dispose$c,
6313
6400
  refresh: refresh$3
6314
6401
  };
6315
6402
 
@@ -6337,7 +6424,7 @@ const appendWidget$2 = state => {
6337
6424
  } = state;
6338
6425
  append$1($Viewlet);
6339
6426
  };
6340
- const dispose$a = state => {
6427
+ const dispose$b = state => {
6341
6428
  remove$1(state.$Viewlet);
6342
6429
  };
6343
6430
 
@@ -6345,7 +6432,7 @@ const ViewletEditorSourceActions = {
6345
6432
  __proto__: null,
6346
6433
  Events: ViewletEditorSourceActionsEvents,
6347
6434
  appendWidget: appendWidget$2,
6348
- dispose: dispose$a,
6435
+ dispose: dispose$b,
6349
6436
  setBounds: setBounds$4
6350
6437
  };
6351
6438
 
@@ -6406,14 +6493,14 @@ const create$g = () => {
6406
6493
  };
6407
6494
  };
6408
6495
  const refresh$2 = (state, context) => {};
6409
- const focus$a = state => {};
6410
- const dispose$9 = state => {};
6496
+ const focus$b = state => {};
6497
+ const dispose$a = state => {};
6411
6498
 
6412
6499
  const ViewletEmpty = {
6413
6500
  __proto__: null,
6414
6501
  create: create$g,
6415
- dispose: dispose$9,
6416
- focus: focus$a,
6502
+ dispose: dispose$a,
6503
+ focus: focus$b,
6417
6504
  refresh: refresh$2
6418
6505
  };
6419
6506
 
@@ -6607,7 +6694,7 @@ const create$d = () => {
6607
6694
  $Viewlet
6608
6695
  };
6609
6696
  };
6610
- const focus$9 = (state, key, source) => {
6697
+ const focus$a = (state, key, source) => {
6611
6698
  if (!key) {
6612
6699
  return;
6613
6700
  }
@@ -6653,7 +6740,7 @@ const setBounds$2 = (state, x, y, width, height) => {
6653
6740
  } = state;
6654
6741
  setBounds$a($Viewlet, x, y, width, height);
6655
6742
  };
6656
- const dispose$8 = state => {
6743
+ const dispose$9 = state => {
6657
6744
  remove$1(state.$Viewlet);
6658
6745
  };
6659
6746
  const Events$3 = ViewletFindWidgetEvents;
@@ -6663,8 +6750,8 @@ const ViewletFindWidget = {
6663
6750
  Events: Events$3,
6664
6751
  appendWidget: appendWidget$1,
6665
6752
  create: create$d,
6666
- dispose: dispose$8,
6667
- focus: focus$9,
6753
+ dispose: dispose$9,
6754
+ focus: focus$a,
6668
6755
  setBounds: setBounds$2,
6669
6756
  setDom: setDom$3,
6670
6757
  setValue: setValue$1
@@ -6711,7 +6798,7 @@ const handleError$3 = (state, message) => {
6711
6798
  } = state;
6712
6799
  $Message.textContent = message;
6713
6800
  };
6714
- const focus$8 = state => {
6801
+ const focus$9 = state => {
6715
6802
  const {
6716
6803
  $Locations
6717
6804
  } = state;
@@ -6723,7 +6810,7 @@ const focus$8 = state => {
6723
6810
  const ViewletImplementations = {
6724
6811
  __proto__: null,
6725
6812
  Events: ViewletLocationsEvents,
6726
- focus: focus$8,
6813
+ focus: focus$9,
6727
6814
  handleError: handleError$3,
6728
6815
  setFocusedIndex: setFocusedIndex$1
6729
6816
  };
@@ -6976,20 +7063,20 @@ const create$c = () => {
6976
7063
  $Viewlet
6977
7064
  };
6978
7065
  };
6979
- const attachEvents$2 = state => {
7066
+ const attachEvents$3 = state => {
6980
7067
  const {
6981
7068
  $SashPanel,
6982
7069
  $SashSidebar
6983
7070
  } = state;
6984
- attachEvents$6($SashSidebar, {
7071
+ attachEvents$7($SashSidebar, {
6985
7072
  [DoubleClick]: handleSashDoubleClick,
6986
7073
  [PointerDown]: handleSashPointerDown
6987
7074
  });
6988
- attachEvents$6($SashPanel, {
7075
+ attachEvents$7($SashPanel, {
6989
7076
  [DoubleClick]: handleSashDoubleClick,
6990
7077
  [PointerDown]: handleSashPointerDown
6991
7078
  });
6992
- attachEvents$6(window, {
7079
+ attachEvents$7(window, {
6993
7080
  [Blur]: handleBlur$3,
6994
7081
  [Focus]: handleFocus$2,
6995
7082
  [KeyDown]: handleKeyDown$1,
@@ -7010,7 +7097,7 @@ const setSashes = (state, sashSidebar, sashPanel) => {
7010
7097
 
7011
7098
  const ViewletLayout = {
7012
7099
  __proto__: null,
7013
- attachEvents: attachEvents$2,
7100
+ attachEvents: attachEvents$3,
7014
7101
  create: create$c,
7015
7102
  setSashes
7016
7103
  };
@@ -7099,9 +7186,9 @@ const handleError$2 = (state, error) => {
7099
7186
  string(error);
7100
7187
  state.content.textContent = error;
7101
7188
  };
7102
- const focus$7 = state => {
7189
+ const focus$8 = state => {
7103
7190
  object(state);
7104
- focus$d(state.$ViewletOutputContent);
7191
+ focus$e(state.$ViewletOutputContent);
7105
7192
  send('Focus.setFocus', FocusOutput);
7106
7193
  };
7107
7194
 
@@ -7114,15 +7201,15 @@ const disposeFindWidget = state => {
7114
7201
  return;
7115
7202
  }
7116
7203
  };
7117
- const dispose$7 = state => {};
7204
+ const dispose$8 = state => {};
7118
7205
 
7119
7206
  const ViewletOutput = {
7120
7207
  __proto__: null,
7121
7208
  clear: clear$1,
7122
7209
  create: create$b,
7123
- dispose: dispose$7,
7210
+ dispose: dispose$8,
7124
7211
  disposeFindWidget,
7125
- focus: focus$7,
7212
+ focus: focus$8,
7126
7213
  handleError: handleError$2,
7127
7214
  openFindWidget,
7128
7215
  setText
@@ -7211,19 +7298,19 @@ const create$a = () => {
7211
7298
  };
7212
7299
  // await openViewlet('Terminal')
7213
7300
  };
7214
- const attachEvents$1 = state => {
7301
+ const attachEvents$2 = state => {
7215
7302
  const {
7216
7303
  $ButtonClose,
7217
7304
  $ButtonMaximize,
7218
7305
  $PanelHeader
7219
7306
  } = state;
7220
- attachEvents$6($PanelHeader, {
7307
+ attachEvents$7($PanelHeader, {
7221
7308
  [Click]: handleHeaderClick$1
7222
7309
  });
7223
- attachEvents$6($ButtonMaximize, {
7310
+ attachEvents$7($ButtonMaximize, {
7224
7311
  [Click]: handleClickMaximize
7225
7312
  });
7226
- attachEvents$6($ButtonClose, {
7313
+ attachEvents$7($ButtonClose, {
7227
7314
  [Click]: handleClickClose
7228
7315
  });
7229
7316
  };
@@ -7235,14 +7322,14 @@ const setTabsDom$1 = (state, dom) => {
7235
7322
  };
7236
7323
 
7237
7324
  // TODO add test for focus method
7238
- const focus$6 = state => {
7325
+ const focus$7 = state => {
7239
7326
  object(state);
7240
7327
  if (!state.currentViewlet) {
7241
7328
  return;
7242
7329
  }
7243
7330
  state.currentViewlet.factory.focus(state.currentViewlet.state);
7244
7331
  };
7245
- const dispose$6 = state => {
7332
+ const dispose$7 = state => {
7246
7333
  if (state.$PanelContent) {
7247
7334
  state.$PanelContent.remove();
7248
7335
  state.$PanelContent = undefined;
@@ -7286,10 +7373,10 @@ const setActionsDom$1 = (state, actions, childUid) => {
7286
7373
 
7287
7374
  const ViewletPanel = {
7288
7375
  __proto__: null,
7289
- attachEvents: attachEvents$1,
7376
+ attachEvents: attachEvents$2,
7290
7377
  create: create$a,
7291
- dispose: dispose$6,
7292
- focus: focus$6,
7378
+ dispose: dispose$7,
7379
+ focus: focus$7,
7293
7380
  setActionsDom: setActionsDom$1,
7294
7381
  setSelectedIndex,
7295
7382
  setTabsDom: setTabsDom$1
@@ -7298,7 +7385,7 @@ const ViewletPanel = {
7298
7385
  const ViewletReferences = {
7299
7386
  __proto__: null,
7300
7387
  Events: ViewletLocationsEvents,
7301
- focus: focus$8,
7388
+ focus: focus$9,
7302
7389
  handleError: handleError$3,
7303
7390
  setFocusedIndex: setFocusedIndex$1
7304
7391
  };
@@ -7379,15 +7466,15 @@ const create$8 = () => {
7379
7466
  $Viewlet
7380
7467
  };
7381
7468
  };
7382
- const attachEvents = state => {
7469
+ const attachEvents$1 = state => {
7383
7470
  const {
7384
7471
  $SidebarTitleArea
7385
7472
  } = state;
7386
- attachEvents$6($SidebarTitleArea, {
7473
+ attachEvents$7($SidebarTitleArea, {
7387
7474
  [Click]: handleHeaderClick
7388
7475
  });
7389
7476
  };
7390
- const dispose$5 = state => {
7477
+ const dispose$6 = state => {
7391
7478
  object(state);
7392
7479
  state.$Sidebar.replaceChildren();
7393
7480
  };
@@ -7415,16 +7502,16 @@ const setActionsDom = (state, actions, parentId, eventMap = {}) => {
7415
7502
  }
7416
7503
  state.$Actions = $NewViewlet;
7417
7504
  };
7418
- const focus$5 = async () => {
7505
+ const focus$6 = async () => {
7419
7506
  // await
7420
7507
  };
7421
7508
 
7422
7509
  const ViewletSidebar = {
7423
7510
  __proto__: null,
7424
- attachEvents,
7511
+ attachEvents: attachEvents$1,
7425
7512
  create: create$8,
7426
- dispose: dispose$5,
7427
- focus: focus$5,
7513
+ dispose: dispose$6,
7514
+ focus: focus$6,
7428
7515
  setActionsDom,
7429
7516
  setTitle
7430
7517
  };
@@ -7607,7 +7694,7 @@ const ViewletSourceControlEvents = {
7607
7694
  handleWheel: handleWheel$2
7608
7695
  };
7609
7696
 
7610
- const focus$4 = state => {
7697
+ const focus$5 = state => {
7611
7698
  const {
7612
7699
  $Viewlet
7613
7700
  } = state;
@@ -7617,7 +7704,7 @@ const focus$4 = state => {
7617
7704
  const ViewletSourceControl = {
7618
7705
  __proto__: null,
7619
7706
  Events: ViewletSourceControlEvents,
7620
- focus: focus$4
7707
+ focus: focus$5
7621
7708
  };
7622
7709
 
7623
7710
  const handleClick$2 = event => {
@@ -7653,7 +7740,7 @@ const setDom$2 = (state, dom) => {
7653
7740
  } = state;
7654
7741
  renderInto($Viewlet, dom, ViewletStatusBarEvents);
7655
7742
  };
7656
- const focus$3 = state => {
7743
+ const focus$4 = state => {
7657
7744
  object(state);
7658
7745
  const {
7659
7746
  $Viewlet
@@ -7664,7 +7751,7 @@ const focus$3 = state => {
7664
7751
  const ViewletStatusBar = {
7665
7752
  __proto__: null,
7666
7753
  create: create$7,
7667
- focus: focus$3,
7754
+ focus: focus$4,
7668
7755
  setDom: setDom$2
7669
7756
  };
7670
7757
 
@@ -7822,8 +7909,8 @@ const ViewletTitleBarMenuBarEvents = {
7822
7909
  };
7823
7910
 
7824
7911
  const activeId = 'TitleBarEntryActive';
7825
- const dispose$4 = state => {};
7826
- const focus$2 = state => {
7912
+ const dispose$5 = state => {};
7913
+ const focus$3 = state => {
7827
7914
  const {
7828
7915
  $TitleBarMenuBar
7829
7916
  } = state;
@@ -8059,8 +8146,8 @@ const ViewletTitleBarMenuBar = {
8059
8146
  __proto__: null,
8060
8147
  Events: ViewletTitleBarMenuBarEvents,
8061
8148
  closeMenu,
8062
- dispose: dispose$4,
8063
- focus: focus$2,
8149
+ dispose: dispose$5,
8150
+ focus: focus$3,
8064
8151
  openMenu,
8065
8152
  setFocusedIndex,
8066
8153
  setMenus
@@ -8078,8 +8165,8 @@ const ViewletTitleBar = {
8078
8165
  __proto__: null,
8079
8166
  Events: ViewletTitleBarMenuBarEvents,
8080
8167
  closeMenu,
8081
- dispose: dispose$4,
8082
- focus: focus$2,
8168
+ dispose: dispose$5,
8169
+ focus: focus$3,
8083
8170
  openMenu,
8084
8171
  setFocused,
8085
8172
  setFocusedIndex,
@@ -8389,7 +8476,7 @@ const invoke = (viewletId, method, ...args) => {
8389
8476
  }
8390
8477
  return instance.factory[method](instance.state, ...args);
8391
8478
  };
8392
- const focus$1 = viewletId => {
8479
+ const focus$2 = viewletId => {
8393
8480
  if (location.search.includes('traceFocus')) {
8394
8481
  // eslint-disable-next-line no-console
8395
8482
  console.trace(`focus ${viewletId}`);
@@ -8637,7 +8724,7 @@ const move = async (uid, selector, target) => {
8637
8724
  $Target.moveBefore($Source, null);
8638
8725
  };
8639
8726
  const attachWindowEvents = () => {
8640
- attachEvents$6(window, {
8727
+ attachEvents$7(window, {
8641
8728
  [Blur]: handleBlur$3,
8642
8729
  [Focus]: handleFocus$2,
8643
8730
  [KeyDown]: handleKeyDown$1,
@@ -8650,7 +8737,7 @@ const attachWindowEvents = () => {
8650
8737
  const sendMultiple = commands => {
8651
8738
  executeCommands(commands);
8652
8739
  };
8653
- const dispose$3 = id => {
8740
+ const dispose$4 = id => {
8654
8741
  try {
8655
8742
  number(id);
8656
8743
  const instance = get$a(id);
@@ -8874,8 +8961,8 @@ const commandHandlers = {
8874
8961
  'Viewlet.create': create$4,
8875
8962
  'Viewlet.createFunctionalRoot': createFunctionalRoot,
8876
8963
  'Viewlet.createPlaceholder': createPlaceholder,
8877
- 'Viewlet.dispose': dispose$3,
8878
- 'Viewlet.focus': focus$1,
8964
+ 'Viewlet.dispose': dispose$4,
8965
+ 'Viewlet.focus': focus$2,
8879
8966
  'Viewlet.focusElementByName': focusElementByName,
8880
8967
  'Viewlet.focusSelector': focusSelector,
8881
8968
  'Viewlet.handleError': handleError$1,
@@ -9079,7 +9166,7 @@ const setPort = (uid, port, origin, portType) => {
9079
9166
  params: [port, portType]
9080
9167
  }, origin, [port]);
9081
9168
  };
9082
- const dispose$2 = uid => {
9169
+ const dispose$3 = uid => {
9083
9170
  const $Iframe = get$1(uid);
9084
9171
  $Iframe.remove();
9085
9172
  remove(uid);
@@ -9090,7 +9177,7 @@ const commandMap = {
9090
9177
  'ClipBoard.execCopy': execCopy,
9091
9178
  'ClipBoard.read': read,
9092
9179
  'ClipBoard.readText': readText,
9093
- 'ClipBoard.write': write$1,
9180
+ 'ClipBoard.write': write$2,
9094
9181
  'ClipBoard.writeImage': writeImage,
9095
9182
  'ClipBoard.writeText': writeText,
9096
9183
  'ConfirmPrompt.prompt': confirm$1,
@@ -9125,7 +9212,7 @@ const commandMap = {
9125
9212
  'Meta.setThemeColor': setThemeColor,
9126
9213
  'Notification.create': create$v,
9127
9214
  'Notification.createWithOptions': createWithOptions,
9128
- 'Notification.dispose': dispose$h,
9215
+ 'Notification.dispose': dispose$i,
9129
9216
  'OffscreenCanvas.create': create$u,
9130
9217
  'OffscreenCanvas.create2': create2,
9131
9218
  'Open.openUrl': openUrl,
@@ -9148,9 +9235,9 @@ const commandMap = {
9148
9235
  'TestFrameWork.transferToWebView': transferToWebView,
9149
9236
  'Viewlet.addKeyBindings': addKeyBindings,
9150
9237
  'Viewlet.appendViewlet': appendViewlet,
9151
- 'Viewlet.dispose': dispose$3,
9238
+ 'Viewlet.dispose': dispose$4,
9152
9239
  'Viewlet.executeCommands': executeCommands,
9153
- 'Viewlet.focus': focus$1,
9240
+ 'Viewlet.focus': focus$2,
9154
9241
  'Viewlet.focusElementByName': focusElementByName,
9155
9242
  'Viewlet.focusSelector': focusSelector,
9156
9243
  'Viewlet.handleError': handleError$1,
@@ -9169,7 +9256,7 @@ const commandMap = {
9169
9256
  'WebStorage.setJsonObjects': setJsonObjects,
9170
9257
  'WebView.appendOnly': appendOnly,
9171
9258
  'WebView.create': create$3,
9172
- 'WebView.dispose': dispose$2,
9259
+ 'WebView.dispose': dispose$3,
9173
9260
  'WebView.load': load,
9174
9261
  'WebView.loadOnly': loadOnly,
9175
9262
  'WebView.setPort': setPort,
@@ -9315,7 +9402,7 @@ const appendWidget = state => {
9315
9402
  } = state;
9316
9403
  append$1($Viewlet);
9317
9404
  };
9318
- const dispose$1 = state => {
9405
+ const dispose$2 = state => {
9319
9406
  remove$1(state.$Viewlet);
9320
9407
  };
9321
9408
 
@@ -9323,7 +9410,7 @@ const ViewletEditorRename = {
9323
9410
  __proto__: null,
9324
9411
  Events: ViewletEditorRenameEvents,
9325
9412
  appendWidget,
9326
- dispose: dispose$1,
9413
+ dispose: dispose$2,
9327
9414
  setBounds
9328
9415
  };
9329
9416
 
@@ -9737,9 +9824,9 @@ const handleBlur = event => {
9737
9824
  const uid = fromEvent(event);
9738
9825
  handleBlur$7(uid);
9739
9826
  };
9740
- const handleMouseDown = (event, ...args) => {
9827
+ const handleMouseDown$1 = (event, ...args) => {
9741
9828
  const uid = fromEvent(event);
9742
- handleMouseDown$1(uid, ...args);
9829
+ handleMouseDown$2(uid, ...args);
9743
9830
  };
9744
9831
  const handleKeyDown = (event, ...args) => {
9745
9832
  const uid = fromEvent(event);
@@ -9754,7 +9841,7 @@ const create$1 = () => {
9754
9841
  terminal: undefined
9755
9842
  };
9756
9843
  };
9757
- const setTerminal = (state, canvasCursorId, canvasTextId) => {
9844
+ const setTerminal$1 = (state, canvasCursorId, canvasTextId) => {
9758
9845
  const canvasText = get$4(canvasTextId);
9759
9846
  const canvasCursor = get$4(canvasCursorId);
9760
9847
  const {
@@ -9778,7 +9865,7 @@ const setTerminal = (state, canvasCursorId, canvasTextId) => {
9778
9865
  }, ...args);
9779
9866
  },
9780
9867
  handleMouseDown: (...args) => {
9781
- handleMouseDown({
9868
+ handleMouseDown$1({
9782
9869
  target: $Viewlet
9783
9870
  }, ...args);
9784
9871
  }
@@ -9794,13 +9881,13 @@ const focusTextArea = state => {
9794
9881
  const refresh = (state, context) => {
9795
9882
  // state.element.textContent = context.text
9796
9883
  };
9797
- const dispose = state => {
9884
+ const dispose$1 = state => {
9798
9885
  // TODO unregister callback
9799
9886
  // SharedProcess.unregisterChannel(channel )
9800
9887
 
9801
9888
  window.removeEventListener('resize', state.handleUpdate);
9802
9889
  };
9803
- const focus = state => {
9890
+ const focus$1 = state => {
9804
9891
  object(state);
9805
9892
  const {
9806
9893
  terminal
@@ -9824,28 +9911,28 @@ const reduce = (state, action) => {
9824
9911
  }
9825
9912
  }
9826
9913
  };
9827
- const write = (state, data) => {
9914
+ const write$1 = (state, data) => {
9828
9915
  if (!isUint8Array(data)) {
9829
9916
  throw new TypeError(`data must be of type Uint8Array`);
9830
9917
  }
9831
9918
  };
9832
9919
  const Commands = {
9833
- 9922: write
9920
+ 9922: write$1
9834
9921
  };
9835
9922
 
9836
9923
  const ViewletTerminal = {
9837
9924
  __proto__: null,
9838
9925
  Commands,
9839
9926
  create: create$1,
9840
- dispose,
9841
- focus,
9927
+ dispose: dispose$1,
9928
+ focus: focus$1,
9842
9929
  focusTextArea,
9843
9930
  reduce,
9844
9931
  reduceFocus,
9845
9932
  reduceWrite,
9846
9933
  refresh,
9847
- setTerminal,
9848
- write
9934
+ setTerminal: setTerminal$1,
9935
+ write: write$1
9849
9936
  };
9850
9937
 
9851
9938
  /**
@@ -9881,19 +9968,91 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
9881
9968
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===xl+1&&(this._liveRegion.textContent+=_i.get())));}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0;}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e);}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows);}_renderRows(e,i){let r=this._terminal.buffer,n=r.lines.length.toString();for(let o=e;o<=i;o++){let l=r.lines.get(r.ydisp+o),a=[],u=l?.translateToString(true,void 0,void 0,a)||"",h=(r.ydisp+o+1).toString(),c=this._rowElements[o];c&&(u.length===0?(c.textContent="\xA0",this._rowColumns.set(c,[0,1])):(c.textContent=u,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",n),this._alignRowWidth(c));}this._announceCharacters();}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="");}_handleBoundaryFocus(e,i){let r=e.target,n=this._rowElements[i===0?1:this._rowElements.length-2],o=r.getAttribute("aria-posinset"),l=i===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==n)return;let a,u;if(i===0?(a=r,u=this._rowElements.pop(),this._rowContainer.removeChild(u)):(a=this._rowElements.shift(),u=r,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),u.removeEventListener("focus",this._bottomBoundaryFocusListener),i===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h);}else {let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h);}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(i===0?-1:1),this._rowElements[i===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation();}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let i={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===r.node&&i.offset>r.offset)&&([i,r]=[r,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let o=({node:u,offset:h})=>{let c=u instanceof Text?u.parentNode:u,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(c);if(!_)return console.warn("columns is null. Race condition?"),null;let p=h<_.length?_[h]:_.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},l=o(i),a=o(r);if(!(!l||!a)){if(l.row>a.row||l.row===a.row&&l.column>=a.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(a.row-l.row)*this._terminal.cols-l.column+a.column);}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let i=this._rowContainer.children.length;i<this._terminal.rows;i++)this._rowElements[i]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[i]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions();}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e]);}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`;}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/i})`;}};Tt=M([S(1,xt),S(2,ae),S(3,ce)],Tt);var hi=class extends D{constructor(e,i,r,n,o){super();this._element=e;this._mouseService=i;this._renderService=r;this._bufferService=n;this._linkProviderService=o;this._linkCacheDisposables=[];this._isMouseOut=true;this._wasResized=false;this._activeLine=-1;this._onShowLinkUnderline=this._register(new v);this.onShowLinkUnderline=this._onShowLinkUnderline.event;this._onHideLinkUnderline=this._register(new v);this.onHideLinkUnderline=this._onHideLinkUnderline.event;this._register(C(()=>{Ne(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear();})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=true;})),this._register(L(this._element,"mouseleave",()=>{this._isMouseOut=true,this._clearCurrentLink();})),this._register(L(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(L(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(L(this._element,"mouseup",this._handleMouseUp.bind(this)));}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=false;let r=e.composedPath();for(let n=0;n<r.length;n++){let o=r[n];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||i.x!==this._lastBufferCell.x||i.y!==this._lastBufferCell.y)&&(this._handleHover(i),this._lastBufferCell=i);}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,false),this._wasResized=false;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,true));}_askForLink(e,i){(!this._activeProviderReplies||!i)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(o=>{o.link.dispose&&o.link.dispose();});}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=false;for(let[n,o]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(n)&&(r=this._checkLinkProviderResult(n,e,r)):o.provideLinks(e.y,l=>{if(this._isMouseOut)return;let a=l?.map(u=>({link:u}));this._activeProviderReplies?.set(n,a),r=this._checkLinkProviderResult(n,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies);});}_removeIntersectingLinks(e,i){let r=new Set;for(let n=0;n<i.size;n++){let o=i.get(n);if(o)for(let l=0;l<o.length;l++){let a=o[l],u=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=u;c<=h;c++){if(r.has(c)){o.splice(l--,1);break}r.add(c);}}}}_checkLinkProviderResult(e,i,r){if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),o=false;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(o=true);if(!o&&n){let l=n.find(a=>this._linkAtPosition(a.link,i));l&&(r=true,this._handleNewLink(l));}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let l=0;l<this._activeProviderReplies.size;l++){let a=this._activeProviderReplies.get(l)?.find(u=>this._linkAtPosition(u.link,i));if(a){r=true,this._handleNewLink(a);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink;}_handleMouseUp(e){if(!this._currentLink)return;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);i&&this._mouseDownLink&&Ec(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(e,this._currentLink.link.text);}_clearCurrentLink(e,i){!this._currentLink||!this._lastMouseEvent||(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ne(this._linkCacheDisposables),this._linkCacheDisposables.length=0);}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?true:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?true:e.link.decorations.pointerCursor},isHovered:true},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r));}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r));}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(n,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,false);}})));}_linkHover(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=true,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,true),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(r,i.text);}_fireUnderlineEvent(e,i){let r=e.range,n=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o);}_linkLeave(e,i,r){this._currentLink?.state&&(this._currentLink.state.isHovered=false,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,false),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(r,i.text);}_linkAtPosition(e,i){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,o=i.y*this._bufferService.cols+i.x;return r<=o&&o<=n}_positionFromMouseEvent(e,i,r){let n=r.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(n)return {x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,r,n,o){return {x1:e,y1:i,x2:r,y2:n,cols:this._bufferService.cols,fg:o}}};hi=M([S(1,Dt),S(2,ce),S(3,F),S(4,lr)],hi);function Ec(s,t){return s.text===t.text&&s.range.start.x===t.range.start.x&&s.range.start.y===t.range.start.y&&s.range.end.x===t.range.end.x&&s.range.end.y===t.range.end.y}var yn=class extends Sn{constructor(e={}){super(e);this._linkifier=this._register(new ye);this.browser=tn;this._keyDownHandled=false;this._keyDownSeen=false;this._keyPressHandled=false;this._unprocessedDeadKey=false;this._accessibilityManager=this._register(new ye);this._onCursorMove=this._register(new v);this.onCursorMove=this._onCursorMove.event;this._onKey=this._register(new v);this.onKey=this._onKey.event;this._onRender=this._register(new v);this.onRender=this._onRender.event;this._onSelectionChange=this._register(new v);this.onSelectionChange=this._onSelectionChange.event;this._onTitleChange=this._register(new v);this.onTitleChange=this._onTitleChange.event;this._onBell=this._register(new v);this.onBell=this._onBell.event;this._onFocus=this._register(new v);this._onBlur=this._register(new v);this._onA11yCharEmitter=this._register(new v);this._onA11yTabEmitter=this._register(new v);this._onWillOpen=this._register(new v);this._setup(),this._decorationService=this._instantiationService.createInstance(Tn),this._instantiationService.setService(Be,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Qr),this._instantiationService.setService(lr,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(wt)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(i=>this.refresh(i?.start??0,i?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(i=>this._reportWindowsOptions(i))),this._register(this._inputHandler.onColor(i=>this._handleColorEvent(i))),this._register($.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(i=>this._afterResize(i.cols,i.rows))),this._register(C(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element);}));}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let i of e){let r,n="";switch(i.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+i.index;}switch(i.type){case 0:let o=U.toColorRGB(r==="ansi"?this._themeService.colors.ansi[i.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${b.ESC}]${n};${ml(o)}${fs.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(l=>l.ansi[i.index]=j.toColor(...i.color));else {let l=r;this._themeService.modifyColors(a=>a[l]=j.toColor(...i.color));}break;case 2:this._themeService.restoreColor(i.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0;}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:true});}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Tt,this)):this._accessibilityManager.clear();}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(b.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire();}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(b.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire();}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,o=i.getWidth(r),l=this._renderService.dimensions.css.cell.width*o,a=this.buffer.y*this._renderService.dimensions.css.cell.height,u=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=u+"px",this.textarea.style.top=a+"px",this.textarea.style.width=l+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5";}_initGlobal(){this._bindKeys(),this._register(L(this.element,"copy",i=>{this.hasSelection()&&Vs(i,this._selectionService);}));let e=i=>qs(i,this.textarea,this.coreService,this.optionsService);this._register(L(this.textarea,"paste",e)),this._register(L(this.element,"paste",e)),Ss?this._register(L(this.element,"mousedown",i=>{i.button===2&&Pn(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord);})):this._register(L(this.element,"contextmenu",i=>{Pn(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord);})),Bi&&this._register(L(this.element,"auxclick",i=>{i.button===1&&Mn(i,this.textarea,this.screenElement);}));}_bindKeys(){this._register(L(this.textarea,"keyup",e=>this._keyUp(e),true)),this._register(L(this.textarea,"keydown",e=>this._keyDown(e),true)),this._register(L(this.textarea,"keypress",e=>this._keyPress(e),true)),this._register(L(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(L(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(L(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(L(this.textarea,"input",e=>this._inputEvent(e),true)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()));}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(L(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",mi.get()),Ts||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Jr,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ae,this._coreBrowserService),this._register(L(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(L(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(jt,this._document,this._helperContainer),this._instantiationService.setService(nt,this._charSizeService),this._themeService=this._instantiationService.createInstance(ti),this._instantiationService.setService(Re,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ct),this._instantiationService.setService(or,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Qt,this.rows,this.screenElement)),this._instantiationService.setService(ce,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance($t,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xt),this._instantiationService.setService(Dt,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(hi,this.screenElement));this.element.appendChild(i);try{this._onWillOpen.fire(this.element);}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea();})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(zt,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,false),this.refresh(0,this.rows-1);})),this._selectionService=this._register(this._instantiationService.createInstance(ei,this.element,this.screenElement,n)),this._instantiationService.setService(Qs,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select();})),this._register($.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync();})),this._register(this._instantiationService.createInstance(Gt,this.screenElement)),this._register(L(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Tt,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bt,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(bt,this._viewportElement,this.screenElement)));}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse();}_createRenderer(){return this._instantiationService.createInstance(Yt,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function r(l){let a=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!a)return false;let u,h;switch(l.overrideType||l.type){case "mousemove":h=32,l.buttons===void 0?(u=3,l.button!==void 0&&(u=l.button<3?l.button:3)):u=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case "mouseup":h=0,u=l.button<3?l.button:3;break;case "mousedown":h=1,u=l.button<3?l.button:3;break;case "wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===false)return false;let c=l.deltaY;if(c===0||e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return false;h=c<0?0:1,u=4;break;default:return false}return h===void 0||u===void 0||u>4?false:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:u,action:h,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(r(l),l.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(l)),wheel:l=>(r(l),this.cancel(l,true)),mousedrag:l=>{l.buttons&&r(l);},mousemove:l=>{l.buttons||r(l);}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?n.mousemove||(i.addEventListener("mousemove",o.mousemove),n.mousemove=o.mousemove):(i.removeEventListener("mousemove",n.mousemove),n.mousemove=null),l&16?n.wheel||(i.addEventListener("wheel",o.wheel,{passive:false}),n.wheel=o.wheel):(i.removeEventListener("wheel",n.wheel),n.wheel=null),l&2?n.mouseup||(n.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),l&4?n.mousedrag||(n.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null);})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(L(i,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return r(l),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(l)})),this._register(L(i,"wheel",l=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===false)return false;if(!this.buffer.hasScrollback){if(l.deltaY===0)return false;if(e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(l,true);let h=b.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,true),this.cancel(l,true)}}},{passive:false}));}refresh(e,i){this._renderService?.refreshRows(e,i);}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select");}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=true,this.refresh(this.buffer.y,this.buffer.y));}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1);}scrollPages(e){this.scrollLines(e*(this.rows-1));}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp);}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,true):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i);}paste(e){Cn(e,this.textarea,this.coreService,this.optionsService);}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e;}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e;}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1);}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:false}select(e,i,r){this._selectionService.setSelection(e,i,r);}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return {start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection();}selectAll(){this._selectionService?.selectAll();}selectLines(e,i){this._selectionService?.selectLines(e,i);}_keyDown(e){if(this._keyDownHandled=false,this._keyDownSeen=true,this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)return false;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(true),false;!i&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=true);let r=Il(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,true)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,true),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return true;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=false,true;if((r.key===b.ETX||r.key===b.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,true),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,true);this._keyDownHandled=true;}_isThirdLevelShift(e,i){let r=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return i.type==="keypress"?r:r&&(!i.keyCode||i.keyCode>47)}_keyUp(e){this._keyDownSeen=false,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)&&(Tc(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=false);}_keyPress(e){let i;if(this._keyPressHandled=false,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)return false;if(this.cancel(e),e.charCode)i=e.charCode;else if(e.which===null||e.which===void 0)i=e.keyCode;else if(e.which!==0&&e.charCode!==0)i=e.which;else return false;return !i||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?false:(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,true),this._keyPressHandled=true,this._unprocessedDeadKey=false,true)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return false;this._unprocessedDeadKey=false;let i=e.data;return this.coreService.triggerDataEvent(i,true),this.cancel(e),true}return false}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i);}_afterResize(e,i){this._charSizeService?.measure();}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(X));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1);}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1);}clearTextureAtlas(){this._renderService?.clearTextureAtlas();}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(b.ESC+"[I"):this.coreService.triggerDataEvent(b.ESC+"[O");}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${b.ESC}[4;${r};${i}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${b.ESC}[6;${o};${n}t`);break}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),false}};function Tc(s){return s.keyCode===16||s.keyCode===17||s.keyCode===18}var xn=class{constructor(){this._addons=[];}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose();}loadAddon(t,e){let i={instance:e,dispose:e.dispose,isDisposed:false};this._addons.push(i),e.dispose=()=>this._wrappedAddonDispose(i),e.activate(t);}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===t){e=i;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=true,t.dispose.apply(t.instance),this._addons.splice(e,1);}};var wn=class{constructor(t){this._line=t;}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new q)}translateToString(t,e,i){return this._line.translateToString(t,e,i)}};var Ji=class{constructor(t,e){this._buffer=t;this.type=e;}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new wn(e)}getNullCell(){return new q}};var Dn=class extends D{constructor(e){super();this._core=e;this._onBufferChange=this._register(new v);this.onBufferChange=this._onBufferChange.event;this._normal=new Ji(this._core.buffers.normal,"normal"),this._alternate=new Ji(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active));}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}};var Rn=class{constructor(t){this._core=t;}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,r)=>e(i,r.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}};var Ln=class{constructor(t){this._core=t;}register(t){this._core.unicodeService.register(t);}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t;}};var Ic=["cols","rows"],Ue=0,Dl=class extends D{constructor(t){super(),this._core=this._register(new yn(t)),this._addonManager=this._register(new xn),this._publicOptions={...this._core.options};let e=r=>this._core.options[r],i=(r,n)=>{this._checkReadonlyOptions(r),this._core.options[r]=n;};for(let r in this._core.options){let n={get:e.bind(this,r),set:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,n);}}_checkReadonlyOptions(t){if(Ic.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Rn(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ln(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Dn(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case "X10":e="x10";break;case "VT200":e="vt200";break;case "DRAG":e="drag";break;case "ANY":e="any";break}return {applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e];}blur(){this._core.blur();}focus(){this._core.focus();}input(t,e=true){this._core.input(t,e);}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e);}open(t){this._core.open(t);}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t);}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t);}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t);}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i);}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection();}selectAll(){this._core.selectAll();}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e);}dispose(){super.dispose();}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t);}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t);}scrollToTop(){this._core.scrollToTop();}scrollToBottom(){this._core.scrollToBottom();}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t);}clear(){this._core.clear();}write(t,e){this._core.write(t,e);}writeln(t,e){this._core.write(t),this._core.write(`\r
9882
9969
  `,e);}paste(t){this._core.paste(t);}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e);}reset(){this._core.reset();}clearTextureAtlas(){this._core.clearTextureAtlas();}loadAddon(t){this._addonManager.loadAddon(this,t);}static get strings(){return {get promptLabel(){return mi.get()},set promptLabel(t){mi.set(t);},get tooMuchOutput(){return _i.get()},set tooMuchOutput(t){_i.set(t);}}}_verifyIntegers(...t){for(Ue of t)if(Ue===1/0||isNaN(Ue)||Ue%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Ue of t)if(Ue&&(Ue===1/0||isNaN(Ue)||Ue%1!==0||Ue<0))throw new Error("This API only accepts positive integers")}};
9883
9970
 
9971
+ const defaultColumns = 80;
9972
+ const defaultRows = 24;
9973
+ const createTerminal = () => {
9974
+ return new Dl({
9975
+ cols: defaultColumns,
9976
+ convertEol: true,
9977
+ cursorBlink: true,
9978
+ rows: defaultRows
9979
+ });
9980
+ };
9884
9981
  const create = () => {
9885
9982
  const $Viewlet = document.createElement('div');
9886
- const term = new Dl();
9887
- term.open($Viewlet);
9888
- term.write('Hello from \u{1B}[1;3;31mxterm.js\u{1B}[0m $ ');
9983
+ $Viewlet.className = 'Viewlet Terminal XtermTerminal';
9889
9984
  return {
9890
- $Viewlet
9985
+ $Viewlet,
9986
+ disposables: [],
9987
+ terminal: undefined
9891
9988
  };
9892
9989
  };
9990
+ const setTerminal = (state, uid) => {
9991
+ if (state.terminal) {
9992
+ return;
9993
+ }
9994
+ const terminal = createTerminal();
9995
+ const inputDisposable = terminal.onData(data => {
9996
+ handleInput$6(uid, data);
9997
+ });
9998
+ const resizeDisposable = terminal.onResize(({
9999
+ cols,
10000
+ rows
10001
+ }) => {
10002
+ resize(uid, {
10003
+ columns: cols,
10004
+ rows
10005
+ });
10006
+ });
10007
+ terminal.open(state.$Viewlet);
10008
+ state.terminal = terminal;
10009
+ state.disposables = [inputDisposable, resizeDisposable];
10010
+ };
10011
+ const write = (state, data) => {
10012
+ const {
10013
+ terminal
10014
+ } = state;
10015
+ if (!terminal) {
10016
+ return;
10017
+ }
10018
+ terminal.write(data);
10019
+ };
10020
+ const focus = state => {
10021
+ object(state);
10022
+ const {
10023
+ terminal
10024
+ } = state;
10025
+ if (!terminal) {
10026
+ return;
10027
+ }
10028
+ terminal.focus();
10029
+ };
10030
+ const handleMouseDown = state => {
10031
+ focus(state);
10032
+ };
10033
+ const attachEvents = state => {
10034
+ state.$Viewlet.addEventListener('mousedown', () => {
10035
+ handleMouseDown(state);
10036
+ });
10037
+ };
10038
+ const dispose = state => {
10039
+ for (const disposable of state.disposables) {
10040
+ disposable.dispose();
10041
+ }
10042
+ state.disposables = [];
10043
+ state.terminal?.dispose();
10044
+ state.terminal = undefined;
10045
+ };
9893
10046
 
9894
10047
  const ViewletTerminal2 = {
9895
10048
  __proto__: null,
9896
- create
10049
+ attachEvents,
10050
+ create,
10051
+ dispose,
10052
+ focus,
10053
+ handleMouseDown,
10054
+ setTerminal,
10055
+ write
9897
10056
  };
9898
10057
 
9899
10058
  // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "29.2.0",
3
+ "version": "29.4.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"