@lvce-editor/renderer-process 30.46.0 → 30.46.1

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.
@@ -5450,6 +5450,41 @@ const SingleElementConditions = {
5450
5450
  toHaveValue
5451
5451
  };
5452
5452
 
5453
+ const conditionTimeout = 2000;
5454
+ const mutationTimeout = 100;
5455
+ const waitForMutation = maxDelay => {
5456
+ return new Promise(resolve => {
5457
+ const observer = new MutationObserver(() => {
5458
+ clearTimeout(timeout);
5459
+ observer.disconnect();
5460
+ resolve();
5461
+ });
5462
+ const timeout = setTimeout(() => {
5463
+ observer.disconnect();
5464
+ resolve();
5465
+ }, maxDelay);
5466
+ observer.observe(document.body, {
5467
+ attributes: true,
5468
+ characterData: true,
5469
+ childList: true,
5470
+ subtree: true
5471
+ });
5472
+ });
5473
+ };
5474
+ const waitForCondition = async check => {
5475
+ const endTime = performance.now() + conditionTimeout;
5476
+ while (performance.now() < endTime) {
5477
+ if (check()) {
5478
+ return {
5479
+ error: false
5480
+ };
5481
+ }
5482
+ await waitForMutation(mutationTimeout);
5483
+ }
5484
+ return {
5485
+ error: true
5486
+ };
5487
+ };
5453
5488
  const create$Overlay = () => {
5454
5489
  const $TestOverlay = document.createElement('div');
5455
5490
  $TestOverlay.id = 'TestOverlay';
@@ -5523,32 +5558,18 @@ const performKeyboardAction = (fnName, options) => {
5523
5558
  const checkSingleElementCondition = async (locator, fnName, options) => {
5524
5559
  const fn = SingleElementConditions[fnName];
5525
5560
  const parsedSelector = getParsedSelector(locator);
5526
- const element = querySelectorOne(parsedSelector);
5527
- if (element) {
5528
- const successful = fn(element, options);
5529
- if (successful) {
5530
- return {
5531
- error: false
5532
- };
5533
- }
5534
- }
5535
- return {
5536
- error: true
5537
- };
5561
+ return waitForCondition(() => {
5562
+ const element = querySelectorOne(parsedSelector);
5563
+ return Boolean(element && fn(element, options));
5564
+ });
5538
5565
  };
5539
5566
  const checkMultiElementCondition = async (locator, fnName, options) => {
5540
5567
  const fn = MultiElementConditions[fnName];
5541
5568
  const parsedSelector = getParsedSelector(locator);
5542
- const elements = querySelector(parsedSelector);
5543
- const successful = fn(elements, options);
5544
- if (successful) {
5545
- return {
5546
- error: false
5547
- };
5548
- }
5549
- return {
5550
- error: true
5551
- };
5569
+ return waitForCondition(() => {
5570
+ const elements = querySelector(parsedSelector);
5571
+ return fn(elements, options);
5572
+ });
5552
5573
  };
5553
5574
  const checkConditionError = (fnName, ...params) => {
5554
5575
  const fn = ConditionValues[fnName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.46.0",
3
+ "version": "30.46.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"