@hatiolab/things-scene 9.0.0-beta.36 → 9.0.0-beta.37

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 (397) hide show
  1. package/package.json +1 -1
  2. package/things-scene-min.js +11 -11
  3. package/things-scene-min.js.map +1 -1
  4. package/things-scene.mjs +11 -11
  5. package/things-scene.mjs.map +1 -1
  6. package/.cursorignore +0 -62
  7. package/.prettierrc +0 -21
  8. package/assets/icon-audio.png +0 -0
  9. package/assets/icon-gif-viewer.png +0 -0
  10. package/assets/images/spinner.png +0 -0
  11. package/babel.config.js +0 -23
  12. package/db.sqlite +0 -0
  13. package/dist/animation/animate.js +0 -63
  14. package/dist/animation/animate.js.map +0 -1
  15. package/dist/animation/animations/animation.js +0 -122
  16. package/dist/animation/animations/animation.js.map +0 -1
  17. package/dist/animation/animations/fade.js +0 -28
  18. package/dist/animation/animations/fade.js.map +0 -1
  19. package/dist/animation/animations/heartbeat.js +0 -28
  20. package/dist/animation/animations/heartbeat.js.map +0 -1
  21. package/dist/animation/animations/moving.js +0 -24
  22. package/dist/animation/animations/moving.js.map +0 -1
  23. package/dist/animation/animations/outline.js +0 -47
  24. package/dist/animation/animations/outline.js.map +0 -1
  25. package/dist/animation/animations/rotation.js +0 -22
  26. package/dist/animation/animations/rotation.js.map +0 -1
  27. package/dist/animation/animations/vibration.js +0 -31
  28. package/dist/animation/animations/vibration.js.map +0 -1
  29. package/dist/animation/compile.js +0 -31
  30. package/dist/animation/compile.js.map +0 -1
  31. package/dist/animation/delta.js +0 -51
  32. package/dist/animation/delta.js.map +0 -1
  33. package/dist/animation/index.js +0 -14
  34. package/dist/animation/index.js.map +0 -1
  35. package/dist/command/command-change.js +0 -33
  36. package/dist/command/command-change.js.map +0 -1
  37. package/dist/command/command-migrate.js +0 -103
  38. package/dist/command/command-migrate.js.map +0 -1
  39. package/dist/command/command.js +0 -18
  40. package/dist/command/command.js.map +0 -1
  41. package/dist/command/snapshot-commander.js +0 -84
  42. package/dist/command/snapshot-commander.js.map +0 -1
  43. package/dist/components/anchor/anchor.js +0 -105
  44. package/dist/components/anchor/anchor.js.map +0 -1
  45. package/dist/components/anchor/ellipse-anchors.js +0 -53
  46. package/dist/components/anchor/ellipse-anchors.js.map +0 -1
  47. package/dist/components/anchor/rect-anchors.js +0 -53
  48. package/dist/components/anchor/rect-anchors.js.map +0 -1
  49. package/dist/components/audio.js +0 -154
  50. package/dist/components/audio.js.map +0 -1
  51. package/dist/components/cloud.js +0 -44
  52. package/dist/components/cloud.js.map +0 -1
  53. package/dist/components/component.js +0 -1086
  54. package/dist/components/component.js.map +0 -1
  55. package/dist/components/container-abstract.js +0 -387
  56. package/dist/components/container-abstract.js.map +0 -1
  57. package/dist/components/container.js +0 -331
  58. package/dist/components/container.js.map +0 -1
  59. package/dist/components/data/data-mapping.js +0 -82
  60. package/dist/components/data/data-mapping.js.map +0 -1
  61. package/dist/components/data/data.js +0 -166
  62. package/dist/components/data/data.js.map +0 -1
  63. package/dist/components/data/evaluator.js +0 -103
  64. package/dist/components/data/evaluator.js.map +0 -1
  65. package/dist/components/donut.js +0 -104
  66. package/dist/components/donut.js.map +0 -1
  67. package/dist/components/drawer/draw-image-pendable.js +0 -20
  68. package/dist/components/drawer/draw-image-pendable.js.map +0 -1
  69. package/dist/components/drawer/effect.js +0 -19
  70. package/dist/components/drawer/effect.js.map +0 -1
  71. package/dist/components/drawer/fill.js +0 -228
  72. package/dist/components/drawer/fill.js.map +0 -1
  73. package/dist/components/drawer/format.js +0 -115
  74. package/dist/components/drawer/format.js.map +0 -1
  75. package/dist/components/drawer/line.js +0 -191
  76. package/dist/components/drawer/line.js.map +0 -1
  77. package/dist/components/drawer/stroke.js +0 -62
  78. package/dist/components/drawer/stroke.js.map +0 -1
  79. package/dist/components/drawer/text-wrapper.js +0 -51
  80. package/dist/components/drawer/text-wrapper.js.map +0 -1
  81. package/dist/components/drawer/text.js +0 -269
  82. package/dist/components/drawer/text.js.map +0 -1
  83. package/dist/components/ellipse.js +0 -110
  84. package/dist/components/ellipse.js.map +0 -1
  85. package/dist/components/file/ondropfile.js +0 -19
  86. package/dist/components/file/ondropfile.js.map +0 -1
  87. package/dist/components/fit/fit.js +0 -137
  88. package/dist/components/fit/fit.js.map +0 -1
  89. package/dist/components/geometry/transcoord.js +0 -339
  90. package/dist/components/geometry/transcoord.js.map +0 -1
  91. package/dist/components/geometry/union.js +0 -35
  92. package/dist/components/geometry/union.js.map +0 -1
  93. package/dist/components/gif-view.js +0 -128
  94. package/dist/components/gif-view.js.map +0 -1
  95. package/dist/components/global-ref.js +0 -154
  96. package/dist/components/global-ref.js.map +0 -1
  97. package/dist/components/group.js +0 -171
  98. package/dist/components/group.js.map +0 -1
  99. package/dist/components/html/elements.js +0 -24
  100. package/dist/components/html/elements.js.map +0 -1
  101. package/dist/components/html/fill.js +0 -126
  102. package/dist/components/html/fill.js.map +0 -1
  103. package/dist/components/html/reposition.js +0 -119
  104. package/dist/components/html/reposition.js.map +0 -1
  105. package/dist/components/html/shadow.js +0 -24
  106. package/dist/components/html/shadow.js.map +0 -1
  107. package/dist/components/html-overlay-container.js +0 -27
  108. package/dist/components/html-overlay-container.js.map +0 -1
  109. package/dist/components/html-overlay-element.js +0 -22
  110. package/dist/components/html-overlay-element.js.map +0 -1
  111. package/dist/components/image-view.js +0 -193
  112. package/dist/components/image-view.js.map +0 -1
  113. package/dist/components/index.js +0 -231
  114. package/dist/components/index.js.map +0 -1
  115. package/dist/components/info-window.js +0 -416
  116. package/dist/components/info-window.js.map +0 -1
  117. package/dist/components/line.js +0 -374
  118. package/dist/components/line.js.map +0 -1
  119. package/dist/components/local-ref.js +0 -114
  120. package/dist/components/local-ref.js.map +0 -1
  121. package/dist/components/mixins/connectable.js +0 -128
  122. package/dist/components/mixins/connectable.js.map +0 -1
  123. package/dist/components/mixins/data-source.js +0 -34
  124. package/dist/components/mixins/data-source.js.map +0 -1
  125. package/dist/components/mixins/html-element.js +0 -107
  126. package/dist/components/mixins/html-element.js.map +0 -1
  127. package/dist/components/mixins/move-handle.js +0 -73
  128. package/dist/components/mixins/move-handle.js.map +0 -1
  129. package/dist/components/mixins/rect-path.js +0 -113
  130. package/dist/components/mixins/rect-path.js.map +0 -1
  131. package/dist/components/mixins/value-holder.js +0 -81
  132. package/dist/components/mixins/value-holder.js.map +0 -1
  133. package/dist/components/mutater/bounds.js +0 -68
  134. package/dist/components/mutater/bounds.js.map +0 -1
  135. package/dist/components/mutater/path.js +0 -73
  136. package/dist/components/mutater/path.js.map +0 -1
  137. package/dist/components/ortholine.js +0 -763
  138. package/dist/components/ortholine.js.map +0 -1
  139. package/dist/components/outline/ellipse-outline.js +0 -23
  140. package/dist/components/outline/ellipse-outline.js.map +0 -1
  141. package/dist/components/outline/path-outline.js +0 -48
  142. package/dist/components/outline/path-outline.js.map +0 -1
  143. package/dist/components/path.js +0 -49
  144. package/dist/components/path.js.map +0 -1
  145. package/dist/components/polygon.js +0 -91
  146. package/dist/components/polygon.js.map +0 -1
  147. package/dist/components/polyline.js +0 -114
  148. package/dist/components/polyline.js.map +0 -1
  149. package/dist/components/popup.js +0 -160
  150. package/dist/components/popup.js.map +0 -1
  151. package/dist/components/rect.js +0 -72
  152. package/dist/components/rect.js.map +0 -1
  153. package/dist/components/retention/retention-manager.js +0 -81
  154. package/dist/components/retention/retention-manager.js.map +0 -1
  155. package/dist/components/root-container.js +0 -519
  156. package/dist/components/root-container.js.map +0 -1
  157. package/dist/components/ruler.js +0 -103
  158. package/dist/components/ruler.js.map +0 -1
  159. package/dist/components/shape.js +0 -97
  160. package/dist/components/shape.js.map +0 -1
  161. package/dist/components/star.js +0 -103
  162. package/dist/components/star.js.map +0 -1
  163. package/dist/components/text/substitutor.js +0 -92
  164. package/dist/components/text/substitutor.js.map +0 -1
  165. package/dist/components/text.js +0 -21
  166. package/dist/components/text.js.map +0 -1
  167. package/dist/components/triangle.js +0 -92
  168. package/dist/components/triangle.js.map +0 -1
  169. package/dist/const.js +0 -71
  170. package/dist/const.js.map +0 -1
  171. package/dist/core/collection.js +0 -28
  172. package/dist/core/collection.js.map +0 -1
  173. package/dist/core/debug.js +0 -12
  174. package/dist/core/debug.js.map +0 -1
  175. package/dist/core/deep-equals.js +0 -112
  176. package/dist/core/deep-equals.js.map +0 -1
  177. package/dist/core/dom-to-image.js +0 -617
  178. package/dist/core/dom-to-image.js.map +0 -1
  179. package/dist/core/event.js +0 -205
  180. package/dist/core/event.js.map +0 -1
  181. package/dist/core/index.js +0 -21
  182. package/dist/core/index.js.map +0 -1
  183. package/dist/core/list.js +0 -87
  184. package/dist/core/list.js.map +0 -1
  185. package/dist/core/logger.js +0 -29
  186. package/dist/core/logger.js.map +0 -1
  187. package/dist/core/memoize.js +0 -40
  188. package/dist/core/memoize.js.map +0 -1
  189. package/dist/core/mixin.js +0 -26
  190. package/dist/core/mixin.js.map +0 -1
  191. package/dist/core/obj-accessor.js +0 -26
  192. package/dist/core/obj-accessor.js.map +0 -1
  193. package/dist/core/reference-map.js +0 -147
  194. package/dist/core/reference-map.js.map +0 -1
  195. package/dist/core/round-rect.js +0 -62
  196. package/dist/core/round-rect.js.map +0 -1
  197. package/dist/core/safe-round.js +0 -10
  198. package/dist/core/safe-round.js.map +0 -1
  199. package/dist/core/script-loader.js +0 -148
  200. package/dist/core/script-loader.js.map +0 -1
  201. package/dist/core/snapshot-taker.js +0 -59
  202. package/dist/core/snapshot-taker.js.map +0 -1
  203. package/dist/core/stack.js +0 -18
  204. package/dist/core/stack.js.map +0 -1
  205. package/dist/core/timecapsule.js +0 -88
  206. package/dist/core/timecapsule.js.map +0 -1
  207. package/dist/core/utils.js +0 -309
  208. package/dist/core/utils.js.map +0 -1
  209. package/dist/decorator/anchors-decorator.js +0 -53
  210. package/dist/decorator/anchors-decorator.js.map +0 -1
  211. package/dist/decorator/bouncing-arrow-decorator.js +0 -52
  212. package/dist/decorator/bouncing-arrow-decorator.js.map +0 -1
  213. package/dist/decorator/data-spread-decorator.js +0 -69
  214. package/dist/decorator/data-spread-decorator.js.map +0 -1
  215. package/dist/decorator/decotag-decorator.js +0 -33
  216. package/dist/decorator/decotag-decorator.js.map +0 -1
  217. package/dist/decorator/index.js +0 -31
  218. package/dist/decorator/index.js.map +0 -1
  219. package/dist/decorator/link-decorator.js +0 -66
  220. package/dist/decorator/link-decorator.js.map +0 -1
  221. package/dist/effect/gradation.js +0 -37
  222. package/dist/effect/gradation.js.map +0 -1
  223. package/dist/effect/index.js +0 -23
  224. package/dist/effect/index.js.map +0 -1
  225. package/dist/effect/shadow.js +0 -33
  226. package/dist/effect/shadow.js.map +0 -1
  227. package/dist/effect/turn.js +0 -25
  228. package/dist/effect/turn.js.map +0 -1
  229. package/dist/event/event-engine.js +0 -76
  230. package/dist/event/event-engine.js.map +0 -1
  231. package/dist/event/event-pump.js +0 -92
  232. package/dist/event/event-pump.js.map +0 -1
  233. package/dist/event/event-tracker.js +0 -97
  234. package/dist/event/event-tracker.js.map +0 -1
  235. package/dist/event/index.js +0 -21
  236. package/dist/event/index.js.map +0 -1
  237. package/dist/event/ua-event-handler.js +0 -453
  238. package/dist/event/ua-event-handler.js.map +0 -1
  239. package/dist/event-map/animator-handler.js +0 -225
  240. package/dist/event-map/animator-handler.js.map +0 -1
  241. package/dist/event-map/animators/animated-icon.js +0 -265
  242. package/dist/event-map/animators/animated-icon.js.map +0 -1
  243. package/dist/event-map/animators/border-highlighting.js +0 -476
  244. package/dist/event-map/animators/border-highlighting.js.map +0 -1
  245. package/dist/event-map/animators/bouncing-arrow.js +0 -226
  246. package/dist/event-map/animators/bouncing-arrow.js.map +0 -1
  247. package/dist/event-map/event-map.js +0 -36
  248. package/dist/event-map/event-map.js.map +0 -1
  249. package/dist/event-map/index.js +0 -20
  250. package/dist/event-map/index.js.map +0 -1
  251. package/dist/event-map/move-handler.js +0 -233
  252. package/dist/event-map/move-handler.js.map +0 -1
  253. package/dist/event-map/paste-handler.js +0 -176
  254. package/dist/event-map/paste-handler.js.map +0 -1
  255. package/dist/event-map/shift-handler.js +0 -55
  256. package/dist/event-map/shift-handler.js.map +0 -1
  257. package/dist/event-map/text-editor-lite.js +0 -276
  258. package/dist/event-map/text-editor-lite.js.map +0 -1
  259. package/dist/event-map/zoom-handler.js +0 -49
  260. package/dist/event-map/zoom-handler.js.map +0 -1
  261. package/dist/index.js +0 -20
  262. package/dist/index.js.map +0 -1
  263. package/dist/layer/action/emphasize.js +0 -42
  264. package/dist/layer/action/emphasize.js.map +0 -1
  265. package/dist/layer/action/popup.js +0 -461
  266. package/dist/layer/action/popup.js.map +0 -1
  267. package/dist/layer/action/pressed.js +0 -31
  268. package/dist/layer/action/pressed.js.map +0 -1
  269. package/dist/layer/add-layer.js +0 -180
  270. package/dist/layer/add-layer.js.map +0 -1
  271. package/dist/layer/decotag-layer.js +0 -121
  272. package/dist/layer/decotag-layer.js.map +0 -1
  273. package/dist/layer/guide-layer.js +0 -292
  274. package/dist/layer/guide-layer.js.map +0 -1
  275. package/dist/layer/index.js +0 -70
  276. package/dist/layer/index.js.map +0 -1
  277. package/dist/layer/layer.js +0 -230
  278. package/dist/layer/layer.js.map +0 -1
  279. package/dist/layer/minimap-layer.js +0 -84
  280. package/dist/layer/minimap-layer.js.map +0 -1
  281. package/dist/layer/model-layer.js +0 -465
  282. package/dist/layer/model-layer.js.map +0 -1
  283. package/dist/layer/modeler/anchor-handler.js +0 -193
  284. package/dist/layer/modeler/anchor-handler.js.map +0 -1
  285. package/dist/layer/modeler/control-handler.js +0 -95
  286. package/dist/layer/modeler/control-handler.js.map +0 -1
  287. package/dist/layer/modeler/focus-outline.js +0 -41
  288. package/dist/layer/modeler/focus-outline.js.map +0 -1
  289. package/dist/layer/modeler/group-outline.js +0 -30
  290. package/dist/layer/modeler/group-outline.js.map +0 -1
  291. package/dist/layer/modeler/index.js +0 -56
  292. package/dist/layer/modeler/index.js.map +0 -1
  293. package/dist/layer/modeler/path-handler.js +0 -300
  294. package/dist/layer/modeler/path-handler.js.map +0 -1
  295. package/dist/layer/modeler/resizer.js +0 -333
  296. package/dist/layer/modeler/resizer.js.map +0 -1
  297. package/dist/layer/modeler/rotator.js +0 -134
  298. package/dist/layer/modeler/rotator.js.map +0 -1
  299. package/dist/layer/modeling-layer.js +0 -491
  300. package/dist/layer/modeling-layer.js.map +0 -1
  301. package/dist/layer/reaction-layer.js +0 -111
  302. package/dist/layer/reaction-layer.js.map +0 -1
  303. package/dist/layer/scroll-layer.js +0 -191
  304. package/dist/layer/scroll-layer.js.map +0 -1
  305. package/dist/layer/selection/selected-finder.js +0 -96
  306. package/dist/layer/selection/selected-finder.js.map +0 -1
  307. package/dist/layer/selection-layer.js +0 -373
  308. package/dist/layer/selection-layer.js.map +0 -1
  309. package/dist/layer/shift-layer.js +0 -83
  310. package/dist/layer/shift-layer.js.map +0 -1
  311. package/dist/layout/absolute.js +0 -30
  312. package/dist/layout/absolute.js.map +0 -1
  313. package/dist/layout/card.js +0 -52
  314. package/dist/layout/card.js.map +0 -1
  315. package/dist/layout/html-absolute.js +0 -32
  316. package/dist/layout/html-absolute.js.map +0 -1
  317. package/dist/layout/index.js +0 -56
  318. package/dist/layout/index.js.map +0 -1
  319. package/dist/layout/layout.js +0 -36
  320. package/dist/layout/layout.js.map +0 -1
  321. package/dist/layout/linear-horizontal.js +0 -56
  322. package/dist/layout/linear-horizontal.js.map +0 -1
  323. package/dist/layout/linear-vertical.js +0 -56
  324. package/dist/layout/linear-vertical.js.map +0 -1
  325. package/dist/layout/table.js +0 -106
  326. package/dist/layout/table.js.map +0 -1
  327. package/dist/license/license.js +0 -170
  328. package/dist/license/license.js.map +0 -1
  329. package/dist/model/compile.js +0 -40
  330. package/dist/model/compile.js.map +0 -1
  331. package/dist/model/duplicate.js +0 -19
  332. package/dist/model/duplicate.js.map +0 -1
  333. package/dist/model/index.js +0 -34
  334. package/dist/model/index.js.map +0 -1
  335. package/dist/model/selector.js +0 -104
  336. package/dist/model/selector.js.map +0 -1
  337. package/dist/style/compile.js +0 -14
  338. package/dist/style/compile.js.map +0 -1
  339. package/dist/style/index.js +0 -14
  340. package/dist/style/index.js.map +0 -1
  341. package/dist/things-scene/api/add-start.js +0 -18
  342. package/dist/things-scene/api/add-start.js.map +0 -1
  343. package/dist/things-scene/api/add.js +0 -71
  344. package/dist/things-scene/api/add.js.map +0 -1
  345. package/dist/things-scene/api/align.js +0 -116
  346. package/dist/things-scene/api/align.js.map +0 -1
  347. package/dist/things-scene/api/center-to.js +0 -50
  348. package/dist/things-scene/api/center-to.js.map +0 -1
  349. package/dist/things-scene/api/change.js +0 -27
  350. package/dist/things-scene/api/change.js.map +0 -1
  351. package/dist/things-scene/api/clipboard.js +0 -45
  352. package/dist/things-scene/api/clipboard.js.map +0 -1
  353. package/dist/things-scene/api/distribute.js +0 -57
  354. package/dist/things-scene/api/distribute.js.map +0 -1
  355. package/dist/things-scene/api/duplicate.js +0 -47
  356. package/dist/things-scene/api/duplicate.js.map +0 -1
  357. package/dist/things-scene/api/fullscreen.js +0 -26
  358. package/dist/things-scene/api/fullscreen.js.map +0 -1
  359. package/dist/things-scene/api/group.js +0 -91
  360. package/dist/things-scene/api/group.js.map +0 -1
  361. package/dist/things-scene/api/ids.js +0 -28
  362. package/dist/things-scene/api/ids.js.map +0 -1
  363. package/dist/things-scene/api/index.js +0 -192
  364. package/dist/things-scene/api/index.js.map +0 -1
  365. package/dist/things-scene/api/listener.js +0 -69
  366. package/dist/things-scene/api/listener.js.map +0 -1
  367. package/dist/things-scene/api/paste-start.js +0 -27
  368. package/dist/things-scene/api/paste-start.js.map +0 -1
  369. package/dist/things-scene/api/place.js +0 -98
  370. package/dist/things-scene/api/place.js.map +0 -1
  371. package/dist/things-scene/api/remove.js +0 -57
  372. package/dist/things-scene/api/remove.js.map +0 -1
  373. package/dist/things-scene/api/symmetry.js +0 -47
  374. package/dist/things-scene/api/symmetry.js.map +0 -1
  375. package/dist/things-scene/api/to-data-url.js +0 -76
  376. package/dist/things-scene/api/to-data-url.js.map +0 -1
  377. package/dist/things-scene/api/zorder.js +0 -68
  378. package/dist/things-scene/api/zorder.js.map +0 -1
  379. package/dist/things-scene/application-context.js +0 -168
  380. package/dist/things-scene/application-context.js.map +0 -1
  381. package/dist/things-scene/config.js +0 -18
  382. package/dist/things-scene/config.js.map +0 -1
  383. package/dist/things-scene/create.js +0 -67
  384. package/dist/things-scene/create.js.map +0 -1
  385. package/dist/things-scene/fps.js +0 -26
  386. package/dist/things-scene/fps.js.map +0 -1
  387. package/dist/things-scene/index.js +0 -152
  388. package/dist/things-scene/index.js.map +0 -1
  389. package/dist/things-scene/polyfill.js +0 -111
  390. package/dist/things-scene/polyfill.js.map +0 -1
  391. package/dist/things-scene/scene.js +0 -442
  392. package/dist/things-scene/scene.js.map +0 -1
  393. package/dist/things-scene/version.js +0 -12
  394. package/dist/things-scene/version.js.map +0 -1
  395. package/rollup.config.js +0 -67
  396. package/schema.graphql +0 -4606
  397. package/tsconfig.json +0 -31
@@ -1,617 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _logger = require("./logger.js");
8
- var util = newUtil();
9
- var inliner = newInliner();
10
- var fontFaces = newFontFaces();
11
- var images = newImages();
12
-
13
- // Default impl options
14
- var defaultOptions = {
15
- // Default is to fail on error, no placeholder
16
- imagePlaceholder: undefined,
17
- // Default cache bust is false, it will use the cache
18
- cacheBust: false
19
- };
20
-
21
- /**
22
- * @param {Node} node - The DOM Node object to render
23
- * @param {Object} options - Rendering options
24
- * @param {Function} options.filter - Should return true if passed node should be included in the output
25
- * (excluding node means excluding it's children as well). Not called on the root node.
26
- * @param {String} options.bgcolor - color for the background, any valid CSS color value.
27
- * @param {Number} options.width - width to be applied to node before rendering.
28
- * @param {Number} options.height - height to be applied to node before rendering.
29
- * @param {Object} options.style - an object whose properties to be copied to node's style before rendering.
30
- * @param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
31
- defaults to 1.0.
32
- * @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
33
- * @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
34
- * @return {Promise} - A promise that is fulfilled with a SVG image data URL
35
- * */
36
- function toSvg(node, options) {
37
- options = options || {};
38
- copyOptions(options);
39
- return Promise.resolve(node).then(function (node) {
40
- return cloneNode(node, options.filter, true);
41
- })
42
- // .then(embedFonts) /* Web Font 로딩시간이 오래걸려서, 제거함 */
43
- .then(inlineImages).then(applyOptions).then(function (clone) {
44
- return makeSvgDataUri(clone, options.width || util.width(node), options.height || util.height(node));
45
- });
46
- function applyOptions(clone) {
47
- var {
48
- bgcolor,
49
- width,
50
- height,
51
- style,
52
- sx = 1,
53
- sy = 1
54
- } = options;
55
- var styles = clone.style;
56
- if (bgcolor) styles.backgroundColor = bgcolor;
57
- if (width) styles.width = width + 'px';
58
- if (height) styles.height = height + 'px';
59
- styles['margin-left'] = '0px';
60
- styles['margin-top'] = '0px';
61
-
62
- /* CONFIRM-ME `transform: perspective(1px)` 스타일 설정은 scaling된 dom element를 좀 더 선명하게 보이도록 해준다. (Chrome 브라우저에서) */
63
- styles.transform = `rotate(0rad) translate(0px, 0px) scale(${sx}, ${sy}) perspective(1px)`;
64
- if (style) Object.keys(style).forEach(function (property) {
65
- styles[property] = style[property];
66
- });
67
- return clone;
68
- }
69
- }
70
-
71
- /**
72
- * @param {Node} node - The DOM Node object to render
73
- * @param {Object} options - Rendering options, @see {@link toSvg}
74
- * @return {Promise} - A promise that is fulfilled with a Uint8Array containing RGBA pixel data.
75
- * */
76
- function toPixelData(node, options) {
77
- return draw(node, options || {}).then(function (canvas) {
78
- return canvas.getContext('2d').getImageData(0, 0, util.width(node), util.height(node)).data;
79
- });
80
- }
81
-
82
- /**
83
- * @param {Node} node - The DOM Node object to render
84
- * @param {Object} options - Rendering options, @see {@link toSvg}
85
- * @return {Promise} - A promise that is fulfilled with a PNG image data URL
86
- * */
87
- function toPng(node, options) {
88
- return draw(node, options || {}).then(function (canvas) {
89
- return canvas.toDataURL();
90
- });
91
- }
92
-
93
- /**
94
- * @param {Node} node - The DOM Node object to render
95
- * @param {Object} options - Rendering options, @see {@link toSvg}
96
- * @return {Promise} - A promise that is fulfilled with a JPEG image data URL
97
- * */
98
- function toJpeg(node, options) {
99
- options = options || {};
100
- return draw(node, options).then(function (canvas) {
101
- return canvas.toDataURL('image/jpeg', options.quality || 1.0);
102
- });
103
- }
104
-
105
- /**
106
- * @param {Node} node - The DOM Node object to render
107
- * @param {Object} options - Rendering options, @see {@link toSvg}
108
- * @return {Promise} - A promise that is fulfilled with a PNG image blob
109
- * */
110
- function toBlob(node, options) {
111
- return draw(node, options || {}).then(util.canvasToBlob);
112
- }
113
- function copyOptions(options) {
114
- // Copy options to impl options for use in impl
115
- if (typeof options.imagePlaceholder === 'undefined') {
116
- domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
117
- } else {
118
- domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
119
- }
120
- if (typeof options.cacheBust === 'undefined') {
121
- domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
122
- } else {
123
- domtoimage.impl.options.cacheBust = options.cacheBust;
124
- }
125
- }
126
- function draw(domNode, options) {
127
- return toSvg(domNode, options).then(util.makeImage).then(util.delay(100)).then(function (image) {
128
- var canvas = newCanvas(domNode);
129
- canvas.getContext('2d').drawImage(image, 0, 0);
130
- return canvas;
131
- });
132
- function newCanvas(domNode) {
133
- var canvas = document.createElement('canvas');
134
- var {
135
- width,
136
- height
137
- } = options;
138
- canvas.width = options.width || util.width(domNode);
139
- canvas.height = options.height || util.height(domNode);
140
- if (options.bgcolor) {
141
- var ctx = canvas.getContext('2d');
142
- ctx.fillStyle = options.bgcolor;
143
- ctx.fillRect(0, 0, canvas.width, canvas.height);
144
- }
145
- return canvas;
146
- }
147
- }
148
- function cloneNode(node, filter, root) {
149
- if (!root && filter && !filter(node)) return Promise.resolve();
150
- return Promise.resolve(node).then(makeNodeCopy).then(function (clone) {
151
- return cloneChildren(node, clone, filter);
152
- }).then(function (clone) {
153
- return processClone(node, clone);
154
- });
155
- function makeNodeCopy(node) {
156
- if (node instanceof HTMLCanvasElement) {
157
- try {
158
- return util.makeImage(node.toDataURL());
159
- } catch (e) {
160
- (0, _logger.warn)(e);
161
- }
162
- }
163
- return node.cloneNode(false);
164
- }
165
- function cloneChildren(original, clone, filter) {
166
- var children = original.childNodes;
167
- if (children.length === 0) return Promise.resolve(clone);
168
- return cloneChildrenInOrder(clone, util.asArray(children), filter).then(function () {
169
- return clone;
170
- });
171
- function cloneChildrenInOrder(parent, children, filter) {
172
- var done = Promise.resolve();
173
- children.forEach(function (child) {
174
- done = done.then(function () {
175
- return cloneNode(child, filter);
176
- }).then(function (childClone) {
177
- if (childClone) parent.appendChild(childClone);
178
- });
179
- });
180
- return done;
181
- }
182
- }
183
- function processClone(original, clone) {
184
- if (!(clone instanceof Element)) return clone;
185
- return Promise.resolve().then(cloneStyle).then(clonePseudoElements).then(copyUserInput).then(fixSvg).then(function () {
186
- return clone;
187
- });
188
- function cloneStyle() {
189
- copyStyle(window.getComputedStyle(original), clone.style);
190
- function copyStyle(source, target) {
191
- if (source.cssText) target.cssText = source.cssText;else copyProperties(source, target);
192
- function copyProperties(source, target) {
193
- util.asArray(source).forEach(function (name) {
194
- target.setProperty(name, source.getPropertyValue(name), source.getPropertyPriority(name));
195
- });
196
- }
197
- }
198
- }
199
- function clonePseudoElements() {
200
- ;
201
- [':before', ':after'].forEach(function (element) {
202
- clonePseudoElement(element);
203
- });
204
- function clonePseudoElement(element) {
205
- var style = window.getComputedStyle(original, element);
206
- var content = style.getPropertyValue('content');
207
- if (content === '' || content === 'none') return;
208
- var className = util.uid();
209
- clone.className = clone.className + ' ' + className;
210
- var styleElement = document.createElement('style');
211
- styleElement.appendChild(formatPseudoElementStyle(className, element, style));
212
- clone.appendChild(styleElement);
213
- function formatPseudoElementStyle(className, element, style) {
214
- var selector = '.' + className + ':' + element;
215
- var cssText = style.cssText ? formatCssText(style) : formatCssProperties(style);
216
- return document.createTextNode(selector + '{' + cssText + '}');
217
- function formatCssText(style) {
218
- var content = style.getPropertyValue('content');
219
- return style.cssText + ' content: ' + content + ';';
220
- }
221
- function formatCssProperties(style) {
222
- return util.asArray(style).map(formatProperty).join('; ') + ';';
223
- function formatProperty(name) {
224
- return name + ': ' + style.getPropertyValue(name) + (style.getPropertyPriority(name) ? ' !important' : '');
225
- }
226
- }
227
- }
228
- }
229
- }
230
- function copyUserInput() {
231
- if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
232
- if (original instanceof HTMLInputElement) clone.setAttribute('value', original.value);
233
- }
234
- function fixSvg() {
235
- if (!(clone instanceof SVGElement)) return;
236
- clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
237
- if (!(clone instanceof SVGRectElement)) return;
238
- ['width', 'height'].forEach(function (attribute) {
239
- var value = clone.getAttribute(attribute);
240
- if (!value) return;
241
- clone.style.setProperty(attribute, value);
242
- });
243
- }
244
- }
245
- }
246
- function embedFonts(node) {
247
- return fontFaces.resolveAll().then(function (cssText) {
248
- var styleNode = document.createElement('style');
249
- node.appendChild(styleNode);
250
- styleNode.appendChild(document.createTextNode(cssText));
251
- return node;
252
- });
253
- }
254
- function inlineImages(node) {
255
- return images.inlineAll(node).then(function () {
256
- return node;
257
- });
258
- }
259
- function makeSvgDataUri(node, width, height) {
260
- return Promise.resolve(node).then(function (node) {
261
- node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
262
- return new XMLSerializer().serializeToString(node);
263
- }).then(util.escapeXhtml).then(function (xhtml) {
264
- return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
265
- }).then(function (foreignObject) {
266
- return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' + foreignObject + '</svg>';
267
- }).then(function (svg) {
268
- return 'data:image/svg+xml;charset=utf-8,' + svg;
269
- });
270
- }
271
- function newUtil() {
272
- return {
273
- escape: escape,
274
- parseExtension: parseExtension,
275
- mimeType: mimeType,
276
- dataAsUrl: dataAsUrl,
277
- isDataUrl: isDataUrl,
278
- canvasToBlob: canvasToBlob,
279
- resolveUrl: resolveUrl,
280
- getAndEncode: getAndEncode,
281
- uid: uid(),
282
- delay: delay,
283
- asArray: asArray,
284
- escapeXhtml: escapeXhtml,
285
- makeImage: makeImage,
286
- width: width,
287
- height: height
288
- };
289
- function mimes() {
290
- /*
291
- * Only WOFF and EOT mime types for fonts are 'real'
292
- * see http://www.iana.org/assignments/media-types/media-types.xhtml
293
- */
294
- var WOFF = 'application/font-woff';
295
- var JPEG = 'image/jpeg';
296
- return {
297
- woff: WOFF,
298
- woff2: WOFF,
299
- ttf: 'application/font-truetype',
300
- eot: 'application/vnd.ms-fontobject',
301
- png: 'image/png',
302
- jpg: JPEG,
303
- jpeg: JPEG,
304
- gif: 'image/gif',
305
- tiff: 'image/tiff',
306
- svg: 'image/svg+xml'
307
- };
308
- }
309
- function parseExtension(url) {
310
- var match = /\.([^\.\/]*?)$/g.exec(url);
311
- if (match) return match[1];else return '';
312
- }
313
- function mimeType(url) {
314
- var extension = parseExtension(url).toLowerCase();
315
- return mimes()[extension] || '';
316
- }
317
- function isDataUrl(url) {
318
- return url.search(/^(data:)/) !== -1;
319
- }
320
- function toBlob(canvas) {
321
- return new Promise(function (resolve) {
322
- var binaryString = window.atob(canvas.toDataURL().split(',')[1]);
323
- var length = binaryString.length;
324
- var binaryArray = new Uint8Array(length);
325
- for (var i = 0; i < length; i++) binaryArray[i] = binaryString.charCodeAt(i);
326
- resolve(new Blob([binaryArray], {
327
- type: 'image/png'
328
- }));
329
- });
330
- }
331
- function canvasToBlob(canvas) {
332
- if (canvas.toBlob) return new Promise(function (resolve) {
333
- canvas.toBlob(resolve);
334
- });
335
- return toBlob(canvas);
336
- }
337
- function resolveUrl(url, baseUrl) {
338
- var doc = document.implementation.createHTMLDocument();
339
- var base = doc.createElement('base');
340
- doc.head.appendChild(base);
341
- var a = doc.createElement('a');
342
- doc.body.appendChild(a);
343
- base.href = baseUrl;
344
- a.href = url;
345
- return a.href;
346
- }
347
- function uid() {
348
- var index = 0;
349
- return function () {
350
- return 'u' + fourRandomChars() + index++;
351
- function fourRandomChars() {
352
- /* see http://stackoverflow.com/a/6248722/2519373 */
353
- return ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
354
- }
355
- };
356
- }
357
- function makeImage(uri) {
358
- return new Promise(function (resolve, reject) {
359
- var image = new Image();
360
- image.onload = function () {
361
- resolve(image);
362
- };
363
- image.onerror = reject;
364
- image.src = uri;
365
- });
366
- }
367
- function getAndEncode(url) {
368
- var TIMEOUT = 30000;
369
- if (domtoimage.impl.options.cacheBust) {
370
- // Cache bypass so we dont have CORS issues with cached images
371
- // Source: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
372
- url += (/\?/.test(url) ? '&' : '?') + new Date().getTime();
373
- }
374
- return new Promise(function (resolve) {
375
- var request = new XMLHttpRequest();
376
- request.onreadystatechange = done;
377
- request.ontimeout = timeout;
378
- request.responseType = 'blob';
379
- request.timeout = TIMEOUT;
380
- request.open('GET', url, true);
381
- request.send();
382
- var placeholder;
383
- if (domtoimage.impl.options.imagePlaceholder) {
384
- var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
385
- if (split && split[1]) {
386
- placeholder = split[1];
387
- }
388
- }
389
- function done() {
390
- if (request.readyState !== 4) return;
391
- if (request.status !== 200) {
392
- if (placeholder) {
393
- resolve(placeholder);
394
- } else {
395
- fail('cannot fetch resource: ' + url + ', status: ' + request.status);
396
- }
397
- return;
398
- }
399
- var encoder = new FileReader();
400
- encoder.onloadend = function () {
401
- var content = encoder.result.split(/,/)[1];
402
- resolve(content);
403
- };
404
- encoder.readAsDataURL(request.response);
405
- }
406
- function timeout() {
407
- if (placeholder) {
408
- resolve(placeholder);
409
- } else {
410
- fail('timeout of ' + TIMEOUT + 'ms occured while fetching resource: ' + url);
411
- }
412
- }
413
- function fail(message) {
414
- console.error(message);
415
- resolve('');
416
- }
417
- });
418
- }
419
- function dataAsUrl(content, type) {
420
- return 'data:' + type + ';base64,' + content;
421
- }
422
- function escape(string) {
423
- return string.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1');
424
- }
425
- function delay(ms) {
426
- return function (arg) {
427
- return new Promise(function (resolve) {
428
- setTimeout(function () {
429
- resolve(arg);
430
- }, ms);
431
- });
432
- };
433
- }
434
- function asArray(arrayLike) {
435
- var array = [];
436
- var length = arrayLike.length;
437
- for (var i = 0; i < length; i++) array.push(arrayLike[i]);
438
- return array;
439
- }
440
- function escapeXhtml(string) {
441
- return string.replace(/#/g, '%23').replace(/\n/g, '%0A');
442
- }
443
- function width(node) {
444
- var leftBorder = px(node, 'border-left-width');
445
- var rightBorder = px(node, 'border-right-width');
446
- return node.scrollWidth + leftBorder + rightBorder;
447
- }
448
- function height(node) {
449
- var topBorder = px(node, 'border-top-width');
450
- var bottomBorder = px(node, 'border-bottom-width');
451
- return node.scrollHeight + topBorder + bottomBorder;
452
- }
453
- function px(node, styleProperty) {
454
- var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
455
- return parseFloat(value.replace('px', ''));
456
- }
457
- }
458
- function newInliner() {
459
- var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
460
- return {
461
- inlineAll: inlineAll,
462
- shouldProcess: shouldProcess,
463
- impl: {
464
- readUrls: readUrls,
465
- inline: inline
466
- }
467
- };
468
- function shouldProcess(string) {
469
- return string.search(URL_REGEX) !== -1;
470
- }
471
- function readUrls(string) {
472
- var result = [];
473
- var match;
474
- while ((match = URL_REGEX.exec(string)) !== null) {
475
- result.push(match[1]);
476
- }
477
- return result.filter(function (url) {
478
- return !util.isDataUrl(url);
479
- });
480
- }
481
- function inline(string, url, baseUrl, get) {
482
- return Promise.resolve(url).then(function (url) {
483
- return baseUrl ? util.resolveUrl(url, baseUrl) : url;
484
- }).then(get || util.getAndEncode).then(function (data) {
485
- return util.dataAsUrl(data, util.mimeType(url));
486
- }).then(function (dataUrl) {
487
- return string.replace(urlAsRegex(url), '$1' + dataUrl + '$3');
488
- });
489
- function urlAsRegex(url) {
490
- return new RegExp('(url\\([\'"]?)(' + util.escape(url) + ')([\'"]?\\))', 'g');
491
- }
492
- }
493
- function inlineAll(string, baseUrl, get) {
494
- if (nothingToInline()) return Promise.resolve(string);
495
- return Promise.resolve(string).then(readUrls).then(function (urls) {
496
- var done = Promise.resolve(string);
497
- urls.forEach(function (url) {
498
- done = done.then(function (string) {
499
- return inline(string, url, baseUrl, get);
500
- });
501
- });
502
- return done;
503
- });
504
- function nothingToInline() {
505
- return !shouldProcess(string);
506
- }
507
- }
508
- }
509
- function newFontFaces() {
510
- return {
511
- resolveAll: resolveAll,
512
- impl: {
513
- readAll: readAll
514
- }
515
- };
516
- function resolveAll() {
517
- return readAll(document).then(function (webFonts) {
518
- return Promise.all(webFonts.map(function (webFont) {
519
- return webFont.resolve();
520
- }));
521
- }).then(function (cssStrings) {
522
- return cssStrings.join('\n');
523
- });
524
- }
525
- function readAll() {
526
- return Promise.resolve(util.asArray(document.styleSheets)).then(getCssRules).then(selectWebFontRules).then(function (rules) {
527
- return rules.map(newWebFont);
528
- });
529
- function selectWebFontRules(cssRules) {
530
- return cssRules.filter(function (rule) {
531
- return rule.type === CSSRule.FONT_FACE_RULE;
532
- }).filter(function (rule) {
533
- return inliner.shouldProcess(rule.style.getPropertyValue('src'));
534
- });
535
- }
536
- function getCssRules(styleSheets) {
537
- var cssRules = [];
538
- styleSheets.forEach(function (sheet) {
539
- try {
540
- util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
541
- } catch (e) {
542
- console.log('Error while reading CSS rules from ' + sheet.href, e.toString());
543
- }
544
- });
545
- return cssRules;
546
- }
547
- function newWebFont(webFontRule) {
548
- return {
549
- resolve: function resolve() {
550
- var baseUrl = (webFontRule.parentStyleSheet || {}).href;
551
- return inliner.inlineAll(webFontRule.cssText, baseUrl);
552
- },
553
- src: function () {
554
- return webFontRule.style.getPropertyValue('src');
555
- }
556
- };
557
- }
558
- }
559
- }
560
- function newImages() {
561
- return {
562
- inlineAll: inlineAll,
563
- impl: {
564
- newImage: newImage
565
- }
566
- };
567
- function newImage(element) {
568
- return {
569
- inline: inline
570
- };
571
- function inline(get) {
572
- if (util.isDataUrl(element.src)) return Promise.resolve();
573
- return Promise.resolve(element.src).then(get || util.getAndEncode).then(function (data) {
574
- return util.dataAsUrl(data, util.mimeType(element.src));
575
- }).then(function (dataUrl) {
576
- return new Promise(function (resolve, reject) {
577
- element.onload = resolve;
578
- element.onerror = reject;
579
- element.src = dataUrl;
580
- });
581
- });
582
- }
583
- }
584
- function inlineAll(node) {
585
- if (!(node instanceof Element)) return Promise.resolve(node);
586
- return inlineBackground(node).then(function () {
587
- if (node instanceof HTMLImageElement) return newImage(node).inline();else return Promise.all(util.asArray(node.childNodes).map(function (child) {
588
- return inlineAll(child);
589
- }));
590
- });
591
- function inlineBackground(node) {
592
- var background = node.style.getPropertyValue('background');
593
- if (!background) return Promise.resolve(node);
594
- return inliner.inlineAll(background).then(function (inlined) {
595
- node.style.setProperty('background', inlined, node.style.getPropertyPriority('background'));
596
- }).then(function () {
597
- return node;
598
- });
599
- }
600
- }
601
- }
602
- var domtoimage = {
603
- toSvg: toSvg,
604
- toPng: toPng,
605
- toJpeg: toJpeg,
606
- toBlob: toBlob,
607
- toPixelData: toPixelData,
608
- impl: {
609
- fontFaces: fontFaces,
610
- images: images,
611
- util: util,
612
- inliner: inliner,
613
- options: {}
614
- }
615
- };
616
- var _default = exports.default = domtoimage;
617
- //# sourceMappingURL=dom-to-image.js.map