@symbo.ls/connect 3.2.7

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.
Files changed (77) hide show
  1. package/build.js +205 -0
  2. package/dist/assets/1024x1024.png +0 -0
  3. package/dist/assets/128x128.png +0 -0
  4. package/dist/assets/144x144.png +0 -0
  5. package/dist/assets/192x192.png +0 -0
  6. package/dist/assets/48x48.png +0 -0
  7. package/dist/assets/512x512.png +0 -0
  8. package/dist/assets/72x72.png +0 -0
  9. package/dist/assets/96x96.png +0 -0
  10. package/dist/assets/active_cursor.png +0 -0
  11. package/dist/assets/favicon.svg +6 -0
  12. package/dist/assets/old/144x144.png +0 -0
  13. package/dist/assets/old/192x192.png +0 -0
  14. package/dist/assets/old/48x48.png +0 -0
  15. package/dist/assets/old/48x48_faint.png +0 -0
  16. package/dist/assets/old/512x512.png +0 -0
  17. package/dist/assets/old/72x72.png +0 -0
  18. package/dist/assets/old/96x96.png +0 -0
  19. package/dist/auth.js +373 -0
  20. package/dist/content.css +46 -0
  21. package/dist/content.js +1171 -0
  22. package/dist/content.js.map +7 -0
  23. package/dist/devtools.html +7 -0
  24. package/dist/devtools.js +5 -0
  25. package/dist/manifest.json +87 -0
  26. package/dist/page-agent.js +727 -0
  27. package/dist/panel.css +2239 -0
  28. package/dist/panel.html +235 -0
  29. package/dist/panel.js +4973 -0
  30. package/dist/picker.html +111 -0
  31. package/dist/picker.js +300 -0
  32. package/dist/service_worker.js +219 -0
  33. package/dist/service_worker.js.map +7 -0
  34. package/dist/settings.css +128 -0
  35. package/dist/settings.html +26 -0
  36. package/dist/settings_ui.js +57 -0
  37. package/dist/settings_ui.js.map +7 -0
  38. package/package.json +20 -0
  39. package/src/content.js +104 -0
  40. package/src/grabber/clean.js +605 -0
  41. package/src/grabber/computed.js +78 -0
  42. package/src/grabber/parse.js +268 -0
  43. package/src/grabber/stylesheets.js +117 -0
  44. package/src/grabber/utils.js +238 -0
  45. package/src/service_worker.js +246 -0
  46. package/src/settings/settings_ui.js +52 -0
  47. package/src/settings/settings_utils.js +70 -0
  48. package/static/assets/1024x1024.png +0 -0
  49. package/static/assets/128x128.png +0 -0
  50. package/static/assets/144x144.png +0 -0
  51. package/static/assets/192x192.png +0 -0
  52. package/static/assets/48x48.png +0 -0
  53. package/static/assets/512x512.png +0 -0
  54. package/static/assets/72x72.png +0 -0
  55. package/static/assets/96x96.png +0 -0
  56. package/static/assets/active_cursor.png +0 -0
  57. package/static/assets/favicon.svg +6 -0
  58. package/static/assets/old/144x144.png +0 -0
  59. package/static/assets/old/192x192.png +0 -0
  60. package/static/assets/old/48x48.png +0 -0
  61. package/static/assets/old/48x48_faint.png +0 -0
  62. package/static/assets/old/512x512.png +0 -0
  63. package/static/assets/old/72x72.png +0 -0
  64. package/static/assets/old/96x96.png +0 -0
  65. package/static/auth.js +373 -0
  66. package/static/content.css +46 -0
  67. package/static/devtools.html +7 -0
  68. package/static/devtools.js +5 -0
  69. package/static/manifest.json +56 -0
  70. package/static/page-agent.js +727 -0
  71. package/static/panel.css +2239 -0
  72. package/static/panel.html +235 -0
  73. package/static/panel.js +4973 -0
  74. package/static/picker.html +111 -0
  75. package/static/picker.js +300 -0
  76. package/static/settings.css +128 -0
  77. package/static/settings.html +26 -0
@@ -0,0 +1,605 @@
1
+ import { deepClone } from '@domql/utils'
2
+ import { allEqual } from './utils'
3
+
4
+ /**
5
+ * Utility function to consolidate CSS values
6
+ * @param {string[]} values
7
+ * @returns string
8
+ */
9
+ function consolidateValues(values) {
10
+ const uniqueValues = new Set(values)
11
+
12
+ if (uniqueValues.size === 1) {
13
+ return values[0] // All values are the same
14
+ }
15
+
16
+ if (uniqueValues.size === 2) {
17
+ const [vertical, horizontal] = values
18
+ if (vertical === horizontal) {
19
+ return `${vertical}`
20
+ }
21
+ } else if (uniqueValues.size === 4) {
22
+ const [topLeft, topRight, bottomRight, bottomLeft] = values
23
+ if (topLeft === topRight && bottomLeft === bottomRight) {
24
+ return `${topLeft} ${bottomLeft}`
25
+ }
26
+ }
27
+
28
+ return values.join(' ')
29
+ }
30
+
31
+ function consolidateTextDecoration(style) {
32
+ const updatedStyle = deepClone(style)
33
+
34
+ const decorationProps = [
35
+ 'textDecorationThickness',
36
+ 'textDecorationStyle',
37
+ 'textDecorationColor'
38
+ ]
39
+
40
+ const thickness =
41
+ style.textDecorationThickness && style.textDecorationThickness !== 'initial'
42
+ ? style.textDecorationThickness
43
+ : ''
44
+ const styleProp =
45
+ style.textDecorationStyle && style.textDecorationStyle !== 'initial'
46
+ ? style.textDecorationStyle
47
+ : ''
48
+ const color =
49
+ style.textDecorationColor && style.textDecorationColor !== 'initial'
50
+ ? style.textDecorationColor
51
+ : ''
52
+
53
+ // Build the consolidated textDecoration shorthand
54
+ const consolidatedTextDecoration = [thickness, styleProp, color]
55
+ .filter(Boolean)
56
+ .join(' ')
57
+ .trim()
58
+
59
+ // Set the textDecoration shorthand if there's any valid value
60
+ if (consolidatedTextDecoration) {
61
+ updatedStyle.textDecoration = consolidatedTextDecoration
62
+ }
63
+
64
+ // Remove individual textDecoration properties from the style
65
+ decorationProps.forEach((prop) => delete updatedStyle[prop])
66
+
67
+ return updatedStyle
68
+ }
69
+
70
+ function consolidateBorderRadius(style) {
71
+ const radiusProps = [
72
+ 'borderBottomLeftRadius',
73
+ 'borderBottomRightRadius',
74
+ 'borderEndEndRadius',
75
+ 'borderEndStartRadius',
76
+ 'borderStartEndRadius',
77
+ 'borderStartStartRadius',
78
+ 'borderTopLeftRadius',
79
+ 'borderTopRightRadius'
80
+ ]
81
+
82
+ const sides = ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft']
83
+ const radii = []
84
+
85
+ // Collect valid border radius values from each side
86
+ sides.forEach((side) => {
87
+ const radius = style[`border${side}Radius`]
88
+ if (radius && radius !== 'initial') {
89
+ radii.push(radius)
90
+ } else {
91
+ radii.push('0') // If undefined or initial, add 0
92
+ }
93
+ })
94
+
95
+ // Consolidate border radius values
96
+ const consolidatedRadius = consolidateValues(radii).trim()
97
+
98
+ const updated = { ...style }
99
+ // Set the consolidated border radius if there's a valid value
100
+ if (consolidatedRadius && consolidatedRadius !== '0') {
101
+ updated.borderRadius = consolidatedRadius
102
+ }
103
+
104
+ // Remove individual radius properties from the style object
105
+ radiusProps.forEach((prop) => delete updated[prop])
106
+
107
+ return updated
108
+ }
109
+
110
+ function consolidateAndUpdateBorderProperties(style) {
111
+ const updatedStyle = deepClone(style)
112
+ const result = {}
113
+ const sides = ['Top', 'Right', 'Bottom', 'Left']
114
+ const properties = ['Width', 'Style', 'Color']
115
+
116
+ // Extract border properties
117
+ const borderProps = {}
118
+ sides.forEach((side) => {
119
+ properties.forEach((prop) => {
120
+ const key = `border${side}${prop}`
121
+ if (updatedStyle[key] && updatedStyle[key] !== 'initial') {
122
+ borderProps[key] = updatedStyle[key]
123
+ }
124
+ })
125
+ })
126
+
127
+ // Check if all sides are equal
128
+ const allSidesEqual = properties.every((prop) =>
129
+ allEqual(sides.map((side) => borderProps[`border${side}${prop}`]))
130
+ )
131
+
132
+ if (allSidesEqual) {
133
+ // All sides are equal, use shorthand
134
+ const width = borderProps.borderTopWidth
135
+ const borderStyle = borderProps.borderTopStyle
136
+ const color = borderProps.borderTopColor
137
+
138
+ if (width && borderStyle && color) {
139
+ result.border = `${width} ${borderStyle} ${color}`
140
+ } else {
141
+ if (width) {
142
+ result.borderWidth = width
143
+ }
144
+ if (borderStyle) {
145
+ result.borderStyle = borderStyle
146
+ }
147
+ if (color) {
148
+ result.borderColor = color
149
+ }
150
+ }
151
+ } else {
152
+ // Check if logical properties can be used
153
+ const logicalSides = ['BlockStart', 'BlockEnd', 'InlineStart', 'InlineEnd']
154
+ const logicalEqual = properties.every((prop) =>
155
+ allEqual(logicalSides.map((side) => borderProps[`border${side}${prop}`]))
156
+ )
157
+
158
+ if (logicalEqual) {
159
+ // Use logical shorthands
160
+ const blockWidth = borderProps.borderBlockStartWidth
161
+ const blockStyle = borderProps.borderBlockStartStyle
162
+ const blockColor = borderProps.borderBlockStartColor
163
+ const inlineWidth = borderProps.borderInlineStartWidth
164
+ const inlineStyle = borderProps.borderInlineStartStyle
165
+ const inlineColor = borderProps.borderInlineStartColor
166
+
167
+ if (
168
+ blockWidth === inlineWidth &&
169
+ blockStyle === inlineStyle &&
170
+ blockColor === inlineColor
171
+ ) {
172
+ result.border = `${blockWidth} ${blockStyle} ${blockColor}`
173
+ } else {
174
+ if (blockWidth) {
175
+ result.borderBlockWidth = blockWidth
176
+ }
177
+ if (blockStyle) {
178
+ result.borderBlockStyle = blockStyle
179
+ }
180
+ if (blockColor) {
181
+ result.borderBlockColor = blockColor
182
+ }
183
+ if (inlineWidth && inlineWidth !== blockWidth) {
184
+ result.borderInlineWidth = inlineWidth
185
+ }
186
+ if (inlineStyle && inlineStyle !== blockStyle) {
187
+ result.borderInlineStyle = inlineStyle
188
+ }
189
+ if (inlineColor && inlineColor !== blockColor) {
190
+ result.borderInlineColor = inlineColor
191
+ }
192
+ }
193
+ } else {
194
+ // Use individual logical properties
195
+ logicalSides.forEach((side) => {
196
+ const width = borderProps[`border${side}Width`]
197
+ const borderStyle = borderProps[`border${side}Style`]
198
+ const color = borderProps[`border${side}Color`]
199
+ if (width && borderStyle && color) {
200
+ result[`border${side}`] = `${width} ${borderStyle} ${color}`
201
+ } else {
202
+ if (width) {
203
+ result[`border${side}Width`] = width
204
+ }
205
+ if (borderStyle) {
206
+ result[`border${side}Style`] = borderStyle
207
+ }
208
+ if (color) {
209
+ result[`border${side}Color`] = color
210
+ }
211
+ }
212
+ })
213
+ }
214
+ }
215
+
216
+ // Add any border image properties
217
+ ;[
218
+ 'borderImageSource',
219
+ 'borderImageSlice',
220
+ 'borderImageWidth',
221
+ 'borderImageOutset',
222
+ 'borderImageRepeat'
223
+ ].forEach((prop) => {
224
+ if (updatedStyle[prop] && updatedStyle[prop] !== 'initial') {
225
+ result[prop] = updatedStyle[prop]
226
+ }
227
+ delete updatedStyle[prop]
228
+ })
229
+
230
+ // Clean up old border properties
231
+ sides.forEach((side) => {
232
+ properties.forEach((prop) => {
233
+ delete updatedStyle[`border${side}${prop}`]
234
+ })
235
+ })
236
+ ;[
237
+ 'border',
238
+ 'borderWidth',
239
+ 'borderStyle',
240
+ 'borderColor',
241
+ 'borderBlock',
242
+ 'borderInline'
243
+ ].forEach((prop) => {
244
+ delete updatedStyle[prop]
245
+ })
246
+
247
+ // Add consolidated properties back to style
248
+ return { ...updatedStyle, ...result }
249
+ }
250
+
251
+ function consolidateSpacing(style, property = 'padding') {
252
+ const updatedStyle = deepClone(style)
253
+ const propertyMap = {
254
+ top:
255
+ style[`${property}Top`] ||
256
+ style[`${property}BlockStart`] ||
257
+ style[`${property}Block`],
258
+ right:
259
+ style[`${property}Right`] ||
260
+ style[`${property}InlineEnd`] ||
261
+ style[`${property}Inline`],
262
+ bottom:
263
+ style[`${property}Bottom`] ||
264
+ style[`${property}BlockEnd`] ||
265
+ style[`${property}Block`],
266
+ left:
267
+ style[`${property}Left`] ||
268
+ style[`${property}InlineStart`] ||
269
+ style[`${property}Inline`]
270
+ }
271
+
272
+ const consolidatedValues = ['top', 'right', 'bottom', 'left'].map(
273
+ (side) => propertyMap[side] || '0'
274
+ )
275
+
276
+ // Check if any value was actually applied
277
+ if (consolidatedValues.every((value) => value === '0')) {
278
+ return updatedStyle // Return unchanged style if no values were applied
279
+ }
280
+
281
+ // Simplify the values if possible
282
+ const [top, right, bottom, left] = consolidatedValues
283
+ let result = consolidatedValues.join(' ') // All four sides are different or have placeholders
284
+
285
+ if (right === left) {
286
+ if (top === bottom) {
287
+ if (top === right) {
288
+ // All sides are the same
289
+ result = top
290
+ } else {
291
+ // Vertical and horizontal values are different
292
+ result = `${top} ${right}`
293
+ }
294
+ } else {
295
+ // Top, horizontal, and bottom values
296
+ result = `${top} ${right} ${bottom}`
297
+ }
298
+ }
299
+
300
+ // Remove related properties from style
301
+ ;[
302
+ `${property}Top`,
303
+ `${property}Right`,
304
+ `${property}Bottom`,
305
+ `${property}Left`,
306
+ `${property}BlockStart`,
307
+ `${property}BlockEnd`,
308
+ `${property}InlineStart`,
309
+ `${property}InlineEnd`,
310
+ `${property}Block`,
311
+ `${property}Inline`,
312
+ property
313
+ ].forEach((prop) => {
314
+ delete updatedStyle[prop]
315
+ })
316
+
317
+ updatedStyle[property] = result
318
+
319
+ return updatedStyle
320
+ }
321
+
322
+ export function splitPropsFromStyles(style) {
323
+ const updatedStyle = deepClone(style)
324
+ const props = {}
325
+
326
+ const stylesWithProps = [
327
+ 'alignContent',
328
+ 'alignItems',
329
+ 'alignSelf',
330
+ 'animation',
331
+ 'animationDelay',
332
+ 'animationDirection',
333
+ 'animationDuration',
334
+ 'animationFillMode',
335
+ 'animationIterationCount',
336
+ 'animationName',
337
+ 'animationPlayState',
338
+ 'animationTimingFunction',
339
+ 'appearance',
340
+ 'aspectRatio',
341
+ 'background',
342
+ 'backgroundColor',
343
+ 'backgroundPosition',
344
+ 'backgroundRepeat',
345
+ 'backgroundSize',
346
+ 'backfaceVisibility',
347
+ 'backdropFilter',
348
+ 'blockSize',
349
+ 'border',
350
+ 'borderBottom',
351
+ 'borderColor',
352
+ 'borderLeft',
353
+ 'borderRadius',
354
+ 'borderRight',
355
+ 'borderStyle',
356
+ 'borderTop',
357
+ 'borderWidth',
358
+ 'bottom',
359
+ 'boxShadow',
360
+ 'boxSize',
361
+ 'boxSizing',
362
+ 'caretColor',
363
+ 'columns',
364
+ 'columnCount',
365
+ 'columnFill',
366
+ 'columnGap',
367
+ 'columnRule',
368
+ 'columnRule',
369
+ 'columnSpan',
370
+ 'columnWidth',
371
+ 'color',
372
+ 'content',
373
+ 'cursor',
374
+ 'depth',
375
+ 'direction',
376
+ 'direction',
377
+ 'display',
378
+ 'filter',
379
+ 'flex',
380
+ 'flexAlign',
381
+ 'flexDirection',
382
+ 'flexFlow',
383
+ 'flexWrap',
384
+ 'float',
385
+ 'gap',
386
+ 'gridArea',
387
+ 'gridColumn',
388
+ 'gridColumnStart',
389
+ 'gridRow',
390
+ 'gridRowStart',
391
+ 'height',
392
+ 'heightRange',
393
+ 'horizontalInset',
394
+ 'inlineSize',
395
+ 'inset',
396
+ 'justifyContent',
397
+ 'justifyItems',
398
+ 'left',
399
+ 'maxBlockSize',
400
+ 'maxHeight',
401
+ 'maxInlineSize',
402
+ 'maxSize',
403
+ 'maxWidth',
404
+ 'mixBlendMode',
405
+ 'minBlockSize',
406
+ 'minHeight',
407
+ 'minInlineSize',
408
+ 'minSize',
409
+ 'minWidth',
410
+ 'margin',
411
+ 'marginBlock',
412
+ 'marginBlockEnd',
413
+ 'marginBlockStart',
414
+ 'marginInline',
415
+ 'marginInlineEnd',
416
+ 'marginInlineStart',
417
+ 'objectFit',
418
+ 'opacity',
419
+ 'order',
420
+ 'overflow',
421
+ 'overflowX',
422
+ 'overflowY',
423
+ 'outline',
424
+ 'outlineOffset',
425
+ 'overscrollBehavior',
426
+ 'padding',
427
+ 'paddingBlock',
428
+ 'paddingBlockEnd',
429
+ 'paddingBlockStart',
430
+ 'paddingInline',
431
+ 'paddingInlineEnd',
432
+ 'paddingInlineStart',
433
+ 'perspective',
434
+ 'perspectiveOrigin',
435
+ 'pointerEvents',
436
+ 'position',
437
+ 'right',
438
+ 'resize',
439
+ 'round',
440
+ 'rowGap',
441
+ 'scrollPadding',
442
+ 'shape',
443
+ 'shapeDirection',
444
+ 'shapeDirectionColor',
445
+ 'shadow',
446
+ 'size',
447
+ 'textShadow',
448
+ 'textStroke',
449
+ 'theme',
450
+ 'top',
451
+ 'transform',
452
+ 'transformOrigin',
453
+ 'transition',
454
+ 'transitionDelay',
455
+ 'transitionDuration',
456
+ 'transitionProperty',
457
+ 'transitionTimingFunction',
458
+ 'userSelect',
459
+ 'verticalAlign',
460
+ 'verticalInset',
461
+ 'visibility',
462
+ 'width',
463
+ 'widthRange',
464
+ 'willChange',
465
+ 'zIndex',
466
+ 'zoom'
467
+ ]
468
+
469
+ stylesWithProps.forEach((key) => {
470
+ if (key in updatedStyle) {
471
+ props[key] = updatedStyle[key]
472
+ delete updatedStyle[key]
473
+ }
474
+ })
475
+
476
+ return { props, style: updatedStyle }
477
+ }
478
+
479
+ export function consolidateStyles(style) {
480
+ let updatedStyle = deepClone(style)
481
+
482
+ // Consolidate outline properties
483
+ if (style.outlineWidth || style.outlineStyle || style.outlineColor) {
484
+ updatedStyle.outline = `${style.outlineWidth || 'initial'} ${
485
+ style.outlineStyle || 'initial'
486
+ } ${style.outlineColor || 'initial'}`
487
+
488
+ delete updatedStyle.outlineWidth
489
+ delete updatedStyle.outlineStyle
490
+ delete updatedStyle.outlineColor
491
+ }
492
+
493
+ // Consolidate padding
494
+ const insetProps = [
495
+ 'insetInlineStart',
496
+ 'insetBlockEnd',
497
+ 'insetInlineEnd',
498
+ 'insetBlockStart'
499
+ ]
500
+ const insetValues = insetProps.map((prop) => style[prop] || '0')
501
+ if (insetValues.some((val) => val !== '0')) {
502
+ updatedStyle.inset = consolidateValues(insetValues)
503
+ insetProps.forEach((prop) => delete updatedStyle[prop])
504
+ }
505
+
506
+ // Consolidate transition properties
507
+ if (
508
+ style.transition &&
509
+ style.transitionProperty &&
510
+ style.transitionDuration
511
+ ) {
512
+ updatedStyle.transition = `${style.transition} ${style.transitionProperty} ${style.transitionDuration}`
513
+
514
+ delete updatedStyle.transitionProperty
515
+ delete updatedStyle.transitionDuration
516
+ }
517
+
518
+ const sizeProps = ['inlineSize', 'blockSize']
519
+ const sizeValues = sizeProps.map((prop) => style[prop] || '0')
520
+ if (sizeValues.some((val) => val !== '0')) {
521
+ updatedStyle.size = consolidateValues(sizeValues)
522
+ sizeProps.forEach((prop) => delete updatedStyle[prop])
523
+ }
524
+
525
+ let gapValues = []
526
+ if (style.gap) {
527
+ gapValues = [...gapValues, ...style.gap.split(' ')]
528
+ delete updatedStyle.gap
529
+ }
530
+ const gapProps = ['rowGap', 'columnGap']
531
+ gapValues = [...gapValues, ...gapProps.map((prop) => style[prop] || '0')]
532
+ if (gapValues.some((val) => val !== '0')) {
533
+ updatedStyle.gap = consolidateValues(gapValues)
534
+ gapProps.forEach((prop) => delete updatedStyle[prop])
535
+ }
536
+
537
+ if (style.webkitTextStroke) {
538
+ updatedStyle.textStroke = style.webkitTextStroke
539
+ delete updatedStyle.webkitTextStroke
540
+ }
541
+
542
+ updatedStyle = consolidateBorderRadius(updatedStyle)
543
+ updatedStyle = consolidateAndUpdateBorderProperties(updatedStyle)
544
+ updatedStyle = consolidateSpacing(updatedStyle, 'padding')
545
+ updatedStyle = consolidateSpacing(updatedStyle, 'margin')
546
+ updatedStyle = consolidateSpacing(updatedStyle, 'borderWidth')
547
+ updatedStyle = consolidateTextDecoration(updatedStyle)
548
+
549
+ if (style.minWidth && style.maxWidth) {
550
+ updatedStyle.widthRange = `${style.minWidth} ${style.maxWidth}`
551
+
552
+ delete updatedStyle.minWidth
553
+ delete updatedStyle.maxWidth
554
+ }
555
+
556
+ if (style.minHeight && style.maxHeight) {
557
+ style.heightRange = `${style.minHeight} ${style.maxHeight}`
558
+
559
+ delete updatedStyle.minHeight
560
+ delete updatedStyle.maxHeight
561
+ }
562
+
563
+ // Return the new cleaned style object
564
+ return updatedStyle
565
+ }
566
+
567
+ export function consolidateFlexCSS(props) {
568
+ const updatedProps = deepClone(props)
569
+
570
+ // Consolidate alignItems and justifyContent
571
+ if (props.alignItems || props.justifyContent) {
572
+ updatedProps.align = `${props.alignItems || ''} ${
573
+ props.justifyContent || ''
574
+ }`.trim()
575
+ delete updatedProps.alignItems
576
+ delete updatedProps.justifyContent
577
+ }
578
+
579
+ // Consolidate flexDirection and flexWrap
580
+ if (props.flexDirection || props.flexWrap) {
581
+ updatedProps.flow = `${props.flexDirection || 'row'} ${
582
+ props.flexWrap || ''
583
+ }`.trim()
584
+ delete updatedProps.flexDirection
585
+ delete updatedProps.flexWrap
586
+ }
587
+
588
+ return updatedProps
589
+ }
590
+
591
+ export function consolidateGridCSS(props) {
592
+ const updatedProps = deepClone(props)
593
+
594
+ if (props.gridTemplateColumns) {
595
+ updatedProps.columns = props.gridTemplateColumns
596
+ delete updatedProps.gridTemplateColumns
597
+ }
598
+
599
+ if (props.gridTemplateRows) {
600
+ updatedProps.rows = props.gridTemplateRows
601
+ delete updatedProps.gridTemplateRows
602
+ }
603
+
604
+ return updatedProps
605
+ }
@@ -0,0 +1,78 @@
1
+ export function getComputedStyles(node) {
2
+ const computedStyle = window.getComputedStyle(node)
3
+ const style = {}
4
+
5
+ for (let i = 0; i < computedStyle.length; i++) {
6
+ const property = computedStyle[i]
7
+ const value = computedStyle.getPropertyValue(property)
8
+ style[property] = value
9
+ }
10
+
11
+ return style
12
+ }
13
+
14
+ export function getStyleDefaultsFromEmptyNode(tag) {
15
+ const node = document.createElement(tag)
16
+ document.body.appendChild(node)
17
+ const computed = getComputedStyles(node)
18
+ document.body.removeChild(node)
19
+ return computed
20
+ }
21
+
22
+ export function getAppliedComputedStyles(node, defaults) {
23
+ const css = getComputedStyles(node)
24
+ const styles = {}
25
+
26
+ Object.keys(css).forEach((prop) => {
27
+ const value = css[prop]
28
+
29
+ const ignoreAllVals = [
30
+ 'width',
31
+ 'height',
32
+ 'inline-size',
33
+ 'block-size',
34
+ 'transform-origin',
35
+ 'perspective-origin'
36
+ ]
37
+ const ignoreAutoVals = [
38
+ 'margin',
39
+ 'margin-top',
40
+ 'margin-bottom',
41
+ 'margin-left',
42
+ 'margin-right',
43
+ 'padding',
44
+ 'padding-top',
45
+ 'padding-bottom',
46
+ 'padding-left',
47
+ 'padding-right',
48
+ 'top',
49
+ 'bottom',
50
+ 'left',
51
+ 'right',
52
+ 'min-width',
53
+ 'min-height',
54
+ 'min-block-size',
55
+ 'min-inline-size'
56
+ ]
57
+
58
+ /**
59
+ * @type {Array<[string, () => boolean]>}
60
+ */
61
+ const skipDefault = [['flex-direction', (s) => s.display === 'flex']]
62
+
63
+ const defaultIsValid =
64
+ skipDefault.some(([p, con]) => prop === p && con(css)) ||
65
+ value !== defaults[prop]
66
+
67
+ if (
68
+ !ignoreAllVals.includes(prop) &&
69
+ value &&
70
+ defaultIsValid &&
71
+ !(ignoreAutoVals.includes(prop) && value === 'auto')
72
+ ) {
73
+ styles[prop] = value
74
+ }
75
+ })
76
+
77
+ return styles
78
+ }