@lvce-editor/renderer-process 29.1.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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "29.1.0",
3
+ "version": "29.2.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"