html2canvas-pro 2.1.0 → 2.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.
Files changed (266) hide show
  1. package/dist/html2canvas-pro.esm.js +10226 -10526
  2. package/dist/html2canvas-pro.esm.js.map +1 -1
  3. package/dist/html2canvas-pro.js +10869 -11171
  4. package/dist/html2canvas-pro.js.map +1 -1
  5. package/dist/html2canvas-pro.min.js +8 -8
  6. package/dist/lib/config.js +0 -22
  7. package/dist/lib/core/cache-storage.js +3 -40
  8. package/dist/lib/core/constants.js +25 -0
  9. package/dist/lib/core/context.js +1 -0
  10. package/dist/lib/core/features.js +3 -2
  11. package/dist/lib/core/validator.js +3 -3
  12. package/dist/lib/css/grouped/background-styles.js +36 -0
  13. package/dist/lib/css/grouped/border-styles.js +75 -0
  14. package/dist/lib/css/grouped/font-styles.js +93 -0
  15. package/dist/lib/css/grouped/layout-styles.js +127 -0
  16. package/dist/lib/css/index.js +74 -46
  17. package/dist/lib/css/layout/text.js +7 -6
  18. package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
  19. package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
  20. package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
  21. package/dist/lib/css/property-descriptors/border-image-source.js +21 -0
  22. package/dist/lib/css/property-descriptors/border-radius.js +1 -1
  23. package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
  24. package/dist/lib/css/property-descriptors/counter-increment.js +17 -12
  25. package/dist/lib/css/property-descriptors/counter-reset.js +4 -12
  26. package/dist/lib/css/property-descriptors/filter.js +76 -0
  27. package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
  28. package/dist/lib/css/property-descriptors/object-fit.js +1 -1
  29. package/dist/lib/css/property-descriptors/object-position.js +42 -0
  30. package/dist/lib/css/property-descriptors/visibility.js +1 -1
  31. package/dist/lib/css/property-descriptors/zoom.js +18 -0
  32. package/dist/lib/css/syntax/parser.js +0 -1
  33. package/dist/lib/css/types/color.js +5 -1
  34. package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
  35. package/dist/lib/css/types/image.js +12 -2
  36. package/dist/lib/css/types/length-percentage.js +6 -2
  37. package/dist/lib/css/types/safe-eval.js +80 -0
  38. package/dist/lib/dom/document-cloner.js +23 -163
  39. package/dist/lib/dom/slot-cloner.js +176 -0
  40. package/dist/lib/index.js +1 -17
  41. package/dist/lib/render/canvas/background-renderer.js +169 -30
  42. package/dist/lib/render/canvas/border-image-renderer.js +153 -0
  43. package/dist/lib/render/canvas/canvas-renderer.js +39 -190
  44. package/dist/lib/render/canvas/content-renderer.js +202 -0
  45. package/dist/lib/render/canvas/effects-renderer.js +3 -0
  46. package/dist/lib/render/canvas/foreignobject-renderer.js +5 -1
  47. package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
  48. package/dist/lib/render/canvas/text-renderer.js +100 -224
  49. package/dist/lib/render/effects.js +38 -3
  50. package/dist/lib/render/object-fit.js +19 -15
  51. package/dist/lib/render/stacking-context.js +11 -0
  52. package/dist/types/config.d.ts +0 -10
  53. package/dist/types/core/cache-storage.d.ts +0 -24
  54. package/dist/types/core/constants.d.ts +22 -0
  55. package/dist/types/core/context.d.ts +3 -0
  56. package/dist/types/core/performance-monitor.d.ts +4 -4
  57. package/dist/types/core/validator.d.ts +6 -8
  58. package/dist/types/css/grouped/background-styles.d.ts +16 -0
  59. package/dist/types/css/grouped/border-styles.d.ts +31 -0
  60. package/dist/types/css/grouped/font-styles.d.ts +35 -0
  61. package/dist/types/css/grouped/layout-styles.d.ts +46 -0
  62. package/dist/types/css/index.d.ts +30 -0
  63. package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
  64. package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
  65. package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
  66. package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
  67. package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
  68. package/dist/types/css/property-descriptors/counter-increment.d.ts +3 -0
  69. package/dist/types/css/property-descriptors/filter.d.ts +3 -0
  70. package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
  71. package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
  72. package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
  73. package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
  74. package/dist/types/css/types/image.d.ts +4 -2
  75. package/dist/types/css/types/safe-eval.d.ts +8 -0
  76. package/dist/types/dom/document-cloner.d.ts +3 -44
  77. package/dist/types/dom/slot-cloner.d.ts +66 -0
  78. package/dist/types/index.d.ts +3 -7
  79. package/dist/types/options.d.ts +11 -0
  80. package/dist/types/render/canvas/background-renderer.d.ts +23 -0
  81. package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
  82. package/dist/types/render/canvas/canvas-renderer.d.ts +1 -0
  83. package/dist/types/render/canvas/content-renderer.d.ts +44 -0
  84. package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
  85. package/dist/types/render/canvas/text-renderer.d.ts +12 -1
  86. package/dist/types/render/effects.d.ts +12 -2
  87. package/dist/types/render/object-fit.d.ts +2 -1
  88. package/dist/types/render/renderer-interface.d.ts +11 -9
  89. package/package.json +7 -20
  90. package/dist/lib/dom/replaced-elements/pseudo-elements.js +0 -0
  91. package/dist/lib/invariant.js +0 -9
  92. package/dist/types/dom/replaced-elements/pseudo-elements.d.ts +0 -0
  93. package/dist/types/invariant.d.ts +0 -1
  94. package/src/__tests__/index.ts +0 -99
  95. package/src/config.ts +0 -107
  96. package/src/core/__mocks__/cache-storage.ts +0 -1
  97. package/src/core/__mocks__/context.ts +0 -19
  98. package/src/core/__mocks__/features.ts +0 -8
  99. package/src/core/__mocks__/logger.ts +0 -17
  100. package/src/core/__tests__/cache-storage.test.ts +0 -205
  101. package/src/core/__tests__/cache-storage.ts +0 -278
  102. package/src/core/__tests__/logger.ts +0 -29
  103. package/src/core/__tests__/validator.ts +0 -359
  104. package/src/core/bitwise.ts +0 -1
  105. package/src/core/cache-storage.ts +0 -315
  106. package/src/core/context.ts +0 -31
  107. package/src/core/debugger.ts +0 -32
  108. package/src/core/features.ts +0 -222
  109. package/src/core/logger.ts +0 -64
  110. package/src/core/origin-checker.ts +0 -57
  111. package/src/core/performance-monitor.ts +0 -241
  112. package/src/core/render-element.ts +0 -272
  113. package/src/core/util.ts +0 -1
  114. package/src/core/validator.ts +0 -593
  115. package/src/css/index.ts +0 -427
  116. package/src/css/layout/__mocks__/bounds.ts +0 -6
  117. package/src/css/layout/bounds.ts +0 -79
  118. package/src/css/layout/text.ts +0 -161
  119. package/src/css/property-descriptor.ts +0 -49
  120. package/src/css/property-descriptors/__tests__/background-tests.ts +0 -65
  121. package/src/css/property-descriptors/__tests__/clip-path.test.ts +0 -280
  122. package/src/css/property-descriptors/__tests__/font-family.ts +0 -25
  123. package/src/css/property-descriptors/__tests__/image-rendering-integration.test.ts +0 -153
  124. package/src/css/property-descriptors/__tests__/image-rendering-performance.test.ts +0 -175
  125. package/src/css/property-descriptors/__tests__/image-rendering.test.ts +0 -72
  126. package/src/css/property-descriptors/__tests__/paint-order.ts +0 -87
  127. package/src/css/property-descriptors/__tests__/text-shadow.ts +0 -94
  128. package/src/css/property-descriptors/__tests__/transform-tests.ts +0 -18
  129. package/src/css/property-descriptors/background-clip.ts +0 -30
  130. package/src/css/property-descriptors/background-color.ts +0 -9
  131. package/src/css/property-descriptors/background-image.ts +0 -27
  132. package/src/css/property-descriptors/background-origin.ts +0 -31
  133. package/src/css/property-descriptors/background-position.ts +0 -38
  134. package/src/css/property-descriptors/background-repeat.ts +0 -44
  135. package/src/css/property-descriptors/background-size.ts +0 -27
  136. package/src/css/property-descriptors/border-color.ts +0 -13
  137. package/src/css/property-descriptors/border-radius.ts +0 -19
  138. package/src/css/property-descriptors/border-style.ts +0 -34
  139. package/src/css/property-descriptors/border-width.ts +0 -20
  140. package/src/css/property-descriptors/box-shadow.ts +0 -60
  141. package/src/css/property-descriptors/clip-path.ts +0 -271
  142. package/src/css/property-descriptors/color.ts +0 -9
  143. package/src/css/property-descriptors/content.ts +0 -26
  144. package/src/css/property-descriptors/counter-increment.ts +0 -43
  145. package/src/css/property-descriptors/counter-reset.ts +0 -36
  146. package/src/css/property-descriptors/direction.ts +0 -23
  147. package/src/css/property-descriptors/display.ts +0 -117
  148. package/src/css/property-descriptors/duration.ts +0 -14
  149. package/src/css/property-descriptors/float.ts +0 -29
  150. package/src/css/property-descriptors/font-family.ts +0 -38
  151. package/src/css/property-descriptors/font-size.ts +0 -9
  152. package/src/css/property-descriptors/font-style.ts +0 -25
  153. package/src/css/property-descriptors/font-variant.ts +0 -12
  154. package/src/css/property-descriptors/font-weight.ts +0 -26
  155. package/src/css/property-descriptors/image-rendering.ts +0 -33
  156. package/src/css/property-descriptors/letter-spacing.ts +0 -25
  157. package/src/css/property-descriptors/line-break.ts +0 -22
  158. package/src/css/property-descriptors/line-height.ts +0 -22
  159. package/src/css/property-descriptors/list-style-image.ts +0 -19
  160. package/src/css/property-descriptors/list-style-position.ts +0 -22
  161. package/src/css/property-descriptors/list-style-type.ts +0 -179
  162. package/src/css/property-descriptors/margin.ts +0 -13
  163. package/src/css/property-descriptors/mix-blend-mode.ts +0 -35
  164. package/src/css/property-descriptors/object-fit.ts +0 -39
  165. package/src/css/property-descriptors/opacity.ts +0 -15
  166. package/src/css/property-descriptors/overflow-wrap.ts +0 -22
  167. package/src/css/property-descriptors/overflow.ts +0 -34
  168. package/src/css/property-descriptors/padding.ts +0 -14
  169. package/src/css/property-descriptors/paint-order.ts +0 -42
  170. package/src/css/property-descriptors/position.ts +0 -30
  171. package/src/css/property-descriptors/quotes.ts +0 -57
  172. package/src/css/property-descriptors/rotate.ts +0 -34
  173. package/src/css/property-descriptors/text-align.ts +0 -26
  174. package/src/css/property-descriptors/text-decoration-color.ts +0 -9
  175. package/src/css/property-descriptors/text-decoration-line.ts +0 -38
  176. package/src/css/property-descriptors/text-decoration-style.ts +0 -32
  177. package/src/css/property-descriptors/text-decoration-thickness.ts +0 -30
  178. package/src/css/property-descriptors/text-overflow.ts +0 -23
  179. package/src/css/property-descriptors/text-shadow.ts +0 -52
  180. package/src/css/property-descriptors/text-transform.ts +0 -27
  181. package/src/css/property-descriptors/text-underline-offset.ts +0 -27
  182. package/src/css/property-descriptors/transform-origin.ts +0 -29
  183. package/src/css/property-descriptors/transform.ts +0 -74
  184. package/src/css/property-descriptors/visibility.ts +0 -25
  185. package/src/css/property-descriptors/webkit-line-clamp.ts +0 -30
  186. package/src/css/property-descriptors/webkit-text-stroke-color.ts +0 -8
  187. package/src/css/property-descriptors/webkit-text-stroke-width.ts +0 -15
  188. package/src/css/property-descriptors/word-break.ts +0 -25
  189. package/src/css/property-descriptors/writing-mode.ts +0 -37
  190. package/src/css/property-descriptors/z-index.ts +0 -27
  191. package/src/css/syntax/__tests__/tokernizer-tests.ts +0 -29
  192. package/src/css/syntax/parser.ts +0 -188
  193. package/src/css/syntax/tokenizer.ts +0 -822
  194. package/src/css/type-descriptor.ts +0 -7
  195. package/src/css/types/__tests__/color-tests.ts +0 -147
  196. package/src/css/types/__tests__/image-tests.ts +0 -239
  197. package/src/css/types/angle.ts +0 -86
  198. package/src/css/types/color-math.ts +0 -22
  199. package/src/css/types/color-spaces/a98.ts +0 -86
  200. package/src/css/types/color-spaces/p3.ts +0 -92
  201. package/src/css/types/color-spaces/pro-photo.ts +0 -87
  202. package/src/css/types/color-spaces/rec2020.ts +0 -90
  203. package/src/css/types/color-spaces/srgb.ts +0 -87
  204. package/src/css/types/color-utilities.ts +0 -452
  205. package/src/css/types/color.ts +0 -485
  206. package/src/css/types/functions/-prefix-linear-gradient.ts +0 -35
  207. package/src/css/types/functions/-prefix-radial-gradient.ts +0 -106
  208. package/src/css/types/functions/-webkit-gradient.ts +0 -69
  209. package/src/css/types/functions/__tests__/radial-gradient.ts +0 -69
  210. package/src/css/types/functions/counter.ts +0 -511
  211. package/src/css/types/functions/gradient.ts +0 -206
  212. package/src/css/types/functions/linear-gradient.ts +0 -28
  213. package/src/css/types/functions/radial-gradient.ts +0 -101
  214. package/src/css/types/image.ts +0 -120
  215. package/src/css/types/index.ts +0 -1
  216. package/src/css/types/length-percentage.ts +0 -137
  217. package/src/css/types/length.ts +0 -7
  218. package/src/css/types/time.ts +0 -20
  219. package/src/dom/__mocks__/document-cloner.ts +0 -22
  220. package/src/dom/__tests__/dom-normalizer.test.ts +0 -133
  221. package/src/dom/__tests__/element-container.test.ts +0 -129
  222. package/src/dom/document-cloner.ts +0 -929
  223. package/src/dom/dom-normalizer.ts +0 -133
  224. package/src/dom/element-container.ts +0 -75
  225. package/src/dom/elements/li-element-container.ts +0 -10
  226. package/src/dom/elements/ol-element-container.ts +0 -12
  227. package/src/dom/elements/select-element-container.ts +0 -10
  228. package/src/dom/elements/textarea-element-container.ts +0 -9
  229. package/src/dom/node-parser.ts +0 -177
  230. package/src/dom/node-type-guards.ts +0 -70
  231. package/src/dom/replaced-elements/canvas-element-container.ts +0 -15
  232. package/src/dom/replaced-elements/iframe-element-container.ts +0 -55
  233. package/src/dom/replaced-elements/image-element-container.ts +0 -16
  234. package/src/dom/replaced-elements/index.ts +0 -5
  235. package/src/dom/replaced-elements/input-element-container.ts +0 -105
  236. package/src/dom/replaced-elements/pseudo-elements.ts +0 -0
  237. package/src/dom/replaced-elements/svg-element-container.ts +0 -23
  238. package/src/dom/text-container.ts +0 -42
  239. package/src/global.d.ts +0 -19
  240. package/src/index.ts +0 -82
  241. package/src/invariant.ts +0 -5
  242. package/src/options.ts +0 -55
  243. package/src/render/__tests__/object-fit.test.ts +0 -85
  244. package/src/render/background.ts +0 -298
  245. package/src/render/bezier-curve.ts +0 -47
  246. package/src/render/border.ts +0 -165
  247. package/src/render/bound-curves.ts +0 -388
  248. package/src/render/box-sizing.ts +0 -31
  249. package/src/render/canvas/__tests__/background-renderer.test.ts +0 -72
  250. package/src/render/canvas/__tests__/border-renderer.test.ts +0 -24
  251. package/src/render/canvas/__tests__/effects-renderer.test.ts +0 -32
  252. package/src/render/canvas/__tests__/text-renderer.test.ts +0 -471
  253. package/src/render/canvas/background-renderer.ts +0 -271
  254. package/src/render/canvas/border-renderer.ts +0 -224
  255. package/src/render/canvas/canvas-path.ts +0 -31
  256. package/src/render/canvas/canvas-renderer.ts +0 -641
  257. package/src/render/canvas/effects-renderer.ts +0 -130
  258. package/src/render/canvas/foreignobject-renderer.ts +0 -53
  259. package/src/render/canvas/text-renderer.ts +0 -700
  260. package/src/render/effects.ts +0 -75
  261. package/src/render/font-metrics.ts +0 -72
  262. package/src/render/object-fit.ts +0 -100
  263. package/src/render/path.ts +0 -37
  264. package/src/render/renderer-interface.ts +0 -28
  265. package/src/render/stacking-context.ts +0 -386
  266. package/src/render/vector.ts +0 -19
package/src/css/index.ts DELETED
@@ -1,427 +0,0 @@
1
- import { CSSPropertyDescriptor, PropertyDescriptorParsingType } from './property-descriptor';
2
- import { backgroundClip } from './property-descriptors/background-clip';
3
- import { backgroundColor } from './property-descriptors/background-color';
4
- import { backgroundImage } from './property-descriptors/background-image';
5
- import { backgroundOrigin } from './property-descriptors/background-origin';
6
- import { backgroundPosition } from './property-descriptors/background-position';
7
- import { backgroundRepeat } from './property-descriptors/background-repeat';
8
- import { backgroundSize } from './property-descriptors/background-size';
9
- import {
10
- borderBottomColor,
11
- borderLeftColor,
12
- borderRightColor,
13
- borderTopColor
14
- } from './property-descriptors/border-color';
15
- import {
16
- borderBottomLeftRadius,
17
- borderBottomRightRadius,
18
- borderTopLeftRadius,
19
- borderTopRightRadius
20
- } from './property-descriptors/border-radius';
21
- import {
22
- borderBottomStyle,
23
- borderLeftStyle,
24
- borderRightStyle,
25
- borderTopStyle
26
- } from './property-descriptors/border-style';
27
- import {
28
- borderBottomWidth,
29
- borderLeftWidth,
30
- borderRightWidth,
31
- borderTopWidth
32
- } from './property-descriptors/border-width';
33
- import { clipPath, ClipPathValue } from './property-descriptors/clip-path';
34
- import { color } from './property-descriptors/color';
35
- import { direction } from './property-descriptors/direction';
36
- import { display, DISPLAY } from './property-descriptors/display';
37
- import { float, FLOAT } from './property-descriptors/float';
38
- import { letterSpacing } from './property-descriptors/letter-spacing';
39
- import { lineBreak } from './property-descriptors/line-break';
40
- import { lineHeight } from './property-descriptors/line-height';
41
- import { listStyleImage } from './property-descriptors/list-style-image';
42
- import { listStylePosition } from './property-descriptors/list-style-position';
43
- import { listStyleType } from './property-descriptors/list-style-type';
44
- import { marginBottom, marginLeft, marginRight, marginTop } from './property-descriptors/margin';
45
- import { overflow, OVERFLOW } from './property-descriptors/overflow';
46
- import { overflowWrap } from './property-descriptors/overflow-wrap';
47
- import { paddingBottom, paddingLeft, paddingRight, paddingTop } from './property-descriptors/padding';
48
- import { textAlign } from './property-descriptors/text-align';
49
- import { position, POSITION } from './property-descriptors/position';
50
- import { textShadow } from './property-descriptors/text-shadow';
51
- import { textTransform } from './property-descriptors/text-transform';
52
- import { transform } from './property-descriptors/transform';
53
- import { transformOrigin } from './property-descriptors/transform-origin';
54
- import { rotate } from './property-descriptors/rotate';
55
- import { visibility, VISIBILITY } from './property-descriptors/visibility';
56
- import { wordBreak } from './property-descriptors/word-break';
57
- import { writingMode } from './property-descriptors/writing-mode';
58
- import { zIndex } from './property-descriptors/z-index';
59
- import { CSSValue, isIdentToken, Parser } from './syntax/parser';
60
- import { Tokenizer } from './syntax/tokenizer';
61
- import { Color, color as colorType } from './types/color';
62
- import { isTransparent } from './types/color-utilities';
63
- import { angle } from './types/angle';
64
- import { image } from './types/image';
65
- import { time } from './types/time';
66
- import { opacity } from './property-descriptors/opacity';
67
- import { textDecorationColor } from './property-descriptors/text-decoration-color';
68
- import { textDecorationLine } from './property-descriptors/text-decoration-line';
69
- import { textDecorationStyle } from './property-descriptors/text-decoration-style';
70
- import { textDecorationThickness } from './property-descriptors/text-decoration-thickness';
71
- import { textUnderlineOffset } from './property-descriptors/text-underline-offset';
72
- import { isLengthPercentage, LengthPercentage, ZERO_LENGTH } from './types/length-percentage';
73
- import { fontFamily } from './property-descriptors/font-family';
74
- import { fontSize } from './property-descriptors/font-size';
75
- import { isLength } from './types/length';
76
- import { fontWeight } from './property-descriptors/font-weight';
77
- import { fontVariant } from './property-descriptors/font-variant';
78
- import { fontStyle } from './property-descriptors/font-style';
79
- import { contains } from '../core/bitwise';
80
- import { content } from './property-descriptors/content';
81
- import { counterIncrement } from './property-descriptors/counter-increment';
82
- import { counterReset } from './property-descriptors/counter-reset';
83
- import { duration } from './property-descriptors/duration';
84
- import { quotes } from './property-descriptors/quotes';
85
- import { boxShadow } from './property-descriptors/box-shadow';
86
- import { paintOrder } from './property-descriptors/paint-order';
87
- import { webkitTextStrokeColor } from './property-descriptors/webkit-text-stroke-color';
88
- import { webkitTextStrokeWidth } from './property-descriptors/webkit-text-stroke-width';
89
- import { webkitLineClamp } from './property-descriptors/webkit-line-clamp';
90
- import { Context } from '../core/context';
91
- import { objectFit } from './property-descriptors/object-fit';
92
- import { textOverflow } from './property-descriptors/text-overflow';
93
- import { imageRendering } from './property-descriptors/image-rendering';
94
- import { mixBlendMode, MixBlendMode } from './property-descriptors/mix-blend-mode';
95
-
96
- export class CSSParsedDeclaration {
97
- animationDuration!: ReturnType<typeof duration.parse>;
98
- backgroundClip!: ReturnType<typeof backgroundClip.parse>;
99
- backgroundColor!: Color;
100
- backgroundImage!: ReturnType<typeof backgroundImage.parse>;
101
- backgroundOrigin!: ReturnType<typeof backgroundOrigin.parse>;
102
- backgroundPosition!: ReturnType<typeof backgroundPosition.parse>;
103
- backgroundRepeat!: ReturnType<typeof backgroundRepeat.parse>;
104
- backgroundSize!: ReturnType<typeof backgroundSize.parse>;
105
- borderTopColor!: Color;
106
- borderRightColor!: Color;
107
- borderBottomColor!: Color;
108
- borderLeftColor!: Color;
109
- borderTopLeftRadius!: ReturnType<typeof borderTopLeftRadius.parse>;
110
- borderTopRightRadius!: ReturnType<typeof borderTopRightRadius.parse>;
111
- borderBottomRightRadius!: ReturnType<typeof borderBottomRightRadius.parse>;
112
- borderBottomLeftRadius!: ReturnType<typeof borderBottomLeftRadius.parse>;
113
- borderTopStyle!: ReturnType<typeof borderTopStyle.parse>;
114
- borderRightStyle!: ReturnType<typeof borderRightStyle.parse>;
115
- borderBottomStyle!: ReturnType<typeof borderBottomStyle.parse>;
116
- borderLeftStyle!: ReturnType<typeof borderLeftStyle.parse>;
117
- borderTopWidth!: ReturnType<typeof borderTopWidth.parse>;
118
- borderRightWidth!: ReturnType<typeof borderRightWidth.parse>;
119
- borderBottomWidth!: ReturnType<typeof borderBottomWidth.parse>;
120
- borderLeftWidth!: ReturnType<typeof borderLeftWidth.parse>;
121
- boxShadow!: ReturnType<typeof boxShadow.parse>;
122
- clipPath!: ClipPathValue;
123
- color!: Color;
124
- direction!: ReturnType<typeof direction.parse>;
125
- display!: ReturnType<typeof display.parse>;
126
- float!: ReturnType<typeof float.parse>;
127
- fontFamily!: ReturnType<typeof fontFamily.parse>;
128
- fontSize!: LengthPercentage;
129
- fontStyle!: ReturnType<typeof fontStyle.parse>;
130
- fontVariant!: ReturnType<typeof fontVariant.parse>;
131
- fontWeight!: ReturnType<typeof fontWeight.parse>;
132
- letterSpacing!: ReturnType<typeof letterSpacing.parse>;
133
- lineBreak!: ReturnType<typeof lineBreak.parse>;
134
- lineHeight!: CSSValue;
135
- listStyleImage!: ReturnType<typeof listStyleImage.parse>;
136
- listStylePosition!: ReturnType<typeof listStylePosition.parse>;
137
- listStyleType!: ReturnType<typeof listStyleType.parse>;
138
- marginTop!: CSSValue;
139
- marginRight!: CSSValue;
140
- marginBottom!: CSSValue;
141
- marginLeft!: CSSValue;
142
- opacity!: ReturnType<typeof opacity.parse>;
143
- overflowX!: OVERFLOW;
144
- overflowY!: OVERFLOW;
145
- overflowWrap!: ReturnType<typeof overflowWrap.parse>;
146
- paddingTop!: LengthPercentage;
147
- paddingRight!: LengthPercentage;
148
- paddingBottom!: LengthPercentage;
149
- paddingLeft!: LengthPercentage;
150
- paintOrder!: ReturnType<typeof paintOrder.parse>;
151
- position!: ReturnType<typeof position.parse>;
152
- textAlign!: ReturnType<typeof textAlign.parse>;
153
- textDecorationColor!: Color;
154
- textDecorationLine!: ReturnType<typeof textDecorationLine.parse>;
155
- textDecorationStyle!: ReturnType<typeof textDecorationStyle.parse>;
156
- textDecorationThickness!: ReturnType<typeof textDecorationThickness.parse>;
157
- textUnderlineOffset!: ReturnType<typeof textUnderlineOffset.parse>;
158
- textShadow!: ReturnType<typeof textShadow.parse>;
159
- textTransform!: ReturnType<typeof textTransform.parse>;
160
- textOverflow!: ReturnType<typeof textOverflow.parse>;
161
- transform!: ReturnType<typeof transform.parse>;
162
- transformOrigin!: ReturnType<typeof transformOrigin.parse>;
163
- rotate!: ReturnType<typeof rotate.parse>;
164
- visibility!: ReturnType<typeof visibility.parse>;
165
- webkitTextStrokeColor!: Color;
166
- webkitTextStrokeWidth!: ReturnType<typeof webkitTextStrokeWidth.parse>;
167
- webkitLineClamp!: ReturnType<typeof webkitLineClamp.parse>;
168
- wordBreak!: ReturnType<typeof wordBreak.parse>;
169
- writingMode!: ReturnType<typeof writingMode.parse>;
170
- zIndex!: ReturnType<typeof zIndex.parse>;
171
- objectFit!: ReturnType<typeof objectFit.parse>;
172
- imageRendering!: ReturnType<typeof imageRendering.parse>;
173
- mixBlendMode!: MixBlendMode;
174
-
175
- private static readonly standardProps: [keyof CSSParsedDeclaration, CSSPropertyDescriptor<unknown>, string][] = [
176
- ['animationDuration', duration, 'animationDuration'],
177
- ['backgroundClip', backgroundClip, 'backgroundClip'],
178
- ['backgroundColor', backgroundColor, 'backgroundColor'],
179
- ['backgroundImage', backgroundImage, 'backgroundImage'],
180
- ['backgroundOrigin', backgroundOrigin, 'backgroundOrigin'],
181
- ['backgroundPosition', backgroundPosition, 'backgroundPosition'],
182
- ['backgroundRepeat', backgroundRepeat, 'backgroundRepeat'],
183
- ['backgroundSize', backgroundSize, 'backgroundSize'],
184
- ['borderTopColor', borderTopColor, 'borderTopColor'],
185
- ['borderRightColor', borderRightColor, 'borderRightColor'],
186
- ['borderBottomColor', borderBottomColor, 'borderBottomColor'],
187
- ['borderLeftColor', borderLeftColor, 'borderLeftColor'],
188
- ['borderTopLeftRadius', borderTopLeftRadius, 'borderTopLeftRadius'],
189
- ['borderTopRightRadius', borderTopRightRadius, 'borderTopRightRadius'],
190
- ['borderBottomRightRadius', borderBottomRightRadius, 'borderBottomRightRadius'],
191
- ['borderBottomLeftRadius', borderBottomLeftRadius, 'borderBottomLeftRadius'],
192
- ['borderTopStyle', borderTopStyle, 'borderTopStyle'],
193
- ['borderRightStyle', borderRightStyle, 'borderRightStyle'],
194
- ['borderBottomStyle', borderBottomStyle, 'borderBottomStyle'],
195
- ['borderLeftStyle', borderLeftStyle, 'borderLeftStyle'],
196
- ['borderTopWidth', borderTopWidth, 'borderTopWidth'],
197
- ['borderRightWidth', borderRightWidth, 'borderRightWidth'],
198
- ['borderBottomWidth', borderBottomWidth, 'borderBottomWidth'],
199
- ['borderLeftWidth', borderLeftWidth, 'borderLeftWidth'],
200
- ['boxShadow', boxShadow, 'boxShadow'],
201
- ['clipPath', clipPath, 'clipPath'],
202
- ['color', color, 'color'],
203
- ['direction', direction, 'direction'],
204
- ['display', display, 'display'],
205
- ['fontFamily', fontFamily, 'fontFamily'],
206
- ['fontSize', fontSize, 'fontSize'],
207
- ['fontStyle', fontStyle, 'fontStyle'],
208
- ['fontVariant', fontVariant, 'fontVariant'],
209
- ['fontWeight', fontWeight, 'fontWeight'],
210
- ['letterSpacing', letterSpacing, 'letterSpacing'],
211
- ['lineBreak', lineBreak, 'lineBreak'],
212
- ['lineHeight', lineHeight, 'lineHeight'],
213
- ['listStyleImage', listStyleImage, 'listStyleImage'],
214
- ['listStylePosition', listStylePosition, 'listStylePosition'],
215
- ['listStyleType', listStyleType, 'listStyleType'],
216
- ['marginTop', marginTop, 'marginTop'],
217
- ['marginRight', marginRight, 'marginRight'],
218
- ['marginBottom', marginBottom, 'marginBottom'],
219
- ['marginLeft', marginLeft, 'marginLeft'],
220
- ['opacity', opacity, 'opacity'],
221
- ['overflowWrap', overflowWrap, 'overflowWrap'],
222
- ['paddingTop', paddingTop, 'paddingTop'],
223
- ['paddingRight', paddingRight, 'paddingRight'],
224
- ['paddingBottom', paddingBottom, 'paddingBottom'],
225
- ['paddingLeft', paddingLeft, 'paddingLeft'],
226
- ['paintOrder', paintOrder, 'paintOrder'],
227
- ['position', position, 'position'],
228
- ['textAlign', textAlign, 'textAlign'],
229
- ['textDecorationStyle', textDecorationStyle, 'textDecorationStyle'],
230
- ['textDecorationThickness', textDecorationThickness, 'textDecorationThickness'],
231
- ['textUnderlineOffset', textUnderlineOffset, 'textUnderlineOffset'],
232
- ['textShadow', textShadow, 'textShadow'],
233
- ['textTransform', textTransform, 'textTransform'],
234
- ['textOverflow', textOverflow, 'textOverflow'],
235
- ['transform', transform, 'transform'],
236
- ['transformOrigin', transformOrigin, 'transformOrigin'],
237
- ['rotate', rotate, 'rotate'],
238
- ['visibility', visibility, 'visibility'],
239
- ['webkitTextStrokeColor', webkitTextStrokeColor, 'webkitTextStrokeColor'],
240
- ['webkitTextStrokeWidth', webkitTextStrokeWidth, 'webkitTextStrokeWidth'],
241
- ['webkitLineClamp', webkitLineClamp, 'webkitLineClamp'],
242
- ['wordBreak', wordBreak, 'wordBreak'],
243
- ['writingMode', writingMode, 'writingMode'],
244
- ['zIndex', zIndex, 'zIndex'],
245
- ['objectFit', objectFit, 'objectFit'],
246
- ['imageRendering', imageRendering, 'imageRendering'],
247
- ['mixBlendMode', mixBlendMode, 'mixBlendMode']
248
- ];
249
-
250
- constructor(context: Context, declaration: CSSStyleDeclaration) {
251
- const standardProps = CSSParsedDeclaration.standardProps;
252
-
253
- // Fast path: display:none elements are invisible and their descendants
254
- // are never rendered. Parse only initial values instead of full computed styles.
255
- if (declaration.display === 'none') {
256
- this.display = DISPLAY.NONE;
257
- for (const [key, descriptor] of standardProps) {
258
- if (key !== 'display') {
259
- (this as Record<string, unknown>)[key] = parse(context, descriptor, undefined);
260
- }
261
- }
262
- this.float = parse(context, float, undefined);
263
- this.textDecorationColor = parse(context, textDecorationColor, undefined);
264
- this.textDecorationLine = parse(context, textDecorationLine, undefined);
265
- const overflowTuple = parse(context, overflow, undefined);
266
- this.overflowX = overflowTuple[0];
267
- this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
268
- return;
269
- }
270
-
271
- for (const [key, descriptor, cssProp] of standardProps) {
272
- (this as Record<string, unknown>)[key] = parse(
273
- context,
274
- descriptor,
275
- (declaration as unknown as Record<string, string | undefined>)[cssProp]
276
- );
277
- }
278
-
279
- // Special cases that need different CSS property names or fallback values
280
- this.float = parse(context, float, declaration.cssFloat);
281
- this.textDecorationColor = parse(
282
- context,
283
- textDecorationColor,
284
- declaration.textDecorationColor ?? declaration.color
285
- );
286
- this.textDecorationLine = parse(
287
- context,
288
- textDecorationLine,
289
- declaration.textDecorationLine ?? declaration.textDecoration
290
- );
291
-
292
- // overflow returns a tuple that must be split into X/Y
293
- const overflowTuple = parse(context, overflow, declaration.overflow);
294
- this.overflowX = overflowTuple[0];
295
- this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
296
- }
297
-
298
- isVisible(): boolean {
299
- return this.display > 0 && this.opacity > 0 && this.visibility === VISIBILITY.VISIBLE;
300
- }
301
-
302
- isTransparent(): boolean {
303
- return isTransparent(this.backgroundColor);
304
- }
305
-
306
- isTransformed(): boolean {
307
- return this.transform !== null || this.rotate !== null;
308
- }
309
-
310
- isPositioned(): boolean {
311
- return this.position !== POSITION.STATIC;
312
- }
313
-
314
- isPositionedWithZIndex(): boolean {
315
- return this.isPositioned() && !this.zIndex.auto;
316
- }
317
-
318
- isFloating(): boolean {
319
- return this.float !== FLOAT.NONE;
320
- }
321
-
322
- isInlineLevel(): boolean {
323
- return (
324
- contains(this.display, DISPLAY.INLINE) ||
325
- contains(this.display, DISPLAY.INLINE_BLOCK) ||
326
- contains(this.display, DISPLAY.INLINE_FLEX) ||
327
- contains(this.display, DISPLAY.INLINE_GRID) ||
328
- contains(this.display, DISPLAY.INLINE_LIST_ITEM) ||
329
- contains(this.display, DISPLAY.INLINE_TABLE)
330
- );
331
- }
332
- }
333
-
334
- export class CSSParsedPseudoDeclaration {
335
- content: ReturnType<typeof content.parse>;
336
- quotes: ReturnType<typeof quotes.parse>;
337
-
338
- constructor(context: Context, declaration: CSSStyleDeclaration) {
339
- this.content = parse(context, content, declaration.content);
340
- this.quotes = parse(context, quotes, declaration.quotes);
341
- }
342
- }
343
-
344
- export class CSSParsedCounterDeclaration {
345
- counterIncrement: ReturnType<typeof counterIncrement.parse>;
346
- counterReset: ReturnType<typeof counterReset.parse>;
347
-
348
- constructor(context: Context, declaration: CSSStyleDeclaration) {
349
- this.counterIncrement = parse(context, counterIncrement, declaration.counterIncrement);
350
- this.counterReset = parse(context, counterReset, declaration.counterReset);
351
- }
352
- }
353
-
354
- const parseCache = new Map<CSSPropertyDescriptor<any>, Map<string, unknown>>();
355
- const PARSE_CACHE_MAX_PER_DESCRIPTOR = 200;
356
-
357
- const parse = (context: Context, descriptor: CSSPropertyDescriptor<any>, style?: string | null) => {
358
- const rawValue = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
359
-
360
- let valueCache = parseCache.get(descriptor);
361
- if (valueCache) {
362
- const cached = valueCache.get(rawValue);
363
- if (cached !== undefined) {
364
- return cached;
365
- }
366
- }
367
-
368
- const tokenizer = Tokenizer.get();
369
- tokenizer.write(rawValue);
370
- const parser = new Parser(tokenizer.read());
371
- Tokenizer.release(tokenizer);
372
-
373
- let result: any;
374
- switch (descriptor.type) {
375
- case PropertyDescriptorParsingType.IDENT_VALUE: {
376
- const token = parser.parseComponentValue();
377
- result = descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue);
378
- break;
379
- }
380
- case PropertyDescriptorParsingType.VALUE:
381
- result = descriptor.parse(context, parser.parseComponentValue());
382
- break;
383
- case PropertyDescriptorParsingType.LIST:
384
- result = descriptor.parse(context, parser.parseComponentValues());
385
- break;
386
- case PropertyDescriptorParsingType.TOKEN_VALUE:
387
- result = parser.parseComponentValue();
388
- break;
389
- case PropertyDescriptorParsingType.TYPE_VALUE:
390
- switch (descriptor.format) {
391
- case 'angle':
392
- result = angle.parse(context, parser.parseComponentValue());
393
- break;
394
- case 'color':
395
- result = colorType.parse(context, parser.parseComponentValue());
396
- break;
397
- case 'image':
398
- result = image.parse(context, parser.parseComponentValue());
399
- break;
400
- case 'length': {
401
- const length = parser.parseComponentValue();
402
- result = isLength(length) ? length : ZERO_LENGTH;
403
- break;
404
- }
405
- case 'length-percentage': {
406
- const value = parser.parseComponentValue();
407
- result = isLengthPercentage(value) ? value : ZERO_LENGTH;
408
- break;
409
- }
410
- case 'time':
411
- result = time.parse(context, parser.parseComponentValue());
412
- break;
413
- }
414
- break;
415
- }
416
-
417
- if (!valueCache) {
418
- valueCache = new Map();
419
- parseCache.set(descriptor, valueCache);
420
- }
421
- if (valueCache.size >= PARSE_CACHE_MAX_PER_DESCRIPTOR) {
422
- valueCache.clear();
423
- }
424
- valueCache.set(rawValue, result);
425
-
426
- return result;
427
- };
@@ -1,6 +0,0 @@
1
- import type { Bounds as BoundsType } from '../bounds';
2
- const actual = await vi.importActual<typeof import('../bounds')>('../bounds');
3
- export const { Bounds } = actual;
4
- export const parseBounds = (): BoundsType => {
5
- return new Bounds(0, 0, 200, 50);
6
- };
@@ -1,79 +0,0 @@
1
- import { Context } from '../../core/context';
2
-
3
- export class Bounds {
4
- constructor(
5
- readonly left: number,
6
- readonly top: number,
7
- readonly width: number,
8
- readonly height: number
9
- ) {}
10
-
11
- add(x: number, y: number, w: number, h: number): Bounds {
12
- return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);
13
- }
14
-
15
- static fromClientRect(context: Context, clientRect: ClientRect): Bounds {
16
- return new Bounds(
17
- clientRect.left + context.windowBounds.left,
18
- clientRect.top + context.windowBounds.top,
19
- clientRect.width,
20
- clientRect.height
21
- );
22
- }
23
-
24
- static fromDOMRectList(context: Context, domRectList: DOMRectList): Bounds {
25
- const rects = Array.from(domRectList);
26
-
27
- // First try to find a rect with non-zero width
28
- let domRect = rects.find((rect) => rect.width !== 0);
29
-
30
- // If not found, try to find a rect with non-zero height
31
- // This handles cases like inline-flex with single child where width might be 0
32
- if (!domRect) {
33
- domRect = rects.find((rect) => rect.height !== 0);
34
- }
35
-
36
- // If still not found but rects exist, use the first rect
37
- // Position info (left, top) might still be valid even if dimensions are 0
38
- if (!domRect && rects.length > 0) {
39
- domRect = rects[0];
40
- }
41
-
42
- return domRect
43
- ? new Bounds(
44
- domRect.left + context.windowBounds.left,
45
- domRect.top + context.windowBounds.top,
46
- domRect.width,
47
- domRect.height
48
- )
49
- : Bounds.EMPTY;
50
- }
51
-
52
- static EMPTY = new Bounds(0, 0, 0, 0);
53
- }
54
-
55
- export const parseBounds = (context: Context, node: Element): Bounds => {
56
- return Bounds.fromClientRect(context, node.getBoundingClientRect());
57
- };
58
-
59
- export const parseDocumentSize = (document: Document): Bounds => {
60
- const body = document.body;
61
- const documentElement = document.documentElement;
62
-
63
- if (!body || !documentElement) {
64
- throw new Error(`Unable to get document size`);
65
- }
66
- const width = Math.max(
67
- Math.max(body.scrollWidth, documentElement.scrollWidth),
68
- Math.max(body.offsetWidth, documentElement.offsetWidth),
69
- Math.max(body.clientWidth, documentElement.clientWidth)
70
- );
71
-
72
- const height = Math.max(
73
- Math.max(body.scrollHeight, documentElement.scrollHeight),
74
- Math.max(body.offsetHeight, documentElement.offsetHeight),
75
- Math.max(body.clientHeight, documentElement.clientHeight)
76
- );
77
-
78
- return new Bounds(0, 0, width, height);
79
- };
@@ -1,161 +0,0 @@
1
- import { OVERFLOW_WRAP } from '../property-descriptors/overflow-wrap';
2
- import { CSSParsedDeclaration } from '../index';
3
- import { fromCodePoint, LineBreaker, toCodePoints } from 'css-line-break';
4
- import { splitGraphemes } from 'text-segmentation';
5
- import { Bounds, parseBounds } from './bounds';
6
- import { FEATURES } from '../../core/features';
7
- import { Context } from '../../core/context';
8
- import { isVerticalWritingMode } from '../property-descriptors/writing-mode';
9
-
10
- export class TextBounds {
11
- readonly text: string;
12
- readonly bounds: Bounds;
13
-
14
- constructor(text: string, bounds: Bounds) {
15
- this.text = text;
16
- this.bounds = bounds;
17
- }
18
- }
19
-
20
- export const parseTextBounds = (
21
- context: Context,
22
- value: string,
23
- styles: CSSParsedDeclaration,
24
- node: Text
25
- ): TextBounds[] => {
26
- const textList = breakText(value, styles);
27
- const textBounds: TextBounds[] = [];
28
- let offset = 0;
29
- textList.forEach((text) => {
30
- if (styles.textDecorationLine.length || text.trim().length > 0) {
31
- if (FEATURES.SUPPORT_RANGE_BOUNDS) {
32
- const clientRects = createRange(node, offset, text.length).getClientRects();
33
- if (clientRects.length > 1) {
34
- const subSegments = segmentGraphemes(text);
35
- let subOffset = 0;
36
- subSegments.forEach((subSegment) => {
37
- textBounds.push(
38
- new TextBounds(
39
- subSegment,
40
- Bounds.fromDOMRectList(
41
- context,
42
- createRange(node, subOffset + offset, subSegment.length).getClientRects()
43
- )
44
- )
45
- );
46
- subOffset += subSegment.length;
47
- });
48
- } else {
49
- textBounds.push(new TextBounds(text, Bounds.fromDOMRectList(context, clientRects)));
50
- }
51
- } else {
52
- const replacementNode = node.splitText(text.length);
53
- textBounds.push(new TextBounds(text, getWrapperBounds(context, node)));
54
- node = replacementNode;
55
- }
56
- } else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {
57
- node = node.splitText(text.length);
58
- }
59
- offset += text.length;
60
- });
61
-
62
- return textBounds;
63
- };
64
-
65
- const getWrapperBounds = (context: Context, node: Text): Bounds => {
66
- const ownerDocument = node.ownerDocument;
67
- if (ownerDocument) {
68
- const wrapper = ownerDocument.createElement('html2canvaswrapper');
69
- wrapper.appendChild(node.cloneNode(true));
70
- const parentNode = node.parentNode;
71
- if (parentNode) {
72
- parentNode.replaceChild(wrapper, node);
73
- const bounds = parseBounds(context, wrapper);
74
- if (wrapper.firstChild) {
75
- parentNode.replaceChild(wrapper.firstChild, wrapper);
76
- }
77
- return bounds;
78
- }
79
- }
80
-
81
- return Bounds.EMPTY;
82
- };
83
-
84
- const createRange = (node: Text, offset: number, length: number): Range => {
85
- const ownerDocument = node.ownerDocument;
86
- if (!ownerDocument) {
87
- throw new Error('Node has no owner document');
88
- }
89
- const range = ownerDocument.createRange();
90
- range.setStart(node, offset);
91
- range.setEnd(node, offset + length);
92
- return range;
93
- };
94
-
95
- export const segmentGraphemes = (value: string): string[] => {
96
- if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
97
- const segmenter = new (Intl as any).Segmenter(void 0, { granularity: 'grapheme' });
98
-
99
- return Array.from(segmenter.segment(value)).map((segment: any) => segment.segment);
100
- }
101
-
102
- return splitGraphemes(value);
103
- };
104
-
105
- const segmentWords = (value: string, styles: CSSParsedDeclaration): string[] => {
106
- if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
107
- const segmenter = new (Intl as any).Segmenter(void 0, {
108
- granularity: 'word'
109
- });
110
-
111
- return Array.from(segmenter.segment(value)).map((segment: any) => segment.segment);
112
- }
113
-
114
- return breakWords(value, styles);
115
- };
116
-
117
- const breakText = (value: string, styles: CSSParsedDeclaration): string[] => {
118
- if (isVerticalWritingMode(styles.writingMode)) {
119
- return segmentGraphemes(value);
120
- }
121
-
122
- return styles.letterSpacing !== 0 ? segmentGraphemes(value) : segmentWords(value, styles);
123
- };
124
-
125
- // https://drafts.csswg.org/css-text/#word-separator
126
- const wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
127
-
128
- const breakWords = (str: string, styles: CSSParsedDeclaration): string[] => {
129
- const breaker = LineBreaker(str, {
130
- lineBreak: styles.lineBreak,
131
- wordBreak: styles.overflowWrap === OVERFLOW_WRAP.BREAK_WORD ? 'break-word' : styles.wordBreak
132
- });
133
-
134
- const words = [];
135
- let bk;
136
-
137
- while (!(bk = breaker.next()).done) {
138
- if (bk.value) {
139
- const value = bk.value.slice();
140
- const codePoints = toCodePoints(value);
141
- let word = '';
142
- codePoints.forEach((codePoint) => {
143
- if (wordSeparators.indexOf(codePoint) === -1) {
144
- word += fromCodePoint(codePoint);
145
- } else {
146
- if (word.length) {
147
- words.push(word);
148
- }
149
- words.push(fromCodePoint(codePoint));
150
- word = '';
151
- }
152
- });
153
-
154
- if (word.length) {
155
- words.push(word);
156
- }
157
- }
158
- }
159
-
160
- return words;
161
- };