@lvce-editor/renderer-process 10.58.0 → 10.59.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.
@@ -1209,7 +1209,7 @@ var A = "a";
1209
1209
  var Br = "br";
1210
1210
  var Cite = "cite";
1211
1211
  var Data = "data";
1212
- var Time$1 = "time";
1212
+ var Time = "time";
1213
1213
  var Tfoot = "tfoot";
1214
1214
  var Ul = "ul";
1215
1215
  var Video$1 = "video";
@@ -1365,7 +1365,7 @@ var getElementTag = type => {
1365
1365
  case Data2:
1366
1366
  return Data;
1367
1367
  case Time2:
1368
- return Time$1;
1368
+ return Time;
1369
1369
  case Tfoot2:
1370
1370
  return Tfoot;
1371
1371
  case Ul2:
@@ -5290,6 +5290,113 @@ const ScreenCapture_ipc = {
5290
5290
  name: name$b
5291
5291
  };
5292
5292
 
5293
+ const getTimeStamp = () => {
5294
+ return performance.now();
5295
+ };
5296
+
5297
+ const waitForMutation = async maxDelay => {
5298
+ const disposables = [];
5299
+ await Promise.race([new Promise(resolve => {
5300
+ const timeout = setTimeout(resolve, maxDelay);
5301
+ // @ts-expect-error
5302
+ disposables.push(() => {
5303
+ clearTimeout(timeout);
5304
+ });
5305
+ }), new Promise(resolve => {
5306
+ const callback = mutations => {
5307
+ resolve(undefined);
5308
+ };
5309
+ const observer = new MutationObserver(callback);
5310
+ observer.observe(document.body, {
5311
+ childList: true,
5312
+ attributes: true,
5313
+ characterData: true,
5314
+ subtree: true,
5315
+ attributeOldValue: true,
5316
+ characterDataOldValue: true
5317
+ });
5318
+ // @ts-expect-error
5319
+ disposables.push(() => {
5320
+ observer.disconnect();
5321
+ });
5322
+ })]);
5323
+ for (const disposable of disposables) {
5324
+ // @ts-expect-error
5325
+ disposable();
5326
+ }
5327
+ };
5328
+
5329
+ const getEventClass = eventType => {
5330
+ switch (eventType) {
5331
+ case Wheel:
5332
+ return WheelEvent;
5333
+ case PointerDown:
5334
+ case PointerUp:
5335
+ case PointerMove:
5336
+ return PointerEvent;
5337
+ default:
5338
+ return Event;
5339
+ }
5340
+ };
5341
+
5342
+ const mouseEvent = (element, eventType, options) => {
5343
+ const event = new MouseEvent(eventType, options);
5344
+ element.dispatchEvent(event);
5345
+ };
5346
+ const mouseDown = (element, options) => {
5347
+ mouseEvent(element, MouseDown, options);
5348
+ };
5349
+ const mouseUp = (element, options) => {
5350
+ mouseEvent(element, MouseUp, options);
5351
+ };
5352
+ const contextMenu = (element, options) => {
5353
+ mouseEvent(element, ContextMenu, options);
5354
+ };
5355
+ const click = (element, options) => {
5356
+ mouseDown(element, options);
5357
+ mouseEvent(element, Click, options);
5358
+ mouseUp(element, options);
5359
+ if (options.button === 2 /* right */) {
5360
+ contextMenu(element, options);
5361
+ }
5362
+ };
5363
+ const hover = (element, options) => {
5364
+ mouseEvent(element, MouseEnter, options);
5365
+ };
5366
+ const type = (element, options) => {
5367
+ element.value = options.text;
5368
+ };
5369
+ const keyboardEvent = (element, eventType, options) => {
5370
+ const event = new KeyboardEvent(eventType, options);
5371
+ element.dispatchEvent(event);
5372
+ };
5373
+ const keyDown = (element, options) => {
5374
+ keyboardEvent(element, KeyDown, options);
5375
+ };
5376
+ const keyUp = (element, options) => {
5377
+ keyboardEvent(element, KeyUp, options);
5378
+ };
5379
+ const dispatchEvent = (element, options) => {
5380
+ const EventClass = getEventClass(options.type);
5381
+ const event = new EventClass(options.type, options.init);
5382
+ element.dispatchEvent(event);
5383
+ };
5384
+
5385
+ const ElementActions = {
5386
+ __proto__: null,
5387
+ click,
5388
+ contextMenu,
5389
+ dispatchEvent,
5390
+ hover,
5391
+ keyDown,
5392
+ keyUp,
5393
+ keyboardEvent,
5394
+ mouseDown,
5395
+ mouseEvent,
5396
+ mouseUp,
5397
+ type
5398
+ };
5399
+
5293
5400
  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'];
5294
5401
 
5295
5402
  const querySelectorByText = (root, text) => {
@@ -5365,6 +5472,30 @@ const querySelectorWithOptions = (selector, {
5365
5472
  return element;
5366
5473
  };
5367
5474
 
5475
+ // TODO this should also come in via options
5476
+ const maxTimeout$1 = 2000;
5477
+ const performAction2 = async (locator, fnName, options) => {
5478
+ object(locator);
5479
+ string(fnName);
5480
+ object(options);
5481
+ const startTime = getTimeStamp();
5482
+ const endTime = startTime + maxTimeout$1;
5483
+ let currentTime = startTime;
5484
+ const fn = ElementActions[fnName];
5485
+ while (currentTime < endTime) {
5486
+ const element = querySelectorWithOptions(locator._selector, {
5487
+ hasText: locator._hasText,
5488
+ nth: locator._nth
5489
+ });
5490
+ if (element) {
5491
+ fn(element, options);
5492
+ return;
5493
+ }
5494
+ await waitForMutation(100);
5495
+ currentTime = getTimeStamp();
5496
+ }
5497
+ };
5498
+
5368
5499
  const toBeVisible$1 = locator => {
5369
5500
  return `expected selector to be visible ${locator._selector}`;
5370
5501
  };
@@ -5501,76 +5632,6 @@ const getFunction = fnName => {
5501
5632
  }
5502
5633
  };
5503
5634
 
5504
- const mouseEvent = (element, eventType, options) => {
5505
- const event = new MouseEvent(eventType, options);
5506
- element.dispatchEvent(event);
5507
- };
5508
- const mouseDown = (element, options) => {
5509
- mouseEvent(element, MouseDown, options);
5510
- };
5511
- const mouseUp = (element, options) => {
5512
- mouseEvent(element, MouseUp, options);
5513
- };
5514
- const contextMenu = (element, options) => {
5515
- mouseEvent(element, ContextMenu, options);
5516
- };
5517
- const click = (element, options) => {
5518
- mouseDown(element, options);
5519
- mouseEvent(element, Click, options);
5520
- mouseUp(element, options);
5521
- if (options.button === 2 /* right */) {
5522
- contextMenu(element, options);
5523
- }
5524
- };
5525
- const hover = (element, options) => {
5526
- mouseEvent(element, MouseEnter, options);
5527
- };
5528
- const type = (element, options) => {
5529
- element.value = options.text;
5530
- };
5531
- const keyboardEvent = (element, eventType, options) => {
5532
- const event = new KeyboardEvent(eventType, options);
5533
- element.dispatchEvent(event);
5534
- };
5535
- const keyDown = (element, options) => {
5536
- keyboardEvent(element, KeyDown, options);
5537
- };
5538
- const keyUp = (element, options) => {
5539
- keyboardEvent(element, KeyUp, options);
5540
- };
5541
- const getEventClass = eventType => {
5542
- switch (eventType) {
5543
- case Wheel:
5544
- return WheelEvent;
5545
- case PointerDown:
5546
- case PointerUp:
5547
- case PointerMove:
5548
- return PointerEvent;
5549
- default:
5550
- return Event;
5551
- }
5552
- };
5553
- const dispatchEvent = (element, options) => {
5554
- const EventClass = getEventClass(options.type);
5555
- const event = new EventClass(options.type, options.init);
5556
- element.dispatchEvent(event);
5557
- };
5558
-
5559
- const ElementActions = {
5560
- __proto__: null,
5561
- click,
5562
- contextMenu,
5563
- dispatchEvent,
5564
- hover,
5565
- keyDown,
5566
- keyUp,
5567
- keyboardEvent,
5568
- mouseDown,
5569
- mouseEvent,
5570
- mouseUp,
5571
- type
5572
- };
5573
-
5574
5635
  const press = options => {
5575
5636
  const element = document.activeElement;
5576
5637
  keyDown(element, options);
@@ -5684,53 +5745,12 @@ const showOverlay = (state, background, text) => {
5684
5745
  $TestOverlay.textContent = text;
5685
5746
  document.body.append($TestOverlay);
5686
5747
  };
5687
- const Time = {
5688
- getTimeStamp() {
5689
- return performance.now();
5690
- }
5691
- };
5692
5748
  const maxTimeout = 2000;
5693
- const Timeout = {
5694
- async short() {
5695
- await new Promise(resolve => setTimeout(resolve, 1000));
5696
- },
5697
- async waitForMutation(maxDelay) {
5698
- const disposables = [];
5699
- await Promise.race([new Promise(resolve => {
5700
- const timeout = setTimeout(resolve, maxDelay);
5701
- // @ts-expect-error
5702
- disposables.push(() => {
5703
- clearTimeout(timeout);
5704
- });
5705
- }), new Promise(resolve => {
5706
- const callback = mutations => {
5707
- resolve(undefined);
5708
- };
5709
- const observer = new MutationObserver(callback);
5710
- observer.observe(document.body, {
5711
- childList: true,
5712
- attributes: true,
5713
- characterData: true,
5714
- subtree: true,
5715
- attributeOldValue: true,
5716
- characterDataOldValue: true
5717
- });
5718
- // @ts-expect-error
5719
- disposables.push(() => {
5720
- observer.disconnect();
5721
- });
5722
- })]);
5723
- for (const disposable of disposables) {
5724
- // @ts-expect-error
5725
- disposable();
5726
- }
5727
- }
5728
- };
5729
5749
  const performAction = async (locator, fnName, options) => {
5730
5750
  object(locator);
5731
5751
  string(fnName);
5732
5752
  object(options);
5733
- const startTime = Time.getTimeStamp();
5753
+ const startTime = getTimeStamp();
5734
5754
  const endTime = startTime + maxTimeout;
5735
5755
  let currentTime = startTime;
5736
5756
  const fn = ElementActions[fnName];
@@ -5743,8 +5763,8 @@ const performAction = async (locator, fnName, options) => {
5743
5763
  fn(element, options);
5744
5764
  return;
5745
5765
  }
5746
- await Timeout.waitForMutation(100);
5747
- currentTime = Time.getTimeStamp();
5766
+ await waitForMutation(100);
5767
+ currentTime = getTimeStamp();
5748
5768
  }
5749
5769
  };
5750
5770
  const performKeyBoardAction = (fnName, options) => {
@@ -5758,7 +5778,7 @@ class AssertionError extends Error {
5758
5778
  }
5759
5779
  }
5760
5780
  const checkSingleElementCondition = async (locator, fnName, options) => {
5761
- const startTime = Time.getTimeStamp();
5781
+ const startTime = getTimeStamp();
5762
5782
  const endTime = startTime + maxTimeout;
5763
5783
  let currentTime = startTime;
5764
5784
  const fn = SingleElementConditions[fnName];
@@ -5773,15 +5793,15 @@ const checkSingleElementCondition = async (locator, fnName, options) => {
5773
5793
  return;
5774
5794
  }
5775
5795
  }
5776
- await Timeout.waitForMutation(100);
5777
- currentTime = Time.getTimeStamp();
5796
+ await waitForMutation(100);
5797
+ currentTime = getTimeStamp();
5778
5798
  }
5779
5799
  const errorMessageFn = getFunction(fnName);
5780
5800
  const message = errorMessageFn(locator, options);
5781
5801
  throw new AssertionError(message);
5782
5802
  };
5783
5803
  const checkMultiElementCondition = async (locator, fnName, options) => {
5784
- const startTime = Time.getTimeStamp();
5804
+ const startTime = getTimeStamp();
5785
5805
  const endTime = startTime + maxTimeout;
5786
5806
  let currentTime = startTime;
5787
5807
  const fn = MultiElementConditions[fnName];
@@ -5791,8 +5811,8 @@ const checkMultiElementCondition = async (locator, fnName, options) => {
5791
5811
  if (successful) {
5792
5812
  return;
5793
5813
  }
5794
- await Timeout.waitForMutation(100);
5795
- currentTime = Time.getTimeStamp();
5814
+ await waitForMutation(100);
5815
+ currentTime = getTimeStamp();
5796
5816
  }
5797
5817
  const errorMessageFn = getFunction(fnName);
5798
5818
  const message = errorMessageFn(locator, options);
@@ -5800,12 +5820,11 @@ const checkMultiElementCondition = async (locator, fnName, options) => {
5800
5820
  };
5801
5821
 
5802
5822
  const name$a = 'TestFrameWork';
5803
-
5804
- // prettier-ignore
5805
5823
  const Commands$b = {
5806
5824
  checkMultiElementCondition: checkMultiElementCondition,
5807
5825
  checkSingleElementCondition: checkSingleElementCondition,
5808
5826
  performAction: performAction,
5827
+ performAction2: performAction2,
5809
5828
  performKeyBoardAction: performKeyBoardAction,
5810
5829
  showOverlay: showOverlay
5811
5830
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "10.58.0",
3
+ "version": "10.59.0",
4
4
  "description": "",
5
5
  "main": "dist/rendererProcessMain.js",
6
6
  "type": "module",