@lvce-editor/renderer-process 15.6.0 → 16.1.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.
@@ -3436,42 +3436,6 @@ const start = async (id, options) => {
3436
3436
  }
3437
3437
  };
3438
3438
 
3439
- const getTimeStamp = () => {
3440
- return performance.now();
3441
- };
3442
-
3443
- const waitForMutation = async maxDelay => {
3444
- const disposables = [];
3445
- await Promise.race([new Promise(resolve => {
3446
- const timeout = setTimeout(resolve, maxDelay);
3447
- // @ts-expect-error
3448
- disposables.push(() => {
3449
- clearTimeout(timeout);
3450
- });
3451
- }), new Promise(resolve => {
3452
- const callback = mutations => {
3453
- resolve(undefined);
3454
- };
3455
- const observer = new MutationObserver(callback);
3456
- observer.observe(document.body, {
3457
- childList: true,
3458
- attributes: true,
3459
- characterData: true,
3460
- subtree: true,
3461
- attributeOldValue: true,
3462
- characterDataOldValue: true
3463
- });
3464
- // @ts-expect-error
3465
- disposables.push(() => {
3466
- observer.disconnect();
3467
- });
3468
- })]);
3469
- for (const disposable of disposables) {
3470
- // @ts-expect-error
3471
- disposable();
3472
- }
3473
- };
3474
-
3475
3439
  const getEventClass = eventType => {
3476
3440
  switch (eventType) {
3477
3441
  case Wheel:
@@ -3543,32 +3507,6 @@ const ElementActions = {
3543
3507
  type
3544
3508
  };
3545
3509
 
3546
- const press = options => {
3547
- const element = document.activeElement;
3548
- keyDown(element, options);
3549
- keyUp(element, options);
3550
- };
3551
-
3552
- const KeyBoardActions = {
3553
- __proto__: null,
3554
- press
3555
- };
3556
-
3557
- const toHaveCount$1 = (elements, {
3558
- count
3559
- }) => {
3560
- return elements.length === count;
3561
- };
3562
- const toBeHidden = elements => {
3563
- return elements.length === 0;
3564
- };
3565
-
3566
- const MultiElementConditions = {
3567
- __proto__: null,
3568
- toBeHidden,
3569
- toHaveCount: toHaveCount$1
3570
- };
3571
-
3572
3510
  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'];
3573
3511
 
3574
3512
  const querySelectorByText = (root, text) => {
@@ -3644,81 +3582,23 @@ const querySelectorWithOptions = (selector, {
3644
3582
  return element;
3645
3583
  };
3646
3584
 
3647
- const toBeVisible = element => {
3648
- if (typeof element.isVisible === 'function') {
3649
- return element.isVisible();
3650
- }
3651
- return element.isConnected;
3652
- };
3653
- const toHaveValue = (element, {
3654
- value
3655
- }) => {
3656
- return element.value === value;
3657
- };
3658
- const toHaveText$1 = (element, {
3659
- text
3660
- }) => {
3661
- return element.textContent === text;
3662
- };
3663
- const toContainText = (element, {
3664
- text
3665
- }) => {
3666
- return element.textContent.includes(text);
3667
- };
3668
- const toHaveAttribute$1 = (element, {
3669
- key,
3670
- value
3671
- }) => {
3672
- const attribute = element.getAttribute(key);
3673
- return attribute === value;
3674
- };
3675
- const toHaveJSProperty$1 = (element, {
3676
- key,
3677
- value
3678
- }) => {
3679
- const attribute = element[key];
3680
- return attribute === value;
3681
- };
3682
- const toBeFocused$1 = element => {
3683
- return element === document.activeElement;
3684
- };
3685
- const toHaveClass$1 = (element, {
3686
- className
3687
- }) => {
3688
- return element.classList.contains(className);
3689
- };
3690
- const toHaveId$1 = (element, {
3691
- id
3692
- }) => {
3693
- return element.id === id;
3694
- };
3695
- const toHaveCss$1 = (element, {
3696
- key,
3697
- value
3698
- }) => {
3699
- const style = getComputedStyle(element);
3700
- const actualValue = style[key];
3701
- if (value instanceof RegExp) {
3702
- return value.test(actualValue);
3585
+ const performAction2 = async (locator, fnName, options) => {
3586
+ object(locator);
3587
+ string(fnName);
3588
+ object(options);
3589
+ const fn = ElementActions[fnName];
3590
+ const element = querySelectorWithOptions(locator._selector, {
3591
+ hasText: locator._hasText,
3592
+ nth: locator._nth
3593
+ });
3594
+ if (!element) {
3595
+ throw new Error(`element not found`);
3703
3596
  }
3704
- return actualValue === value;
3597
+ fn(element, options);
3598
+ return;
3705
3599
  };
3706
3600
 
3707
- const SingleElementConditions = {
3708
- __proto__: null,
3709
- toBeFocused: toBeFocused$1,
3710
- toBeVisible,
3711
- toContainText,
3712
- toHaveAttribute: toHaveAttribute$1,
3713
- toHaveClass: toHaveClass$1,
3714
- toHaveCss: toHaveCss$1,
3715
- toHaveId: toHaveId$1,
3716
- toHaveJSProperty: toHaveJSProperty$1,
3717
- toHaveText: toHaveText$1,
3718
- toHaveValue
3719
- };
3720
-
3721
- const toHaveText = locator => {
3601
+ const toHaveText$1 = locator => {
3722
3602
  const element = querySelectorWithOptions(locator._selector, {
3723
3603
  nth: locator._nth,
3724
3604
  hasText: locator._hasText
@@ -3734,7 +3614,7 @@ const toHaveText = locator => {
3734
3614
  actual: element.textContent
3735
3615
  };
3736
3616
  };
3737
- const toHaveAttribute = (locator, {
3617
+ const toHaveAttribute$1 = (locator, {
3738
3618
  key,
3739
3619
  value
3740
3620
  }) => {
@@ -3754,7 +3634,7 @@ const toHaveAttribute = (locator, {
3754
3634
  actual
3755
3635
  };
3756
3636
  };
3757
- const toHaveCount = locator => {
3637
+ const toHaveCount$1 = locator => {
3758
3638
  const elements = querySelector(locator._selector);
3759
3639
  const actualCount = elements.length;
3760
3640
  return {
@@ -3773,14 +3653,14 @@ const stringifyElement = element => {
3773
3653
  }
3774
3654
  return element.tagName;
3775
3655
  };
3776
- const toBeFocused = locator => {
3656
+ const toBeFocused$1 = locator => {
3777
3657
  const activeElement = document.activeElement;
3778
3658
  const stringifiedActiveElement = stringifyElement(activeElement);
3779
3659
  return {
3780
3660
  actual: stringifiedActiveElement
3781
3661
  };
3782
3662
  };
3783
- const toHaveClass = (locator, {
3663
+ const toHaveClass$1 = (locator, {
3784
3664
  className
3785
3665
  }) => {
3786
3666
  const [element] = querySelector(locator._selector);
@@ -3795,7 +3675,7 @@ const toHaveClass = (locator, {
3795
3675
  actual: className
3796
3676
  };
3797
3677
  };
3798
- const toHaveId = locator => {
3678
+ const toHaveId$1 = locator => {
3799
3679
  const [element] = querySelector(locator._selector);
3800
3680
  if (!element) {
3801
3681
  return {
@@ -3808,7 +3688,7 @@ const toHaveId = locator => {
3808
3688
  actual: element.id
3809
3689
  };
3810
3690
  };
3811
- const toHaveCss = (locator, {
3691
+ const toHaveCss$1 = (locator, {
3812
3692
  key
3813
3693
  }) => {
3814
3694
  const [element] = querySelector(locator._selector);
@@ -3825,7 +3705,7 @@ const toHaveCss = (locator, {
3825
3705
  actual
3826
3706
  };
3827
3707
  };
3828
- const toHaveJSProperty = (locator, {
3708
+ const toHaveJSProperty$1 = (locator, {
3829
3709
  key
3830
3710
  }) => {
3831
3711
  const [element] = querySelector(locator._selector);
@@ -3843,39 +3723,115 @@ const toHaveJSProperty = (locator, {
3843
3723
  };
3844
3724
 
3845
3725
  const ConditionValues = {
3726
+ __proto__: null,
3727
+ toBeFocused: toBeFocused$1,
3728
+ toHaveAttribute: toHaveAttribute$1,
3729
+ toHaveClass: toHaveClass$1,
3730
+ toHaveCount: toHaveCount$1,
3731
+ toHaveCss: toHaveCss$1,
3732
+ toHaveId: toHaveId$1,
3733
+ toHaveJSProperty: toHaveJSProperty$1,
3734
+ toHaveText: toHaveText$1
3735
+ };
3736
+
3737
+ const press = options => {
3738
+ const element = document.activeElement;
3739
+ keyDown(element, options);
3740
+ keyUp(element, options);
3741
+ };
3742
+
3743
+ const KeyBoardActions = {
3744
+ __proto__: null,
3745
+ press
3746
+ };
3747
+
3748
+ const toHaveCount = (elements, {
3749
+ count
3750
+ }) => {
3751
+ return elements.length === count;
3752
+ };
3753
+ const toBeHidden = elements => {
3754
+ return elements.length === 0;
3755
+ };
3756
+
3757
+ const MultiElementConditions = {
3758
+ __proto__: null,
3759
+ toBeHidden,
3760
+ toHaveCount
3761
+ };
3762
+
3763
+ const toBeVisible = element => {
3764
+ if (typeof element.isVisible === 'function') {
3765
+ return element.isVisible();
3766
+ }
3767
+ return element.isConnected;
3768
+ };
3769
+ const toHaveValue = (element, {
3770
+ value
3771
+ }) => {
3772
+ return element.value === value;
3773
+ };
3774
+ const toHaveText = (element, {
3775
+ text
3776
+ }) => {
3777
+ return element.textContent === text;
3778
+ };
3779
+ const toContainText = (element, {
3780
+ text
3781
+ }) => {
3782
+ return element.textContent.includes(text);
3783
+ };
3784
+ const toHaveAttribute = (element, {
3785
+ key,
3786
+ value
3787
+ }) => {
3788
+ const attribute = element.getAttribute(key);
3789
+ return attribute === value;
3790
+ };
3791
+ const toHaveJSProperty = (element, {
3792
+ key,
3793
+ value
3794
+ }) => {
3795
+ const attribute = element[key];
3796
+ return attribute === value;
3797
+ };
3798
+ const toBeFocused = element => {
3799
+ return element === document.activeElement;
3800
+ };
3801
+ const toHaveClass = (element, {
3802
+ className
3803
+ }) => {
3804
+ return element.classList.contains(className);
3805
+ };
3806
+ const toHaveId = (element, {
3807
+ id
3808
+ }) => {
3809
+ return element.id === id;
3810
+ };
3811
+ const toHaveCss = (element, {
3812
+ key,
3813
+ value
3814
+ }) => {
3815
+ const style = getComputedStyle(element);
3816
+ const actualValue = style[key];
3817
+ if (value instanceof RegExp) {
3818
+ return value.test(actualValue);
3819
+ }
3820
+ return actualValue === value;
3821
+ };
3822
+
3823
+ const SingleElementConditions = {
3846
3824
  __proto__: null,
3847
3825
  toBeFocused,
3826
+ toBeVisible,
3827
+ toContainText,
3848
3828
  toHaveAttribute,
3849
3829
  toHaveClass,
3850
- toHaveCount,
3851
3830
  toHaveCss,
3852
3831
  toHaveId,
3853
3832
  toHaveJSProperty,
3854
- toHaveText
3855
- };
3856
-
3857
- // TODO this should also come in via options
3858
- const maxTimeout$1 = 2000;
3859
- const performAction2 = async (locator, fnName, options) => {
3860
- object(locator);
3861
- string(fnName);
3862
- object(options);
3863
- const startTime = getTimeStamp();
3864
- const endTime = startTime + maxTimeout$1;
3865
- let currentTime = startTime;
3866
- const fn = ElementActions[fnName];
3867
- while (currentTime < endTime) {
3868
- const element = querySelectorWithOptions(locator._selector, {
3869
- hasText: locator._hasText,
3870
- nth: locator._nth
3871
- });
3872
- if (element) {
3873
- fn(element, options);
3874
- return;
3875
- }
3876
- await waitForMutation(100);
3877
- currentTime = getTimeStamp();
3878
- }
3833
+ toHaveText,
3834
+ toHaveValue
3879
3835
  };
3880
3836
 
3881
3837
  const create$Overlay = () => {
@@ -3899,26 +3855,21 @@ const showOverlay = (state, background, text) => {
3899
3855
  $TestOverlay.textContent = text;
3900
3856
  document.body.append($TestOverlay);
3901
3857
  };
3902
- const maxTimeout = 2000;
3903
3858
  const performAction = async (locator, fnName, options) => {
3904
3859
  object(locator);
3905
3860
  string(fnName);
3906
3861
  object(options);
3907
- const startTime = getTimeStamp();
3908
- const endTime = startTime + maxTimeout;
3909
- let currentTime = startTime;
3910
3862
  const fn = ElementActions[fnName];
3911
- while (currentTime < endTime) {
3912
- const element = querySelectorWithOptions(locator._selector, {
3913
- hasText: locator._hasText,
3914
- nth: locator._nth
3915
- });
3916
- if (element) {
3917
- fn(element, options);
3918
- return;
3919
- }
3920
- await waitForMutation(100);
3921
- currentTime = getTimeStamp();
3863
+ const element = querySelectorWithOptions(locator._selector, {
3864
+ hasText: locator._hasText,
3865
+ nth: locator._nth
3866
+ });
3867
+ if (!element) {
3868
+ throw new Error(`element not found`);
3869
+ }
3870
+ if (element) {
3871
+ fn(element, options);
3872
+ return;
3922
3873
  }
3923
3874
  };
3924
3875
  const performKeyBoardAction = (fnName, options) => {
@@ -3926,45 +3877,31 @@ const performKeyBoardAction = (fnName, options) => {
3926
3877
  fn(options);
3927
3878
  };
3928
3879
  const checkSingleElementCondition = async (locator, fnName, options) => {
3929
- const startTime = getTimeStamp();
3930
- const endTime = startTime + maxTimeout;
3931
- let currentTime = startTime;
3932
3880
  const fn = SingleElementConditions[fnName];
3933
- while (currentTime < endTime) {
3934
- const element = querySelectorWithOptions(locator._selector, {
3935
- hasText: locator._hasText,
3936
- nth: locator._nth
3937
- });
3938
- if (element) {
3939
- const successful = fn(element, options);
3940
- if (successful) {
3941
- return {
3942
- error: false
3943
- };
3944
- }
3881
+ const element = querySelectorWithOptions(locator._selector, {
3882
+ hasText: locator._hasText,
3883
+ nth: locator._nth
3884
+ });
3885
+ if (element) {
3886
+ const successful = fn(element, options);
3887
+ if (successful) {
3888
+ return {
3889
+ error: false
3890
+ };
3945
3891
  }
3946
- await waitForMutation(100);
3947
- currentTime = getTimeStamp();
3948
3892
  }
3949
3893
  return {
3950
3894
  error: true
3951
3895
  };
3952
3896
  };
3953
3897
  const checkMultiElementCondition = async (locator, fnName, options) => {
3954
- const startTime = getTimeStamp();
3955
- const endTime = startTime + maxTimeout;
3956
- let currentTime = startTime;
3957
3898
  const fn = MultiElementConditions[fnName];
3958
- while (currentTime < endTime) {
3959
- const elements = querySelector(locator._selector);
3960
- const successful = fn(elements, options);
3961
- if (successful) {
3962
- return {
3963
- error: false
3964
- };
3965
- }
3966
- await waitForMutation(100);
3967
- currentTime = getTimeStamp();
3899
+ const elements = querySelector(locator._selector);
3900
+ const successful = fn(elements, options);
3901
+ if (successful) {
3902
+ return {
3903
+ error: false
3904
+ };
3968
3905
  }
3969
3906
  return {
3970
3907
  error: true
@@ -6571,6 +6508,7 @@ const getSashId = $Target => {
6571
6508
  const Backspace$1 = 'Backspace';
6572
6509
  const Tab$1 = 'Tab';
6573
6510
  const Space$1 = ' ';
6511
+ const Space2 = 'Space';
6574
6512
  const Enter$1 = 'Enter';
6575
6513
  const Escape$1 = 'Escape';
6576
6514
  const PageUp$1 = 'PageUp';
@@ -6758,6 +6696,7 @@ const getKeyCode = key => {
6758
6696
  case Enter$1:
6759
6697
  return Enter;
6760
6698
  case Space$1:
6699
+ case Space2:
6761
6700
  return Space;
6762
6701
  case PageUp$1:
6763
6702
  return PageUp;
@@ -6934,10 +6873,13 @@ const CtrlCmd = 1 << 11 >>> 0;
6934
6873
  const Shift = 1 << 10 >>> 0;
6935
6874
  const Alt = 1 << 9 >>> 0;
6936
6875
 
6937
- const normalizeKey = key => {
6876
+ const normalizeKey = (key, code) => {
6938
6877
  if (key.length === 1) {
6939
6878
  return key.toLowerCase();
6940
6879
  }
6880
+ if (key === 'Unidentified') {
6881
+ return code;
6882
+ }
6941
6883
  return key;
6942
6884
  };
6943
6885
 
@@ -6946,12 +6888,13 @@ const getKeyBindingIdentifier = event => {
6946
6888
  ctrlKey,
6947
6889
  shiftKey,
6948
6890
  altKey,
6949
- key
6891
+ key,
6892
+ code
6950
6893
  } = event;
6951
6894
  const modifierControl = ctrlKey ? CtrlCmd : 0;
6952
6895
  const modifierShift = shiftKey ? Shift : 0;
6953
6896
  const modifierAlt = altKey ? Alt : 0;
6954
- const normalizedKey = normalizeKey(key);
6897
+ const normalizedKey = normalizeKey(key, code);
6955
6898
  const keyCode = getKeyCode(normalizedKey);
6956
6899
  const identifier = modifierControl | modifierShift | modifierAlt | keyCode;
6957
6900
  return identifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "15.6.0",
3
+ "version": "16.1.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"