@lvce-editor/renderer-process 29.1.0 → 29.3.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
  };
@@ -264,21 +264,38 @@ const applyDragInfoMaybe = event => {
264
264
  const PointerMove$1 = 'pointermove';
265
265
  const lostpointercapture = 'lostpointercapture';
266
266
 
267
- let ignore = false;
267
+ const createEventState = () => {
268
+ let ignore = false;
269
+ return {
270
+ startIgnore() {
271
+ ignore = true;
272
+ },
273
+ stopIgnore() {
274
+ ignore = false;
275
+ },
276
+ enabled() {
277
+ return ignore;
278
+ }
279
+ };
280
+ };
281
+ const eventState = createEventState();
268
282
  const startIgnore = () => {
269
- ignore = true;
283
+ eventState.startIgnore();
270
284
  };
271
285
  const stopIgnore = () => {
272
- ignore = false;
286
+ eventState.stopIgnore();
273
287
  };
274
288
  const enabled = () => {
275
- return ignore;
289
+ return eventState.enabled();
276
290
  };
277
291
 
278
- let id$1 = 0;
279
- const create$L = () => {
280
- return ++id$1;
292
+ const createIdGenerator = () => {
293
+ let id = 0;
294
+ return () => {
295
+ return ++id;
296
+ };
281
297
  };
298
+ const create$L = createIdGenerator();
282
299
 
283
300
  const state$9 = Object.create(null);
284
301
  const acquire$1 = id => {
@@ -1282,26 +1299,57 @@ const attachEvent = ($Node, eventMap, key, value, newEventMap) => {
1282
1299
  });
1283
1300
  attachedListeners.set($Node, listenersByEvent);
1284
1301
  };
1302
+ const detachEvent = ($Node, key) => {
1303
+ const keyLower = key.toLowerCase();
1304
+ const listenersByEvent = attachedListeners.get($Node);
1305
+ const previous = listenersByEvent?.get(keyLower);
1306
+ if (!previous) {
1307
+ return;
1308
+ }
1309
+ $Node.removeEventListener(keyLower, previous.listener, previous.options);
1310
+ listenersByEvent?.delete(keyLower);
1311
+ };
1285
1312
 
1286
- const STYLE_REGEX = /([^:;]+):\s*([^;]+)/g;
1287
- const KEBAB_CASE_REGEX = /-([a-z])/g;
1313
+ const toCamelCase = key => {
1314
+ let camelCaseKey = '';
1315
+ let shouldUpperCase = false;
1316
+ for (const char of key) {
1317
+ if (char === '-') {
1318
+ shouldUpperCase = true;
1319
+ continue;
1320
+ }
1321
+ camelCaseKey += shouldUpperCase ? char.toUpperCase() : char;
1322
+ shouldUpperCase = false;
1323
+ }
1324
+ return camelCaseKey;
1325
+ };
1288
1326
  const setStyle = ($Element, styleString) => {
1289
1327
  if (typeof styleString !== 'string') {
1290
1328
  return;
1291
1329
  }
1292
- let match;
1293
- while ((match = STYLE_REGEX.exec(styleString)) !== null) {
1294
- const key = match[1].trim();
1295
- const value = match[2].trim();
1296
- // Convert kebab-case to camelCase for CSS properties with dashes
1297
- const camelCaseKey = key.replaceAll(KEBAB_CASE_REGEX, (_, char) => char.toUpperCase());
1330
+ for (const declaration of styleString.split(';')) {
1331
+ const colonIndex = declaration.indexOf(':');
1332
+ if (colonIndex === -1) {
1333
+ continue;
1334
+ }
1335
+ const key = declaration.slice(0, colonIndex).trim();
1336
+ const value = declaration.slice(colonIndex + 1).trim();
1337
+ if (!key || !value) {
1338
+ continue;
1339
+ }
1340
+ if (key.startsWith('--')) {
1341
+ $Element.style.setProperty(key, value);
1342
+ continue;
1343
+ }
1344
+ const camelCaseKey = toCamelCase(key);
1298
1345
  $Element.style[camelCaseKey] = value;
1299
1346
  }
1300
1347
  };
1301
1348
 
1302
1349
  const optionalAttributeProps = new Map([['ariaActivedescendant', 'aria-activedescendant'], ['ariaOwns', 'aria-owns']]);
1303
1350
  const mappedAttributeProps = new Map([['ariaControls', 'aria-controls'], ['ariaLabelledBy', 'aria-labelledby']]);
1304
- const pixelStyleProps = new Set(['left', 'marginTop', 'paddingLeft', 'paddingRight', 'top']);
1351
+ const removedAttributeProps = new Map([['ariaActivedescendant', 'aria-activedescendant'], ['ariaControls', 'aria-controls'], ['ariaLabelledBy', 'aria-labelledby'], ['ariaOwns', 'aria-owns'], ['className', 'class'], ['htmlFor', 'for'], ['inputType', 'type']]);
1352
+ const pixelStyleProps = new Set(['height', 'left', 'marginTop', 'paddingLeft', 'paddingRight', 'top', 'width']);
1305
1353
  const eventProps = new Set(['onBlur', 'onChange', 'onClick', 'onContextMenu', 'onBeforeInput', 'onDblClick', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onFocus', 'onFocusIn', 'onFocusOut', 'onInput', 'onKeydown', 'onKeyDown', 'onKeyUp', 'onMouseDown', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onPointerDown', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onScroll', 'onSelectionChange', 'onSubmit', 'onWheel']);
1306
1354
  const setOptionalAttribute = ($Element, attributeName, value) => {
1307
1355
  if (value) {
@@ -1327,6 +1375,19 @@ const setEventProp = ($Element, key, value, eventMap, newEventMap) => {
1327
1375
  const eventName = key.slice(2).toLowerCase();
1328
1376
  attachEvent($Element, eventMap, eventName, value, newEventMap);
1329
1377
  };
1378
+ const removeProp = ($Element, key) => {
1379
+ if (eventProps.has(key)) {
1380
+ const eventName = key.slice(2).toLowerCase();
1381
+ detachEvent($Element, eventName);
1382
+ return;
1383
+ }
1384
+ if (pixelStyleProps.has(key)) {
1385
+ $Element.style[key] = '';
1386
+ return;
1387
+ }
1388
+ const attributeName = removedAttributeProps.get(key) || key;
1389
+ $Element.removeAttribute(attributeName);
1390
+ };
1330
1391
  const setProp = ($Element, key, value, eventMap, newEventMap) => {
1331
1392
  const optionalAttributeName = optionalAttributeProps.get(key);
1332
1393
  if (optionalAttributeName) {
@@ -1468,28 +1529,6 @@ const rememberFocus2 = ($Viewlet, dom, eventMap, uid = 0) => {
1468
1529
  return $Viewlet;
1469
1530
  };
1470
1531
 
1471
- // Map of property names to attribute names for cases where they differ
1472
- const propertyToAttribute = {
1473
- className: 'class',
1474
- htmlFor: 'for',
1475
- ariaActivedescendant: 'aria-activedescendant',
1476
- ariaControls: 'aria-controls',
1477
- ariaLabelledBy: 'aria-labelledby',
1478
- ariaOwns: 'aria-owns',
1479
- inputType: 'type'
1480
- };
1481
- // Style properties that need to be set on element.style
1482
- const styleProperties = new Set(['width', 'height', 'top', 'left', 'marginTop', 'paddingLeft', 'paddingRight']);
1483
- const removeAttribute = ($Element, key) => {
1484
- // Handle style properties
1485
- if (styleProperties.has(key)) {
1486
- // @ts-ignore - dynamic style property access
1487
- $Element.style[key] = '';
1488
- return;
1489
- }
1490
- const attributeName = propertyToAttribute[key] || key;
1491
- $Element.removeAttribute(attributeName);
1492
- };
1493
1532
  const setText$1 = ($Element, value) => {
1494
1533
  $Element.nodeValue = value;
1495
1534
  };
@@ -1618,7 +1657,7 @@ const applyMutationPatch = (state, patch, events) => {
1618
1657
  state.hasAppliedMutation = true;
1619
1658
  break;
1620
1659
  case RemoveAttribute:
1621
- removeAttribute(state.current, patch.key);
1660
+ removeProp(state.current, patch.key);
1622
1661
  state.hasAppliedMutation = true;
1623
1662
  break;
1624
1663
  case RemoveChild:
@@ -1768,15 +1807,15 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1768
1807
  const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
1769
1808
  const focused = activeElement?.getAttribute('name') || null;
1770
1809
  const $Hidden = createHiddenContainer(activeElement, focused);
1771
- const inputMap = getInputMap($Viewlet);
1772
1810
  if (uid) {
1773
1811
  const numericUid = Number(uid);
1812
+ const inputMap = getInputMap($Viewlet);
1774
1813
  $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
1775
- $Hidden.remove();
1776
- } else {
1814
+ }
1815
+ if (!uid) {
1777
1816
  renderInto($Viewlet, dom, eventMap);
1778
- $Hidden.remove();
1779
1817
  }
1818
+ $Hidden.remove();
1780
1819
  restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
1781
1820
  $Viewlet.style.top = oldTop;
1782
1821
  $Viewlet.style.left = oldLeft;
@@ -3406,7 +3445,7 @@ const hydrate$3 = async () => {
3406
3445
  };
3407
3446
 
3408
3447
  // TODO needed?
3409
- const dispose$i = () => {
3448
+ const dispose$j = () => {
3410
3449
  if (state$7.rpc) {
3411
3450
  // @ts-expect-error
3412
3451
  state$7.rpc.dispose();
@@ -3431,7 +3470,7 @@ const invokeAndTransfer = (method, ...params) => {
3431
3470
 
3432
3471
  const RendererWorker = {
3433
3472
  __proto__: null,
3434
- dispose: dispose$i,
3473
+ dispose: dispose$j,
3435
3474
  hydrate: hydrate$3,
3436
3475
  invoke: invoke$1,
3437
3476
  invokeAndTransfer,
@@ -3606,7 +3645,7 @@ const createWithOptions = (type, message, options) => {
3606
3645
  const $Notification = create$NotificationWithOptions(message, options);
3607
3646
  append$1($Notification);
3608
3647
  };
3609
- const dispose$h = id => {
3648
+ const dispose$i = id => {
3610
3649
  // const $Notification = state.$Notifications
3611
3650
  };
3612
3651
 
@@ -3743,7 +3782,7 @@ const getElement = () => {
3743
3782
  return state$4.$PreviousFocusElement;
3744
3783
  };
3745
3784
 
3746
- const focus$d = $Element => {
3785
+ const focus$e = $Element => {
3747
3786
  if ($Element === document.activeElement) {
3748
3787
  return;
3749
3788
  }
@@ -3842,7 +3881,7 @@ const getLevel = $Menu => {
3842
3881
  // @ts-expect-error
3843
3882
  return state$3.$$Menus.indexOf($Menu);
3844
3883
  };
3845
- const handleMouseDown$3 = event => {
3884
+ const handleMouseDown$4 = event => {
3846
3885
  const $Target = event.target;
3847
3886
  const $Menu = $Target.closest('.Menu');
3848
3887
  const index = findIndex($Menu, $Target);
@@ -3919,7 +3958,7 @@ const create$Menu$1 = () => {
3919
3958
  $Menu.tabIndex = -1;
3920
3959
  // $ContextMenu.onmousedown = contextMenuHandleMouseDown
3921
3960
  // TODO mousedown vs click? (click is usually better but mousedown is faster, why wait 100ms?)
3922
- $Menu.addEventListener(MouseDown, handleMouseDown$3);
3961
+ $Menu.addEventListener(MouseDown, handleMouseDown$4);
3923
3962
  $Menu.addEventListener(MouseEnter, handleMouseEnter, {
3924
3963
  capture: true
3925
3964
  });
@@ -3992,7 +4031,7 @@ const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom = [],
3992
4031
  state$3.$$Menus.push($Menu);
3993
4032
  append$1($Menu);
3994
4033
  if (level === 0) {
3995
- focus$d($Menu);
4034
+ focus$e($Menu);
3996
4035
  send('Focus.setFocus', FocusMenu);
3997
4036
  }
3998
4037
  };
@@ -4869,14 +4908,14 @@ const create$t = (uri, top, left) => {
4869
4908
  const update = (state, uri) => {
4870
4909
  state.$ImagePreviewImage.uri = uri;
4871
4910
  };
4872
- const dispose$g = state => {
4911
+ const dispose$h = state => {
4873
4912
  remove$1(state.$ImagePreview);
4874
4913
  };
4875
4914
 
4876
4915
  const ImagePreview$1 = {
4877
4916
  __proto__: null,
4878
4917
  create: create$t,
4879
- dispose: dispose$g,
4918
+ dispose: dispose$h,
4880
4919
  showError,
4881
4920
  update
4882
4921
  };
@@ -4899,7 +4938,7 @@ const get$ItemFromEvent = event => {
4899
4938
  }
4900
4939
  return undefined;
4901
4940
  };
4902
- const handleMouseDown$2 = event => {
4941
+ const handleMouseDown$3 = event => {
4903
4942
  const {
4904
4943
  button,
4905
4944
  clientX,
@@ -4939,7 +4978,7 @@ const ViewletActivityBarEvents = {
4939
4978
  handleBlur: handleBlur$8,
4940
4979
  handleContextMenu: handleContextMenu$6,
4941
4980
  handleFocus: handleFocus$8,
4942
- handleMouseDown: handleMouseDown$2,
4981
+ handleMouseDown: handleMouseDown$3,
4943
4982
  returnValue: returnValue$8
4944
4983
  };
4945
4984
 
@@ -5022,7 +5061,7 @@ forwardViewletCommand('handleListBlur');
5022
5061
  forwardViewletCommand('handleListFocus');
5023
5062
  const handleMenuClick$1 = forwardViewletCommand('handleMenuClick');
5024
5063
  const handleMenuMouseOver$1 = forwardViewletCommand('handleMenuMouseOver');
5025
- const handleMouseDown$1 = forwardViewletCommand('handleMouseDown');
5064
+ const handleMouseDown$2 = forwardViewletCommand('handleMouseDown');
5026
5065
  forwardViewletCommand('handleMouseMove');
5027
5066
  const handleMouseOut$1 = forwardViewletCommand('handleMouseOut');
5028
5067
  const handleMouseOver$1 = forwardViewletCommand('handleMouseOver');
@@ -5062,6 +5101,7 @@ forwardViewletCommand('moveRectangleSelectionPx');
5062
5101
  forwardViewletCommand('moveSelectionPx');
5063
5102
  forwardViewletCommand('paste');
5064
5103
  forwardViewletCommand('replaceAll');
5104
+ const resize = forwardViewletCommand('resize');
5065
5105
  const selectIndex = forwardViewletCommand('selectIndex');
5066
5106
  forwardViewletCommand('setDelta');
5067
5107
  forwardViewletCommand('toggleMatchCase');
@@ -5107,7 +5147,7 @@ const create$s = () => {
5107
5147
  $Viewlet
5108
5148
  };
5109
5149
  };
5110
- const dispose$f = state => {};
5150
+ const dispose$g = state => {};
5111
5151
  const refresh$4 = () => {};
5112
5152
  const setTime = (state, time) => {
5113
5153
  object(state);
@@ -5118,7 +5158,7 @@ const setTime = (state, time) => {
5118
5158
  const ViewletClock = {
5119
5159
  __proto__: null,
5120
5160
  create: create$s,
5121
- dispose: dispose$f,
5161
+ dispose: dispose$g,
5122
5162
  refresh: refresh$4,
5123
5163
  setTime
5124
5164
  };
@@ -5314,7 +5354,7 @@ const setValue$2 = (state, value) => {
5314
5354
  const $Input = $Viewlet.querySelector(':scope input');
5315
5355
  $Input.value = value;
5316
5356
  };
5317
- const focus$c = state => {
5357
+ const focus$d = state => {
5318
5358
  const {
5319
5359
  $Viewlet
5320
5360
  } = state;
@@ -5325,7 +5365,7 @@ const focus$c = state => {
5325
5365
  const ViewletDefineKeyBinding = {
5326
5366
  __proto__: null,
5327
5367
  Events: ViewletDefineKeyBindingEvents,
5328
- focus: focus$c,
5368
+ focus: focus$d,
5329
5369
  setValue: setValue$2
5330
5370
  };
5331
5371
 
@@ -5712,10 +5752,10 @@ const appendWidget$5 = state => {
5712
5752
  } = state;
5713
5753
  append$1($Viewlet);
5714
5754
  };
5715
- const dispose$e = state => {
5755
+ const dispose$f = state => {
5716
5756
  remove$1(state.$Viewlet);
5717
5757
  };
5718
- const focus$b = (state, key, source) => {
5758
+ const focus$c = (state, key, source) => {
5719
5759
  if (!key) {
5720
5760
  return;
5721
5761
  }
@@ -5738,8 +5778,8 @@ const ViewletEditorCodeGenerator = {
5738
5778
  __proto__: null,
5739
5779
  Events: ViewletEditorCodeGeneratorEvents,
5740
5780
  appendWidget: appendWidget$5,
5741
- dispose: dispose$e,
5742
- focus: focus$b,
5781
+ dispose: dispose$f,
5782
+ focus: focus$c,
5743
5783
  setBounds: setBounds$9
5744
5784
  };
5745
5785
 
@@ -5909,7 +5949,7 @@ const setDom$8 = (state, dom) => {
5909
5949
  // TODO recycle nodes
5910
5950
  // TODO set right aria attributes on $EditorInput
5911
5951
  };
5912
- const dispose$d = state => {
5952
+ const dispose$e = state => {
5913
5953
  remove$1(state.$Viewlet);
5914
5954
  // state.$EditorInput.removeAttribute('aria-activedescendant')
5915
5955
  };
@@ -5941,7 +5981,7 @@ const ViewletEditorCompletion = {
5941
5981
  __proto__: null,
5942
5982
  attachEvents: attachEvents$5,
5943
5983
  create: create$n,
5944
- dispose: dispose$d,
5984
+ dispose: dispose$e,
5945
5985
  handleError: handleError$5,
5946
5986
  setBounds: setBounds$8,
5947
5987
  setContentHeight,
@@ -5989,7 +6029,7 @@ const appendWidget$4 = state => {
5989
6029
  } = state;
5990
6030
  append$1($Viewlet);
5991
6031
  };
5992
- const dispose$c = state => {
6032
+ const dispose$d = state => {
5993
6033
  remove$1(state.$Viewlet);
5994
6034
  };
5995
6035
  const setBounds$7 = (state, x, y, width, height) => {
@@ -6005,7 +6045,7 @@ const ViewletEditorCompletionDetails = {
6005
6045
  appendWidget: appendWidget$4,
6006
6046
  attachEvents: attachEvents$4,
6007
6047
  create: create$m,
6008
- dispose: dispose$c,
6048
+ dispose: dispose$d,
6009
6049
  setBounds: setBounds$7,
6010
6050
  setDom: setDom$7
6011
6051
  };
@@ -6260,7 +6300,7 @@ const create$j = () => {
6260
6300
  $Viewlet
6261
6301
  };
6262
6302
  };
6263
- const dispose$b = state => {};
6303
+ const dispose$c = state => {};
6264
6304
  const refresh$3 = (state, context) => {
6265
6305
  object(state);
6266
6306
  string(context.content);
@@ -6270,7 +6310,7 @@ const refresh$3 = (state, context) => {
6270
6310
  const ViewletEditorPlainText = {
6271
6311
  __proto__: null,
6272
6312
  create: create$j,
6273
- dispose: dispose$b,
6313
+ dispose: dispose$c,
6274
6314
  refresh: refresh$3
6275
6315
  };
6276
6316
 
@@ -6298,7 +6338,7 @@ const appendWidget$2 = state => {
6298
6338
  } = state;
6299
6339
  append$1($Viewlet);
6300
6340
  };
6301
- const dispose$a = state => {
6341
+ const dispose$b = state => {
6302
6342
  remove$1(state.$Viewlet);
6303
6343
  };
6304
6344
 
@@ -6306,7 +6346,7 @@ const ViewletEditorSourceActions = {
6306
6346
  __proto__: null,
6307
6347
  Events: ViewletEditorSourceActionsEvents,
6308
6348
  appendWidget: appendWidget$2,
6309
- dispose: dispose$a,
6349
+ dispose: dispose$b,
6310
6350
  setBounds: setBounds$4
6311
6351
  };
6312
6352
 
@@ -6367,14 +6407,14 @@ const create$g = () => {
6367
6407
  };
6368
6408
  };
6369
6409
  const refresh$2 = (state, context) => {};
6370
- const focus$a = state => {};
6371
- const dispose$9 = state => {};
6410
+ const focus$b = state => {};
6411
+ const dispose$a = state => {};
6372
6412
 
6373
6413
  const ViewletEmpty = {
6374
6414
  __proto__: null,
6375
6415
  create: create$g,
6376
- dispose: dispose$9,
6377
- focus: focus$a,
6416
+ dispose: dispose$a,
6417
+ focus: focus$b,
6378
6418
  refresh: refresh$2
6379
6419
  };
6380
6420
 
@@ -6568,7 +6608,7 @@ const create$d = () => {
6568
6608
  $Viewlet
6569
6609
  };
6570
6610
  };
6571
- const focus$9 = (state, key, source) => {
6611
+ const focus$a = (state, key, source) => {
6572
6612
  if (!key) {
6573
6613
  return;
6574
6614
  }
@@ -6614,7 +6654,7 @@ const setBounds$2 = (state, x, y, width, height) => {
6614
6654
  } = state;
6615
6655
  setBounds$a($Viewlet, x, y, width, height);
6616
6656
  };
6617
- const dispose$8 = state => {
6657
+ const dispose$9 = state => {
6618
6658
  remove$1(state.$Viewlet);
6619
6659
  };
6620
6660
  const Events$3 = ViewletFindWidgetEvents;
@@ -6624,8 +6664,8 @@ const ViewletFindWidget = {
6624
6664
  Events: Events$3,
6625
6665
  appendWidget: appendWidget$1,
6626
6666
  create: create$d,
6627
- dispose: dispose$8,
6628
- focus: focus$9,
6667
+ dispose: dispose$9,
6668
+ focus: focus$a,
6629
6669
  setBounds: setBounds$2,
6630
6670
  setDom: setDom$3,
6631
6671
  setValue: setValue$1
@@ -6672,7 +6712,7 @@ const handleError$3 = (state, message) => {
6672
6712
  } = state;
6673
6713
  $Message.textContent = message;
6674
6714
  };
6675
- const focus$8 = state => {
6715
+ const focus$9 = state => {
6676
6716
  const {
6677
6717
  $Locations
6678
6718
  } = state;
@@ -6684,7 +6724,7 @@ const focus$8 = state => {
6684
6724
  const ViewletImplementations = {
6685
6725
  __proto__: null,
6686
6726
  Events: ViewletLocationsEvents,
6687
- focus: focus$8,
6727
+ focus: focus$9,
6688
6728
  handleError: handleError$3,
6689
6729
  setFocusedIndex: setFocusedIndex$1
6690
6730
  };
@@ -7060,9 +7100,9 @@ const handleError$2 = (state, error) => {
7060
7100
  string(error);
7061
7101
  state.content.textContent = error;
7062
7102
  };
7063
- const focus$7 = state => {
7103
+ const focus$8 = state => {
7064
7104
  object(state);
7065
- focus$d(state.$ViewletOutputContent);
7105
+ focus$e(state.$ViewletOutputContent);
7066
7106
  send('Focus.setFocus', FocusOutput);
7067
7107
  };
7068
7108
 
@@ -7075,15 +7115,15 @@ const disposeFindWidget = state => {
7075
7115
  return;
7076
7116
  }
7077
7117
  };
7078
- const dispose$7 = state => {};
7118
+ const dispose$8 = state => {};
7079
7119
 
7080
7120
  const ViewletOutput = {
7081
7121
  __proto__: null,
7082
7122
  clear: clear$1,
7083
7123
  create: create$b,
7084
- dispose: dispose$7,
7124
+ dispose: dispose$8,
7085
7125
  disposeFindWidget,
7086
- focus: focus$7,
7126
+ focus: focus$8,
7087
7127
  handleError: handleError$2,
7088
7128
  openFindWidget,
7089
7129
  setText
@@ -7196,14 +7236,14 @@ const setTabsDom$1 = (state, dom) => {
7196
7236
  };
7197
7237
 
7198
7238
  // TODO add test for focus method
7199
- const focus$6 = state => {
7239
+ const focus$7 = state => {
7200
7240
  object(state);
7201
7241
  if (!state.currentViewlet) {
7202
7242
  return;
7203
7243
  }
7204
7244
  state.currentViewlet.factory.focus(state.currentViewlet.state);
7205
7245
  };
7206
- const dispose$6 = state => {
7246
+ const dispose$7 = state => {
7207
7247
  if (state.$PanelContent) {
7208
7248
  state.$PanelContent.remove();
7209
7249
  state.$PanelContent = undefined;
@@ -7249,8 +7289,8 @@ const ViewletPanel = {
7249
7289
  __proto__: null,
7250
7290
  attachEvents: attachEvents$1,
7251
7291
  create: create$a,
7252
- dispose: dispose$6,
7253
- focus: focus$6,
7292
+ dispose: dispose$7,
7293
+ focus: focus$7,
7254
7294
  setActionsDom: setActionsDom$1,
7255
7295
  setSelectedIndex,
7256
7296
  setTabsDom: setTabsDom$1
@@ -7259,7 +7299,7 @@ const ViewletPanel = {
7259
7299
  const ViewletReferences = {
7260
7300
  __proto__: null,
7261
7301
  Events: ViewletLocationsEvents,
7262
- focus: focus$8,
7302
+ focus: focus$9,
7263
7303
  handleError: handleError$3,
7264
7304
  setFocusedIndex: setFocusedIndex$1
7265
7305
  };
@@ -7348,7 +7388,7 @@ const attachEvents = state => {
7348
7388
  [Click]: handleHeaderClick
7349
7389
  });
7350
7390
  };
7351
- const dispose$5 = state => {
7391
+ const dispose$6 = state => {
7352
7392
  object(state);
7353
7393
  state.$Sidebar.replaceChildren();
7354
7394
  };
@@ -7376,7 +7416,7 @@ const setActionsDom = (state, actions, parentId, eventMap = {}) => {
7376
7416
  }
7377
7417
  state.$Actions = $NewViewlet;
7378
7418
  };
7379
- const focus$5 = async () => {
7419
+ const focus$6 = async () => {
7380
7420
  // await
7381
7421
  };
7382
7422
 
@@ -7384,8 +7424,8 @@ const ViewletSidebar = {
7384
7424
  __proto__: null,
7385
7425
  attachEvents,
7386
7426
  create: create$8,
7387
- dispose: dispose$5,
7388
- focus: focus$5,
7427
+ dispose: dispose$6,
7428
+ focus: focus$6,
7389
7429
  setActionsDom,
7390
7430
  setTitle
7391
7431
  };
@@ -7568,7 +7608,7 @@ const ViewletSourceControlEvents = {
7568
7608
  handleWheel: handleWheel$2
7569
7609
  };
7570
7610
 
7571
- const focus$4 = state => {
7611
+ const focus$5 = state => {
7572
7612
  const {
7573
7613
  $Viewlet
7574
7614
  } = state;
@@ -7578,7 +7618,7 @@ const focus$4 = state => {
7578
7618
  const ViewletSourceControl = {
7579
7619
  __proto__: null,
7580
7620
  Events: ViewletSourceControlEvents,
7581
- focus: focus$4
7621
+ focus: focus$5
7582
7622
  };
7583
7623
 
7584
7624
  const handleClick$2 = event => {
@@ -7614,7 +7654,7 @@ const setDom$2 = (state, dom) => {
7614
7654
  } = state;
7615
7655
  renderInto($Viewlet, dom, ViewletStatusBarEvents);
7616
7656
  };
7617
- const focus$3 = state => {
7657
+ const focus$4 = state => {
7618
7658
  object(state);
7619
7659
  const {
7620
7660
  $Viewlet
@@ -7625,7 +7665,7 @@ const focus$3 = state => {
7625
7665
  const ViewletStatusBar = {
7626
7666
  __proto__: null,
7627
7667
  create: create$7,
7628
- focus: focus$3,
7668
+ focus: focus$4,
7629
7669
  setDom: setDom$2
7630
7670
  };
7631
7671
 
@@ -7783,8 +7823,8 @@ const ViewletTitleBarMenuBarEvents = {
7783
7823
  };
7784
7824
 
7785
7825
  const activeId = 'TitleBarEntryActive';
7786
- const dispose$4 = state => {};
7787
- const focus$2 = state => {
7826
+ const dispose$5 = state => {};
7827
+ const focus$3 = state => {
7788
7828
  const {
7789
7829
  $TitleBarMenuBar
7790
7830
  } = state;
@@ -8020,8 +8060,8 @@ const ViewletTitleBarMenuBar = {
8020
8060
  __proto__: null,
8021
8061
  Events: ViewletTitleBarMenuBarEvents,
8022
8062
  closeMenu,
8023
- dispose: dispose$4,
8024
- focus: focus$2,
8063
+ dispose: dispose$5,
8064
+ focus: focus$3,
8025
8065
  openMenu,
8026
8066
  setFocusedIndex,
8027
8067
  setMenus
@@ -8039,8 +8079,8 @@ const ViewletTitleBar = {
8039
8079
  __proto__: null,
8040
8080
  Events: ViewletTitleBarMenuBarEvents,
8041
8081
  closeMenu,
8042
- dispose: dispose$4,
8043
- focus: focus$2,
8082
+ dispose: dispose$5,
8083
+ focus: focus$3,
8044
8084
  openMenu,
8045
8085
  setFocused,
8046
8086
  setFocusedIndex,
@@ -8350,7 +8390,7 @@ const invoke = (viewletId, method, ...args) => {
8350
8390
  }
8351
8391
  return instance.factory[method](instance.state, ...args);
8352
8392
  };
8353
- const focus$1 = viewletId => {
8393
+ const focus$2 = viewletId => {
8354
8394
  if (location.search.includes('traceFocus')) {
8355
8395
  // eslint-disable-next-line no-console
8356
8396
  console.trace(`focus ${viewletId}`);
@@ -8611,7 +8651,7 @@ const attachWindowEvents = () => {
8611
8651
  const sendMultiple = commands => {
8612
8652
  executeCommands(commands);
8613
8653
  };
8614
- const dispose$3 = id => {
8654
+ const dispose$4 = id => {
8615
8655
  try {
8616
8656
  number(id);
8617
8657
  const instance = get$a(id);
@@ -8835,8 +8875,8 @@ const commandHandlers = {
8835
8875
  'Viewlet.create': create$4,
8836
8876
  'Viewlet.createFunctionalRoot': createFunctionalRoot,
8837
8877
  'Viewlet.createPlaceholder': createPlaceholder,
8838
- 'Viewlet.dispose': dispose$3,
8839
- 'Viewlet.focus': focus$1,
8878
+ 'Viewlet.dispose': dispose$4,
8879
+ 'Viewlet.focus': focus$2,
8840
8880
  'Viewlet.focusElementByName': focusElementByName,
8841
8881
  'Viewlet.focusSelector': focusSelector,
8842
8882
  'Viewlet.handleError': handleError$1,
@@ -9040,7 +9080,7 @@ const setPort = (uid, port, origin, portType) => {
9040
9080
  params: [port, portType]
9041
9081
  }, origin, [port]);
9042
9082
  };
9043
- const dispose$2 = uid => {
9083
+ const dispose$3 = uid => {
9044
9084
  const $Iframe = get$1(uid);
9045
9085
  $Iframe.remove();
9046
9086
  remove(uid);
@@ -9051,7 +9091,7 @@ const commandMap = {
9051
9091
  'ClipBoard.execCopy': execCopy,
9052
9092
  'ClipBoard.read': read,
9053
9093
  'ClipBoard.readText': readText,
9054
- 'ClipBoard.write': write$1,
9094
+ 'ClipBoard.write': write$2,
9055
9095
  'ClipBoard.writeImage': writeImage,
9056
9096
  'ClipBoard.writeText': writeText,
9057
9097
  'ConfirmPrompt.prompt': confirm$1,
@@ -9086,7 +9126,7 @@ const commandMap = {
9086
9126
  'Meta.setThemeColor': setThemeColor,
9087
9127
  'Notification.create': create$v,
9088
9128
  'Notification.createWithOptions': createWithOptions,
9089
- 'Notification.dispose': dispose$h,
9129
+ 'Notification.dispose': dispose$i,
9090
9130
  'OffscreenCanvas.create': create$u,
9091
9131
  'OffscreenCanvas.create2': create2,
9092
9132
  'Open.openUrl': openUrl,
@@ -9109,9 +9149,9 @@ const commandMap = {
9109
9149
  'TestFrameWork.transferToWebView': transferToWebView,
9110
9150
  'Viewlet.addKeyBindings': addKeyBindings,
9111
9151
  'Viewlet.appendViewlet': appendViewlet,
9112
- 'Viewlet.dispose': dispose$3,
9152
+ 'Viewlet.dispose': dispose$4,
9113
9153
  'Viewlet.executeCommands': executeCommands,
9114
- 'Viewlet.focus': focus$1,
9154
+ 'Viewlet.focus': focus$2,
9115
9155
  'Viewlet.focusElementByName': focusElementByName,
9116
9156
  'Viewlet.focusSelector': focusSelector,
9117
9157
  'Viewlet.handleError': handleError$1,
@@ -9130,7 +9170,7 @@ const commandMap = {
9130
9170
  'WebStorage.setJsonObjects': setJsonObjects,
9131
9171
  'WebView.appendOnly': appendOnly,
9132
9172
  'WebView.create': create$3,
9133
- 'WebView.dispose': dispose$2,
9173
+ 'WebView.dispose': dispose$3,
9134
9174
  'WebView.load': load,
9135
9175
  'WebView.loadOnly': loadOnly,
9136
9176
  'WebView.setPort': setPort,
@@ -9276,7 +9316,7 @@ const appendWidget = state => {
9276
9316
  } = state;
9277
9317
  append$1($Viewlet);
9278
9318
  };
9279
- const dispose$1 = state => {
9319
+ const dispose$2 = state => {
9280
9320
  remove$1(state.$Viewlet);
9281
9321
  };
9282
9322
 
@@ -9284,7 +9324,7 @@ const ViewletEditorRename = {
9284
9324
  __proto__: null,
9285
9325
  Events: ViewletEditorRenameEvents,
9286
9326
  appendWidget,
9287
- dispose: dispose$1,
9327
+ dispose: dispose$2,
9288
9328
  setBounds
9289
9329
  };
9290
9330
 
@@ -9698,9 +9738,9 @@ const handleBlur = event => {
9698
9738
  const uid = fromEvent(event);
9699
9739
  handleBlur$7(uid);
9700
9740
  };
9701
- const handleMouseDown = (event, ...args) => {
9741
+ const handleMouseDown$1 = (event, ...args) => {
9702
9742
  const uid = fromEvent(event);
9703
- handleMouseDown$1(uid, ...args);
9743
+ handleMouseDown$2(uid, ...args);
9704
9744
  };
9705
9745
  const handleKeyDown = (event, ...args) => {
9706
9746
  const uid = fromEvent(event);
@@ -9715,7 +9755,7 @@ const create$1 = () => {
9715
9755
  terminal: undefined
9716
9756
  };
9717
9757
  };
9718
- const setTerminal = (state, canvasCursorId, canvasTextId) => {
9758
+ const setTerminal$1 = (state, canvasCursorId, canvasTextId) => {
9719
9759
  const canvasText = get$4(canvasTextId);
9720
9760
  const canvasCursor = get$4(canvasCursorId);
9721
9761
  const {
@@ -9739,7 +9779,7 @@ const setTerminal = (state, canvasCursorId, canvasTextId) => {
9739
9779
  }, ...args);
9740
9780
  },
9741
9781
  handleMouseDown: (...args) => {
9742
- handleMouseDown({
9782
+ handleMouseDown$1({
9743
9783
  target: $Viewlet
9744
9784
  }, ...args);
9745
9785
  }
@@ -9755,13 +9795,13 @@ const focusTextArea = state => {
9755
9795
  const refresh = (state, context) => {
9756
9796
  // state.element.textContent = context.text
9757
9797
  };
9758
- const dispose = state => {
9798
+ const dispose$1 = state => {
9759
9799
  // TODO unregister callback
9760
9800
  // SharedProcess.unregisterChannel(channel )
9761
9801
 
9762
9802
  window.removeEventListener('resize', state.handleUpdate);
9763
9803
  };
9764
- const focus = state => {
9804
+ const focus$1 = state => {
9765
9805
  object(state);
9766
9806
  const {
9767
9807
  terminal
@@ -9785,28 +9825,28 @@ const reduce = (state, action) => {
9785
9825
  }
9786
9826
  }
9787
9827
  };
9788
- const write = (state, data) => {
9828
+ const write$1 = (state, data) => {
9789
9829
  if (!isUint8Array(data)) {
9790
9830
  throw new TypeError(`data must be of type Uint8Array`);
9791
9831
  }
9792
9832
  };
9793
9833
  const Commands = {
9794
- 9922: write
9834
+ 9922: write$1
9795
9835
  };
9796
9836
 
9797
9837
  const ViewletTerminal = {
9798
9838
  __proto__: null,
9799
9839
  Commands,
9800
9840
  create: create$1,
9801
- dispose,
9802
- focus,
9841
+ dispose: dispose$1,
9842
+ focus: focus$1,
9803
9843
  focusTextArea,
9804
9844
  reduce,
9805
9845
  reduceFocus,
9806
9846
  reduceWrite,
9807
9847
  refresh,
9808
- setTerminal,
9809
- write
9848
+ setTerminal: setTerminal$1,
9849
+ write: write$1
9810
9850
  };
9811
9851
 
9812
9852
  /**
@@ -9842,19 +9882,85 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
9842
9882
  `&&(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
9843
9883
  `,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")}};
9844
9884
 
9885
+ const defaultColumns = 80;
9886
+ const defaultRows = 24;
9887
+ const createTerminal = () => {
9888
+ return new Dl({
9889
+ cols: defaultColumns,
9890
+ convertEol: true,
9891
+ cursorBlink: true,
9892
+ rows: defaultRows
9893
+ });
9894
+ };
9845
9895
  const create = () => {
9846
9896
  const $Viewlet = document.createElement('div');
9847
- const term = new Dl();
9848
- term.open($Viewlet);
9849
- term.write('Hello from \u{1B}[1;3;31mxterm.js\u{1B}[0m $ ');
9897
+ $Viewlet.className = 'Viewlet Terminal XtermTerminal';
9850
9898
  return {
9851
- $Viewlet
9899
+ $Viewlet,
9900
+ disposables: [],
9901
+ terminal: undefined
9852
9902
  };
9853
9903
  };
9904
+ const setTerminal = (state, uid) => {
9905
+ if (state.terminal) {
9906
+ return;
9907
+ }
9908
+ const terminal = createTerminal();
9909
+ const inputDisposable = terminal.onData(data => {
9910
+ handleInput$6(uid, data);
9911
+ });
9912
+ const resizeDisposable = terminal.onResize(({
9913
+ cols,
9914
+ rows
9915
+ }) => {
9916
+ resize(uid, {
9917
+ columns: cols,
9918
+ rows
9919
+ });
9920
+ });
9921
+ terminal.open(state.$Viewlet);
9922
+ state.terminal = terminal;
9923
+ state.disposables = [inputDisposable, resizeDisposable];
9924
+ };
9925
+ const write = (state, data) => {
9926
+ const {
9927
+ terminal
9928
+ } = state;
9929
+ if (!terminal) {
9930
+ return;
9931
+ }
9932
+ terminal.write(data);
9933
+ };
9934
+ const focus = state => {
9935
+ object(state);
9936
+ const {
9937
+ terminal
9938
+ } = state;
9939
+ if (!terminal) {
9940
+ return;
9941
+ }
9942
+ terminal.focus();
9943
+ };
9944
+ const handleMouseDown = state => {
9945
+ focus(state);
9946
+ };
9947
+ const dispose = state => {
9948
+ for (const disposable of state.disposables) {
9949
+ disposable.dispose();
9950
+ }
9951
+ state.disposables = [];
9952
+ state.terminal?.dispose();
9953
+ state.terminal = undefined;
9954
+ };
9854
9955
 
9855
9956
  const ViewletTerminal2 = {
9856
9957
  __proto__: null,
9857
- create
9958
+ create,
9959
+ dispose,
9960
+ focus,
9961
+ handleMouseDown,
9962
+ setTerminal,
9963
+ write
9858
9964
  };
9859
9965
 
9860
9966
  // 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.1.0",
3
+ "version": "29.3.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"