@lvce-editor/renderer-process 29.0.0 → 29.2.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.
@@ -264,21 +264,38 @@ const applyDragInfoMaybe = event => {
264
264
  const PointerMove$1 = 'pointermove';
265
265
  const lostpointercapture = 'lostpointercapture';
266
266
 
267
- let ignore = false;
267
+ const createEventState = () => {
268
+ let ignore = false;
269
+ return {
270
+ startIgnore() {
271
+ ignore = true;
272
+ },
273
+ stopIgnore() {
274
+ ignore = false;
275
+ },
276
+ enabled() {
277
+ return ignore;
278
+ }
279
+ };
280
+ };
281
+ const eventState = createEventState();
268
282
  const startIgnore = () => {
269
- ignore = true;
283
+ eventState.startIgnore();
270
284
  };
271
285
  const stopIgnore = () => {
272
- ignore = false;
286
+ eventState.stopIgnore();
273
287
  };
274
288
  const enabled = () => {
275
- return ignore;
289
+ return eventState.enabled();
276
290
  };
277
291
 
278
- let id$1 = 0;
279
- const create$L = () => {
280
- return ++id$1;
292
+ const createIdGenerator = () => {
293
+ let id = 0;
294
+ return () => {
295
+ return ++id;
296
+ };
281
297
  };
298
+ const create$L = createIdGenerator();
282
299
 
283
300
  const state$9 = Object.create(null);
284
301
  const acquire$1 = id => {
@@ -1282,26 +1299,57 @@ const attachEvent = ($Node, eventMap, key, value, newEventMap) => {
1282
1299
  });
1283
1300
  attachedListeners.set($Node, listenersByEvent);
1284
1301
  };
1302
+ const detachEvent = ($Node, key) => {
1303
+ const keyLower = key.toLowerCase();
1304
+ const listenersByEvent = attachedListeners.get($Node);
1305
+ const previous = listenersByEvent?.get(keyLower);
1306
+ if (!previous) {
1307
+ return;
1308
+ }
1309
+ $Node.removeEventListener(keyLower, previous.listener, previous.options);
1310
+ listenersByEvent?.delete(keyLower);
1311
+ };
1285
1312
 
1286
- const STYLE_REGEX = /([^:;]+):\s*([^;]+)/g;
1287
- const KEBAB_CASE_REGEX = /-([a-z])/g;
1313
+ const toCamelCase = key => {
1314
+ let camelCaseKey = '';
1315
+ let shouldUpperCase = false;
1316
+ for (const char of key) {
1317
+ if (char === '-') {
1318
+ shouldUpperCase = true;
1319
+ continue;
1320
+ }
1321
+ camelCaseKey += shouldUpperCase ? char.toUpperCase() : char;
1322
+ shouldUpperCase = false;
1323
+ }
1324
+ return camelCaseKey;
1325
+ };
1288
1326
  const setStyle = ($Element, styleString) => {
1289
1327
  if (typeof styleString !== 'string') {
1290
1328
  return;
1291
1329
  }
1292
- let match;
1293
- while ((match = STYLE_REGEX.exec(styleString)) !== null) {
1294
- const key = match[1].trim();
1295
- const value = match[2].trim();
1296
- // Convert kebab-case to camelCase for CSS properties with dashes
1297
- const camelCaseKey = key.replaceAll(KEBAB_CASE_REGEX, (_, char) => char.toUpperCase());
1330
+ for (const declaration of styleString.split(';')) {
1331
+ const colonIndex = declaration.indexOf(':');
1332
+ if (colonIndex === -1) {
1333
+ continue;
1334
+ }
1335
+ const key = declaration.slice(0, colonIndex).trim();
1336
+ const value = declaration.slice(colonIndex + 1).trim();
1337
+ if (!key || !value) {
1338
+ continue;
1339
+ }
1340
+ if (key.startsWith('--')) {
1341
+ $Element.style.setProperty(key, value);
1342
+ continue;
1343
+ }
1344
+ const camelCaseKey = toCamelCase(key);
1298
1345
  $Element.style[camelCaseKey] = value;
1299
1346
  }
1300
1347
  };
1301
1348
 
1302
1349
  const optionalAttributeProps = new Map([['ariaActivedescendant', 'aria-activedescendant'], ['ariaOwns', 'aria-owns']]);
1303
1350
  const mappedAttributeProps = new Map([['ariaControls', 'aria-controls'], ['ariaLabelledBy', 'aria-labelledby']]);
1304
- const pixelStyleProps = new Set(['left', 'marginTop', 'paddingLeft', 'paddingRight', 'top']);
1351
+ const removedAttributeProps = new Map([['ariaActivedescendant', 'aria-activedescendant'], ['ariaControls', 'aria-controls'], ['ariaLabelledBy', 'aria-labelledby'], ['ariaOwns', 'aria-owns'], ['className', 'class'], ['htmlFor', 'for'], ['inputType', 'type']]);
1352
+ const pixelStyleProps = new Set(['height', 'left', 'marginTop', 'paddingLeft', 'paddingRight', 'top', 'width']);
1305
1353
  const eventProps = new Set(['onBlur', 'onChange', 'onClick', 'onContextMenu', 'onBeforeInput', 'onDblClick', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onFocus', 'onFocusIn', 'onFocusOut', 'onInput', 'onKeydown', 'onKeyDown', 'onKeyUp', 'onMouseDown', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onPointerDown', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onScroll', 'onSelectionChange', 'onSubmit', 'onWheel']);
1306
1354
  const setOptionalAttribute = ($Element, attributeName, value) => {
1307
1355
  if (value) {
@@ -1327,6 +1375,19 @@ const setEventProp = ($Element, key, value, eventMap, newEventMap) => {
1327
1375
  const eventName = key.slice(2).toLowerCase();
1328
1376
  attachEvent($Element, eventMap, eventName, value, newEventMap);
1329
1377
  };
1378
+ const removeProp = ($Element, key) => {
1379
+ if (eventProps.has(key)) {
1380
+ const eventName = key.slice(2).toLowerCase();
1381
+ detachEvent($Element, eventName);
1382
+ return;
1383
+ }
1384
+ if (pixelStyleProps.has(key)) {
1385
+ $Element.style[key] = '';
1386
+ return;
1387
+ }
1388
+ const attributeName = removedAttributeProps.get(key) || key;
1389
+ $Element.removeAttribute(attributeName);
1390
+ };
1330
1391
  const setProp = ($Element, key, value, eventMap, newEventMap) => {
1331
1392
  const optionalAttributeName = optionalAttributeProps.get(key);
1332
1393
  if (optionalAttributeName) {
@@ -1468,28 +1529,6 @@ const rememberFocus2 = ($Viewlet, dom, eventMap, uid = 0) => {
1468
1529
  return $Viewlet;
1469
1530
  };
1470
1531
 
1471
- // Map of property names to attribute names for cases where they differ
1472
- const propertyToAttribute = {
1473
- className: 'class',
1474
- htmlFor: 'for',
1475
- ariaActivedescendant: 'aria-activedescendant',
1476
- ariaControls: 'aria-controls',
1477
- ariaLabelledBy: 'aria-labelledby',
1478
- ariaOwns: 'aria-owns',
1479
- inputType: 'type'
1480
- };
1481
- // Style properties that need to be set on element.style
1482
- const styleProperties = new Set(['width', 'height', 'top', 'left', 'marginTop', 'paddingLeft', 'paddingRight']);
1483
- const removeAttribute = ($Element, key) => {
1484
- // Handle style properties
1485
- if (styleProperties.has(key)) {
1486
- // @ts-ignore - dynamic style property access
1487
- $Element.style[key] = '';
1488
- return;
1489
- }
1490
- const attributeName = propertyToAttribute[key] || key;
1491
- $Element.removeAttribute(attributeName);
1492
- };
1493
1532
  const setText$1 = ($Element, value) => {
1494
1533
  $Element.nodeValue = value;
1495
1534
  };
@@ -1618,7 +1657,7 @@ const applyMutationPatch = (state, patch, events) => {
1618
1657
  state.hasAppliedMutation = true;
1619
1658
  break;
1620
1659
  case RemoveAttribute:
1621
- removeAttribute(state.current, patch.key);
1660
+ removeProp(state.current, patch.key);
1622
1661
  state.hasAppliedMutation = true;
1623
1662
  break;
1624
1663
  case RemoveChild:
@@ -1768,15 +1807,15 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1768
1807
  const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
1769
1808
  const focused = activeElement?.getAttribute('name') || null;
1770
1809
  const $Hidden = createHiddenContainer(activeElement, focused);
1771
- const inputMap = getInputMap($Viewlet);
1772
1810
  if (uid) {
1773
1811
  const numericUid = Number(uid);
1812
+ const inputMap = getInputMap($Viewlet);
1774
1813
  $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
1775
- $Hidden.remove();
1776
- } else {
1814
+ }
1815
+ if (!uid) {
1777
1816
  renderInto($Viewlet, dom, eventMap);
1778
- $Hidden.remove();
1779
1817
  }
1818
+ $Hidden.remove();
1780
1819
  restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
1781
1820
  $Viewlet.style.top = oldTop;
1782
1821
  $Viewlet.style.left = oldLeft;
@@ -1838,16 +1877,7 @@ const getHref = () => {
1838
1877
  return location.href;
1839
1878
  };
1840
1879
  const matchesPathName = (a, b) => {
1841
- if (a === b) {
1842
- return true;
1843
- }
1844
- if (a === '/' && b === '') {
1845
- return true;
1846
- }
1847
- if (a === '' && b === '/') {
1848
- return true;
1849
- }
1850
- return false;
1880
+ return a === b || a === '/' && b === '' || a === '' && b === '/';
1851
1881
  };
1852
1882
 
1853
1883
  // TODO should do nothing if it is already at this path
@@ -1898,23 +1928,7 @@ const Message$2 = 'message';
1898
1928
  const Error$3 = 'error';
1899
1929
 
1900
1930
  const withResolvers = () => {
1901
- /**
1902
- * @type {any}
1903
- */
1904
- let _resolve;
1905
- /**
1906
- * @type {any}
1907
- */
1908
- let _reject;
1909
- const promise = new Promise((resolve, reject) => {
1910
- _resolve = resolve;
1911
- _reject = reject;
1912
- });
1913
- return {
1914
- promise,
1915
- reject: _reject,
1916
- resolve: _resolve
1917
- };
1931
+ return Promise.withResolvers();
1918
1932
  };
1919
1933
 
1920
1934
  const getFirstEvent$1 = (eventTarget, eventMap) => {
@@ -4342,7 +4356,7 @@ const selectorToString = parsedSelector => {
4342
4356
  result = part.selector;
4343
4357
  continue;
4344
4358
  }
4345
- result = `${result} >> ${part.selector}`;
4359
+ result += ` >> ${part.selector}`;
4346
4360
  continue;
4347
4361
  }
4348
4362
  if (part.type === 'text') {
@@ -4350,14 +4364,14 @@ const selectorToString = parsedSelector => {
4350
4364
  result = `text=${part.text}`;
4351
4365
  continue;
4352
4366
  }
4353
- result = `${result} text=${part.text}`;
4367
+ result += ` text=${part.text}`;
4354
4368
  continue;
4355
4369
  }
4356
4370
  if (part.type === 'has-text') {
4357
- result = `${result} "${part.text}"`;
4371
+ result += ` "${part.text}"`;
4358
4372
  continue;
4359
4373
  }
4360
- result = `${result}:nth(${part.index})`;
4374
+ result += `:nth(${part.index})`;
4361
4375
  }
4362
4376
  return result;
4363
4377
  };
@@ -4689,6 +4703,16 @@ const showOverlay = (state, background, text, actions = []) => {
4689
4703
  $TestOverlay.append(span, ...$actions);
4690
4704
  document.body.append($TestOverlay);
4691
4705
  };
4706
+ const showTestResults = text => {
4707
+ const existing = document.querySelector('.TestResults');
4708
+ const $TestResults = existing || document.createElement('div');
4709
+ $TestResults.className = 'TestResults';
4710
+ $TestResults.hidden = true;
4711
+ $TestResults.textContent = text;
4712
+ if (!existing) {
4713
+ document.body.append($TestResults);
4714
+ }
4715
+ };
4692
4716
  const performAction = async (locator, fnName, options) => {
4693
4717
  object(locator);
4694
4718
  string(fnName);
@@ -8454,11 +8478,14 @@ const setUid = (viewletId, uid) => {
8454
8478
  } = instance.state;
8455
8479
  set$3($Viewlet, uid);
8456
8480
  };
8457
- const emptyFocusCallback = {
8481
+ const focusCallback = {
8458
8482
  id: 0,
8459
8483
  selector: ''
8460
8484
  };
8461
- let focusCallback = emptyFocusCallback;
8485
+ const resetFocusCallback = () => {
8486
+ focusCallback.id = 0;
8487
+ focusCallback.selector = '';
8488
+ };
8462
8489
  const focusSelector = (viewletId, selector) => {
8463
8490
  const instance = get$a(viewletId);
8464
8491
  if (!instance) {
@@ -8475,10 +8502,8 @@ const focusSelector = (viewletId, selector) => {
8475
8502
  if ($Element.isConnected) {
8476
8503
  $Element.focus();
8477
8504
  } else {
8478
- focusCallback = {
8479
- id: viewletId,
8480
- selector
8481
- };
8505
+ focusCallback.id = viewletId;
8506
+ focusCallback.selector = selector;
8482
8507
  }
8483
8508
  }
8484
8509
  };
@@ -8774,14 +8799,14 @@ const replaceChildren = (parentId, childIds) => {
8774
8799
  $Parent.replaceChildren($Fragment);
8775
8800
  };
8776
8801
  const applyLateFocusMaybe = () => {
8777
- if (focusCallback === emptyFocusCallback) {
8802
+ if (!focusCallback.id) {
8778
8803
  return;
8779
8804
  }
8780
8805
  const {
8781
8806
  id,
8782
8807
  selector
8783
8808
  } = focusCallback;
8784
- focusCallback = emptyFocusCallback;
8809
+ resetFocusCallback();
8785
8810
  const instance = get$a(id);
8786
8811
  if (instance) {
8787
8812
  const {
@@ -8790,7 +8815,6 @@ const applyLateFocusMaybe = () => {
8790
8815
  const $Element = $Viewlet.querySelector(selector);
8791
8816
  if ($Element) {
8792
8817
  $Element.focus();
8793
- focusCallback = emptyFocusCallback;
8794
8818
  }
8795
8819
  }
8796
8820
  };
@@ -8949,17 +8973,16 @@ const set$1 = title => {
8949
8973
 
8950
8974
  // workaround for not being setPointerCapture() not working on
8951
8975
  // synthetic events
8952
- let originalSetPointerCapture;
8953
- let originalReleasePointerCapture;
8976
+ const originalPointerCapture = {};
8954
8977
  const mock = () => {
8955
- originalSetPointerCapture = Element.prototype.setPointerCapture;
8956
- originalReleasePointerCapture = Element.prototype.releasePointerCapture;
8978
+ originalPointerCapture.setPointerCapture = Element.prototype.setPointerCapture;
8979
+ originalPointerCapture.releasePointerCapture = Element.prototype.releasePointerCapture;
8957
8980
  Element.prototype.setPointerCapture = () => {};
8958
8981
  Element.prototype.releasePointerCapture = () => {};
8959
8982
  };
8960
8983
  const unmock = () => {
8961
- Element.prototype.setPointerCapture = originalSetPointerCapture;
8962
- Element.prototype.releasePointerCapture = originalReleasePointerCapture;
8984
+ Element.prototype.setPointerCapture = originalPointerCapture.setPointerCapture;
8985
+ Element.prototype.releasePointerCapture = originalPointerCapture.releasePointerCapture;
8963
8986
  };
8964
8987
 
8965
8988
  const isFile = value => {
@@ -8996,7 +9019,7 @@ const waitForFrameToLoad = $Frame => {
8996
9019
  promise,
8997
9020
  resolve
8998
9021
  } = withResolvers();
8999
- $Frame.addEventListener('load', resolve, {
9022
+ $Frame.addEventListener('load', () => resolve(), {
9000
9023
  once: true
9001
9024
  });
9002
9025
  return promise;
@@ -9120,6 +9143,7 @@ const commandMap = {
9120
9143
  'TestFrameWork.performAction2': performAction2,
9121
9144
  'TestFrameWork.performKeyBoardAction': performKeyboardAction,
9122
9145
  'TestFrameWork.showOverlay': showOverlay,
9146
+ 'TestFrameWork.showTestResults': showTestResults,
9123
9147
  'TestFrameWork.transfer': transfer,
9124
9148
  'TestFrameWork.transferToWebView': transferToWebView,
9125
9149
  'Viewlet.addKeyBindings': addKeyBindings,
@@ -9310,9 +9334,8 @@ const RE_AT = /^\s+at/;
9310
9334
  const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
9311
9335
  const RE_OBJECT_AS = /^\s*at Object\.\w+ \[as ([\w.]+)]/;
9312
9336
  const RE_OBJECT = /^\s*at Object\.(\w+)/;
9313
- const RE_PATH_1$1 = /\((.*):(\d+):(\d+)\)$/;
9314
- const RE_PATH_2$1 = /at (.*):(\d+):(\d+)$/;
9315
- const RE_PATH_3$1 = /@(.*):(\d+):(\d+)$/; // Firefox
9337
+ const RE_PATH_1$1 = /\(([^()]*):(\d+):(\d+)\)$/;
9338
+ const RE_PATH_2$1 = /at ([^\n]*):(\d+):(\d+)$/;
9316
9339
  const RE_RESTORE_JSON_RPC_ERROR = /^\s*at restoreJsonRpcError/;
9317
9340
  const RE_UNWRAP_JSON_RPC_RESULT = /^\s*at unwrapJsonRpcResult/;
9318
9341
  const RE_HANDLE_JSON_RPC_MESSAGE = /^\s*at handleJsonRpcMessage/;
@@ -9325,8 +9348,14 @@ const isInternalLine = line => {
9325
9348
  const isRelevantLine = line => {
9326
9349
  return !isInternalLine(line);
9327
9350
  };
9351
+ const isFirefoxStackLine = line => {
9352
+ const atIndex = line.indexOf('@');
9353
+ const columnIndex = line.lastIndexOf(':');
9354
+ const lineIndex = line.lastIndexOf(':', columnIndex - 1);
9355
+ return Boolean(atIndex !== -1 && lineIndex > atIndex && columnIndex > lineIndex && line.slice(lineIndex + 1, columnIndex) && line.slice(columnIndex + 1));
9356
+ };
9328
9357
  const isNormalStackLine = line => {
9329
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line) || RE_PATH_2$1.test(line) || RE_PATH_3$1.test(line);
9358
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line) || RE_PATH_2$1.test(line) || isFirefoxStackLine(line);
9330
9359
  };
9331
9360
  const isApplicationUsefulLine = (line, index) => {
9332
9361
  if (index === 0) {
@@ -9369,7 +9398,7 @@ const mergeCustom = (custom, relevantStack) => {
9369
9398
  if (RE_PATH_2$1.test(firstLine)) {
9370
9399
  return [` at ${firstLine}`, ...relevantStack];
9371
9400
  }
9372
- if (RE_PATH_3$1.test(firstLine)) {
9401
+ if (isFirefoxStackLine(firstLine)) {
9373
9402
  return [firstLine, ...relevantStack];
9374
9403
  }
9375
9404
  return relevantStack;
@@ -9445,9 +9474,23 @@ const prepareErrorMessageWithCodeFrame = error => {
9445
9474
  stderr: error.stderr
9446
9475
  };
9447
9476
  };
9448
- const RE_PATH_1 = /\((.*):(\d+):(\d+)\)$/;
9449
- const RE_PATH_2 = /at (.*):(\d+):(\d+)$/;
9450
- const RE_PATH_3 = /@(.*):(\d+):(\d+)$/; // Firefox
9477
+ const RE_PATH_1 = /\(([^()]*):(\d+):(\d+)\)$/;
9478
+ const RE_PATH_2 = /at ([^\n]*):(\d+):(\d+)$/;
9479
+ const getFirefoxStackMatch = line => {
9480
+ const atIndex = line.indexOf('@');
9481
+ const columnIndex = line.lastIndexOf(':');
9482
+ const lineIndex = line.lastIndexOf(':', columnIndex - 1);
9483
+ if (atIndex === -1 || lineIndex <= atIndex || columnIndex <= lineIndex) {
9484
+ return undefined;
9485
+ }
9486
+ const path = line.slice(atIndex + 1, lineIndex);
9487
+ const lineNumber = line.slice(lineIndex + 1, columnIndex);
9488
+ const column = line.slice(columnIndex + 1);
9489
+ if (!path || !lineNumber || !column) {
9490
+ return undefined;
9491
+ }
9492
+ return [line, path, lineNumber, column];
9493
+ };
9451
9494
 
9452
9495
  /**
9453
9496
  *
@@ -9456,7 +9499,7 @@ const RE_PATH_3 = /@(.*):(\d+):(\d+)$/; // Firefox
9456
9499
  */
9457
9500
  const getFile = lines => {
9458
9501
  for (const line of lines) {
9459
- if (RE_PATH_1.test(line) || RE_PATH_2.test(line) || RE_PATH_3.test(line)) {
9502
+ if (RE_PATH_1.test(line) || RE_PATH_2.test(line) || getFirefoxStackMatch(line)) {
9460
9503
  return line;
9461
9504
  }
9462
9505
  }
@@ -9471,7 +9514,7 @@ const prepareErrorMessageWithoutCodeFrame = async error => {
9471
9514
  match = file.match(RE_PATH_2);
9472
9515
  }
9473
9516
  if (!match) {
9474
- match = file.match(RE_PATH_3);
9517
+ match = getFirefoxStackMatch(file);
9475
9518
  }
9476
9519
  if (!match) {
9477
9520
  return error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "29.0.0",
3
+ "version": "29.2.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"