@lvce-editor/renderer-process 30.13.1 → 30.14.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$2 = async itemOptions => {
102
+ const write$1 = async itemOptions => {
103
103
  const items = itemOptions.map(toClipboardItem);
104
104
  await navigator.clipboard.write(items);
105
105
  };
@@ -125,7 +125,7 @@ const state$b = {
125
125
  const set$b = (id, sheet) => {
126
126
  state$b.styleSheets[id] = sheet;
127
127
  };
128
- const get$b = id => {
128
+ const get$9 = id => {
129
129
  return state$b.styleSheets[id];
130
130
  };
131
131
  const setText$2 = (id, text) => {
@@ -140,7 +140,7 @@ const remove$5 = id => {
140
140
  };
141
141
 
142
142
  const addCssStyleSheet = (id, text) => {
143
- const existing = get$b(id);
143
+ const existing = get$9(id);
144
144
  if (existing) {
145
145
  existing.replaceSync(text);
146
146
  setText$2(id, text);
@@ -153,7 +153,7 @@ const addCssStyleSheet = (id, text) => {
153
153
  document.adoptedStyleSheets.push(sheet);
154
154
  };
155
155
  const patchCssStyleSheet = (id, start, deleteCount, replacement) => {
156
- const sheet = get$b(id);
156
+ const sheet = get$9(id);
157
157
  const text = getText(id);
158
158
  if (!sheet || typeof text !== 'string') {
159
159
  throw new Error(`stylesheet ${id} must be initialized before it can be patched`);
@@ -172,7 +172,7 @@ const patchCssStyleSheet = (id, start, deleteCount, replacement) => {
172
172
  setText$2(id, newText);
173
173
  };
174
174
  const removeCssStyleSheet = id => {
175
- const sheet = get$b(id);
175
+ const sheet = get$9(id);
176
176
  if (!sheet) {
177
177
  return;
178
178
  }
@@ -336,7 +336,7 @@ const createIdGenerator = () => {
336
336
  return ++id;
337
337
  };
338
338
  };
339
- const create$L = createIdGenerator();
339
+ const create$J = createIdGenerator();
340
340
 
341
341
  const state$a = Object.create(null);
342
342
  const acquire$1 = id => {
@@ -350,7 +350,7 @@ const getFileHandles$1 = async ids => {
350
350
  return handles;
351
351
  };
352
352
  const add$1 = promise => {
353
- const id = create$L();
353
+ const id = create$J();
354
354
  state$a[id] = promise;
355
355
  return id;
356
356
  };
@@ -443,6 +443,17 @@ const getTargetName = event => {
443
443
  }
444
444
  return namedTarget?.getAttribute?.('name') || namedTarget?.name || '';
445
445
  };
446
+ const getNestedProperty = (value, path) => {
447
+ const parts = path.split('.');
448
+ let current = value;
449
+ for (const part of parts) {
450
+ if (current === undefined || current === null) {
451
+ return undefined;
452
+ }
453
+ current = current[part];
454
+ }
455
+ return current;
456
+ };
446
457
  const getEventListenerArg = (param, event) => {
447
458
  switch (param) {
448
459
  case 'event.altKey':
@@ -507,17 +518,12 @@ const getEventListenerArg = (param, event) => {
507
518
  return event.y;
508
519
  default:
509
520
  if (typeof param === 'string' && param.startsWith('event.currentTarget.')) {
510
- const rest = param.slice('event.currentTarget.'.length);
511
- const parts = rest.split('.');
512
- let current = event.currentTarget;
513
- for (const part of parts) {
514
- current = current[part];
515
- }
516
- return current;
521
+ const path = param.slice('event.currentTarget.'.length);
522
+ return getNestedProperty(event.currentTarget, path);
517
523
  }
518
- if (typeof param === 'string' && param.startsWith('event.target.dataset')) {
519
- const rest = param.slice('event.target.dataset.'.length);
520
- return event.target.dataset[rest];
524
+ if (typeof param === 'string' && param.startsWith('event.target.')) {
525
+ const path = param.slice('event.target.'.length);
526
+ return getNestedProperty(event.target, path);
521
527
  }
522
528
  return param;
523
529
  }
@@ -1258,7 +1264,7 @@ const {
1258
1264
  } = ElementTagMap;
1259
1265
 
1260
1266
  const instances = Object.create(null);
1261
- const get$a = viewletId => {
1267
+ const get$8 = viewletId => {
1262
1268
  return instances[viewletId];
1263
1269
  };
1264
1270
  const set$a = (viewletId, instance) => {
@@ -1293,7 +1299,7 @@ const has$1 = listener => {
1293
1299
  const set$9 = (listener, value) => {
1294
1300
  cache.set(listener, value);
1295
1301
  };
1296
- const get$9 = listener => {
1302
+ const get$7 = listener => {
1297
1303
  return cache.get(listener);
1298
1304
  };
1299
1305
 
@@ -1315,7 +1321,7 @@ const getWrappedListener = (listener, returnValue) => {
1315
1321
  nameAnonymousFunction$1(wrapped, listener.name);
1316
1322
  set$9(listener, wrapped);
1317
1323
  }
1318
- return get$9(listener);
1324
+ return get$7(listener);
1319
1325
  };
1320
1326
 
1321
1327
  const attachedListeners = new WeakMap();
@@ -1414,7 +1420,7 @@ const setStyle = ($Element, styleString) => {
1414
1420
 
1415
1421
  const removedAttributeProps = new Map([['ariaActivedescendant', 'aria-activedescendant'], ['ariaControls', 'aria-controls'], ['ariaDescribedBy', 'aria-describedby'], ['ariaInvalid', 'aria-invalid'], ['ariaLabelledBy', 'aria-labelledby'], ['ariaOwns', 'aria-owns'], ['className', 'class'], ['htmlFor', 'for'], ['inputType', 'type']]);
1416
1422
  const pixelStyleProps = new Set(['height', 'left', 'marginTop', 'paddingLeft', 'paddingRight', 'top', 'width']);
1417
- 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']);
1423
+ const eventProps = new Set(['onBlur', 'onChange', 'onClick', 'onContextMenu', 'onBeforeInput', 'onDblClick', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onError', 'onFocus', 'onFocusIn', 'onFocusOut', 'onInput', 'onKeydown', 'onKeyDown', 'onKeyUp', 'onLoadedData', 'onMouseDown', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onPointerDown', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onScroll', 'onSelectionChange', 'onSubmit', 'onTimeUpdate', 'onWheel']);
1418
1424
  const setOptionalAttribute = ($Element, attributeName, value) => {
1419
1425
  if (value) {
1420
1426
  $Element.setAttribute(attributeName, value);
@@ -1549,7 +1555,7 @@ const renderDomElement = (element, eventMap, newEventMap) => {
1549
1555
  return $Element;
1550
1556
  };
1551
1557
  const renderReferenceNode = (element, eventMap, newEventMap) => {
1552
- const instance = get$a(element.uid);
1558
+ const instance = get$8(element.uid);
1553
1559
  if (!instance || !instance.state) {
1554
1560
  return document.createTextNode('Reference node not found');
1555
1561
  }
@@ -1695,7 +1701,7 @@ const handleNavigateSibling = (state, patch, $Element, patchIndex) => {
1695
1701
  return true;
1696
1702
  };
1697
1703
  const handleSetReferenceNodeUid = (state, patch) => {
1698
- const instance = get$a(patch.uid);
1704
+ const instance = get$8(patch.uid);
1699
1705
  if (!instance || !instance.state) {
1700
1706
  console.error('Cannot set reference node uid: instance not found', {
1701
1707
  uid: patch.uid
@@ -1896,7 +1902,7 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1896
1902
  return $Viewlet;
1897
1903
  };
1898
1904
 
1899
- const get$8 = ids => {
1905
+ const get$6 = ids => {
1900
1906
  return getFileHandles$1(ids);
1901
1907
  };
1902
1908
 
@@ -2122,7 +2128,7 @@ const getWorkerDisplayName$1 = name => {
2122
2128
  }
2123
2129
  return `${name} worker`;
2124
2130
  };
2125
- const create$K = async ({
2131
+ const create$I = async ({
2126
2132
  name,
2127
2133
  url
2128
2134
  }) => {
@@ -2190,7 +2196,7 @@ const wrap = worker => {
2190
2196
 
2191
2197
  const IpcParentWithModuleWorker$2 = {
2192
2198
  __proto__: null,
2193
- create: create$K,
2199
+ create: create$I,
2194
2200
  wrap
2195
2201
  };
2196
2202
 
@@ -2198,7 +2204,7 @@ const isMessagePort$1 = value => {
2198
2204
  return value instanceof MessagePort;
2199
2205
  };
2200
2206
 
2201
- const create$J = async ({
2207
+ const create$H = async ({
2202
2208
  url
2203
2209
  }) => {
2204
2210
  string(url);
@@ -2222,10 +2228,10 @@ const create$J = async ({
2222
2228
 
2223
2229
  const IpcParentWithMessagePort$2 = {
2224
2230
  __proto__: null,
2225
- create: create$J
2231
+ create: create$H
2226
2232
  };
2227
2233
 
2228
- const create$I = async url => {
2234
+ const create$G = async url => {
2229
2235
  const referencePort = await new Promise(resolve => {
2230
2236
  Object.defineProperty(globalThis, 'acceptReferencePort', {
2231
2237
  configurable: true,
@@ -2239,7 +2245,7 @@ const create$I = async url => {
2239
2245
 
2240
2246
  const IpcParentWithReferencePort = {
2241
2247
  __proto__: null,
2242
- create: create$I
2248
+ create: create$G
2243
2249
  };
2244
2250
 
2245
2251
  const normalizeLine = line => {
@@ -2823,7 +2829,7 @@ const execute = (command, ...args) => {
2823
2829
 
2824
2830
  const Two$1 = '2.0';
2825
2831
  const callbacks = Object.create(null);
2826
- const get$7 = id => {
2832
+ const get$5 = id => {
2827
2833
  return callbacks[id];
2828
2834
  };
2829
2835
  const remove$4 = id => {
@@ -3013,7 +3019,7 @@ const warn = (...args) => {
3013
3019
  console.warn(...args);
3014
3020
  };
3015
3021
  const resolve = (id, response) => {
3016
- const fn = get$7(id);
3022
+ const fn = get$5(id);
3017
3023
  if (!fn) {
3018
3024
  console.log(response);
3019
3025
  warn(`callback ${id} may already be disposed`);
@@ -3076,7 +3082,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
3076
3082
  const errorProperty = getErrorProperty(error, prettyError);
3077
3083
  return create$1$1(id, errorProperty);
3078
3084
  };
3079
- const create$H = (message, result) => {
3085
+ const create$F = (message, result) => {
3080
3086
  return {
3081
3087
  id: message.id,
3082
3088
  jsonrpc: Two$1,
@@ -3085,7 +3091,7 @@ const create$H = (message, result) => {
3085
3091
  };
3086
3092
  const getSuccessResponse = (message, result) => {
3087
3093
  const resultProperty = result ?? null;
3088
- return create$H(message, resultProperty);
3094
+ return create$F(message, resultProperty);
3089
3095
  };
3090
3096
  const getErrorResponseSimple = (id, error) => {
3091
3097
  return {
@@ -3179,7 +3185,7 @@ const handleJsonRpcMessage = async (...args) => {
3179
3185
 
3180
3186
  const Two = '2.0';
3181
3187
 
3182
- const create$G = (method, params) => {
3188
+ const create$E = (method, params) => {
3183
3189
  return {
3184
3190
  jsonrpc: Two,
3185
3191
  method,
@@ -3187,7 +3193,7 @@ const create$G = (method, params) => {
3187
3193
  };
3188
3194
  };
3189
3195
 
3190
- const create$F = (id, method, params) => {
3196
+ const create$D = (id, method, params) => {
3191
3197
  const message = {
3192
3198
  id,
3193
3199
  jsonrpc: Two,
@@ -3198,12 +3204,12 @@ const create$F = (id, method, params) => {
3198
3204
  };
3199
3205
 
3200
3206
  let id = 0;
3201
- const create$E = () => {
3207
+ const create$C = () => {
3202
3208
  return ++id;
3203
3209
  };
3204
3210
 
3205
3211
  const registerPromise = map => {
3206
- const id = create$E();
3212
+ const id = create$C();
3207
3213
  const {
3208
3214
  promise,
3209
3215
  resolve
@@ -3220,7 +3226,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
3220
3226
  id,
3221
3227
  promise
3222
3228
  } = registerPromise(callbacks);
3223
- const message = create$F(id, method, params);
3229
+ const message = create$D(id, method, params);
3224
3230
  if (useSendAndTransfer && ipc.sendAndTransfer) {
3225
3231
  ipc.sendAndTransfer(message);
3226
3232
  } else {
@@ -3256,7 +3262,7 @@ const createRpc = ipc => {
3256
3262
  * @deprecated
3257
3263
  */
3258
3264
  send(method, ...params) {
3259
- const message = create$G(method, params);
3265
+ const message = create$E(method, params);
3260
3266
  ipc.send(message);
3261
3267
  }
3262
3268
  };
@@ -3295,7 +3301,7 @@ const unhandleIpc = ipc => {
3295
3301
  }
3296
3302
  };
3297
3303
 
3298
- const create$D = async ({
3304
+ const create$B = async ({
3299
3305
  commandMap,
3300
3306
  window
3301
3307
  }) => {
@@ -3307,7 +3313,7 @@ const create$D = async ({
3307
3313
  return rpc;
3308
3314
  };
3309
3315
 
3310
- const create$C = async ({
3316
+ const create$A = async ({
3311
3317
  commandMap,
3312
3318
  isMessagePortOpen = true,
3313
3319
  messagePort
@@ -3329,7 +3335,7 @@ const isWorker = value => {
3329
3335
  return value instanceof Worker;
3330
3336
  };
3331
3337
 
3332
- const create$B = async ({
3338
+ const create$z = async ({
3333
3339
  commandMap,
3334
3340
  name,
3335
3341
  url
@@ -3349,7 +3355,7 @@ const create$B = async ({
3349
3355
  return workerRpc;
3350
3356
  };
3351
3357
 
3352
- const create$A = async ({
3358
+ const create$y = async ({
3353
3359
  commandMap,
3354
3360
  name,
3355
3361
  port,
@@ -3372,11 +3378,11 @@ const create$A = async ({
3372
3378
  return workerRpc;
3373
3379
  };
3374
3380
 
3375
- const create$z = async ({
3381
+ const create$x = async ({
3376
3382
  commandMap,
3377
3383
  messagePort
3378
3384
  }) => {
3379
- return create$C({
3385
+ return create$A({
3380
3386
  commandMap,
3381
3387
  messagePort
3382
3388
  });
@@ -3392,13 +3398,13 @@ const remove$3 = id => {
3392
3398
  return worker;
3393
3399
  };
3394
3400
 
3395
- const create$y = async ({
3401
+ const create$w = async ({
3396
3402
  id,
3397
3403
  name,
3398
3404
  port,
3399
3405
  raw,
3400
3406
  url
3401
- }, createRpc = create$A) => {
3407
+ }, createRpc = create$y) => {
3402
3408
  const rpc = await createRpc({
3403
3409
  commandMap: {},
3404
3410
  name,
@@ -3414,7 +3420,7 @@ const create$y = async ({
3414
3420
 
3415
3421
  const IpcParentWithModuleWorkerWithMessagePort = {
3416
3422
  __proto__: null,
3417
- create: create$y
3423
+ create: create$w
3418
3424
  };
3419
3425
 
3420
3426
  const Web = 1;
@@ -3447,7 +3453,7 @@ const platform = getPlatform();
3447
3453
  const isElectron = platform === Electron;
3448
3454
 
3449
3455
  // TODO use handleIncomingIpc function
3450
- const create$x = async ({
3456
+ const create$v = async ({
3451
3457
  ipcId,
3452
3458
  port
3453
3459
  }) => {
@@ -3455,7 +3461,7 @@ const create$x = async ({
3455
3461
  if (!isElectron) {
3456
3462
  throw new Error('Electron api was requested but is not available');
3457
3463
  }
3458
- const rpc = await create$D({
3464
+ const rpc = await create$B({
3459
3465
  commandMap: {},
3460
3466
  window
3461
3467
  });
@@ -3465,7 +3471,7 @@ const create$x = async ({
3465
3471
 
3466
3472
  const IpcParentWithElectron = {
3467
3473
  __proto__: null,
3468
- create: create$x
3474
+ create: create$v
3469
3475
  };
3470
3476
 
3471
3477
  const getModule = method => {
@@ -3489,7 +3495,7 @@ const ipcs = Object.create(null);
3489
3495
  const set$7 = (name, ipc) => {
3490
3496
  ipcs[name] = ipc;
3491
3497
  };
3492
- const get$6 = name => {
3498
+ const get$4 = name => {
3493
3499
  return ipcs[name];
3494
3500
  };
3495
3501
  const remove$2 = name => {
@@ -3522,7 +3528,7 @@ const launchWorker = async ({
3522
3528
  url
3523
3529
  }) => {
3524
3530
  try {
3525
- const rpc = await create$B({
3531
+ const rpc = await create$z({
3526
3532
  commandMap: commandMapRef,
3527
3533
  name,
3528
3534
  url
@@ -3704,7 +3710,7 @@ const hydrate$3 = async () => {
3704
3710
  };
3705
3711
 
3706
3712
  // TODO needed?
3707
- const dispose$k = () => {
3713
+ const dispose$j = () => {
3708
3714
  if (state$7.rpc) {
3709
3715
  state$7.rpc.dispose();
3710
3716
  }
@@ -3734,7 +3740,7 @@ const invokeAndTransfer = (method, ...params) => {
3734
3740
 
3735
3741
  const RendererWorker = {
3736
3742
  __proto__: null,
3737
- dispose: dispose$k,
3743
+ dispose: dispose$j,
3738
3744
  hydrate: hydrate$3,
3739
3745
  invoke: invoke$1,
3740
3746
  invokeAndTransfer,
@@ -3743,7 +3749,7 @@ const RendererWorker = {
3743
3749
  state: state$7
3744
3750
  };
3745
3751
 
3746
- const create$w = async ({
3752
+ const create$u = async ({
3747
3753
  method,
3748
3754
  ...options
3749
3755
  }) => {
@@ -3753,7 +3759,7 @@ const create$w = async ({
3753
3759
  }
3754
3760
  // TODO rename method
3755
3761
  // TODO avoid cyclic dependency
3756
- const port = get$6(options.name);
3762
+ const port = get$4(options.name);
3757
3763
  remove$2(options.name);
3758
3764
  await invokeAndTransfer('Transferrable.transfer', options.id, port);
3759
3765
  return;
@@ -3762,7 +3768,7 @@ const create$w = async ({
3762
3768
  // @ts-ignore
3763
3769
  return module.create(options);
3764
3770
  };
3765
- const dispose$j = id => {
3771
+ const dispose$i = id => {
3766
3772
  const worker = remove$3(id);
3767
3773
  worker?.terminate();
3768
3774
  };
@@ -3868,7 +3874,7 @@ const create$Notification = message => {
3868
3874
  $Notification.textContent = message;
3869
3875
  return $Notification;
3870
3876
  };
3871
- const create$v = (type, message) => {
3877
+ const create$t = (type, message) => {
3872
3878
  // TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
3873
3879
  const $Notification = create$Notification(message);
3874
3880
  append$1($Notification);
@@ -3913,24 +3919,18 @@ const createWithOptions = (type, message, options) => {
3913
3919
  const $Notification = create$NotificationWithOptions(message, options);
3914
3920
  append$1($Notification);
3915
3921
  };
3916
- const dispose$i = id => {
3922
+ const dispose$h = id => {
3917
3923
  // const $Notification = state.$Notifications
3918
3924
  };
3919
3925
 
3920
3926
  const state$5 = {
3921
3927
  canvasObjects: Object.create(null)
3922
3928
  };
3923
- const get$5 = id => {
3924
- return state$5.canvasObjects[id];
3925
- };
3926
3929
  const set$6 = (canvasId, canvas) => {
3927
3930
  state$5.canvasObjects[canvasId] = canvas;
3928
3931
  };
3929
3932
 
3930
- const get$4 = id => {
3931
- return get$5(id);
3932
- };
3933
- const create$u = async (canvasId, objectId) => {
3933
+ const create$s = async (canvasId, objectId) => {
3934
3934
  const canvas = document.createElement('canvas');
3935
3935
  const offscreenCanvas = canvas.transferControlToOffscreen();
3936
3936
  set$6(canvasId, canvas);
@@ -4050,7 +4050,7 @@ const getElement = () => {
4050
4050
  return state$4.$PreviousFocusElement;
4051
4051
  };
4052
4052
 
4053
- const focus$e = $Element => {
4053
+ const focus$d = $Element => {
4054
4054
  if ($Element === document.activeElement) {
4055
4055
  return;
4056
4056
  }
@@ -4149,7 +4149,7 @@ const getLevel = $Menu => {
4149
4149
  // @ts-expect-error
4150
4150
  return state$3.$$Menus.indexOf($Menu);
4151
4151
  };
4152
- const handleMouseDown$4 = event => {
4152
+ const handleMouseDown$2 = event => {
4153
4153
  const $Target = event.target;
4154
4154
  const $Menu = $Target.closest('.Menu');
4155
4155
  const index = findIndex($Menu, $Target);
@@ -4212,7 +4212,7 @@ const handleMouseLeave = event => {
4212
4212
  };
4213
4213
 
4214
4214
  // const handleBlur = (event) => {}
4215
- const handleKeyDown$5 = event => {
4215
+ const handleKeyDown$4 = event => {
4216
4216
  state$3.handleKeyDown(event);
4217
4217
  };
4218
4218
  const handleFocusOut$1 = event => {
@@ -4226,7 +4226,7 @@ const create$Menu$1 = () => {
4226
4226
  $Menu.tabIndex = -1;
4227
4227
  // $ContextMenu.onmousedown = contextMenuHandleMouseDown
4228
4228
  // TODO mousedown vs click? (click is usually better but mousedown is faster, why wait 100ms?)
4229
- $Menu.addEventListener(MouseDown, handleMouseDown$4);
4229
+ $Menu.addEventListener(MouseDown, handleMouseDown$2);
4230
4230
  $Menu.addEventListener(MouseEnter, handleMouseEnter, {
4231
4231
  capture: true
4232
4232
  });
@@ -4236,7 +4236,7 @@ const create$Menu$1 = () => {
4236
4236
  // $Menu.addEventListener('mousemove', handleMouseMove, {
4237
4237
  // passive: true,
4238
4238
  // })
4239
- $Menu.onkeydown = handleKeyDown$5;
4239
+ $Menu.onkeydown = handleKeyDown$4;
4240
4240
  $Menu.addEventListener(FocusOut, handleFocusOut$1);
4241
4241
  $Menu.oncontextmenu = handleContextMenu$7;
4242
4242
  // $ContextMenu.onfocus = handleFocus
@@ -4299,7 +4299,7 @@ const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom = [],
4299
4299
  state$3.$$Menus.push($Menu);
4300
4300
  append$1($Menu);
4301
4301
  if (level === 0) {
4302
- focus$e($Menu);
4302
+ focus$d($Menu);
4303
4303
  send('Focus.setFocus', FocusMenu);
4304
4304
  }
4305
4305
  };
@@ -4564,6 +4564,7 @@ const hover = (element, options) => {
4564
4564
  mouseEvent(element, MouseEnter, options);
4565
4565
  };
4566
4566
  const type = (element, options) => {
4567
+ element.focus();
4567
4568
  element.value = options.text;
4568
4569
  const event = new InputEvent('input', {
4569
4570
  bubbles: true,
@@ -4914,27 +4915,37 @@ const getKeyboardOptions = options => {
4914
4915
  const isXtermTextArea = element => {
4915
4916
  return element instanceof HTMLTextAreaElement && element.classList.contains('xterm-helper-textarea');
4916
4917
  };
4917
- const getPrintableKey = options => {
4918
- if (options.key === 'Space') {
4919
- return ' ';
4920
- }
4921
- if (options.key?.length === 1) {
4922
- return options.key;
4918
+ const getXtermInput = options => {
4919
+ switch (options.key) {
4920
+ case 'Backspace':
4921
+ return '\u{7F}';
4922
+ case 'Enter':
4923
+ return '\r';
4924
+ case 'Escape':
4925
+ return '\u{1B}';
4926
+ case 'Space':
4927
+ return ' ';
4928
+ case 'Tab':
4929
+ return '\t';
4930
+ default:
4931
+ if (options.key?.length === 1) {
4932
+ return options.key;
4933
+ }
4934
+ return '';
4923
4935
  }
4924
- return '';
4925
4936
  };
4926
4937
  const press = options => {
4927
4938
  const element = document.activeElement;
4928
4939
  if (!element) {
4929
4940
  return;
4930
4941
  }
4931
- const text = getPrintableKey(options);
4932
- if (isXtermTextArea(element) && text) {
4933
- element.value = text;
4942
+ const input = getXtermInput(options);
4943
+ if (isXtermTextArea(element) && input) {
4944
+ element.value = input;
4934
4945
  element.dispatchEvent(new InputEvent('input', {
4935
4946
  bubbles: true,
4936
4947
  cancelable: true,
4937
- data: text,
4948
+ data: input,
4938
4949
  inputType: 'insertText'
4939
4950
  }));
4940
4951
  element.value = '';
@@ -5266,7 +5277,7 @@ const showError = (message, y, x) => {
5266
5277
  $ImagePreviewImage
5267
5278
  };
5268
5279
  };
5269
- const create$t = (uri, top, left) => {
5280
+ const create$r = (uri, top, left) => {
5270
5281
  const $ImagePreviewImage = document.createElement('img');
5271
5282
  $ImagePreviewImage.className = 'ImagePreviewImage';
5272
5283
  $ImagePreviewImage.src = uri;
@@ -5291,14 +5302,14 @@ const create$t = (uri, top, left) => {
5291
5302
  const update = (state, uri) => {
5292
5303
  state.$ImagePreviewImage.uri = uri;
5293
5304
  };
5294
- const dispose$h = state => {
5305
+ const dispose$g = state => {
5295
5306
  remove$1(state.$ImagePreview);
5296
5307
  };
5297
5308
 
5298
5309
  const ImagePreview$1 = {
5299
5310
  __proto__: null,
5300
- create: create$t,
5301
- dispose: dispose$h,
5311
+ create: create$r,
5312
+ dispose: dispose$g,
5302
5313
  showError,
5303
5314
  update
5304
5315
  };
@@ -5314,7 +5325,7 @@ const getNodeIndex = $Node => {
5314
5325
  const get$ItemFromEvent = event => {
5315
5326
  return event.target.closest?.('.ActivityBarItem');
5316
5327
  };
5317
- const handleMouseDown$3 = event => {
5328
+ const handleMouseDown$1 = event => {
5318
5329
  const {
5319
5330
  button,
5320
5331
  clientX,
@@ -5329,7 +5340,7 @@ const handleMouseDown$3 = event => {
5329
5340
  const index = getNodeIndex($Item);
5330
5341
  return ['handleClickIndex', button, index, clientX, clientY];
5331
5342
  };
5332
- const handleBlur$8 = () => {
5343
+ const handleBlur$7 = () => {
5333
5344
  return ['handleBlur'];
5334
5345
  };
5335
5346
  const handleFocus$8 = () => {
@@ -5351,10 +5362,10 @@ const returnValue$8 = true;
5351
5362
 
5352
5363
  const ViewletActivityBarEvents = {
5353
5364
  __proto__: null,
5354
- handleBlur: handleBlur$8,
5365
+ handleBlur: handleBlur$7,
5355
5366
  handleContextMenu: handleContextMenu$6,
5356
5367
  handleFocus: handleFocus$8,
5357
- handleMouseDown: handleMouseDown$3,
5368
+ handleMouseDown: handleMouseDown$1,
5358
5369
  returnValue: returnValue$8
5359
5370
  };
5360
5371
 
@@ -5399,7 +5410,7 @@ forwardViewletCommand('focusPrevious');
5399
5410
  const handleAudioError$1 = forwardViewletCommand('handleAudioError');
5400
5411
  forwardViewletCommand('handleBeforeInput');
5401
5412
  forwardViewletCommand('handleBeforeInputFromContentEditable');
5402
- const handleBlur$7 = forwardViewletCommand('handleBlur');
5413
+ const handleBlur$6 = forwardViewletCommand('handleBlur');
5403
5414
  const handleButtonClick = forwardViewletCommand('handleButtonClick');
5404
5415
  const handleClick$6 = forwardViewletCommand('handleClick');
5405
5416
  const handleClickAction$2 = forwardViewletCommand('handleClickAction');
@@ -5432,12 +5443,12 @@ const handleFocusIn$4 = forwardViewletCommand('handleFocusIn');
5432
5443
  forwardViewletCommand('handleIconError');
5433
5444
  const handleImageError = forwardViewletCommand('handleImageError');
5434
5445
  const handleInput$6 = forwardViewletCommand('handleInput');
5435
- const handleKeyDown$4 = forwardViewletCommand('handleKeyDown');
5446
+ const handleKeyDown$3 = forwardViewletCommand('handleKeyDown');
5436
5447
  forwardViewletCommand('handleListBlur');
5437
5448
  forwardViewletCommand('handleListFocus');
5438
5449
  const handleMenuClick$1 = forwardViewletCommand('handleMenuClick');
5439
5450
  const handleMenuMouseOver$1 = forwardViewletCommand('handleMenuMouseOver');
5440
- const handleMouseDown$2 = forwardViewletCommand('handleMouseDown');
5451
+ forwardViewletCommand('handleMouseDown');
5441
5452
  forwardViewletCommand('handleMouseMove');
5442
5453
  const handleMouseOut$1 = forwardViewletCommand('handleMouseOut');
5443
5454
  const handleMouseOver$1 = forwardViewletCommand('handleMouseOver');
@@ -5516,15 +5527,15 @@ const ViewletAudio = {
5516
5527
  Events: Events$4
5517
5528
  };
5518
5529
 
5519
- const create$s = () => {
5530
+ const create$q = () => {
5520
5531
  const $Viewlet = document.createElement('div');
5521
5532
  $Viewlet.className = 'Viewlet Clock';
5522
5533
  return {
5523
5534
  $Viewlet
5524
5535
  };
5525
5536
  };
5526
- const dispose$g = state => {};
5527
- const refresh$4 = () => {};
5537
+ const dispose$f = state => {};
5538
+ const refresh$3 = () => {};
5528
5539
  const setTime = (state, time) => {
5529
5540
  object(state);
5530
5541
  string(time);
@@ -5533,9 +5544,9 @@ const setTime = (state, time) => {
5533
5544
 
5534
5545
  const ViewletClock = {
5535
5546
  __proto__: null,
5536
- create: create$s,
5537
- dispose: dispose$g,
5538
- refresh: refresh$4,
5547
+ create: create$q,
5548
+ dispose: dispose$f,
5549
+ refresh: refresh$3,
5539
5550
  setTime
5540
5551
  };
5541
5552
 
@@ -5562,7 +5573,7 @@ const stopTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp)
5562
5573
  // TODO use pointerlost event instead
5563
5574
  $Target.removeEventListener(PointerUp, handlePointerUp);
5564
5575
  };
5565
- const create$r = (pointerDown, pointerMove, pointerUp) => {
5576
+ const create$p = (pointerDown, pointerMove, pointerUp) => {
5566
5577
  const shared = (fn, event) => {
5567
5578
  const message = fn(event);
5568
5579
  if (!message || message.length === 0) {
@@ -5595,7 +5606,7 @@ const create$r = (pointerDown, pointerMove, pointerUp) => {
5595
5606
  };
5596
5607
 
5597
5608
  const handleOffset = 20;
5598
- const handleSliderPointerDown = create$r(event => {
5609
+ const handleSliderPointerDown = create$p(event => {
5599
5610
  const {
5600
5611
  clientX,
5601
5612
  clientY
@@ -5677,7 +5688,7 @@ const ViewletDebugConsoleEvents = {
5677
5688
  handleInput: handleInput$5
5678
5689
  };
5679
5690
 
5680
- const create$q = () => {
5691
+ const create$o = () => {
5681
5692
  const $Viewlet = document.createElement('div');
5682
5693
  $Viewlet.className = 'Viewlet DebugConsole';
5683
5694
  return {
@@ -5693,11 +5704,11 @@ const setDom$9 = (state, dom) => {
5693
5704
 
5694
5705
  const ViewletDebugConsole = {
5695
5706
  __proto__: null,
5696
- create: create$q,
5707
+ create: create$o,
5697
5708
  setDom: setDom$9
5698
5709
  };
5699
5710
 
5700
- const handleKeyDown$3 = event => {
5711
+ const handleKeyDown$2 = event => {
5701
5712
  preventDefault(event);
5702
5713
  stopPropagation(event);
5703
5714
  const uid = fromEvent(event);
@@ -5708,17 +5719,17 @@ const handleKeyDown$3 = event => {
5708
5719
  metaKey,
5709
5720
  shiftKey
5710
5721
  } = event;
5711
- handleKeyDown$4(uid, key, altKey, ctrlKey, shiftKey, metaKey);
5722
+ handleKeyDown$3(uid, key, altKey, ctrlKey, shiftKey, metaKey);
5712
5723
  };
5713
- const handleBlur$6 = event => {
5724
+ const handleBlur$5 = event => {
5714
5725
  const uid = fromEvent(event);
5715
- handleBlur$7(uid);
5726
+ handleBlur$6(uid);
5716
5727
  };
5717
5728
 
5718
5729
  const ViewletDefineKeyBindingEvents = {
5719
5730
  __proto__: null,
5720
- handleBlur: handleBlur$6,
5721
- handleKeyDown: handleKeyDown$3
5731
+ handleBlur: handleBlur$5,
5732
+ handleKeyDown: handleKeyDown$2
5722
5733
  };
5723
5734
 
5724
5735
  const setValue$2 = (state, value) => {
@@ -5730,7 +5741,7 @@ const setValue$2 = (state, value) => {
5730
5741
  const $Input = $Viewlet.querySelector(':scope input');
5731
5742
  $Input.value = value;
5732
5743
  };
5733
- const focus$d = state => {
5744
+ const focus$c = state => {
5734
5745
  const {
5735
5746
  $Viewlet
5736
5747
  } = state;
@@ -5741,7 +5752,7 @@ const focus$d = state => {
5741
5752
  const ViewletDefineKeyBinding = {
5742
5753
  __proto__: null,
5743
5754
  Events: ViewletDefineKeyBindingEvents,
5744
- focus: focus$d,
5755
+ focus: focus$c,
5745
5756
  setValue: setValue$2
5746
5757
  };
5747
5758
 
@@ -5754,7 +5765,7 @@ const setMaskImage = ($Element, icon) => {
5754
5765
  }
5755
5766
  };
5756
5767
 
5757
- const create$p = icon => {
5768
+ const create$n = icon => {
5758
5769
  const $Icon = document.createElement('div');
5759
5770
  $Icon.className = 'MaskIcon';
5760
5771
  setMaskImage($Icon, icon);
@@ -5764,7 +5775,7 @@ const create$p = icon => {
5764
5775
 
5765
5776
  const create$Button = (label, icon) => {
5766
5777
  // TODO icon div might not be needed (unnecessary HTML element)
5767
- const $Icon = create$p(icon);
5778
+ const $Icon = create$n(icon);
5768
5779
  const $Button = document.createElement('button');
5769
5780
  $Button.className = 'IconButton';
5770
5781
  $Button.title = label;
@@ -5785,7 +5796,7 @@ const handleClick$4 = event => {
5785
5796
  handleClick$5(index);
5786
5797
  };
5787
5798
 
5788
- const create$o = () => {
5799
+ const create$m = () => {
5789
5800
  const $DialogTitle = document.createElement('h2');
5790
5801
  $DialogTitle.id = 'DialogTitle';
5791
5802
  const $DialogCloseButton = create$Button('Close', 'Close');
@@ -5866,7 +5877,7 @@ const setErrorStack = (state, errorStack) => {
5866
5877
 
5867
5878
  const ViewletDialog = {
5868
5879
  __proto__: null,
5869
- create: create$o,
5880
+ create: create$m,
5870
5881
  postAppend,
5871
5882
  setButtons,
5872
5883
  setCodeFrame,
@@ -5929,7 +5940,7 @@ const handleContextMenu$4 = event => {
5929
5940
  } = event;
5930
5941
  return ['handleContextMenu', button, clientX, clientY];
5931
5942
  };
5932
- const handleSashCornerPointerDown = create$r(event => {
5943
+ const handleSashCornerPointerDown = create$p(event => {
5933
5944
  const {
5934
5945
  clientX,
5935
5946
  clientY
@@ -6103,15 +6114,15 @@ const handleFocusIn$3 = event => {
6103
6114
  const uid = fromEvent(event);
6104
6115
  handleFocusIn$4(uid);
6105
6116
  };
6106
- const handleBlur$5 = event => {
6117
+ const handleBlur$4 = event => {
6107
6118
  preventDefault(event);
6108
6119
  const uid = fromEvent(event);
6109
- handleBlur$7(uid);
6120
+ handleBlur$6(uid);
6110
6121
  };
6111
6122
 
6112
6123
  const ViewletEditorCodeGeneratorEvents = {
6113
6124
  __proto__: null,
6114
- handleBlur: handleBlur$5,
6125
+ handleBlur: handleBlur$4,
6115
6126
  handleFocusIn: handleFocusIn$3
6116
6127
  };
6117
6128
 
@@ -6128,10 +6139,10 @@ const appendWidget$5 = state => {
6128
6139
  } = state;
6129
6140
  append$1($Viewlet);
6130
6141
  };
6131
- const dispose$f = state => {
6142
+ const dispose$e = state => {
6132
6143
  remove$1(state.$Viewlet);
6133
6144
  };
6134
- const focus$c = (state, key, source) => {
6145
+ const focus$b = (state, key, source) => {
6135
6146
  if (!key) {
6136
6147
  return;
6137
6148
  }
@@ -6154,8 +6165,8 @@ const ViewletEditorCodeGenerator = {
6154
6165
  __proto__: null,
6155
6166
  Events: ViewletEditorCodeGeneratorEvents,
6156
6167
  appendWidget: appendWidget$5,
6157
- dispose: dispose$f,
6158
- focus: focus$c,
6168
+ dispose: dispose$e,
6169
+ focus: focus$b,
6159
6170
  setBounds: setBounds$9
6160
6171
  };
6161
6172
 
@@ -6272,7 +6283,7 @@ const setNegativeMargin = (state, negativeMargin) => {
6272
6283
  setTop($ListItems, negativeMargin);
6273
6284
  };
6274
6285
 
6275
- const create$n = () => {
6286
+ const create$l = () => {
6276
6287
  const $ListItems = document.createElement('div');
6277
6288
  $ListItems.className = 'ListItems';
6278
6289
  $ListItems.role = ListBox;
@@ -6325,7 +6336,7 @@ const setDom$8 = (state, dom) => {
6325
6336
  // TODO recycle nodes
6326
6337
  // TODO set right aria attributes on $EditorInput
6327
6338
  };
6328
- const dispose$e = state => {
6339
+ const dispose$d = state => {
6329
6340
  remove$1(state.$Viewlet);
6330
6341
  // state.$EditorInput.removeAttribute('aria-activedescendant')
6331
6342
  };
@@ -6356,8 +6367,8 @@ const setBounds$8 = (state, x, y, width, height) => {
6356
6367
  const ViewletEditorCompletion = {
6357
6368
  __proto__: null,
6358
6369
  attachEvents: attachEvents$6,
6359
- create: create$n,
6360
- dispose: dispose$e,
6370
+ create: create$l,
6371
+ dispose: dispose$d,
6361
6372
  handleError: handleError$5,
6362
6373
  setBounds: setBounds$8,
6363
6374
  setContentHeight,
@@ -6379,7 +6390,7 @@ const ViewletEditorCompletionDetailsEvents = {
6379
6390
  returnValue: returnValue$4
6380
6391
  };
6381
6392
 
6382
- const create$m = () => {
6393
+ const create$k = () => {
6383
6394
  const $Viewlet = document.createElement('div');
6384
6395
  $Viewlet.className = 'Viewlet EditorCompletionDetails';
6385
6396
  $Viewlet.id = 'CompletionsDetails';
@@ -6405,7 +6416,7 @@ const appendWidget$4 = state => {
6405
6416
  } = state;
6406
6417
  append$1($Viewlet);
6407
6418
  };
6408
- const dispose$d = state => {
6419
+ const dispose$c = state => {
6409
6420
  remove$1(state.$Viewlet);
6410
6421
  };
6411
6422
  const setBounds$7 = (state, x, y, width, height) => {
@@ -6420,8 +6431,8 @@ const ViewletEditorCompletionDetails = {
6420
6431
  Events: ViewletEditorCompletionDetailsEvents,
6421
6432
  appendWidget: appendWidget$4,
6422
6433
  attachEvents: attachEvents$5,
6423
- create: create$m,
6424
- dispose: dispose$d,
6434
+ create: create$k,
6435
+ dispose: dispose$c,
6425
6436
  setBounds: setBounds$7,
6426
6437
  setDom: setDom$7
6427
6438
  };
@@ -6439,7 +6450,7 @@ const ViewletEditorCompletionDetails = {
6439
6450
 
6440
6451
  // TODO aria alert
6441
6452
 
6442
- const create$l = () => {
6453
+ const create$j = () => {
6443
6454
  const $Viewlet = document.createElement('div');
6444
6455
  $Viewlet.className = 'Viewlet EditorError';
6445
6456
  return {
@@ -6461,13 +6472,13 @@ const setBounds$6 = (state, x, y, width, height) => {
6461
6472
 
6462
6473
  const ViewletEditorError = {
6463
6474
  __proto__: null,
6464
- create: create$l,
6475
+ create: create$j,
6465
6476
  setBounds: setBounds$6,
6466
6477
  setDom: setDom$6
6467
6478
  };
6468
6479
 
6469
6480
  const returnValue$3 = true;
6470
- const handleSashPointerDown$2 = create$r(event => {
6481
+ const handleSashPointerDown$2 = create$p(event => {
6471
6482
  const {
6472
6483
  clientX,
6473
6484
  clientY
@@ -6619,7 +6630,7 @@ const handleFocus$5 = event => {
6619
6630
  handleFocus$7(uid);
6620
6631
  };
6621
6632
 
6622
- const create$k = () => {
6633
+ const create$i = () => {
6623
6634
  const $Viewlet = document.createElement('div');
6624
6635
  $Viewlet.className = 'Viewlet EditorImage';
6625
6636
  return {
@@ -6662,13 +6673,13 @@ const setDom$4 = (state, dom) => {
6662
6673
  const ViewletEditorImage = {
6663
6674
  __proto__: null,
6664
6675
  attachEvents: attachEvents$4,
6665
- create: create$k,
6676
+ create: create$i,
6666
6677
  setDom: setDom$4,
6667
6678
  setDragging,
6668
6679
  setTransform
6669
6680
  };
6670
6681
 
6671
- const create$j = () => {
6682
+ const create$h = () => {
6672
6683
  const $Viewlet = document.createElement('div');
6673
6684
  $Viewlet.className = 'Viewlet EditorText';
6674
6685
  $Viewlet.textContent = 'loading...';
@@ -6676,8 +6687,8 @@ const create$j = () => {
6676
6687
  $Viewlet
6677
6688
  };
6678
6689
  };
6679
- const dispose$c = state => {};
6680
- const refresh$3 = (state, context) => {
6690
+ const dispose$b = state => {};
6691
+ const refresh$2 = (state, context) => {
6681
6692
  object(state);
6682
6693
  string(context.content);
6683
6694
  state.$Viewlet.textContent = context.content;
@@ -6685,9 +6696,9 @@ const refresh$3 = (state, context) => {
6685
6696
 
6686
6697
  const ViewletEditorPlainText = {
6687
6698
  __proto__: null,
6688
- create: create$j,
6689
- dispose: dispose$c,
6690
- refresh: refresh$3
6699
+ create: create$h,
6700
+ dispose: dispose$b,
6701
+ refresh: refresh$2
6691
6702
  };
6692
6703
 
6693
6704
  const handleFocusIn$2 = event => {
@@ -6714,7 +6725,7 @@ const appendWidget$2 = state => {
6714
6725
  } = state;
6715
6726
  append$1($Viewlet);
6716
6727
  };
6717
- const dispose$b = state => {
6728
+ const dispose$a = state => {
6718
6729
  remove$1(state.$Viewlet);
6719
6730
  };
6720
6731
 
@@ -6722,11 +6733,11 @@ const ViewletEditorSourceActions = {
6722
6733
  __proto__: null,
6723
6734
  Events: ViewletEditorSourceActionsEvents,
6724
6735
  appendWidget: appendWidget$2,
6725
- dispose: dispose$b,
6736
+ dispose: dispose$a,
6726
6737
  setBounds: setBounds$4
6727
6738
  };
6728
6739
 
6729
- const create$i = () => {
6740
+ const create$g = () => {
6730
6741
  const $Viewlet = document.createElement('div');
6731
6742
  $Viewlet.className = 'Viewlet EditorTextError';
6732
6743
  return {
@@ -6742,11 +6753,11 @@ const setMessage$3 = (state, message) => {
6742
6753
 
6743
6754
  const ViewletEditorTextError = {
6744
6755
  __proto__: null,
6745
- create: create$i,
6756
+ create: create$g,
6746
6757
  setMessage: setMessage$3
6747
6758
  };
6748
6759
 
6749
- const create$h = () => {
6760
+ const create$f = () => {
6750
6761
  const $Viewlet = document.createElement('div');
6751
6762
  $Viewlet.className = 'Viewlet EditorWidgetError EditorOverlayMessage';
6752
6763
  return {
@@ -6769,12 +6780,12 @@ const setBounds$3 = (state, x, y, width, height) => {
6769
6780
 
6770
6781
  const ViewletEditorWidgetError = {
6771
6782
  __proto__: null,
6772
- create: create$h,
6783
+ create: create$f,
6773
6784
  setBounds: setBounds$3,
6774
6785
  setMessage: setMessage$2
6775
6786
  };
6776
6787
 
6777
- const create$g = () => {
6788
+ const create$e = () => {
6778
6789
  const $Viewlet = document.createElement('div');
6779
6790
  $Viewlet.dataset.viewlet = 'Empty';
6780
6791
  $Viewlet.className = 'Viewlet';
@@ -6782,19 +6793,19 @@ const create$g = () => {
6782
6793
  $Viewlet
6783
6794
  };
6784
6795
  };
6785
- const refresh$2 = (state, context) => {};
6786
- const focus$b = state => {};
6787
- const dispose$a = state => {};
6796
+ const refresh$1 = (state, context) => {};
6797
+ const focus$a = state => {};
6798
+ const dispose$9 = state => {};
6788
6799
 
6789
6800
  const ViewletEmpty = {
6790
6801
  __proto__: null,
6791
- create: create$g,
6792
- dispose: dispose$a,
6793
- focus: focus$b,
6794
- refresh: refresh$2
6802
+ create: create$e,
6803
+ dispose: dispose$9,
6804
+ focus: focus$a,
6805
+ refresh: refresh$1
6795
6806
  };
6796
6807
 
6797
- const create$f = () => {
6808
+ const create$d = () => {
6798
6809
  const $Viewlet = document.createElement('div');
6799
6810
  $Viewlet.className = 'Viewlet EmptyEditor';
6800
6811
  return {
@@ -6804,10 +6815,10 @@ const create$f = () => {
6804
6815
 
6805
6816
  const ViewletEmptyEditor = {
6806
6817
  __proto__: null,
6807
- create: create$f
6818
+ create: create$d
6808
6819
  };
6809
6820
 
6810
- const create$e = () => {
6821
+ const create$c = () => {
6811
6822
  const $Viewlet = document.createElement('div');
6812
6823
  $Viewlet.className = 'Viewlet Error';
6813
6824
  return {
@@ -6823,7 +6834,7 @@ const setMessage$1 = (state, message) => {
6823
6834
 
6824
6835
  const ViewletError = {
6825
6836
  __proto__: null,
6826
- create: create$e,
6837
+ create: create$c,
6827
6838
  setMessage: setMessage$1
6828
6839
  };
6829
6840
 
@@ -6976,7 +6987,7 @@ const ViewletFindWidgetEvents = {
6976
6987
  returnValue: returnValue$2
6977
6988
  };
6978
6989
 
6979
- const create$d = () => {
6990
+ const create$b = () => {
6980
6991
  const $Viewlet = document.createElement('div');
6981
6992
  $Viewlet.className = 'Viewlet FindWidget';
6982
6993
  $Viewlet.role = Group;
@@ -6984,7 +6995,7 @@ const create$d = () => {
6984
6995
  $Viewlet
6985
6996
  };
6986
6997
  };
6987
- const focus$a = (state, key, source) => {
6998
+ const focus$9 = (state, key, source) => {
6988
6999
  if (!key) {
6989
7000
  return;
6990
7001
  }
@@ -7030,7 +7041,7 @@ const setBounds$2 = (state, x, y, width, height) => {
7030
7041
  } = state;
7031
7042
  setBounds$a($Viewlet, x, y, width, height);
7032
7043
  };
7033
- const dispose$9 = state => {
7044
+ const dispose$8 = state => {
7034
7045
  remove$1(state.$Viewlet);
7035
7046
  };
7036
7047
  const Events$3 = ViewletFindWidgetEvents;
@@ -7039,9 +7050,9 @@ const ViewletFindWidget = {
7039
7050
  __proto__: null,
7040
7051
  Events: Events$3,
7041
7052
  appendWidget: appendWidget$1,
7042
- create: create$d,
7043
- dispose: dispose$9,
7044
- focus: focus$a,
7053
+ create: create$b,
7054
+ dispose: dispose$8,
7055
+ focus: focus$9,
7045
7056
  setBounds: setBounds$2,
7046
7057
  setDom: setDom$3,
7047
7058
  setValue: setValue$1
@@ -7088,7 +7099,7 @@ const handleError$3 = (state, message) => {
7088
7099
  } = state;
7089
7100
  $Message.textContent = message;
7090
7101
  };
7091
- const focus$9 = state => {
7102
+ const focus$8 = state => {
7092
7103
  const {
7093
7104
  $Locations
7094
7105
  } = state;
@@ -7100,7 +7111,7 @@ const focus$9 = state => {
7100
7111
  const ViewletImplementations = {
7101
7112
  __proto__: null,
7102
7113
  Events: ViewletLocationsEvents,
7103
- focus: focus$9,
7114
+ focus: focus$8,
7104
7115
  handleError: handleError$3,
7105
7116
  setFocusedIndex: setFocusedIndex$1
7106
7117
  };
@@ -7248,7 +7259,7 @@ const isMatchingKeyBinding = (identifiers, identifier) => {
7248
7259
  const handleMatchingKeyBinding = identifier => {
7249
7260
  send(/* KeyBindings.handleKeyBinding */'KeyBindings.handleKeyBinding', /* keyBinding */identifier);
7250
7261
  };
7251
- const handleKeyDown$2 = event => {
7262
+ const handleKeyDown$1 = event => {
7252
7263
  const identifier = getKeyBindingIdentifier(event);
7253
7264
  const identifiers = getIdentifiers();
7254
7265
  const matchingKeyBinding = isMatchingKeyBinding(identifiers, identifier);
@@ -7280,7 +7291,7 @@ const handleResize$1 = (width, height) => {
7280
7291
  const handleFocus$3 = () => {
7281
7292
  send('Layout.handleFocus');
7282
7293
  };
7283
- const handleBlur$4 = () => {
7294
+ const handleBlur$3 = () => {
7284
7295
  send('Layout.handleBlur');
7285
7296
  };
7286
7297
 
@@ -7326,13 +7337,13 @@ const handleResize = () => {
7326
7337
  const handleFocus$2 = () => {
7327
7338
  handleFocus$3();
7328
7339
  };
7329
- const handleBlur$3 = () => {
7330
- handleBlur$4();
7340
+ const handleBlur$2 = () => {
7341
+ handleBlur$3();
7331
7342
  };
7332
- const handleKeyDown$1 = handleKeyDown$2;
7343
+ const handleKeyDown = handleKeyDown$1;
7333
7344
  const handleKeyUp = handleKeyUp$1;
7334
7345
 
7335
- const create$c = () => {
7346
+ const create$a = () => {
7336
7347
  // TODO use aria role splitter once supported https://github.com/w3c/aria/issues/1348
7337
7348
  const $SashSidebar = document.createElement('div');
7338
7349
  $SashSidebar.className = 'Viewlet Sash SashVertical';
@@ -7367,9 +7378,9 @@ const attachEvents$3 = state => {
7367
7378
  [PointerDown]: handleSashPointerDown
7368
7379
  });
7369
7380
  attachEvents$7(window, {
7370
- [Blur]: handleBlur$3,
7381
+ [Blur]: handleBlur$2,
7371
7382
  [Focus]: handleFocus$2,
7372
- [KeyDown]: handleKeyDown$1,
7383
+ [KeyDown]: handleKeyDown,
7373
7384
  [KeyUp]: handleKeyUp,
7374
7385
  [Resize]: handleResize
7375
7386
  });
@@ -7388,7 +7399,7 @@ const setSashes = (state, sashSidebar, sashPanel) => {
7388
7399
  const ViewletLayout = {
7389
7400
  __proto__: null,
7390
7401
  attachEvents: attachEvents$3,
7391
- create: create$c,
7402
+ create: create$a,
7392
7403
  setSashes
7393
7404
  };
7394
7405
 
@@ -7426,7 +7437,6 @@ const SimpleBrowser = 'SimpleBrowser';
7426
7437
  const SourceControl = 'Source Control';
7427
7438
  const StatusBar$1 = 'StatusBar';
7428
7439
  const Storage = 'Storage';
7429
- const Terminal = 'Terminal';
7430
7440
  const Terminal2 = 'Terminal2';
7431
7441
  const Terminals = 'Terminals';
7432
7442
  const TitleBar = 'TitleBar';
@@ -7444,7 +7454,7 @@ const EditorTextError = 'EditorTextError';
7444
7454
  const EditorRename = 'EditorRename';
7445
7455
  const EditorCodeGenerator = 'EditorCodeGenerator';
7446
7456
 
7447
- const create$b = () => {
7457
+ const create$9 = () => {
7448
7458
  const $ViewletOutputContent = document.createElement('div');
7449
7459
  $ViewletOutputContent.className = 'OutputContent';
7450
7460
  $ViewletOutputContent.role = Log;
@@ -7476,9 +7486,9 @@ const handleError$2 = (state, error) => {
7476
7486
  string(error);
7477
7487
  state.content.textContent = error;
7478
7488
  };
7479
- const focus$8 = state => {
7489
+ const focus$7 = state => {
7480
7490
  object(state);
7481
- focus$e(state.$ViewletOutputContent);
7491
+ focus$d(state.$ViewletOutputContent);
7482
7492
  send('Focus.setFocus', FocusOutput);
7483
7493
  };
7484
7494
 
@@ -7491,15 +7501,15 @@ const disposeFindWidget = state => {
7491
7501
  return;
7492
7502
  }
7493
7503
  };
7494
- const dispose$8 = state => {};
7504
+ const dispose$7 = state => {};
7495
7505
 
7496
7506
  const ViewletOutput = {
7497
7507
  __proto__: null,
7498
7508
  clear: clear$1,
7499
- create: create$b,
7500
- dispose: dispose$8,
7509
+ create: create$9,
7510
+ dispose: dispose$7,
7501
7511
  disposeFindWidget,
7502
- focus: focus$8,
7512
+ focus: focus$7,
7503
7513
  handleError: handleError$2,
7504
7514
  openFindWidget,
7505
7515
  setText
@@ -7551,7 +7561,7 @@ const UiStrings = {
7551
7561
  Close: 'Close',
7552
7562
  Maximize: 'Maximize'
7553
7563
  };
7554
- const create$a = () => {
7564
+ const create$8 = () => {
7555
7565
  const $PanelTabs = document.createElement('div');
7556
7566
  $PanelTabs.className = 'PanelTabs';
7557
7567
  $PanelTabs.role = TabList;
@@ -7613,14 +7623,14 @@ const setTabsDom$1 = (state, dom) => {
7613
7623
  };
7614
7624
 
7615
7625
  // TODO add test for focus method
7616
- const focus$7 = state => {
7626
+ const focus$6 = state => {
7617
7627
  object(state);
7618
7628
  if (!state.currentViewlet) {
7619
7629
  return;
7620
7630
  }
7621
7631
  state.currentViewlet.factory.focus(state.currentViewlet.state);
7622
7632
  };
7623
- const dispose$7 = state => {
7633
+ const dispose$6 = state => {
7624
7634
  if (state.$PanelContent) {
7625
7635
  state.$PanelContent.remove();
7626
7636
  state.$PanelContent = undefined;
@@ -7652,7 +7662,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
7652
7662
  const {
7653
7663
  $PanelActions
7654
7664
  } = state;
7655
- const instance = get$a(childUid);
7665
+ const instance = get$8(childUid);
7656
7666
  if (!instance) {
7657
7667
  throw new Error(`child instance not found`);
7658
7668
  }
@@ -7665,9 +7675,9 @@ const setActionsDom$1 = (state, actions, childUid) => {
7665
7675
  const ViewletPanel = {
7666
7676
  __proto__: null,
7667
7677
  attachEvents: attachEvents$2,
7668
- create: create$a,
7669
- dispose: dispose$7,
7670
- focus: focus$7,
7678
+ create: create$8,
7679
+ dispose: dispose$6,
7680
+ focus: focus$6,
7671
7681
  setActionsDom: setActionsDom$1,
7672
7682
  setSelectedIndex,
7673
7683
  setTabsDom: setTabsDom$1
@@ -7676,7 +7686,7 @@ const ViewletPanel = {
7676
7686
  const ViewletReferences = {
7677
7687
  __proto__: null,
7678
7688
  Events: ViewletLocationsEvents,
7679
- focus: focus$9,
7689
+ focus: focus$8,
7680
7690
  handleError: handleError$3,
7681
7691
  setFocusedIndex: setFocusedIndex$1
7682
7692
  };
@@ -7693,7 +7703,7 @@ const handleLoadedMetadata = event => {
7693
7703
  target.play();
7694
7704
  };
7695
7705
 
7696
- const create$9 = () => {
7706
+ const create$7 = () => {
7697
7707
  const $Viewlet = document.createElement('div');
7698
7708
  $Viewlet.className = 'Viewlet ScreenCapture';
7699
7709
  return {
@@ -7713,7 +7723,7 @@ const setScreenCapture = (state, id) => {
7713
7723
 
7714
7724
  const ViewletScreenCapture = {
7715
7725
  __proto__: null,
7716
- create: create$9,
7726
+ create: create$7,
7717
7727
  setScreenCapture
7718
7728
  };
7719
7729
 
@@ -7737,7 +7747,7 @@ const handleHeaderClick = event => {
7737
7747
  }
7738
7748
  };
7739
7749
 
7740
- const create$8 = () => {
7750
+ const create$6 = () => {
7741
7751
  const $SidebarTitleAreaTitle = document.createElement('h2');
7742
7752
  $SidebarTitleAreaTitle.className = 'SideBarTitleAreaTitle';
7743
7753
  const $SidebarTitleArea = document.createElement('div');
@@ -7766,7 +7776,7 @@ const attachEvents$1 = state => {
7766
7776
  [Click]: handleHeaderClick
7767
7777
  });
7768
7778
  };
7769
- const dispose$6 = state => {
7779
+ const dispose$5 = state => {
7770
7780
  object(state);
7771
7781
  state.$Sidebar.replaceChildren();
7772
7782
  };
@@ -7794,16 +7804,16 @@ const setActionsDom = (state, actions, parentId, eventMap = {}) => {
7794
7804
  }
7795
7805
  state.$Actions = $NewViewlet;
7796
7806
  };
7797
- const focus$6 = async () => {
7807
+ const focus$5 = async () => {
7798
7808
  // await
7799
7809
  };
7800
7810
 
7801
7811
  const ViewletSidebar = {
7802
7812
  __proto__: null,
7803
7813
  attachEvents: attachEvents$1,
7804
- create: create$8,
7805
- dispose: dispose$6,
7806
- focus: focus$6,
7814
+ create: create$6,
7815
+ dispose: dispose$5,
7816
+ focus: focus$5,
7807
7817
  setActionsDom,
7808
7818
  setTitle
7809
7819
  };
@@ -7845,7 +7855,7 @@ const handleFocus$1 = event => {
7845
7855
  target.select();
7846
7856
  });
7847
7857
  };
7848
- const handleBlur$2 = event => {
7858
+ const handleBlur$1 = event => {
7849
7859
  const {
7850
7860
  target
7851
7861
  } = event;
@@ -7875,7 +7885,7 @@ const handleClickOpenExternal = () => {
7875
7885
 
7876
7886
  const ViewletSimpleBrowserEvents = {
7877
7887
  __proto__: null,
7878
- handleBlur: handleBlur$2,
7888
+ handleBlur: handleBlur$1,
7879
7889
  handleClickBackward,
7880
7890
  handleClickForward,
7881
7891
  handleClickOpenExternal,
@@ -7984,7 +7994,7 @@ const ViewletSourceControlEvents = {
7984
7994
  handleWheel: handleWheel$2
7985
7995
  };
7986
7996
 
7987
- const focus$5 = state => {
7997
+ const focus$4 = state => {
7988
7998
  const {
7989
7999
  $Viewlet
7990
8000
  } = state;
@@ -7994,7 +8004,7 @@ const focus$5 = state => {
7994
8004
  const ViewletSourceControl = {
7995
8005
  __proto__: null,
7996
8006
  Events: ViewletSourceControlEvents,
7997
- focus: focus$5
8007
+ focus: focus$4
7998
8008
  };
7999
8009
 
8000
8010
  const handleClick$2 = event => {
@@ -8011,7 +8021,7 @@ const ViewletStatusBarEvents = {
8011
8021
  handleClick: handleClick$2
8012
8022
  };
8013
8023
 
8014
- const create$7 = () => {
8024
+ const create$5 = () => {
8015
8025
  const $Viewlet = document.createElement('div');
8016
8026
  $Viewlet.id = 'StatusBar';
8017
8027
  $Viewlet.className = 'Viewlet StatusBar';
@@ -8030,7 +8040,7 @@ const setDom$2 = (state, dom) => {
8030
8040
  } = state;
8031
8041
  renderInto($Viewlet, dom, ViewletStatusBarEvents);
8032
8042
  };
8033
- const focus$4 = state => {
8043
+ const focus$3 = state => {
8034
8044
  object(state);
8035
8045
  const {
8036
8046
  $Viewlet
@@ -8040,8 +8050,8 @@ const focus$4 = state => {
8040
8050
 
8041
8051
  const ViewletStatusBar = {
8042
8052
  __proto__: null,
8043
- create: create$7,
8044
- focus: focus$4,
8053
+ create: create$5,
8054
+ focus: focus$3,
8045
8055
  setDom: setDom$2
8046
8056
  };
8047
8057
 
@@ -8071,7 +8081,7 @@ const handleClickTab = event => {
8071
8081
  handleClickTab$2(uid, index);
8072
8082
  };
8073
8083
 
8074
- const create$6 = () => {
8084
+ const create$4 = () => {
8075
8085
  const $Viewlet = document.createElement('div');
8076
8086
  $Viewlet.className = 'Viewlet Terminals';
8077
8087
  return {
@@ -8098,7 +8108,7 @@ const setTabsDom = (state, dom) => {
8098
8108
 
8099
8109
  const ViewletTerminals = {
8100
8110
  __proto__: null,
8101
- create: create$6,
8111
+ create: create$4,
8102
8112
  setTabsDom
8103
8113
  };
8104
8114
 
@@ -8199,8 +8209,8 @@ const ViewletTitleBarMenuBarEvents = {
8199
8209
  };
8200
8210
 
8201
8211
  const activeId = 'TitleBarEntryActive';
8202
- const dispose$5 = state => {};
8203
- const focus$3 = state => {
8212
+ const dispose$4 = state => {};
8213
+ const focus$2 = state => {
8204
8214
  const {
8205
8215
  $TitleBarMenuBar
8206
8216
  } = state;
@@ -8436,8 +8446,8 @@ const ViewletTitleBarMenuBar = {
8436
8446
  __proto__: null,
8437
8447
  Events: ViewletTitleBarMenuBarEvents,
8438
8448
  closeMenu,
8439
- dispose: dispose$5,
8440
- focus: focus$3,
8449
+ dispose: dispose$4,
8450
+ focus: focus$2,
8441
8451
  openMenu,
8442
8452
  setFocusedIndex,
8443
8453
  setMenus
@@ -8455,8 +8465,8 @@ const ViewletTitleBar = {
8455
8465
  __proto__: null,
8456
8466
  Events: ViewletTitleBarMenuBarEvents,
8457
8467
  closeMenu,
8458
- dispose: dispose$5,
8459
- focus: focus$3,
8468
+ dispose: dispose$4,
8469
+ focus: focus$2,
8460
8470
  openMenu,
8461
8471
  setFocused,
8462
8472
  setFocusedIndex,
@@ -8493,7 +8503,7 @@ const ViewletTitleBarIcon = {
8493
8503
  Events
8494
8504
  };
8495
8505
 
8496
- const create$5 = () => {
8506
+ const create$3 = () => {
8497
8507
  const $Viewlet = document.createElement('div');
8498
8508
  $Viewlet.className = 'Viewlet TitleBarTitle';
8499
8509
  return {
@@ -8509,7 +8519,7 @@ const setDom$1 = (state, dom) => {
8509
8519
 
8510
8520
  const ViewletTitleBarTitle = {
8511
8521
  __proto__: null,
8512
- create: create$5,
8522
+ create: create$3,
8513
8523
  setDom: setDom$1
8514
8524
  };
8515
8525
 
@@ -8671,7 +8681,6 @@ const moduleLoaders = {
8671
8681
  [SourceControl]: () => ViewletSourceControl,
8672
8682
  [StatusBar$1]: () => ViewletStatusBar,
8673
8683
  [Storage]: () => ViewletStorage,
8674
- [Terminal]: () => Promise.resolve().then(function () { return ViewletTerminal; }),
8675
8684
  [Terminal2]: () => Promise.resolve().then(function () { return ViewletTerminal2; }),
8676
8685
  [Terminals]: () => ViewletTerminals,
8677
8686
  [TitleBar]: () => ViewletTitleBar,
@@ -8696,12 +8705,12 @@ const state$1 = {
8696
8705
  modules: Object.create(null)
8697
8706
  };
8698
8707
 
8699
- const create$4 = (id, uid = id) => {
8708
+ const create$2 = (id, uid = id) => {
8700
8709
  const module = state$1.modules[id];
8701
8710
  if (!module) {
8702
8711
  throw new Error(`module not found: ${id}`);
8703
8712
  }
8704
- const existing = get$a(id);
8713
+ const existing = get$8(id);
8705
8714
  if (existing?.state.$Viewlet.isConnected) {
8706
8715
  existing.state.$Viewlet.remove();
8707
8716
  }
@@ -8723,7 +8732,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8723
8732
  if (!module) {
8724
8733
  throw new Error(`module not found: ${id}`);
8725
8734
  }
8726
- const existing = get$a(id);
8735
+ const existing = get$8(id);
8727
8736
  if (existing?.state.$Viewlet.isConnected) {
8728
8737
  existing.state.$Viewlet.remove();
8729
8738
  }
@@ -8753,7 +8762,7 @@ const loadModule = async id => {
8753
8762
  };
8754
8763
  const invoke = (viewletId, method, ...args) => {
8755
8764
  string(method);
8756
- const instance = get$a(viewletId);
8765
+ const instance = get$8(viewletId);
8757
8766
  if (!instance?.factory) {
8758
8767
  if (viewletId && method !== 'setActionsDom') {
8759
8768
  warn$1(`cannot execute ${method} viewlet instance ${viewletId} not found`);
@@ -8766,12 +8775,12 @@ const invoke = (viewletId, method, ...args) => {
8766
8775
  }
8767
8776
  return instance.factory[method](instance.state, ...args);
8768
8777
  };
8769
- const focus$2 = viewletId => {
8778
+ const focus$1 = viewletId => {
8770
8779
  if (location.search.includes('traceFocus')) {
8771
8780
  // eslint-disable-next-line no-console
8772
8781
  console.trace(`focus ${viewletId}`);
8773
8782
  }
8774
- const instance = get$a(viewletId);
8783
+ const instance = get$8(viewletId);
8775
8784
  if (instance.factory?.setFocused) {
8776
8785
  instance.factory.setFocused(instance.state, true);
8777
8786
  } else if (instance?.factory?.focus) {
@@ -8787,7 +8796,7 @@ const focusElementByName = (viewletId, name) => {
8787
8796
  // eslint-disable-next-line no-console
8788
8797
  console.trace(`focusByName ${viewletId} ${name}`);
8789
8798
  }
8790
- const instance = get$a(viewletId);
8799
+ const instance = get$8(viewletId);
8791
8800
  if (!instance) {
8792
8801
  return;
8793
8802
  }
@@ -8802,7 +8811,7 @@ const focusElementByName = (viewletId, name) => {
8802
8811
  };
8803
8812
  const setElementProperty = (viewletId, name, key, value) => {
8804
8813
  const selector = `[name="${name}"]`;
8805
- const instance = get$a(viewletId);
8814
+ const instance = get$8(viewletId);
8806
8815
  if (!instance) {
8807
8816
  return;
8808
8817
  }
@@ -8831,7 +8840,7 @@ const setCheckboxValue = (viewletId, name, value) => {
8831
8840
  };
8832
8841
  const setSelectionByName = (viewletId, name, start, end) => {
8833
8842
  const selector = `[name="${name}"]`;
8834
- const instance = get$a(viewletId);
8843
+ const instance = get$8(viewletId);
8835
8844
  if (!instance) {
8836
8845
  return;
8837
8846
  }
@@ -8846,7 +8855,7 @@ const setSelectionByName = (viewletId, name, start, end) => {
8846
8855
  $Element.selectionEnd = end;
8847
8856
  };
8848
8857
  const setUid = (viewletId, uid) => {
8849
- const instance = get$a(viewletId);
8858
+ const instance = get$8(viewletId);
8850
8859
  if (!instance) {
8851
8860
  return;
8852
8861
  }
@@ -8864,7 +8873,7 @@ const resetFocusCallback = () => {
8864
8873
  focusCallback.selector = '';
8865
8874
  };
8866
8875
  const focusSelector = (viewletId, selector) => {
8867
- const instance = get$a(viewletId);
8876
+ const instance = get$8(viewletId);
8868
8877
  if (!instance) {
8869
8878
  return;
8870
8879
  }
@@ -8888,8 +8897,8 @@ const focusSelector = (viewletId, selector) => {
8888
8897
  /**
8889
8898
  * @deprecated
8890
8899
  */
8891
- const refresh$1 = (viewletId, viewletContext) => {
8892
- const instance = get$a(viewletId);
8900
+ const refresh = (viewletId, viewletContext) => {
8901
+ const instance = get$8(viewletId);
8893
8902
  if (instance) {
8894
8903
  instance.factory.refresh(instance.state, viewletContext);
8895
8904
  } else {
@@ -8908,7 +8917,7 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
8908
8917
  if (isSpecial(viewletId)) {
8909
8918
  $Placeholder.id = viewletId;
8910
8919
  }
8911
- const parentInstance = get$a(parentId);
8920
+ const parentInstance = get$8(parentId);
8912
8921
  const $Parent = parentInstance.state.$Viewlet;
8913
8922
  $Parent.append($Placeholder);
8914
8923
  set$a(viewletId, {
@@ -8921,7 +8930,7 @@ const setDragData = (viewletId, dragData) => {
8921
8930
  set$2(viewletId, dragData);
8922
8931
  };
8923
8932
  const setDom = (viewletId, dom) => {
8924
- const instance = get$a(viewletId);
8933
+ const instance = get$8(viewletId);
8925
8934
  if (!instance) {
8926
8935
  return;
8927
8936
  }
@@ -8934,7 +8943,7 @@ const setDom = (viewletId, dom) => {
8934
8943
  renderInto($Viewlet, dom, Events);
8935
8944
  };
8936
8945
  const setDom2 = (viewletId, dom) => {
8937
- const instance = get$a(viewletId);
8946
+ const instance = get$8(viewletId);
8938
8947
  if (!instance) {
8939
8948
  return;
8940
8949
  }
@@ -8965,7 +8974,7 @@ const setDom2 = (viewletId, dom) => {
8965
8974
  });
8966
8975
  };
8967
8976
  const setPatches = (uid, patches) => {
8968
- const instance = get$a(uid);
8977
+ const instance = get$8(uid);
8969
8978
  if (!instance) {
8970
8979
  return;
8971
8980
  }
@@ -9015,9 +9024,9 @@ const move = async (uid, selector, target) => {
9015
9024
  };
9016
9025
  const attachWindowEvents = () => {
9017
9026
  attachEvents$7(window, {
9018
- [Blur]: handleBlur$3,
9027
+ [Blur]: handleBlur$2,
9019
9028
  [Focus]: handleFocus$2,
9020
- [KeyDown]: handleKeyDown$1,
9029
+ [KeyDown]: handleKeyDown,
9021
9030
  [KeyUp]: handleKeyUp,
9022
9031
  [Resize]: handleResize
9023
9032
  });
@@ -9027,10 +9036,10 @@ const attachWindowEvents = () => {
9027
9036
  const sendMultiple = commands => {
9028
9037
  executeCommands(commands);
9029
9038
  };
9030
- const dispose$4 = id => {
9039
+ const dispose$3 = id => {
9031
9040
  try {
9032
9041
  number(id);
9033
- const instance = get$a(id);
9042
+ const instance = get$8(id);
9034
9043
  if (!instance) {
9035
9044
  warn$1(`viewlet instance ${id} not found and cannot be disposed`);
9036
9045
  return;
@@ -9049,7 +9058,7 @@ const dispose$4 = id => {
9049
9058
  };
9050
9059
  const handleError$1 = (id, parentId, message) => {
9051
9060
  info(`[viewlet-error] ${id}: ${message}`);
9052
- const instance = get$a(id);
9061
+ const instance = get$8(id);
9053
9062
  if (instance?.state.$Viewlet.isConnected) {
9054
9063
  instance.state.$Viewlet.remove();
9055
9064
  }
@@ -9061,7 +9070,7 @@ const handleError$1 = (id, parentId, message) => {
9061
9070
  instance.state.$Viewlet.textContent = String(message);
9062
9071
  }
9063
9072
  // TODO error should bubble up to until highest possible component
9064
- const parentInstance = get$a(parentId);
9073
+ const parentInstance = get$8(parentId);
9065
9074
  if (parentInstance?.factory?.handleError) {
9066
9075
  parentInstance.factory.handleError(instance.state, message);
9067
9076
  }
@@ -9075,9 +9084,9 @@ const appendViewlet = (parentId, childId, focus) => {
9075
9084
  // TODO
9076
9085
  return;
9077
9086
  }
9078
- const parentInstanceState = get$a(parentId); // TODO must ensure that parent is already created
9087
+ const parentInstanceState = get$8(parentId); // TODO must ensure that parent is already created
9079
9088
  const parentModule = parentInstanceState.factory;
9080
- const childInstance = get$a(childId);
9089
+ const childInstance = get$8(childId);
9081
9090
  if (!childInstance) {
9082
9091
  throw new Error(`child instance ${childId} must be defined to be appended to parent ${parentId}`);
9083
9092
  }
@@ -9101,7 +9110,7 @@ const prependChild = ($Parent, $Child) => {
9101
9110
  const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9102
9111
  for (let i = childIndex - 1; i >= 0; i--) {
9103
9112
  const beforeId = referenceNodes[i];
9104
- const beforeInstance = get$a(beforeId);
9113
+ const beforeInstance = get$8(beforeId);
9105
9114
  if (beforeInstance) {
9106
9115
  const $ReferenceNode = beforeInstance.state.$Viewlet;
9107
9116
  $ReferenceNode.after($Child);
@@ -9113,7 +9122,7 @@ const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9113
9122
  const appendBeforeNextReference = (referenceNodes, childIndex, $Child) => {
9114
9123
  for (let i = childIndex + 1; i < referenceNodes.length; i++) {
9115
9124
  const afterId = referenceNodes[i];
9116
- const afterInstance = get$a(afterId);
9125
+ const afterInstance = get$8(afterId);
9117
9126
  if (afterInstance) {
9118
9127
  const $ReferenceNode = afterInstance.state.$Viewlet;
9119
9128
  $ReferenceNode.before($Child);
@@ -9143,12 +9152,12 @@ const appendWithReferenceNodes = ($Parent, $Child, childId, referenceNodes) => {
9143
9152
  const append = (parentId, childId, referenceNodes) => {
9144
9153
  number(parentId);
9145
9154
  number(childId);
9146
- const parentInstance = get$a(parentId);
9155
+ const parentInstance = get$8(parentId);
9147
9156
  if (!parentInstance) {
9148
9157
  throw new Error(`cannot append child: instance ${parentId} not found`);
9149
9158
  }
9150
9159
  const $Parent = parentInstance.state.$Viewlet;
9151
- const childInstance = get$a(childId);
9160
+ const childInstance = get$8(childId);
9152
9161
  if (!childInstance) {
9153
9162
  throw new Error(`cannot append child: child instance not found ${childId}`);
9154
9163
  }
@@ -9167,11 +9176,11 @@ const append = (parentId, childId, referenceNodes) => {
9167
9176
  applyLateFocusMaybe();
9168
9177
  };
9169
9178
  const replaceChildren = (parentId, childIds) => {
9170
- const parentInstance = get$a(parentId);
9179
+ const parentInstance = get$8(parentId);
9171
9180
  const $Parent = parentInstance.state.$Viewlet;
9172
9181
  const $Fragment = document.createDocumentFragment();
9173
9182
  for (const childId of childIds) {
9174
- const childInstance = get$a(childId);
9183
+ const childInstance = get$8(childId);
9175
9184
  const $Child = childInstance.state.$Viewlet;
9176
9185
  $Fragment.append($Child);
9177
9186
  }
@@ -9186,7 +9195,7 @@ const applyLateFocusMaybe = () => {
9186
9195
  selector
9187
9196
  } = focusCallback;
9188
9197
  resetFocusCallback();
9189
- const instance = get$a(id);
9198
+ const instance = get$8(id);
9190
9199
  if (instance) {
9191
9200
  const {
9192
9201
  $Viewlet
@@ -9199,7 +9208,7 @@ const applyLateFocusMaybe = () => {
9199
9208
  };
9200
9209
  const appendToBody = childId => {
9201
9210
  const $Parent = document.body;
9202
- const childInstance = get$a(childId);
9211
+ const childInstance = get$8(childId);
9203
9212
  const $Child = childInstance.state.$Viewlet;
9204
9213
  $Parent.append($Child);
9205
9214
  applyLateFocusMaybe();
@@ -9212,7 +9221,7 @@ const executeCommands = commands => {
9212
9221
  }
9213
9222
  };
9214
9223
  const show = id => {
9215
- const instance = get$a(id);
9224
+ const instance = get$8(id);
9216
9225
  const $Viewlet = instance.state.$Viewlet;
9217
9226
  const $Workbench = document.getElementById('Workbench');
9218
9227
  // @ts-expect-error
@@ -9222,7 +9231,7 @@ const show = id => {
9222
9231
  }
9223
9232
  };
9224
9233
  const setBounds$1 = (id, left, top, width, height) => {
9225
- const instance = get$a(id);
9234
+ const instance = get$8(id);
9226
9235
  if (!instance) {
9227
9236
  return;
9228
9237
  }
@@ -9230,7 +9239,7 @@ const setBounds$1 = (id, left, top, width, height) => {
9230
9239
  setBounds$a($Viewlet, left, top, width, height);
9231
9240
  };
9232
9241
  const setProperty = (id, selector, property, value) => {
9233
- const instance = get$a(id);
9242
+ const instance = get$8(id);
9234
9243
  if (!instance) {
9235
9244
  return;
9236
9245
  }
@@ -9250,11 +9259,11 @@ const commandHandlers = {
9250
9259
  'Viewlet.appendViewlet': appendViewlet,
9251
9260
  'Viewlet.ariaAnnounce': ariaAnnounce,
9252
9261
  'Viewlet.attachWindowEvents': attachWindowEvents,
9253
- 'Viewlet.create': create$4,
9262
+ 'Viewlet.create': create$2,
9254
9263
  'Viewlet.createFunctionalRoot': createFunctionalRoot,
9255
9264
  'Viewlet.createPlaceholder': createPlaceholder,
9256
- 'Viewlet.dispose': dispose$4,
9257
- 'Viewlet.focus': focus$2,
9265
+ 'Viewlet.dispose': dispose$3,
9266
+ 'Viewlet.focus': focus$1,
9258
9267
  'Viewlet.focusElementByName': focusElementByName,
9259
9268
  'Viewlet.focusSelector': focusSelector,
9260
9269
  'Viewlet.handleError': handleError$1,
@@ -9387,7 +9396,7 @@ const getFilePathElectron = async file => {
9387
9396
  };
9388
9397
 
9389
9398
  const handleMessagePort = async port => {
9390
- await create$z({
9399
+ await create$x({
9391
9400
  commandMap: {},
9392
9401
  messagePort: port
9393
9402
  });
@@ -9412,7 +9421,7 @@ const waitForFrameToLoad = $Frame => {
9412
9421
  };
9413
9422
 
9414
9423
  // TODO could use browser view when running in electron
9415
- const create$3 = async (uid, src, sandbox, csp, credentialless, permissionPolicy, title) => {
9424
+ const create$1 = async (uid, src, sandbox, csp, credentialless, permissionPolicy, title) => {
9416
9425
  const $Iframe = document.createElement('iframe');
9417
9426
  setIframeCredentialless($Iframe, credentialless);
9418
9427
  setIframeCsp($Iframe, csp);
@@ -9465,7 +9474,7 @@ const setPort = (uid, port, origin, portType) => {
9465
9474
  params: [port, portType]
9466
9475
  }, origin, [port]);
9467
9476
  };
9468
- const dispose$3 = uid => {
9477
+ const dispose$2 = uid => {
9469
9478
  const $Iframe = get$1(uid);
9470
9479
  $Iframe.remove();
9471
9480
  remove(uid);
@@ -9476,7 +9485,7 @@ const commandMap = {
9476
9485
  'ClipBoard.execCopy': execCopy,
9477
9486
  'ClipBoard.read': read,
9478
9487
  'ClipBoard.readText': readText,
9479
- 'ClipBoard.write': write$2,
9488
+ 'ClipBoard.write': write$1,
9480
9489
  'ClipBoard.writeImage': writeImage,
9481
9490
  'ClipBoard.writeText': writeText,
9482
9491
  'ConfirmPrompt.prompt': confirm,
@@ -9484,7 +9493,7 @@ const commandMap = {
9484
9493
  'Css.getSelectionText': getSelectionText,
9485
9494
  'Developer.showState': showState,
9486
9495
  'Download.downloadFile': downloadFile,
9487
- 'FileHandles.get': get$8,
9496
+ 'FileHandles.get': get$6,
9488
9497
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
9489
9498
  'FilePicker.showFilePicker': showFilePicker,
9490
9499
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
@@ -9494,8 +9503,8 @@ const commandMap = {
9494
9503
  'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
9495
9504
  'HandleMessagePort.handleMessagePort': handleMessagePort,
9496
9505
  'InitData.getInitData': getInitData,
9497
- 'IpcParent.create': create$w,
9498
- 'IpcParent.dispose': dispose$j,
9506
+ 'IpcParent.create': create$u,
9507
+ 'IpcParent.dispose': dispose$i,
9499
9508
  'KeyBindings.setIdentifiers': setIdentifiers,
9500
9509
  'Layout.getBounds': getBounds,
9501
9510
  'Location.getHref': getHref,
@@ -9510,10 +9519,10 @@ const commandMap = {
9510
9519
  'Menu.showControlled': showControlled,
9511
9520
  'Menu.showMenu': showMenu,
9512
9521
  'Meta.setThemeColor': setThemeColor,
9513
- 'Notification.create': create$v,
9522
+ 'Notification.create': create$t,
9514
9523
  'Notification.createWithOptions': createWithOptions,
9515
- 'Notification.dispose': dispose$i,
9516
- 'OffscreenCanvas.create': create$u,
9524
+ 'Notification.dispose': dispose$h,
9525
+ 'OffscreenCanvas.create': create$s,
9517
9526
  'OffscreenCanvas.create2': create2,
9518
9527
  'Open.openUrl': openUrl,
9519
9528
  'Open.redirectToUrl': redirectToUrl,
@@ -9535,15 +9544,15 @@ const commandMap = {
9535
9544
  'TestFrameWork.transferToWebView': transferToWebView,
9536
9545
  'Viewlet.addKeyBindings': addKeyBindings,
9537
9546
  'Viewlet.appendViewlet': appendViewlet,
9538
- 'Viewlet.dispose': dispose$4,
9547
+ 'Viewlet.dispose': dispose$3,
9539
9548
  'Viewlet.executeCommands': executeCommands,
9540
- 'Viewlet.focus': focus$2,
9549
+ 'Viewlet.focus': focus$1,
9541
9550
  'Viewlet.focusElementByName': focusElementByName,
9542
9551
  'Viewlet.focusSelector': focusSelector,
9543
9552
  'Viewlet.handleError': handleError$1,
9544
9553
  'Viewlet.invoke': invoke,
9545
9554
  'Viewlet.loadModule': loadModule,
9546
- 'Viewlet.refresh': refresh$1,
9555
+ 'Viewlet.refresh': refresh,
9547
9556
  'Viewlet.registerEventListeners': registerEventListeners,
9548
9557
  'Viewlet.removeKeyBindings': removeKeyBindings,
9549
9558
  'Viewlet.send': invoke,
@@ -9555,8 +9564,8 @@ const commandMap = {
9555
9564
  'WebStorage.setItem': setItem,
9556
9565
  'WebStorage.setJsonObjects': setJsonObjects,
9557
9566
  'WebView.appendOnly': appendOnly,
9558
- 'WebView.create': create$3,
9559
- 'WebView.dispose': dispose$3,
9567
+ 'WebView.create': create$1,
9568
+ 'WebView.dispose': dispose$2,
9560
9569
  'WebView.load': load,
9561
9570
  'WebView.loadOnly': loadOnly,
9562
9571
  'WebView.setPort': setPort,
@@ -9850,7 +9859,7 @@ const editorWorkerUrl = getConfiguredEditorWorkerUrl() || `${assetDir}/packages/
9850
9859
 
9851
9860
  const launchEditorWorker = async port => {
9852
9861
  try {
9853
- await create$w({
9862
+ await create$u({
9854
9863
  method: ModuleWorkerWithMessagePort,
9855
9864
  name: 'Editor Worker',
9856
9865
  port,
@@ -9887,7 +9896,7 @@ const extensionHostWorkerUrl = getConfiguredExtensionHostWorkerUrl() || `${asset
9887
9896
  const launchExtensionHostWorker = async port => {
9888
9897
  const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
9889
9898
  try {
9890
- await create$w({
9899
+ await create$u({
9891
9900
  method: ModuleWorkerWithMessagePort,
9892
9901
  name,
9893
9902
  port,
@@ -9924,7 +9933,7 @@ const syntaxHighlightingWorkerUrl = getConfiguredSyntaxHighlightingWorkerUrl() |
9924
9933
 
9925
9934
  const launchSyntaxHighlightingWorker = async port => {
9926
9935
  try {
9927
- await create$w({
9936
+ await create$u({
9928
9937
  method: ModuleWorkerWithMessagePort,
9929
9938
  name: 'Syntax Highlighting Worker',
9930
9939
  port,
@@ -9972,7 +9981,7 @@ const handleFocusIn = event => {
9972
9981
  const uid = fromEvent(event);
9973
9982
  handleFocusIn$4(uid);
9974
9983
  };
9975
- const handleBlur$1 = event => {
9984
+ const handleBlur = event => {
9976
9985
  const uid = fromEvent(event);
9977
9986
  executeViewletCommand(uid, 'EditorRename.handleBlur');
9978
9987
  };
@@ -9989,7 +9998,7 @@ const handleInput = event => {
9989
9998
 
9990
9999
  const ViewletEditorRenameEvents = {
9991
10000
  __proto__: null,
9992
- handleBlur: handleBlur$1,
10001
+ handleBlur,
9993
10002
  handleFocusIn,
9994
10003
  handleInput
9995
10004
  };
@@ -10007,7 +10016,7 @@ const appendWidget = state => {
10007
10016
  } = state;
10008
10017
  append$1($Viewlet);
10009
10018
  };
10010
- const dispose$2 = state => {
10019
+ const dispose$1 = state => {
10011
10020
  remove$1(state.$Viewlet);
10012
10021
  };
10013
10022
 
@@ -10015,7 +10024,7 @@ const ViewletEditorRename = {
10015
10024
  __proto__: null,
10016
10025
  Events: ViewletEditorRenameEvents,
10017
10026
  appendWidget,
10018
- dispose: dispose$2,
10027
+ dispose: dispose$1,
10019
10028
  setBounds
10020
10029
  };
10021
10030
 
@@ -10079,227 +10088,46 @@ const main = async () => {
10079
10088
 
10080
10089
  main();
10081
10090
 
10082
- const isUint8Array = value => {
10083
- return value instanceof Uint8Array;
10084
- };
10085
-
10086
- const CHAR_WIDTH = 12;
10087
- const CHAR_HEIGHT = 15;
10088
-
10089
- const tmpCanvas = new OffscreenCanvas(CHAR_WIDTH, CHAR_HEIGHT) ;
10090
- tmpCanvas.getContext("2d", {
10091
- // desynchronized: true, // perf
10092
- alpha: false // perf
10093
- });
10094
-
10095
- const noop = () => {};
10096
- const createOffscreenTerminalDom = (root, {
10097
- handleMouseDown = noop,
10098
- handleKeyDown = noop,
10099
- handleBlur = noop,
10100
- canvasText = document.createElement("canvas"),
10101
- canvasCursor = document.createElement("canvas")
10102
- }) => {
10103
- root.onmousedown = event => {
10104
- event.preventDefault();
10105
- textarea.focus();
10106
- handleMouseDown();
10107
- };
10108
- canvasText.className = "TerminalCanvasText";
10109
- canvasCursor.className = "TerminalCanvasCursor";
10110
- const $Layers = document.createElement("div");
10111
- $Layers.className = "TerminalLayers";
10112
- const textarea = document.createElement("textarea");
10113
- textarea.className = "TerminalTextArea";
10114
- textarea.name = "terminal-input";
10115
- $Layers.append(canvasText, canvasCursor);
10116
- root.append(textarea, $Layers);
10117
- const wrappedKeyDown = event => {
10118
- // @ts-ignore
10119
- handleKeyDown({
10120
- key: event.key,
10121
- shiftKey: event.shiftKey,
10122
- altKey: event.altKey,
10123
- ctrlKey: event.ctrlKey,
10124
- metaKey: event.metaKey
10125
- });
10126
- };
10127
- textarea.onkeydown = wrappedKeyDown;
10128
- const handleBeforeInput = event => {
10129
- event.preventDefault();
10130
- };
10131
- textarea.addEventListener("beforeinput", handleBeforeInput);
10132
- textarea.onblur = handleBlur;
10133
- const focusTextArea = () => {
10134
- textarea.focus();
10135
- };
10136
- return {
10137
- /**
10138
- * @deprecated
10139
- */
10140
- get offscreenCanvasCursor() {
10141
- return canvasCursor.transferControlToOffscreen();
10142
- },
10143
- /**
10144
- * @deprecated
10145
- */
10146
- get offscreenCanvasText() {
10147
- return canvasText.transferControlToOffscreen();
10148
- },
10149
- focusTextArea
10150
- };
10151
- };
10152
-
10153
- const create$2 = ({
10154
- $Element,
10155
- ...options
10156
- }) => {
10157
- const terminal = createOffscreenTerminalDom($Element, options);
10158
- return terminal;
10159
- };
10160
-
10161
- const handleBlur = event => {
10162
- const uid = fromEvent(event);
10163
- handleBlur$7(uid);
10164
- };
10165
- const handleMouseDown$1 = (event, ...args) => {
10166
- const uid = fromEvent(event);
10167
- handleMouseDown$2(uid, ...args);
10168
- };
10169
- const handleKeyDown = (event, ...args) => {
10170
- const uid = fromEvent(event);
10171
- handleKeyDown$4(uid, ...args);
10172
- };
10173
-
10174
- const create$1 = () => {
10175
- const $Viewlet = document.createElement('div');
10176
- $Viewlet.className = 'Viewlet Terminal';
10177
- return {
10178
- $Viewlet,
10179
- terminal: undefined
10180
- };
10181
- };
10182
- const setTerminal$1 = (state, canvasCursorId, canvasTextId) => {
10183
- const canvasText = get$4(canvasTextId);
10184
- const canvasCursor = get$4(canvasCursorId);
10185
- const {
10186
- $Viewlet
10187
- } = state;
10188
- const terminal = create$2({
10189
- $Element: $Viewlet,
10190
- background: `#1b2020`,
10191
- canvasCursor,
10192
- canvasText,
10193
- foreground: 'white',
10194
- handleBlur: (...args) => {
10195
- // @ts-ignore
10196
- handleBlur({
10197
- target: $Viewlet
10198
- }, ...args);
10199
- },
10200
- handleKeyDown: (...args) => {
10201
- handleKeyDown({
10202
- target: $Viewlet
10203
- }, ...args);
10204
- },
10205
- handleMouseDown: (...args) => {
10206
- handleMouseDown$1({
10207
- target: $Viewlet
10208
- }, ...args);
10209
- }
10210
- });
10211
- state.terminal = terminal;
10212
- };
10213
- const focusTextArea = state => {
10214
- const {
10215
- terminal
10216
- } = state;
10217
- terminal.focusTextArea();
10218
- };
10219
- const refresh = (state, context) => {
10220
- // state.element.textContent = context.text
10221
- };
10222
- const dispose$1 = state => {
10223
- // TODO unregister callback
10224
- // SharedProcess.unregisterChannel(channel )
10225
-
10226
- window.removeEventListener('resize', state.handleUpdate);
10227
- };
10228
- const focus$1 = state => {
10229
- object(state);
10230
- const {
10231
- terminal
10232
- } = state;
10233
- terminal.focus();
10234
- };
10235
- const reduceFocus = (state, action) => {};
10236
-
10237
- // TODO what is this
10238
- const reduceWrite = (state, action) => {
10239
- };
10240
- const reduce = (state, action) => {
10241
- switch (action.type) {
10242
- case 'focus':
10243
- {
10244
- return;
10245
- }
10246
- case 'write':
10247
- {
10248
- return;
10249
- }
10250
- }
10251
- };
10252
- const write$1 = (state, data) => {
10253
- if (!isUint8Array(data)) {
10254
- throw new TypeError(`data must be of type Uint8Array`);
10255
- }
10256
- };
10257
- const Commands = {
10258
- 9922: write$1
10259
- };
10260
-
10261
- const ViewletTerminal = {
10262
- __proto__: null,
10263
- Commands,
10264
- create: create$1,
10265
- dispose: dispose$1,
10266
- focus: focus$1,
10267
- focusTextArea,
10268
- reduce,
10269
- reduceFocus,
10270
- reduceWrite,
10271
- refresh,
10272
- setTerminal: setTerminal$1,
10273
- write: write$1
10274
- };
10275
-
10276
10091
  const defaultColumns = 80;
10277
10092
  const defaultRows = 24;
10278
10093
  const createTerminal = async () => {
10279
- const {
10094
+ const [{
10095
+ FitAddon
10096
+ }, {
10280
10097
  Terminal
10281
- } = await import('./xterm.js');
10282
- return new Terminal({
10098
+ }] = await Promise.all([import('./xterm.js'), import('./xterm.js')]);
10099
+ const terminal = new Terminal({
10283
10100
  cols: defaultColumns,
10284
10101
  convertEol: true,
10285
10102
  cursorBlink: true,
10286
10103
  rows: defaultRows
10287
10104
  });
10288
- };
10289
- const create = () => {
10290
- const $Viewlet = document.createElement('div');
10291
- $Viewlet.className = 'Viewlet Terminal XtermTerminal';
10105
+ const fitAddon = new FitAddon();
10106
+ terminal.loadAddon(fitAddon);
10292
10107
  return {
10293
- $Viewlet,
10294
- disposables: [],
10295
- terminal: undefined
10108
+ fitAddon,
10109
+ terminal
10296
10110
  };
10297
10111
  };
10298
- const setTerminal = async (state, uid) => {
10299
- if (state.terminal) {
10112
+ const flushPendingData = state => {
10113
+ const {
10114
+ pendingData,
10115
+ terminal
10116
+ } = state;
10117
+ for (const data of pendingData) {
10118
+ terminal.write(data);
10119
+ }
10120
+ pendingData.length = 0;
10121
+ };
10122
+ const mountTerminal = async (state, uid) => {
10123
+ const {
10124
+ fitAddon,
10125
+ terminal
10126
+ } = await createTerminal();
10127
+ if (state.disposed) {
10128
+ terminal.dispose();
10300
10129
  return;
10301
10130
  }
10302
- const terminal = await createTerminal();
10303
10131
  const inputDisposable = terminal.onData(data => {
10304
10132
  handleInput$6(uid, data);
10305
10133
  });
@@ -10313,14 +10141,49 @@ const setTerminal = async (state, uid) => {
10313
10141
  });
10314
10142
  });
10315
10143
  terminal.open(state.$Viewlet);
10144
+ const resizeObserver = new ResizeObserver(() => {
10145
+ fitAddon.fit();
10146
+ });
10147
+ resizeObserver.observe(state.$Viewlet);
10148
+ state.fitAddon = fitAddon;
10149
+ state.resizeObserver = resizeObserver;
10316
10150
  state.terminal = terminal;
10317
10151
  state.disposables = [inputDisposable, resizeDisposable];
10152
+ fitAddon.fit();
10153
+ flushPendingData(state);
10154
+ };
10155
+ const create = () => {
10156
+ const $Viewlet = document.createElement('div');
10157
+ $Viewlet.className = 'Viewlet Terminal XtermTerminal';
10158
+ return {
10159
+ $Viewlet,
10160
+ disposables: [],
10161
+ disposed: false,
10162
+ fitAddon: undefined,
10163
+ mountPromise: undefined,
10164
+ mouseDownListener: undefined,
10165
+ pendingData: [],
10166
+ resizeObserver: undefined,
10167
+ terminal: undefined
10168
+ };
10169
+ };
10170
+ const setTerminal = (state, uid) => {
10171
+ if (state.terminal) {
10172
+ return Promise.resolve();
10173
+ }
10174
+ if (!state.mountPromise) {
10175
+ state.mountPromise = mountTerminal(state, uid);
10176
+ }
10177
+ return state.mountPromise;
10318
10178
  };
10319
10179
  const write = (state, data) => {
10320
10180
  const {
10321
10181
  terminal
10322
10182
  } = state;
10323
10183
  if (!terminal) {
10184
+ if (!state.disposed) {
10185
+ state.pendingData.push(data);
10186
+ }
10324
10187
  return;
10325
10188
  }
10326
10189
  terminal.write(data);
@@ -10339,15 +10202,27 @@ const handleMouseDown = state => {
10339
10202
  focus(state);
10340
10203
  };
10341
10204
  const attachEvents = state => {
10342
- state.$Viewlet.addEventListener('mousedown', () => {
10205
+ if (state.mouseDownListener) {
10206
+ return;
10207
+ }
10208
+ state.mouseDownListener = () => {
10343
10209
  handleMouseDown(state);
10344
- });
10210
+ };
10211
+ state.$Viewlet.addEventListener('mousedown', state.mouseDownListener);
10345
10212
  };
10346
10213
  const dispose = state => {
10214
+ state.disposed = true;
10215
+ if (state.mouseDownListener) {
10216
+ state.$Viewlet.removeEventListener('mousedown', state.mouseDownListener);
10217
+ state.mouseDownListener = undefined;
10218
+ }
10347
10219
  for (const disposable of state.disposables) {
10348
10220
  disposable.dispose();
10349
10221
  }
10350
10222
  state.disposables = [];
10223
+ state.pendingData.length = 0;
10224
+ state.resizeObserver?.disconnect();
10225
+ state.resizeObserver = undefined;
10351
10226
  state.terminal?.dispose();
10352
10227
  state.terminal = undefined;
10353
10228
  };