@lvce-editor/renderer-process 14.0.0 → 14.0.2

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.
@@ -2038,7 +2038,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
2038
2038
  const responseMessage = await promise;
2039
2039
  return unwrapJsonRpcResult(responseMessage);
2040
2040
  };
2041
- const send$2 = (transport, method, ...params) => {
2041
+ const send$1 = (transport, method, ...params) => {
2042
2042
  const message = create$4$2(method, params);
2043
2043
  transport.send(message);
2044
2044
  };
@@ -2072,7 +2072,7 @@ const createRpc = ipc => {
2072
2072
  * @deprecated
2073
2073
  */
2074
2074
  send(method, ...params) {
2075
- send$2(ipc, method, ...params);
2075
+ send$1(ipc, method, ...params);
2076
2076
  },
2077
2077
  invoke(method, ...params) {
2078
2078
  return invoke$2(ipc, method, ...params);
@@ -2303,7 +2303,7 @@ const dispose$k = () => {
2303
2303
  state$7.rpc.dispose();
2304
2304
  }
2305
2305
  };
2306
- const send$1 = (method, ...params) => {
2306
+ const send = (method, ...params) => {
2307
2307
  // @ts-ignore
2308
2308
  state$7.rpc.send(method, ...params);
2309
2309
  };
@@ -2326,7 +2326,7 @@ const RendererWorker = {
2326
2326
  hydrate: hydrate$3,
2327
2327
  invoke: invoke$1,
2328
2328
  invokeAndTransfer,
2329
- send: send$1,
2329
+ send,
2330
2330
  sendAndTransfer,
2331
2331
  state: state$7
2332
2332
  };
@@ -2467,7 +2467,7 @@ const handleNotificationClick = event => {
2467
2467
  switch ($Target.className) {
2468
2468
  case 'NotificationOption':
2469
2469
  const index = findIndex$1($Target);
2470
- send$1(/* Notification.handleClick */'Notification.handleClick', /* index */index);
2470
+ send(/* Notification.handleClick */'Notification.handleClick', /* index */index);
2471
2471
  break;
2472
2472
  }
2473
2473
  };
@@ -2745,7 +2745,7 @@ const handleMouseDown$4 = event => {
2745
2745
  }
2746
2746
  preventDefault(event);
2747
2747
  const level = getLevel($Menu);
2748
- send$1(/* Menu.handleClick */'Menu.selectIndex', /* level */level, /* index */index);
2748
+ send(/* Menu.handleClick */'Menu.selectIndex', /* level */level, /* index */index);
2749
2749
  };
2750
2750
 
2751
2751
  // const handleKeyDown = (event) => {
@@ -2790,7 +2790,7 @@ const handleMouseEnter = event => {
2790
2790
  return;
2791
2791
  }
2792
2792
  const level = getLevel($Menu);
2793
- send$1(/* Menu.handleMouseEnter */'Menu.handleMouseEnter', /* level */level, /* index */index, /* x */clientX, /* y */clientY, /* timeStamp */timeStamp);
2793
+ send(/* Menu.handleMouseEnter */'Menu.handleMouseEnter', /* level */level, /* index */index, /* x */clientX, /* y */clientY, /* timeStamp */timeStamp);
2794
2794
  };
2795
2795
  const handleMouseLeave = event => {
2796
2796
  const $RelatedTarget = event.relatedTarget;
@@ -2852,7 +2852,7 @@ const focusIndex = (level, oldFocusedIndex, newFocusedIndex) => {
2852
2852
  const handleBackDropMouseDown = event => {
2853
2853
  preventDefault(event);
2854
2854
  stopPropagation(event);
2855
- send$1(/* Menu.hide */'Menu.hide');
2855
+ send(/* Menu.hide */'Menu.hide');
2856
2856
  };
2857
2857
  const handleContextMenu$b = event => {
2858
2858
  preventDefault(event);
@@ -2883,7 +2883,7 @@ const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom, mous
2883
2883
  append$1($Menu);
2884
2884
  if (level === 0) {
2885
2885
  focus$h($Menu);
2886
- send$1('Focus.setFocus', FocusMenu);
2886
+ send('Focus.setFocus', FocusMenu);
2887
2887
  }
2888
2888
  };
2889
2889
  const hideSubMenu = level => {
@@ -3204,7 +3204,7 @@ const KeyBoardActions = {
3204
3204
  press
3205
3205
  };
3206
3206
 
3207
- const toHaveCount = (elements, {
3207
+ const toHaveCount$1 = (elements, {
3208
3208
  count
3209
3209
  }) => {
3210
3210
  return elements.length === count;
@@ -3216,7 +3216,7 @@ const toBeHidden = elements => {
3216
3216
  const MultiElementConditions = {
3217
3217
  __proto__: null,
3218
3218
  toBeHidden,
3219
- toHaveCount
3219
+ toHaveCount: toHaveCount$1
3220
3220
  };
3221
3221
 
3222
3222
  const htmlElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdo', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr'];
@@ -3305,7 +3305,7 @@ const toHaveValue = (element, {
3305
3305
  }) => {
3306
3306
  return element.value === value;
3307
3307
  };
3308
- const toHaveText = (element, {
3308
+ const toHaveText$1 = (element, {
3309
3309
  text
3310
3310
  }) => {
3311
3311
  return element.textContent === text;
@@ -3315,27 +3315,27 @@ const toContainText = (element, {
3315
3315
  }) => {
3316
3316
  return element.textContent.includes(text);
3317
3317
  };
3318
- const toHaveAttribute = (element, {
3318
+ const toHaveAttribute$1 = (element, {
3319
3319
  key,
3320
3320
  value
3321
3321
  }) => {
3322
3322
  const attribute = element.getAttribute(key);
3323
3323
  return attribute === value;
3324
3324
  };
3325
- const toBeFocused = element => {
3325
+ const toBeFocused$1 = element => {
3326
3326
  return element === document.activeElement;
3327
3327
  };
3328
- const toHaveClass = (element, {
3328
+ const toHaveClass$1 = (element, {
3329
3329
  className
3330
3330
  }) => {
3331
3331
  return element.classList.contains(className);
3332
3332
  };
3333
- const toHaveId = (element, {
3333
+ const toHaveId$1 = (element, {
3334
3334
  id
3335
3335
  }) => {
3336
3336
  return element.id === id;
3337
3337
  };
3338
- const toHaveCss = (element, {
3338
+ const toHaveCss$1 = (element, {
3339
3339
  key,
3340
3340
  value
3341
3341
  }) => {
@@ -3349,15 +3349,134 @@ const toHaveCss = (element, {
3349
3349
 
3350
3350
  const SingleElementConditions = {
3351
3351
  __proto__: null,
3352
- toBeFocused,
3352
+ toBeFocused: toBeFocused$1,
3353
3353
  toBeVisible,
3354
3354
  toContainText,
3355
+ toHaveAttribute: toHaveAttribute$1,
3356
+ toHaveClass: toHaveClass$1,
3357
+ toHaveCss: toHaveCss$1,
3358
+ toHaveId: toHaveId$1,
3359
+ toHaveText: toHaveText$1,
3360
+ toHaveValue
3361
+ };
3362
+
3363
+ const toHaveText = locator => {
3364
+ const element = querySelectorWithOptions(locator._selector, {
3365
+ nth: locator._nth,
3366
+ hasText: locator._hasText
3367
+ });
3368
+ if (!element) {
3369
+ return {
3370
+ wasFound: false,
3371
+ actual: ''
3372
+ };
3373
+ }
3374
+ return {
3375
+ wasFound: true,
3376
+ actual: element.textContent
3377
+ };
3378
+ };
3379
+ const toHaveAttribute = (locator, {
3380
+ key,
3381
+ value
3382
+ }) => {
3383
+ const element = querySelectorWithOptions(locator._selector, {
3384
+ nth: locator._nth,
3385
+ hasText: locator._hasText
3386
+ });
3387
+ if (!element) {
3388
+ return {
3389
+ wasFound: false,
3390
+ actual: ''
3391
+ };
3392
+ }
3393
+ const actual = element.getAttribute(key);
3394
+ return {
3395
+ wasFound: true,
3396
+ actual
3397
+ };
3398
+ };
3399
+ const toHaveCount = locator => {
3400
+ const elements = querySelector(locator._selector);
3401
+ const actualCount = elements.length;
3402
+ return {
3403
+ actual: actualCount
3404
+ };
3405
+ };
3406
+ const stringifyElement = element => {
3407
+ if (element.id) {
3408
+ return `#${element.id}`;
3409
+ }
3410
+ if (element.className) {
3411
+ return `.${element.className}`;
3412
+ }
3413
+ if (element === document.body) {
3414
+ return 'document.body';
3415
+ }
3416
+ return element.tagName;
3417
+ };
3418
+ const toBeFocused = locator => {
3419
+ const activeElement = document.activeElement;
3420
+ const stringifiedActiveElement = stringifyElement(activeElement);
3421
+ return {
3422
+ actual: stringifiedActiveElement
3423
+ };
3424
+ };
3425
+ const toHaveClass = (locator, {
3426
+ className
3427
+ }) => {
3428
+ const [element] = querySelector(locator._selector);
3429
+ if (!element) {
3430
+ return {
3431
+ wasFound: false,
3432
+ actual: ''
3433
+ };
3434
+ }
3435
+ return {
3436
+ wasFound: true,
3437
+ actual: className
3438
+ };
3439
+ };
3440
+ const toHaveId = locator => {
3441
+ const [element] = querySelector(locator._selector);
3442
+ if (!element) {
3443
+ return {
3444
+ wasFound: false,
3445
+ actual: ''
3446
+ };
3447
+ }
3448
+ return {
3449
+ wasFound: true,
3450
+ actual: element.id
3451
+ };
3452
+ };
3453
+ const toHaveCss = (locator, {
3454
+ key
3455
+ }) => {
3456
+ const [element] = querySelector(locator._selector);
3457
+ if (!element) {
3458
+ return {
3459
+ wasFound: false,
3460
+ actual: ''
3461
+ };
3462
+ }
3463
+ const style = getComputedStyle(element);
3464
+ const actual = style[key];
3465
+ return {
3466
+ wasFound: true,
3467
+ actual
3468
+ };
3469
+ };
3470
+
3471
+ const ConditionValues = {
3472
+ __proto__: null,
3473
+ toBeFocused,
3355
3474
  toHaveAttribute,
3356
3475
  toHaveClass,
3476
+ toHaveCount,
3357
3477
  toHaveCss,
3358
3478
  toHaveId,
3359
- toHaveText,
3360
- toHaveValue
3479
+ toHaveText
3361
3480
  };
3362
3481
 
3363
3482
  // TODO this should also come in via options
@@ -3476,6 +3595,10 @@ const checkMultiElementCondition = async (locator, fnName, options) => {
3476
3595
  error: true
3477
3596
  };
3478
3597
  };
3598
+ const checkConditionError = (fnName, ...params) => {
3599
+ const fn = ConditionValues[fnName];
3600
+ return fn(...params);
3601
+ };
3479
3602
 
3480
3603
  const webViews = Object.create(null);
3481
3604
  const set$4 = (id, webView) => {
@@ -3699,7 +3822,7 @@ const ViewletActivityBar = {
3699
3822
 
3700
3823
  const executeViewletCommand = (uid, command, ...args) => {
3701
3824
  number(uid);
3702
- send$1('Viewlet.executeViewletCommand', uid, command, ...args);
3825
+ send('Viewlet.executeViewletCommand', uid, command, ...args);
3703
3826
  };
3704
3827
 
3705
3828
  const nameAnonymousFunction = (fn, name) => {
@@ -3900,7 +4023,7 @@ const create$B = (pointerDown, pointerMove, pointerUp) => {
3900
4023
  return;
3901
4024
  }
3902
4025
  const uid = fromEvent(event);
3903
- send$1('Viewlet.executeViewletCommand', uid, ...message);
4026
+ send('Viewlet.executeViewletCommand', uid, ...message);
3904
4027
  };
3905
4028
  const handlePointerMove = event => {
3906
4029
  shared(pointerMove, event);
@@ -4105,7 +4228,7 @@ const create$Button = (label, icon) => {
4105
4228
  };
4106
4229
 
4107
4230
  const handleClick$5 = index => {
4108
- send$1(/* Dialog.handleClick */'Dialog.handleClick', /* index */index);
4231
+ send(/* Dialog.handleClick */'Dialog.handleClick', /* index */index);
4109
4232
  };
4110
4233
 
4111
4234
  const handleClick$4 = event => {
@@ -4380,7 +4503,7 @@ const sendToIframe = (contentWindow, message, origin, transfer) => {
4380
4503
  const handleLoad$1 = event => {
4381
4504
  // eslint-disable-next-line no-console
4382
4505
  console.log(event.target.src);
4383
- send$1('E2eTests.handleLoad');
4506
+ send('E2eTests.handleLoad');
4384
4507
  };
4385
4508
  const setIframe$1 = (state, src, sandbox = []) => {
4386
4509
  if (!src) {
@@ -5094,7 +5217,7 @@ const getWrappedListener = (listener, returnValue) => {
5094
5217
  if (result.length === 0) {
5095
5218
  return;
5096
5219
  }
5097
- send$1('Viewlet.executeViewletCommand', uid, ...result);
5220
+ send('Viewlet.executeViewletCommand', uid, ...result);
5098
5221
  };
5099
5222
  nameAnonymousFunction(wrapped, listener.name);
5100
5223
  cache.set(listener, wrapped);
@@ -6202,9 +6325,9 @@ const handleLocationsMouseDown = event => {
6202
6325
  const $Target = event.target;
6203
6326
  if ($Target.classList.contains('TreeItem')) {
6204
6327
  const index = getNodeIndex($Target);
6205
- send$1(/* ViewletLocations.selectIndex */'Locations.selectIndex', /* index */index);
6328
+ send(/* ViewletLocations.selectIndex */'Locations.selectIndex', /* index */index);
6206
6329
  } else if ($Target.classList.contains('LocationList')) {
6207
- send$1(/* ViewletLocations.focusIndex */'Locations.focusIndex', /* index */-1);
6330
+ send(/* ViewletLocations.focusIndex */'Locations.focusIndex', /* index */-1);
6208
6331
  }
6209
6332
  };
6210
6333
 
@@ -6242,7 +6365,7 @@ const focus$a = state => {
6242
6365
  } = state;
6243
6366
  $Locations.classList.add('FocusOutline');
6244
6367
  $Locations.focus();
6245
- send$1('Focus.setFocus', FocusLocationList);
6368
+ send('Focus.setFocus', FocusLocationList);
6246
6369
  };
6247
6370
 
6248
6371
  const ViewletImplementations = {
@@ -6756,7 +6879,7 @@ const isMatchingKeyBinding = (identifiers, identifier) => {
6756
6879
  };
6757
6880
 
6758
6881
  const handleMatchingKeyBinding = identifier => {
6759
- send$1(/* KeyBindings.handleKeyBinding */'KeyBindings.handleKeyBinding', /* keyBinding */identifier);
6882
+ send(/* KeyBindings.handleKeyBinding */'KeyBindings.handleKeyBinding', /* keyBinding */identifier);
6760
6883
  };
6761
6884
  const handleKeyDown$2 = event => {
6762
6885
  const identifier = getKeyBindingIdentifier(event);
@@ -6771,27 +6894,27 @@ const handleKeyDown$2 = event => {
6771
6894
  const handleKeyUp$1 = event => {};
6772
6895
 
6773
6896
  const handleSashPointerMove$1 = (x, y) => {
6774
- send$1('Layout.handleSashPointerMove', x, y);
6897
+ send('Layout.handleSashPointerMove', x, y);
6775
6898
  };
6776
6899
  const handleSashPointerDown$1 = id => {
6777
- send$1('Layout.handleSashPointerDown', id);
6900
+ send('Layout.handleSashPointerDown', id);
6778
6901
  };
6779
6902
 
6780
6903
  // TODO send component uid
6781
6904
  const handleSashPointerUp = id => {
6782
- send$1('Layout.handleSashPointerUp', id);
6905
+ send('Layout.handleSashPointerUp', id);
6783
6906
  };
6784
6907
  const handleSashDoubleClick$1 = id => {
6785
- send$1('Layout.handleSashDoubleClick', id);
6908
+ send('Layout.handleSashDoubleClick', id);
6786
6909
  };
6787
6910
  const handleResize$1 = (width, height) => {
6788
- send$1('Layout.handleResize', width, height);
6911
+ send('Layout.handleResize', width, height);
6789
6912
  };
6790
6913
  const handleFocus$3 = () => {
6791
- send$1('Layout.handleFocus');
6914
+ send('Layout.handleFocus');
6792
6915
  };
6793
6916
  const handleBlur$4 = () => {
6794
- send$1('Layout.handleBlur');
6917
+ send('Layout.handleBlur');
6795
6918
  };
6796
6919
 
6797
6920
  const handleSashPointerMove = event => {
@@ -7315,7 +7438,7 @@ const handleError$2 = (state, error) => {
7315
7438
  const focus$8 = state => {
7316
7439
  object(state);
7317
7440
  focus$h(state.$ViewletOutputContent);
7318
- send$1('Focus.setFocus', FocusOutput);
7441
+ send('Focus.setFocus', FocusOutput);
7319
7442
  };
7320
7443
 
7321
7444
  // TODO handle case when output is opened -> find widget is opened -> output is disposed before find widget is ready
@@ -7709,22 +7832,22 @@ const ViewletSideBar = {
7709
7832
  };
7710
7833
 
7711
7834
  const handleInput$3 = value => {
7712
- send$1('SimpleBrowser.handleInput', value);
7835
+ send('SimpleBrowser.handleInput', value);
7713
7836
  };
7714
7837
  const forward = () => {
7715
- send$1('SimpleBrowser.forward');
7838
+ send('SimpleBrowser.forward');
7716
7839
  };
7717
7840
  const backward = () => {
7718
- send$1('SimpleBrowser.backward');
7841
+ send('SimpleBrowser.backward');
7719
7842
  };
7720
7843
  const reload$1 = () => {
7721
- send$1('SimpleBrowser.reload');
7844
+ send('SimpleBrowser.reload');
7722
7845
  };
7723
7846
  const cancelNavigation = () => {
7724
- send$1('SimpleBrowser.cancelNavigation');
7847
+ send('SimpleBrowser.cancelNavigation');
7725
7848
  };
7726
7849
  const openExternal = () => {
7727
- send$1('SimpleBrowser.openExternal');
7850
+ send('SimpleBrowser.openExternal');
7728
7851
  };
7729
7852
 
7730
7853
  const handleInput$2 = event => {
@@ -7740,7 +7863,7 @@ const handleFocus$1 = event => {
7740
7863
  const {
7741
7864
  target
7742
7865
  } = event;
7743
- send$1('Focus.setFocus', FocusSimpleBrowserInput);
7866
+ send('Focus.setFocus', FocusSimpleBrowserInput);
7744
7867
  setTimeout(() => {
7745
7868
  target.select();
7746
7869
  });
@@ -8435,7 +8558,7 @@ const ViewletTitleBarTitle = {
8435
8558
  };
8436
8559
 
8437
8560
  const handleVideoError$1 = (code, message) => {
8438
- send$1('Video.handleVideoError', code, message);
8561
+ send('Video.handleVideoError', code, message);
8439
8562
  };
8440
8563
 
8441
8564
  const handleVideoError = event => {
@@ -8861,19 +8984,6 @@ const refresh$1 = (viewletId, viewletContext) => {
8861
8984
  state$1.refreshContext[viewletId] = viewletContext;
8862
8985
  }
8863
8986
  };
8864
-
8865
- // TODO handle error when viewlet creation fails
8866
-
8867
- // TODO remove send -> use invoke instead
8868
- const send = (viewletId, method, ...args) => {
8869
- const instance = state$1.instances[viewletId];
8870
- if (instance) {
8871
- instance.factory[method](...args);
8872
- } else {
8873
- // TODO
8874
- warn$1('instance not present');
8875
- }
8876
- };
8877
8987
  const specialIds = new Set(['TitleBar', 'SideBar', 'Main', 'ActivityBar', 'StatusBar', 'Panel']);
8878
8988
  const isSpecial = id => {
8879
8989
  return specialIds.has(id);
@@ -9334,7 +9444,7 @@ const close = () => {
9334
9444
  // window.close()
9335
9445
  };
9336
9446
  const sendVisibilityChangeHint = () => {
9337
- send$1(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9447
+ send(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9338
9448
  };
9339
9449
  const handleBeforeUnload = () => {
9340
9450
  sendVisibilityChangeHint();
@@ -9544,6 +9654,7 @@ const commandMap = {
9544
9654
  'TestFrameWork.showOverlay': showOverlay,
9545
9655
  'TestFrameWork.transfer': transfer,
9546
9656
  'TestFrameWork.transferToWebView': transferToWebView,
9657
+ 'TestFrameWork.checkConditionError': checkConditionError,
9547
9658
  'Viewlet.addKeyBindings': addKeyBindings,
9548
9659
  'Viewlet.appendViewlet': appendViewlet,
9549
9660
  'Viewlet.dispose': dispose$3,
@@ -9557,7 +9668,7 @@ const commandMap = {
9557
9668
  'Viewlet.refresh': refresh$1,
9558
9669
  'Viewlet.registerEventListeners': registerEventListeners,
9559
9670
  'Viewlet.removeKeyBindings': removeKeyBindings,
9560
- 'Viewlet.send': send,
9671
+ 'Viewlet.send': invoke,
9561
9672
  'Viewlet.sendMultiple': sendMultiple,
9562
9673
  'Viewlet.setBounds': setBounds$1,
9563
9674
  'Viewlet.show': show,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "14.0.0",
3
+ "version": "14.0.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lvce-editor",