@lvce-editor/renderer-process 20.4.0 → 21.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.
@@ -180,228 +180,228 @@ const downloadFile = (fileName, url) => {
180
180
  a.click();
181
181
  };
182
182
 
183
- const Audio$1$1 = 'audio';
184
- const Button$1 = 'button';
185
- const Col$1 = 'col';
186
- const ColGroup$1 = 'colgroup';
187
- const Del$1 = 'del';
188
- const Div$1 = 'div';
189
- const H1$1 = 'h1';
190
- const H2$1 = 'h2';
191
- const H3$1 = 'h3';
192
- const H4$1 = 'h4';
193
- const H5$1 = 'h5';
194
- const H6$1 = 'h6';
195
- const I$1 = 'i';
196
- const Img$1 = 'img';
197
- const Input$1 = 'input';
198
- const Ins$1 = 'ins';
199
- const Kbd$1 = 'kbd';
200
- const Span$1 = 'span';
201
- const Table$1 = 'table';
202
- const TBody$1 = 'tbody';
203
- const Td$1 = 'td';
204
- const Th$1 = 'th';
205
- const THead$1 = 'thead';
206
- const Tr$1 = 'tr';
207
- const Article$1 = 'article';
208
- const Aside$1 = 'aside';
209
- const Footer$1 = 'footer';
210
- const Header$1 = 'header';
211
- const Nav$1 = 'nav';
212
- const Section$1 = 'section';
213
- const Search$1 = 'search';
214
- const Dd$1 = 'dd';
215
- const Dl$1 = 'dl';
216
- const Figcaption$1 = 'figcaption';
217
- const Figure$1 = 'figure';
218
- const Hr$1 = 'hr';
219
- const Li$1 = 'li';
220
- const Ol$1 = 'ol';
221
- const P$1 = 'p';
222
- const Pre$1 = 'pre';
223
- const A$1 = 'a';
224
- const Br$1 = 'br';
225
- const Cite$1 = 'cite';
226
- const Data$1 = 'data';
227
- const Time$1 = 'time';
228
- const Tfoot$1 = 'tfoot';
229
- const Ul$1 = 'ul';
230
- const Video$1 = 'video';
231
- const TextArea$1 = 'textarea';
232
- const Select$1 = 'select';
233
- const Option$1 = 'option';
234
- const Code$1 = 'code';
235
- const Label$1 = 'label';
236
- const Dt$1 = 'dt';
237
- const Audio$2 = 0;
238
- const Button = 1;
239
- const Col = 2;
240
- const ColGroup = 3;
241
- const Div = 4;
242
- const H1 = 5;
243
- const Input = 6;
244
- const Kbd = 7;
245
- const Span = 8;
246
- const Table = 9;
247
- const TBody = 10;
248
- const Td = 11;
183
+ const Audio$2 = 'audio';
184
+ const Button$2 = 'button';
185
+ const Col$2 = 'col';
186
+ const ColGroup$2 = 'colgroup';
187
+ const Del$2 = 'del';
188
+ const Div$2 = 'div';
189
+ const H1$2 = 'h1';
190
+ const H2$2 = 'h2';
191
+ const H3$2 = 'h3';
192
+ const H4$2 = 'h4';
193
+ const H5$2 = 'h5';
194
+ const H6$2 = 'h6';
195
+ const I$2 = 'i';
196
+ const Img$2 = 'img';
197
+ const Input$2 = 'input';
198
+ const Ins$2 = 'ins';
199
+ const Kbd$2 = 'kbd';
200
+ const Span$2 = 'span';
201
+ const Table$2 = 'table';
202
+ const TBody$2 = 'tbody';
203
+ const Td$2 = 'td';
204
+ const Th$2 = 'th';
205
+ const THead$2 = 'thead';
206
+ const Tr$2 = 'tr';
207
+ const Article$2 = 'article';
208
+ const Aside$2 = 'aside';
209
+ const Footer$2 = 'footer';
210
+ const Header$2 = 'header';
211
+ const Nav$2 = 'nav';
212
+ const Section$2 = 'section';
213
+ const Search$2 = 'search';
214
+ const Dd$2 = 'dd';
215
+ const Dl$2 = 'dl';
216
+ const Figcaption$2 = 'figcaption';
217
+ const Figure$2 = 'figure';
218
+ const Hr$2 = 'hr';
219
+ const Li$2 = 'li';
220
+ const Ol$2 = 'ol';
221
+ const P$2 = 'p';
222
+ const Pre$2 = 'pre';
223
+ const A$2 = 'a';
224
+ const Br$2 = 'br';
225
+ const Cite$2 = 'cite';
226
+ const Data$2 = 'data';
227
+ const Time$2 = 'time';
228
+ const Tfoot$2 = 'tfoot';
229
+ const Ul$2 = 'ul';
230
+ const Video$2 = 'video';
231
+ const TextArea$2 = 'textarea';
232
+ const Select$2 = 'select';
233
+ const Option$2 = 'option';
234
+ const Code$2 = 'code';
235
+ const Label$2 = 'label';
236
+ const Dt$2 = 'dt';
237
+ const Audio$1$1 = 0;
238
+ const Button$1 = 1;
239
+ const Col$1 = 2;
240
+ const ColGroup$1 = 3;
241
+ const Div$1 = 4;
242
+ const H1$1 = 5;
243
+ const Input$1 = 6;
244
+ const Kbd$1 = 7;
245
+ const Span$1 = 8;
246
+ const Table$1 = 9;
247
+ const TBody$1 = 10;
248
+ const Td$1 = 11;
249
249
  const Text$1 = 12;
250
- const Th = 13;
251
- const THead = 14;
252
- const Tr = 15;
253
- const I = 16;
254
- const Img = 17;
255
- const Ins = 20;
256
- const Del = 21;
257
- const H2 = 22;
258
- const H3 = 23;
259
- const H4 = 24;
260
- const H5 = 25;
261
- const H6 = 26;
262
- const Article = 27;
263
- const Aside = 28;
264
- const Footer = 29;
265
- const Header = 30;
266
- const Nav = 40;
267
- const Section = 41;
268
- const Search = 42;
269
- const Dd = 43;
270
- const Dl = 44;
271
- const Figcaption = 45;
272
- const Figure = 46;
273
- const Hr = 47;
274
- const Li = 48;
275
- const Ol = 49;
276
- const P = 50;
277
- const Pre = 51;
278
- const A = 53;
279
- const Br = 55;
280
- const Cite = 56;
281
- const Data = 57;
282
- const Time = 58;
283
- const Tfoot = 59;
284
- const Ul = 60;
285
- const Video$2 = 61;
286
- const TextArea = 62;
287
- const Select = 63;
288
- const Option = 64;
289
- const Code$2 = 65;
290
- const Label = 66;
291
- const Dt = 67;
292
- const VirtualDomElements = {
250
+ const Th$1 = 13;
251
+ const THead$1 = 14;
252
+ const Tr$1 = 15;
253
+ const I$1 = 16;
254
+ const Img$1 = 17;
255
+ const Ins$1 = 20;
256
+ const Del$1 = 21;
257
+ const H2$1 = 22;
258
+ const H3$1 = 23;
259
+ const H4$1 = 24;
260
+ const H5$1 = 25;
261
+ const H6$1 = 26;
262
+ const Article$1 = 27;
263
+ const Aside$1 = 28;
264
+ const Footer$1 = 29;
265
+ const Header$1 = 30;
266
+ const Nav$1 = 40;
267
+ const Section$1 = 41;
268
+ const Search$1 = 42;
269
+ const Dd$1 = 43;
270
+ const Dl$1 = 44;
271
+ const Figcaption$1 = 45;
272
+ const Figure$1 = 46;
273
+ const Hr$1 = 47;
274
+ const Li$1 = 48;
275
+ const Ol$1 = 49;
276
+ const P$1 = 50;
277
+ const Pre$1 = 51;
278
+ const A$1 = 53;
279
+ const Br$1 = 55;
280
+ const Cite$1 = 56;
281
+ const Data$1 = 57;
282
+ const Time$1 = 58;
283
+ const Tfoot$1 = 59;
284
+ const Ul$1 = 60;
285
+ const Video$1 = 61;
286
+ const TextArea$1 = 62;
287
+ const Select$1 = 63;
288
+ const Option$1 = 64;
289
+ const Code$1 = 65;
290
+ const Label$1 = 66;
291
+ const Dt$1 = 67;
292
+ const VirtualDomElements$1 = {
293
293
  __proto__: null,
294
294
  Text: Text$1};
295
295
  const getElementTag$1 = type => {
296
296
  switch (type) {
297
- case A:
298
- return A$1;
299
- case Article:
300
- return Article$1;
301
- case Aside:
302
- return Aside$1;
303
- case Audio$2:
304
- return Audio$1$1;
305
- case Br:
306
- return Br$1;
307
- case Button:
308
- return Button$1;
309
- case Cite:
310
- return Cite$1;
311
- case Code$2:
312
- return Code$1;
313
- case Col:
314
- return Col$1;
315
- case ColGroup:
316
- return ColGroup$1;
317
- case Data:
318
- return Data$1;
319
- case Dd:
320
- return Dd$1;
321
- case Del:
322
- return Del$1;
323
- case Div:
324
- return Div$1;
325
- case Dl:
326
- return Dl$1;
327
- case Dt:
328
- return Dt$1;
329
- case Figcaption:
330
- return Figcaption$1;
331
- case Figure:
332
- return Figure$1;
333
- case Footer:
334
- return Footer$1;
335
- case H1:
336
- return H1$1;
337
- case H2:
338
- return H2$1;
339
- case H3:
340
- return H3$1;
341
- case H4:
342
- return H4$1;
343
- case H5:
344
- return H5$1;
345
- case H6:
346
- return H6$1;
347
- case Header:
348
- return Header$1;
349
- case Hr:
350
- return Hr$1;
351
- case I:
352
- return I$1;
353
- case Img:
354
- return Img$1;
355
- case Input:
356
- return Input$1;
357
- case Ins:
358
- return Ins$1;
359
- case Kbd:
360
- return Kbd$1;
361
- case Label:
362
- return Label$1;
363
- case Li:
364
- return Li$1;
365
- case Nav:
366
- return Nav$1;
367
- case Ol:
368
- return Ol$1;
369
- case Option:
370
- return Option$1;
371
- case P:
372
- return P$1;
373
- case Pre:
374
- return Pre$1;
375
- case Search:
376
- return Search$1;
377
- case Section:
378
- return Section$1;
379
- case Select:
380
- return Select$1;
381
- case Span:
382
- return Span$1;
383
- case Table:
384
- return Table$1;
385
- case TBody:
386
- return TBody$1;
387
- case Td:
388
- return Td$1;
389
- case TextArea:
390
- return TextArea$1;
391
- case Tfoot:
392
- return Tfoot$1;
393
- case Th:
394
- return Th$1;
395
- case THead:
396
- return THead$1;
397
- case Time:
398
- return Time$1;
399
- case Tr:
400
- return Tr$1;
401
- case Ul:
402
- return Ul$1;
403
- case Video$2:
404
- return Video$1;
297
+ case A$1:
298
+ return A$2;
299
+ case Article$1:
300
+ return Article$2;
301
+ case Aside$1:
302
+ return Aside$2;
303
+ case Audio$1$1:
304
+ return Audio$2;
305
+ case Br$1:
306
+ return Br$2;
307
+ case Button$1:
308
+ return Button$2;
309
+ case Cite$1:
310
+ return Cite$2;
311
+ case Code$1:
312
+ return Code$2;
313
+ case Col$1:
314
+ return Col$2;
315
+ case ColGroup$1:
316
+ return ColGroup$2;
317
+ case Data$1:
318
+ return Data$2;
319
+ case Dd$1:
320
+ return Dd$2;
321
+ case Del$1:
322
+ return Del$2;
323
+ case Div$1:
324
+ return Div$2;
325
+ case Dl$1:
326
+ return Dl$2;
327
+ case Dt$1:
328
+ return Dt$2;
329
+ case Figcaption$1:
330
+ return Figcaption$2;
331
+ case Figure$1:
332
+ return Figure$2;
333
+ case Footer$1:
334
+ return Footer$2;
335
+ case H1$1:
336
+ return H1$2;
337
+ case H2$1:
338
+ return H2$2;
339
+ case H3$1:
340
+ return H3$2;
341
+ case H4$1:
342
+ return H4$2;
343
+ case H5$1:
344
+ return H5$2;
345
+ case H6$1:
346
+ return H6$2;
347
+ case Header$1:
348
+ return Header$2;
349
+ case Hr$1:
350
+ return Hr$2;
351
+ case I$1:
352
+ return I$2;
353
+ case Img$1:
354
+ return Img$2;
355
+ case Input$1:
356
+ return Input$2;
357
+ case Ins$1:
358
+ return Ins$2;
359
+ case Kbd$1:
360
+ return Kbd$2;
361
+ case Label$1:
362
+ return Label$2;
363
+ case Li$1:
364
+ return Li$2;
365
+ case Nav$1:
366
+ return Nav$2;
367
+ case Ol$1:
368
+ return Ol$2;
369
+ case Option$1:
370
+ return Option$2;
371
+ case P$1:
372
+ return P$2;
373
+ case Pre$1:
374
+ return Pre$2;
375
+ case Search$1:
376
+ return Search$2;
377
+ case Section$1:
378
+ return Section$2;
379
+ case Select$1:
380
+ return Select$2;
381
+ case Span$1:
382
+ return Span$2;
383
+ case Table$1:
384
+ return Table$2;
385
+ case TBody$1:
386
+ return TBody$2;
387
+ case Td$1:
388
+ return Td$2;
389
+ case TextArea$1:
390
+ return TextArea$2;
391
+ case Tfoot$1:
392
+ return Tfoot$2;
393
+ case Th$1:
394
+ return Th$2;
395
+ case THead$1:
396
+ return THead$2;
397
+ case Time$1:
398
+ return Time$2;
399
+ case Tr$1:
400
+ return Tr$2;
401
+ case Ul$1:
402
+ return Ul$2;
403
+ case Video$1:
404
+ return Video$2;
405
405
  default:
406
406
  throw new Error(`element tag not found ${type}`);
407
407
  }
@@ -634,8 +634,7 @@ const setProps = ($Element, props, eventMap, newEventMap) => {
634
634
  }
635
635
  };
636
636
  const {
637
- Text: Text$2
638
- } = VirtualDomElements;
637
+ Text: Text$2} = VirtualDomElements$1;
639
638
  const renderDomTextNode = element => {
640
639
  return document.createTextNode(element.text);
641
640
  };
@@ -668,11 +667,61 @@ const renderInternal = ($Parent, elements, eventMap, newEventMap) => {
668
667
  }
669
668
  $Parent.append(...stack);
670
669
  };
670
+
671
+ // Map of property names to attribute names for cases where they differ
672
+ const propertyToAttribute = {
673
+ className: 'class',
674
+ htmlFor: 'for',
675
+ ariaActivedescendant: 'aria-activedescendant',
676
+ ariaControls: 'aria-controls',
677
+ ariaLabelledBy: 'aria-labelledby',
678
+ ariaOwns: 'aria-owns',
679
+ inputType: 'type'
680
+ };
681
+
682
+ // Style properties that need to be set on element.style
683
+ const styleProperties = new Set(['width', 'height', 'top', 'left', 'marginTop', 'paddingLeft', 'paddingRight']);
684
+
685
+ // TODO merge this with the setProp function
686
+
671
687
  const setAttribute = ($Element, key, value) => {
672
- $Element.setAttribute(key, value);
688
+ // Handle width/height for images (set as attributes, not style)
689
+ if ((key === 'width' || key === 'height') && $Element instanceof HTMLImageElement) {
690
+ // @ts-ignore - dynamic property access
691
+ $Element[key] = value;
692
+ return;
693
+ }
694
+
695
+ // Handle style properties
696
+ if (styleProperties.has(key)) {
697
+ // @ts-ignore - dynamic style property access
698
+ $Element.style[key] = typeof value === 'number' ? `${value}px` : value;
699
+ return;
700
+ }
701
+
702
+ // Handle aria attributes - map camelCase to hyphenated form
703
+ if (key in propertyToAttribute) {
704
+ $Element.setAttribute(propertyToAttribute[key], value);
705
+ return;
706
+ }
707
+
708
+ // Use property assignment for known DOM properties, attribute for others
709
+ if (key in $Element) {
710
+ // @ts-ignore - dynamic property access
711
+ $Element[key] = value;
712
+ } else {
713
+ $Element.setAttribute(key, value);
714
+ }
673
715
  };
674
716
  const removeAttribute = ($Element, key) => {
675
- $Element.removeAttribute(key);
717
+ // Handle style properties
718
+ if (styleProperties.has(key)) {
719
+ // @ts-ignore - dynamic style property access
720
+ $Element.style[key] = '';
721
+ return;
722
+ }
723
+ const attributeName = propertyToAttribute[key] || key;
724
+ $Element.removeAttribute(attributeName);
676
725
  };
677
726
  const setText$3 = ($Element, value) => {
678
727
  $Element.nodeValue = value;
@@ -681,10 +730,20 @@ const removeChild = ($Element, index) => {
681
730
  const $Child = $Element.children[index];
682
731
  $Child.remove();
683
732
  };
684
- const add$1 = ($Element, nodes) => {
685
- renderInternal($Element, nodes, {}, {});
733
+ const add$1 = ($Element, nodes, eventMap = {}) => {
734
+ renderInternal($Element, nodes, eventMap, eventMap);
735
+ };
736
+ const replace = ($Element, nodes, eventMap = {}) => {
737
+ // Create a temporary container to render the new nodes
738
+ const $Temp = document.createElement('div');
739
+ renderInternal($Temp, nodes, eventMap, eventMap);
740
+ // Replace the current element with the new ones
741
+ const $NewElement = $Temp.firstElementChild;
742
+ $Element.replaceWith($NewElement);
743
+ return $NewElement;
686
744
  };
687
745
  const SetText = 1;
746
+ const Replace = 2;
688
747
  const SetAttribute = 3;
689
748
  const RemoveAttribute = 4;
690
749
  const Add = 6;
@@ -692,12 +751,12 @@ const NavigateChild = 7;
692
751
  const NavigateParent = 8;
693
752
  const RemoveChild = 9;
694
753
  const NavigateSibling = 10;
695
- const applyPatch = ($Element, patches) => {
754
+ const applyPatch = ($Element, patches, eventMap = {}) => {
696
755
  let $Current = $Element;
697
756
  for (const patch of patches) {
698
757
  switch (patch.type) {
699
758
  case Add:
700
- add$1($Current, patch.nodes);
759
+ add$1($Current, patch.nodes, eventMap);
701
760
  break;
702
761
  case NavigateChild:
703
762
  $Current = $Current.childNodes[patch.index];
@@ -714,6 +773,9 @@ const applyPatch = ($Element, patches) => {
714
773
  case RemoveChild:
715
774
  removeChild($Current, patch.index);
716
775
  break;
776
+ case Replace:
777
+ $Current = replace($Current, patch.nodes, eventMap);
778
+ break;
717
779
  case SetAttribute:
718
780
  setAttribute($Current, patch.key, patch.value);
719
781
  break;
@@ -8905,6 +8967,10 @@ const invoke = (viewletId, method, ...args) => {
8905
8967
  return instance.factory[method](instance.state, ...args);
8906
8968
  };
8907
8969
  const focus$1 = viewletId => {
8970
+ if (location.search.includes('traceFocus')) {
8971
+ // eslint-disable-next-line no-console
8972
+ console.trace(`focus ${viewletId}`);
8973
+ }
8908
8974
  const instance = state$1.instances[viewletId];
8909
8975
  if (instance.factory?.setFocused) {
8910
8976
  instance.factory.setFocused(instance.state, true);
@@ -8917,6 +8983,10 @@ const focusElementByName = (viewletId, name) => {
8917
8983
  return;
8918
8984
  }
8919
8985
  const selector = `[name="${name}"]`;
8986
+ if (location.search.includes('traceFocus')) {
8987
+ // eslint-disable-next-line no-console
8988
+ console.trace(`focusByName ${viewletId} ${name}`);
8989
+ }
8920
8990
  const instance = state$1.instances[viewletId];
8921
8991
  if (!instance) {
8922
8992
  return;
@@ -9084,6 +9154,10 @@ const setPatches = (uid, patches) => {
9084
9154
  if (!$Viewlet) {
9085
9155
  throw new Error('element not found');
9086
9156
  }
9157
+ if (patches.length === 1 && patches[0].type === 6) {
9158
+ setDom2(uid, patches[0].nodes);
9159
+ return;
9160
+ }
9087
9161
  applyPatch($Viewlet, patches);
9088
9162
  };
9089
9163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "20.4.0",
3
+ "version": "21.1.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"