@lvce-editor/renderer-process 6.4.0 → 6.6.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.
@@ -2256,7 +2256,15 @@ var rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
2256
2256
  return $Viewlet;
2257
2257
  };
2258
2258
 
2259
+ const handleWindowMessage = event => {
2260
+ console.log({
2261
+ event
2262
+ });
2263
+ };
2259
2264
  const main = async () => {
2265
+ if (location.pathname.includes('/test')) {
2266
+ window.addEventListener('message', handleWindowMessage);
2267
+ }
2260
2268
  onerror = handleUnhandledError;
2261
2269
  onunhandledrejection = handleUnhandledRejection;
2262
2270
  if ('SecurityPolicyViolationEvent' in self) {
@@ -3336,7 +3344,7 @@ const create$Menu$1 = () => {
3336
3344
  // })
3337
3345
  $Menu.onkeydown = handleKeyDown$5;
3338
3346
  $Menu.addEventListener(FocusOut, handleFocusOut$1);
3339
- $Menu.oncontextmenu = handleContextMenu$a;
3347
+ $Menu.oncontextmenu = handleContextMenu$c;
3340
3348
  // $ContextMenu.onfocus = handleFocus
3341
3349
  // $ContextMenu.onblur = handleBlur
3342
3350
  return $Menu;
@@ -3365,14 +3373,14 @@ const handleBackDropMouseDown = event => {
3365
3373
  stopPropagation(event);
3366
3374
  send( /* Menu.hide */'Menu.hide');
3367
3375
  };
3368
- const handleContextMenu$a = event => {
3376
+ const handleContextMenu$c = event => {
3369
3377
  preventDefault(event);
3370
3378
  };
3371
3379
  const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom, mouseBlocking = false) => {
3372
3380
  if (mouseBlocking) {
3373
3381
  const $BackDrop = create$BackDrop();
3374
3382
  $BackDrop.onmousedown = handleBackDropMouseDown;
3375
- $BackDrop.oncontextmenu = handleContextMenu$a;
3383
+ $BackDrop.oncontextmenu = handleContextMenu$c;
3376
3384
  // @ts-expect-error
3377
3385
  state$2.$BackDrop = $BackDrop;
3378
3386
  append$1($BackDrop);
@@ -4141,6 +4149,11 @@ const objects = Object.create(null);
4141
4149
  const transfer = (objectId, transferable) => {
4142
4150
  objects[objectId] = transferable;
4143
4151
  };
4152
+ const acquire = objectId => {
4153
+ const value = objects[objectId];
4154
+ delete objects[objectId];
4155
+ return value;
4156
+ };
4144
4157
 
4145
4158
  const name$8 = 'Transferrable';
4146
4159
  const Commands$9 = {
@@ -4238,6 +4251,7 @@ const TitleBarTitle = 'TitleBarTitle';
4238
4251
  const About = 'About';
4239
4252
  const EditorSourceActions = 'EditorSourceActions';
4240
4253
  const E2eTests = 'E2eTests';
4254
+ const E2eTest = 'E2eTest';
4241
4255
 
4242
4256
  const load = moduleId => {
4243
4257
  switch (moduleId) {
@@ -4349,6 +4363,8 @@ const load = moduleId => {
4349
4363
  return Promise.resolve().then(function () { return ViewletInlineDiffEditor; });
4350
4364
  case E2eTests:
4351
4365
  return Promise.resolve().then(function () { return ViewletE2eTests; });
4366
+ case E2eTest:
4367
+ return Promise.resolve().then(function () { return ViewletE2eTest; });
4352
4368
  default:
4353
4369
  throw new Error(`${moduleId} module not found in renderer process`);
4354
4370
  }
@@ -5755,7 +5771,7 @@ const handleFocus$c = () => {
5755
5771
 
5756
5772
  // TODO use context menu events function again
5757
5773
 
5758
- const handleContextMenu$9 = event => {
5774
+ const handleContextMenu$b = event => {
5759
5775
  preventDefault(event);
5760
5776
  const {
5761
5777
  button,
@@ -5764,15 +5780,15 @@ const handleContextMenu$9 = event => {
5764
5780
  } = event;
5765
5781
  return ['handleContextMenu', button, clientX, clientY];
5766
5782
  };
5767
- const returnValue$7 = true;
5783
+ const returnValue$8 = true;
5768
5784
 
5769
5785
  const ViewletActivityBarEvents = {
5770
5786
  __proto__: null,
5771
5787
  handleBlur: handleBlur$9,
5772
- handleContextMenu: handleContextMenu$9,
5788
+ handleContextMenu: handleContextMenu$b,
5773
5789
  handleFocus: handleFocus$c,
5774
5790
  handleMouseDown: handleMouseDown$3,
5775
- returnValue: returnValue$7
5791
+ returnValue: returnValue$8
5776
5792
  };
5777
5793
 
5778
5794
  const Events$a = ViewletActivityBarEvents;
@@ -5821,7 +5837,7 @@ const handleButtonClick = forwardViewletCommand('handleButtonClick');
5821
5837
  const handleClick$9 = forwardViewletCommand('handleClick');
5822
5838
  const handleClickAction$2 = forwardViewletCommand('handleClickAction');
5823
5839
  forwardViewletCommand('handleClickAdd');
5824
- const handleClickAt$1 = forwardViewletCommand('handleClickAt');
5840
+ const handleClickAt$2 = forwardViewletCommand('handleClickAt');
5825
5841
  const handleClickOpenFolder$1 = forwardViewletCommand('handleClickOpenFolder');
5826
5842
  forwardViewletCommand('handleClickClose');
5827
5843
  forwardViewletCommand('handleClickCopy');
@@ -5831,7 +5847,7 @@ forwardViewletCommand('handleClickOpenFile');
5831
5847
  forwardViewletCommand('handleClickRestore');
5832
5848
  const handleClickTab$2 = forwardViewletCommand('handleClickTab');
5833
5849
  forwardViewletCommand('handleClickToggleMaximize');
5834
- const handleContextMenu$8 = forwardViewletCommand('handleContextMenu');
5850
+ const handleContextMenu$a = forwardViewletCommand('handleContextMenu');
5835
5851
  const handleDoubleClick = forwardViewletCommand('handleDoubleClick');
5836
5852
  const handleDragEnd$1 = forwardViewletCommand('handleDragEnd');
5837
5853
  const handleDragLeave$1 = forwardViewletCommand('handleDragLeave');
@@ -6037,12 +6053,12 @@ const handlePointerDown$6 = event => {
6037
6053
  }
6038
6054
  return [];
6039
6055
  };
6040
- const returnValue$6 = true;
6056
+ const returnValue$7 = true;
6041
6057
 
6042
6058
  const ViewletColorPickerEvents = {
6043
6059
  __proto__: null,
6044
6060
  handlePointerDown: handlePointerDown$6,
6045
- returnValue: returnValue$6
6061
+ returnValue: returnValue$7
6046
6062
  };
6047
6063
 
6048
6064
  const setColor = (state, color) => {
@@ -6356,7 +6372,7 @@ const handleMousedown = event => {
6356
6372
  clientY
6357
6373
  } = event;
6358
6374
  const uid = fromEvent(event);
6359
- handleClickAt$1(uid, clientX, clientY);
6375
+ handleClickAt$2(uid, clientX, clientY);
6360
6376
  };
6361
6377
  const handleScrollBarThumbPointerMove$2 = event => {
6362
6378
  const {
@@ -6566,7 +6582,7 @@ const ViewletEditorError = {
6566
6582
  setDom: setDom$6
6567
6583
  };
6568
6584
 
6569
- const returnValue$5 = true;
6585
+ const returnValue$6 = true;
6570
6586
  const handleSashPointerDown$2 = create$v(event => {
6571
6587
  const {
6572
6588
  clientX,
@@ -6590,7 +6606,7 @@ const handleSashPointerDown$2 = create$v(event => {
6590
6606
  const ViewletEditorHoverEvents = {
6591
6607
  __proto__: null,
6592
6608
  handleSashPointerDown: handleSashPointerDown$2,
6593
- returnValue: returnValue$5
6609
+ returnValue: returnValue$6
6594
6610
  };
6595
6611
 
6596
6612
  const setBounds$2 = (state, x, y, width, height) => {
@@ -6687,7 +6703,7 @@ const handleWheel$2 = event => {
6687
6703
  *
6688
6704
  * @param {MouseEvent} event
6689
6705
  */
6690
- const handleContextMenu$7 = event => {
6706
+ const handleContextMenu$9 = event => {
6691
6707
  preventDefault(event);
6692
6708
  const {
6693
6709
  button,
@@ -6695,7 +6711,7 @@ const handleContextMenu$7 = event => {
6695
6711
  clientY
6696
6712
  } = event;
6697
6713
  const uid = fromEvent(event);
6698
- handleContextMenu$8(uid, button, clientX, clientY);
6714
+ handleContextMenu$a(uid, button, clientX, clientY);
6699
6715
  };
6700
6716
  const handleError$5 = event => {
6701
6717
  const uid = fromEvent(event);
@@ -6720,7 +6736,7 @@ const attachEvents$9 = state => {
6720
6736
  attachEvents$b($Viewlet, {
6721
6737
  [PointerDown]: handlePointerDown$5,
6722
6738
  [PointerUp]: handlePointerUp,
6723
- [ContextMenu]: handleContextMenu$7,
6739
+ [ContextMenu]: handleContextMenu$9,
6724
6740
  [FocusIn]: handleFocus$9
6725
6741
  });
6726
6742
  $Viewlet.addEventListener(Error$3, handleError$5, Capture);
@@ -7086,7 +7102,7 @@ const handleScrollBarContextMenu = event => {
7086
7102
  preventDefault(event);
7087
7103
  stopPropagation(event);
7088
7104
  };
7089
- const handleContextMenu$6 = event => {
7105
+ const handleContextMenu$8 = event => {
7090
7106
  preventDefault(event);
7091
7107
  const {
7092
7108
  button,
@@ -7242,7 +7258,7 @@ const create$n = () => {
7242
7258
  $Editor.role = Code;
7243
7259
  $Editor.append($LayerGutter, $EditorContent);
7244
7260
  attachEventsFunctional($Editor, {
7245
- [ContextMenu]: handleContextMenu$6,
7261
+ [ContextMenu]: handleContextMenu$8,
7246
7262
  [Wheel]: handleWheel$1,
7247
7263
  returnValue: true
7248
7264
  });
@@ -7441,7 +7457,7 @@ const ViewletError = {
7441
7457
  setMessage: setMessage$1
7442
7458
  };
7443
7459
 
7444
- const handleContextMenu$5 = event => {
7460
+ const handleContextMenu$7 = event => {
7445
7461
  preventDefault(event);
7446
7462
  const {
7447
7463
  button,
@@ -7449,7 +7465,7 @@ const handleContextMenu$5 = event => {
7449
7465
  clientY
7450
7466
  } = event;
7451
7467
  const uid = fromEvent(event);
7452
- handleContextMenu$8(uid, button, clientX, clientY);
7468
+ handleContextMenu$a(uid, button, clientX, clientY);
7453
7469
  };
7454
7470
 
7455
7471
  const CopyMove = 'copyMove';
@@ -7589,7 +7605,7 @@ const handleClick$6 = event => {
7589
7605
  clientY
7590
7606
  } = event;
7591
7607
  const uid = fromEvent(event);
7592
- handleClickAt$1(uid, button, clientX, clientY);
7608
+ handleClickAt$2(uid, button, clientX, clientY);
7593
7609
  };
7594
7610
  const handleClickOpenFolder = event => {
7595
7611
  preventDefault(event);
@@ -7643,7 +7659,7 @@ const ViewletExplorerEvents = {
7643
7659
  handleBlur: handleBlur$5,
7644
7660
  handleClick: handleClick$6,
7645
7661
  handleClickOpenFolder,
7646
- handleContextMenu: handleContextMenu$5,
7662
+ handleContextMenu: handleContextMenu$7,
7647
7663
  handleDragEnd,
7648
7664
  handleDragLeave,
7649
7665
  handleDragOver,
@@ -7908,7 +7924,7 @@ const attachEvents$8 = state => {
7908
7924
  // @ts-expect-error
7909
7925
  $ExtensionHeader.addEventListener(Click, undefined);
7910
7926
  attachEvents$b($ListItems, {
7911
- [ContextMenu]: handleContextMenu$5,
7927
+ [ContextMenu]: handleContextMenu$7,
7912
7928
  [PointerDown]: handlePointerDown$3,
7913
7929
  [Focus]: handleFocus$6,
7914
7930
  [Scroll]: handleScroll
@@ -8268,7 +8284,7 @@ const handlePointerDown$2 = event => {
8268
8284
 
8269
8285
  const ViewletkeyBindingsEvents = {
8270
8286
  __proto__: null,
8271
- handleContextMenu: handleContextMenu$5,
8287
+ handleContextMenu: handleContextMenu$7,
8272
8288
  handleInput: handleInput$4,
8273
8289
  handlePointerDown: handlePointerDown$2,
8274
8290
  handleResizerPointerDown,
@@ -8857,7 +8873,7 @@ const ViewletLayout = {
8857
8873
  setSashes
8858
8874
  };
8859
8875
 
8860
- const handleContextMenu$4 = event => {
8876
+ const handleContextMenu$6 = event => {
8861
8877
  if (event.defaultPrevented) {
8862
8878
  return;
8863
8879
  }
@@ -8867,7 +8883,7 @@ const handleContextMenu$4 = event => {
8867
8883
  clientY
8868
8884
  } = event;
8869
8885
  const uid = fromEvent(event);
8870
- handleContextMenu$8(uid, clientX, clientY);
8886
+ handleContextMenu$a(uid, clientX, clientY);
8871
8887
  };
8872
8888
 
8873
8889
  // TODO Main should not be bound to Editor -> Lazy load Editor
@@ -8901,7 +8917,7 @@ const attachEvents$6 = state => {
8901
8917
  [DragOver]: handleDragOver,
8902
8918
  [DragEnd]: handleDragEnd,
8903
8919
  [DragLeave]: handleDragLeave,
8904
- [ContextMenu]: handleContextMenu$4
8920
+ [ContextMenu]: handleContextMenu$6
8905
8921
  });
8906
8922
  };
8907
8923
  const dispose$7 = state => {};
@@ -9296,7 +9312,7 @@ const handlePointerDown$1 = event => {
9296
9312
  } = event;
9297
9313
  return ['handleClickAt', clientX, clientY];
9298
9314
  };
9299
- const handleContextMenu$3 = event => {
9315
+ const handleContextMenu$5 = event => {
9300
9316
  preventDefault(event);
9301
9317
  const {
9302
9318
  clientX,
@@ -9316,15 +9332,15 @@ const handleFilterInput = event => {
9316
9332
  const handleClearFilterClick = event => {
9317
9333
  return ['clearFilter'];
9318
9334
  };
9319
- const returnValue$4 = true;
9335
+ const returnValue$5 = true;
9320
9336
 
9321
9337
  const ViewletProblemsEvents = {
9322
9338
  __proto__: null,
9323
9339
  handleClearFilterClick,
9324
- handleContextMenu: handleContextMenu$3,
9340
+ handleContextMenu: handleContextMenu$5,
9325
9341
  handleFilterInput,
9326
9342
  handlePointerDown: handlePointerDown$1,
9327
- returnValue: returnValue$4
9343
+ returnValue: returnValue$5
9328
9344
  };
9329
9345
 
9330
9346
  const setFocusedIndex$2 = (state, focusedIndex) => {
@@ -9400,7 +9416,7 @@ const handlePointerDown = event => {
9400
9416
  clientY
9401
9417
  } = event;
9402
9418
  const uid = fromEvent(event);
9403
- handleClickAt$1(uid, clientX, clientY);
9419
+ handleClickAt$2(uid, clientX, clientY);
9404
9420
  };
9405
9421
  const handleBlur$2 = event => {
9406
9422
  const uid = fromEvent(event);
@@ -9901,7 +9917,7 @@ const handleHeaderFocusIn = event => {
9901
9917
  }
9902
9918
  return ['handleFocusIn', key];
9903
9919
  };
9904
- const handleContextMenu$2 = event => {
9920
+ const handleContextMenu$4 = event => {
9905
9921
  preventDefault(event);
9906
9922
  const {
9907
9923
  button,
@@ -9917,12 +9933,12 @@ const handleWheel = event => {
9917
9933
  } = event;
9918
9934
  return ['handleWheel', deltaMode, deltaY];
9919
9935
  };
9920
- const returnValue$3 = true;
9936
+ const returnValue$4 = true;
9921
9937
 
9922
9938
  const ViewletSearchEvents = {
9923
9939
  __proto__: null,
9924
9940
  handleClick: handleClick$4,
9925
- handleContextMenu: handleContextMenu$2,
9941
+ handleContextMenu: handleContextMenu$4,
9926
9942
  handleFocus: handleFocus$2,
9927
9943
  handleHeaderClick: handleHeaderClick$1,
9928
9944
  handleHeaderFocusIn,
@@ -9935,7 +9951,7 @@ const ViewletSearchEvents = {
9935
9951
  handleScrollBarThumbPointerMove,
9936
9952
  handleToggleButtonClick,
9937
9953
  handleWheel,
9938
- returnValue: returnValue$3
9954
+ returnValue: returnValue$4
9939
9955
  };
9940
9956
 
9941
9957
  const focus$5 = state => {
@@ -10217,7 +10233,7 @@ const handleInput = event => {
10217
10233
  const ViewletSourceControlEvents = {
10218
10234
  __proto__: null,
10219
10235
  handleClick: handleClick$3,
10220
- handleContextMenu: handleContextMenu$5,
10236
+ handleContextMenu: handleContextMenu$7,
10221
10237
  handleFocus,
10222
10238
  handleInput,
10223
10239
  handleMouseOut,
@@ -10558,7 +10574,7 @@ const ViewletTerminals = {
10558
10574
  setTabsDom
10559
10575
  };
10560
10576
 
10561
- const handleContextMenu$1 = event => {
10577
+ const handleContextMenu$3 = event => {
10562
10578
  preventDefault(event);
10563
10579
  const {
10564
10580
  button,
@@ -10586,7 +10602,7 @@ const attachEvents = state => {
10586
10602
  $Viewlet
10587
10603
  } = state;
10588
10604
  attachEvents$b($Viewlet, {
10589
- [ContextMenu]: handleContextMenu$1
10605
+ [ContextMenu]: handleContextMenu$3
10590
10606
  });
10591
10607
  };
10592
10608
  const activeClassName = 'TitleBarActive';
@@ -10618,12 +10634,12 @@ const handleTitleBarButtonsClick = event => {
10618
10634
  } = event;
10619
10635
  return ['handleClick', target.className];
10620
10636
  };
10621
- const returnValue$2 = true;
10637
+ const returnValue$3 = true;
10622
10638
 
10623
10639
  const ViewletTitleBarButtonEvents = {
10624
10640
  __proto__: null,
10625
10641
  handleTitleBarButtonsClick,
10626
- returnValue: returnValue$2
10642
+ returnValue: returnValue$3
10627
10643
  };
10628
10644
 
10629
10645
  const Events$3 = ViewletTitleBarButtonEvents;
@@ -11044,20 +11060,20 @@ const handleClickCopy = event => {
11044
11060
  const handleFocusIn$1 = event => {
11045
11061
  return ['handleFocusIn'];
11046
11062
  };
11047
- const handleContextMenu = event => {
11063
+ const handleContextMenu$2 = event => {
11048
11064
  preventDefault(event);
11049
11065
  return [];
11050
11066
  };
11051
- const returnValue$1 = true;
11067
+ const returnValue$2 = true;
11052
11068
 
11053
11069
  const ViewletAboutEvents = {
11054
11070
  __proto__: null,
11055
11071
  handleClickClose,
11056
11072
  handleClickCopy,
11057
11073
  handleClickOk,
11058
- handleContextMenu,
11074
+ handleContextMenu: handleContextMenu$2,
11059
11075
  handleFocusIn: handleFocusIn$1,
11060
- returnValue: returnValue$1
11076
+ returnValue: returnValue$2
11061
11077
  };
11062
11078
 
11063
11079
  const setFocused = (state, selector) => {
@@ -11133,6 +11149,96 @@ const ViewletInlineDiffEditor = {
11133
11149
  setScrollBar: setScrollBar$2
11134
11150
  };
11135
11151
 
11152
+ const handleClickAt$1 = event => {
11153
+ const {
11154
+ clientX,
11155
+ clientY
11156
+ } = event;
11157
+ return ['handleClickAt', clientX, clientY];
11158
+ };
11159
+ const handleLoad$3 = event => {
11160
+ return ['handleLoad'];
11161
+ };
11162
+ const handleContextMenu$1 = event => {
11163
+ preventDefault(event);
11164
+ const {
11165
+ button,
11166
+ clientX,
11167
+ clientY
11168
+ } = event;
11169
+ return ['handleContextMenu', button, clientX, clientY];
11170
+ };
11171
+ const returnValue$1 = true;
11172
+
11173
+ const ViewletE2eTestsEvents = {
11174
+ __proto__: null,
11175
+ handleClickAt: handleClickAt$1,
11176
+ handleContextMenu: handleContextMenu$1,
11177
+ handleLoad: handleLoad$3,
11178
+ returnValue: returnValue$1
11179
+ };
11180
+
11181
+ const sendToIframe = (contentWindow, message, origin, transfer) => {
11182
+ try {
11183
+ console.log('send to iframe', message);
11184
+ contentWindow.postMessage(message, origin, transfer);
11185
+ } catch (error) {
11186
+ throw new VError$1(error, `Failed to send message to iframe`);
11187
+ }
11188
+ };
11189
+
11190
+ const handleLoad$2 = event => {
11191
+ console.log(event.target.src);
11192
+ send('E2eTests.handleLoad');
11193
+ };
11194
+ const setIframe$1 = (state, src, sandbox = []) => {
11195
+ if (!src) {
11196
+ return;
11197
+ }
11198
+ const $ExistingIframe = document.querySelector('.E2eTestsIframe');
11199
+ if ($ExistingIframe) {
11200
+ $ExistingIframe.remove();
11201
+ }
11202
+ const $Iframe = document.createElement('iframe');
11203
+ for (const element of sandbox) {
11204
+ $Iframe.sandbox.add(element);
11205
+ }
11206
+ $Iframe.className = 'E2eTestsIframe';
11207
+ $Iframe.src = src;
11208
+ console.log({
11209
+ src
11210
+ });
11211
+ $Iframe.addEventListener('load', handleLoad$2, {
11212
+ once: true
11213
+ });
11214
+ document.body.append($Iframe);
11215
+ };
11216
+ const setPort$1 = (state, portId, origin) => {
11217
+ const $ExistingIframe = document.querySelector('.E2eTestsIframe');
11218
+ if (!$ExistingIframe) {
11219
+ throw new Error('no iframe found');
11220
+ }
11221
+ const port = acquire(portId);
11222
+ // @ts-ignore
11223
+ const {
11224
+ contentWindow
11225
+ } = $ExistingIframe;
11226
+ const message = {
11227
+ jsonrpc: '2.0',
11228
+ method: 'handleIpc',
11229
+ params: [port]
11230
+ };
11231
+ const transfer = [port];
11232
+ sendToIframe(contentWindow, message, origin, transfer);
11233
+ };
11234
+
11235
+ const ViewletE2eTests = {
11236
+ __proto__: null,
11237
+ Events: ViewletE2eTestsEvents,
11238
+ setIframe: setIframe$1,
11239
+ setPort: setPort$1
11240
+ };
11241
+
11136
11242
  const handleClickAt = event => {
11137
11243
  const {
11138
11244
  clientX,
@@ -11140,29 +11246,80 @@ const handleClickAt = event => {
11140
11246
  } = event;
11141
11247
  return ['handleClickAt', clientX, clientY];
11142
11248
  };
11249
+ const handleLoad$1 = event => {
11250
+ return ['handleLoad'];
11251
+ };
11252
+ const handleContextMenu = event => {
11253
+ preventDefault(event);
11254
+ const {
11255
+ button,
11256
+ clientX,
11257
+ clientY
11258
+ } = event;
11259
+ return ['handleContextMenu', button, clientX, clientY];
11260
+ };
11143
11261
  const returnValue = true;
11144
11262
 
11145
- const ViewletE2eTestsEvents = {
11263
+ const ViewletE2eTestEvents = {
11146
11264
  __proto__: null,
11147
11265
  handleClickAt,
11266
+ handleContextMenu,
11267
+ handleLoad: handleLoad$1,
11148
11268
  returnValue
11149
11269
  };
11150
11270
 
11151
- const setIframe = (state, src) => {
11271
+ const handleLoad = event => {
11272
+ console.log(event.target.src);
11273
+ send('E2eTests.handleLoad');
11274
+ };
11275
+
11276
+ // TODO could use browser view when running in electron
11277
+ const setIframe = (state, src, sandbox = []) => {
11278
+ if (!src) {
11279
+ return;
11280
+ }
11152
11281
  const $ExistingIframe = document.querySelector('.E2eTestsIframe');
11153
11282
  if ($ExistingIframe) {
11154
11283
  $ExistingIframe.remove();
11155
11284
  }
11156
11285
  const $Iframe = document.createElement('iframe');
11286
+ for (const element of sandbox) {
11287
+ $Iframe.sandbox.add(element);
11288
+ }
11157
11289
  $Iframe.className = 'E2eTestsIframe';
11158
11290
  $Iframe.src = src;
11291
+ console.log({
11292
+ src
11293
+ });
11294
+ $Iframe.addEventListener('load', handleLoad, {
11295
+ once: true
11296
+ });
11159
11297
  document.body.append($Iframe);
11160
11298
  };
11299
+ const setPort = (state, portId, origin) => {
11300
+ const $ExistingIframe = document.querySelector('.E2eTestsIframe');
11301
+ if (!$ExistingIframe) {
11302
+ throw new Error('no iframe found');
11303
+ }
11304
+ const port = acquire(portId);
11305
+ // @ts-ignore
11306
+ const {
11307
+ contentWindow
11308
+ } = $ExistingIframe;
11309
+ const message = {
11310
+ jsonrpc: '2.0',
11311
+ method: 'handleIpc',
11312
+ params: [port]
11313
+ };
11314
+ const transfer = [port];
11315
+ sendToIframe(contentWindow, message, origin, transfer);
11316
+ };
11161
11317
 
11162
- const ViewletE2eTests = {
11318
+ const ViewletE2eTest = {
11163
11319
  __proto__: null,
11164
- Events: ViewletE2eTestsEvents,
11165
- setIframe
11320
+ Events: ViewletE2eTestEvents,
11321
+ setIframe,
11322
+ setPort
11166
11323
  };
11167
11324
 
11168
11325
  const getWorkerDisplayName = name => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "description": "",
5
5
  "main": "dist/diffWorkerMain.js",
6
6
  "type": "module",
@@ -18,22 +18,8 @@
18
18
  "url": "https://github.com/lvce-editor/renderer-process.git"
19
19
  },
20
20
  "nodemonConfig": {
21
- "ignore": [
22
- "**/build/**",
23
- "**/misc/**",
24
- "**/playground/**",
25
- "**/static/**",
26
- "**/test/**",
27
- "**/dist/**",
28
- "**/coverage/**",
29
- "**/distmin/**",
30
- "**/scripts/**",
31
- "**/node_modules/**",
32
- "**/coverage/**",
33
- "**/extensions/**",
34
- "**/renderer-worker/**",
35
- "**/renderer-process/**",
36
- "**/extension-host-worker/**"
21
+ "watch": [
22
+ "src"
37
23
  ],
38
24
  "ext": "ts,js",
39
25
  "exec": "node scripts/build.js"