@antv/infographic 0.2.11 → 0.2.13

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 (328) hide show
  1. package/dist/infographic.min.js +98 -94
  2. package/dist/infographic.min.js.map +1 -1
  3. package/esm/designs/components/Btn.js +15 -4
  4. package/esm/designs/components/BtnsGroup.js +1 -1
  5. package/esm/designs/components/Illus.js +15 -3
  6. package/esm/designs/components/ItemDesc.js +17 -11
  7. package/esm/designs/components/ItemIcon.js +17 -18
  8. package/esm/designs/components/ItemLabel.js +17 -11
  9. package/esm/designs/components/ItemValue.js +17 -12
  10. package/esm/designs/components/ItemsGroup.js +1 -1
  11. package/esm/designs/components/ShapesGroup.js +1 -1
  12. package/esm/designs/components/Title.js +2 -2
  13. package/esm/designs/decorations/simple-arrow.js +14 -2
  14. package/esm/designs/decorations/triangle.js +14 -2
  15. package/esm/designs/defs/DropShadow.js +13 -2
  16. package/esm/designs/defs/LinearGradient.js +1 -1
  17. package/esm/designs/items/BadgeCard.js +2 -2
  18. package/esm/designs/items/CandyCardLite.js +1 -1
  19. package/esm/designs/items/CapsuleItem.js +3 -3
  20. package/esm/designs/items/CircleNode.js +1 -1
  21. package/esm/designs/items/CircularProgress.js +3 -2
  22. package/esm/designs/items/CompactCard.js +1 -1
  23. package/esm/designs/items/DoneList.js +1 -1
  24. package/esm/designs/items/HorizontalIconArrow.js +2 -2
  25. package/esm/designs/items/HorizontalIconLine.js +2 -2
  26. package/esm/designs/items/IconBadge.js +4 -3
  27. package/esm/designs/items/IndexedCard.js +1 -1
  28. package/esm/designs/items/LCornerCard.js +1 -1
  29. package/esm/designs/items/LetterCard.js +4 -3
  30. package/esm/designs/items/LinedText.js +6 -5
  31. package/esm/designs/items/PillBadge.js +2 -2
  32. package/esm/designs/items/PlainText.js +4 -4
  33. package/esm/designs/items/ProgressCard.js +4 -4
  34. package/esm/designs/items/QuarterCircular.js +1 -1
  35. package/esm/designs/items/QuarterSimpleCard.js +1 -1
  36. package/esm/designs/items/RibbonCard.js +2 -2
  37. package/esm/designs/items/RoundedRectNode.js +2 -2
  38. package/esm/designs/items/SimpleCircleNode.js +1 -1
  39. package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
  40. package/esm/designs/items/SimpleIllusItem.js +1 -1
  41. package/esm/designs/items/SimpleItem.js +3 -3
  42. package/esm/designs/items/SimpleVerticalArrow.js +2 -2
  43. package/esm/designs/items/UnderlineText.js +1 -1
  44. package/esm/designs/items/VerticalIconArrow.js +2 -2
  45. package/esm/designs/layouts/Align.js +22 -15
  46. package/esm/designs/layouts/Flex.js +23 -16
  47. package/esm/designs/structures/chart-bar.js +7 -5
  48. package/esm/designs/structures/chart-column.js +3 -2
  49. package/esm/designs/structures/chart-line.js +7 -5
  50. package/esm/designs/structures/chart-pie.d.ts +25 -0
  51. package/esm/designs/structures/chart-pie.js +186 -26
  52. package/esm/designs/structures/chart-wordcloud.js +5 -14
  53. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  54. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  55. package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  56. package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
  57. package/esm/designs/structures/compare-hierarchy-row.js +3 -2
  58. package/esm/designs/structures/compare-quadrant.js +2 -3
  59. package/esm/designs/structures/hierarchy-mindmap.js +19 -19
  60. package/esm/designs/structures/hierarchy-structure.js +1 -1
  61. package/esm/designs/structures/hierarchy-tree.js +15 -24
  62. package/esm/designs/structures/list-sector.js +5 -6
  63. package/esm/designs/structures/list-zigzag.js +2 -1
  64. package/esm/designs/structures/relation-dagre-flow.js +30 -35
  65. package/esm/designs/structures/relation-network.js +2 -2
  66. package/esm/designs/structures/sequence-funnel.js +1 -1
  67. package/esm/designs/structures/sequence-mountain.js +4 -4
  68. package/esm/designs/structures/sequence-pyramid.js +1 -1
  69. package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
  70. package/esm/designs/utils/color.js +8 -4
  71. package/esm/designs/utils/index.d.ts +1 -0
  72. package/esm/designs/utils/index.js +1 -0
  73. package/esm/designs/utils/item.js +3 -2
  74. package/esm/designs/utils/normalize-percent.d.ts +19 -0
  75. package/esm/designs/utils/normalize-percent.js +32 -0
  76. package/esm/editor/commands/Batch.js +21 -8
  77. package/esm/editor/commands/UpdateElement.js +25 -22
  78. package/esm/editor/commands/UpdateOptions.js +23 -10
  79. package/esm/editor/commands/UpdateText.js +24 -11
  80. package/esm/editor/interactions/brush-select.js +27 -13
  81. package/esm/editor/interactions/click-select.js +13 -3
  82. package/esm/editor/interactions/dblclick-edit-text.js +36 -20
  83. package/esm/editor/interactions/drag-element.js +23 -9
  84. package/esm/editor/interactions/hotkey-history.js +17 -7
  85. package/esm/editor/interactions/select-highlight.js +5 -9
  86. package/esm/editor/interactions/zoom-wheel.d.ts +3 -0
  87. package/esm/editor/interactions/zoom-wheel.js +46 -22
  88. package/esm/editor/managers/command.js +45 -27
  89. package/esm/editor/managers/interaction.js +46 -33
  90. package/esm/editor/managers/state.js +9 -3
  91. package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
  92. package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
  93. package/esm/editor/plugins/edit-bar/components/select.js +10 -8
  94. package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
  95. package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  96. package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  97. package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  98. package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  99. package/esm/editor/plugins/resize-element.js +6 -4
  100. package/esm/editor/utils/click-handler.js +6 -3
  101. package/esm/editor/utils/coordinate.js +2 -1
  102. package/esm/editor/utils/element.js +2 -1
  103. package/esm/editor/utils/event.js +2 -1
  104. package/esm/editor/utils/extension.js +1 -1
  105. package/esm/editor/utils/hotkey.js +2 -1
  106. package/esm/exporter/font.js +106 -90
  107. package/esm/exporter/png.js +49 -37
  108. package/esm/exporter/svg.js +55 -38
  109. package/esm/jsx/components/Ellipse.js +5 -4
  110. package/esm/jsx/components/Path.js +2 -4
  111. package/esm/jsx/components/Polygon.js +15 -6
  112. package/esm/jsx/components/Text.js +21 -41
  113. package/esm/jsx/renderer.js +15 -7
  114. package/esm/jsx/utils/bounds.js +18 -16
  115. package/esm/jsx/utils/children.js +2 -1
  116. package/esm/jsx/utils/clone.js +13 -2
  117. package/esm/jsx/utils/element.js +2 -1
  118. package/esm/options/parser.js +45 -46
  119. package/esm/renderer/composites/background.js +3 -2
  120. package/esm/renderer/composites/icon.js +14 -19
  121. package/esm/renderer/composites/illus.js +17 -22
  122. package/esm/renderer/composites/shape.js +4 -2
  123. package/esm/renderer/composites/svg.js +2 -1
  124. package/esm/renderer/composites/text.js +5 -3
  125. package/esm/renderer/fonts/loader.js +4 -3
  126. package/esm/renderer/fonts/registry.js +1 -1
  127. package/esm/renderer/palettes/utils.js +3 -2
  128. package/esm/renderer/renderer.js +7 -5
  129. package/esm/renderer/stylize/gradient.js +3 -2
  130. package/esm/renderer/stylize/pattern.js +15 -8
  131. package/esm/renderer/stylize/rough.js +1 -1
  132. package/esm/resource/load-tracker.js +22 -10
  133. package/esm/resource/loader.js +80 -67
  134. package/esm/resource/loaders/image.js +71 -59
  135. package/esm/resource/loaders/remote.js +26 -15
  136. package/esm/resource/loaders/search.js +38 -25
  137. package/esm/resource/utils/parser.js +2 -1
  138. package/esm/runtime/Infographic.js +26 -13
  139. package/esm/runtime/utils.js +5 -8
  140. package/esm/ssr/renderer.js +42 -35
  141. package/esm/syntax/index.js +19 -6
  142. package/esm/syntax/mapper.js +2 -2
  143. package/esm/templates/built-in.js +91 -269
  144. package/esm/templates/chart-pie.d.ts +2 -0
  145. package/esm/templates/chart-pie.js +87 -0
  146. package/esm/templates/hierarchy-mindmap.js +1 -5
  147. package/esm/templates/hierarchy-tree.js +1 -5
  148. package/esm/templates/relation-dagre-flow.js +4 -28
  149. package/esm/themes/generator.js +8 -14
  150. package/esm/utils/fetch.js +48 -35
  151. package/esm/utils/icon.js +1 -4
  152. package/esm/utils/is-browser.js +2 -2
  153. package/esm/utils/measure-text.js +2 -1
  154. package/esm/utils/padding.js +1 -1
  155. package/esm/utils/recognizer.js +2 -1
  156. package/esm/utils/text.js +14 -3
  157. package/esm/utils/viewbox.d.ts +20 -0
  158. package/esm/utils/viewbox.js +10 -0
  159. package/esm/version.d.ts +1 -1
  160. package/esm/version.js +1 -1
  161. package/lib/designs/components/Btn.js +15 -4
  162. package/lib/designs/components/BtnsGroup.js +1 -1
  163. package/lib/designs/components/Illus.js +15 -3
  164. package/lib/designs/components/ItemDesc.js +17 -11
  165. package/lib/designs/components/ItemIcon.js +17 -18
  166. package/lib/designs/components/ItemLabel.js +17 -11
  167. package/lib/designs/components/ItemValue.js +17 -12
  168. package/lib/designs/components/ItemsGroup.js +1 -1
  169. package/lib/designs/components/ShapesGroup.js +1 -1
  170. package/lib/designs/components/Title.js +2 -2
  171. package/lib/designs/decorations/simple-arrow.js +14 -2
  172. package/lib/designs/decorations/triangle.js +14 -2
  173. package/lib/designs/defs/DropShadow.js +13 -2
  174. package/lib/designs/defs/LinearGradient.js +1 -1
  175. package/lib/designs/items/BadgeCard.js +2 -2
  176. package/lib/designs/items/CandyCardLite.js +1 -1
  177. package/lib/designs/items/CapsuleItem.js +3 -3
  178. package/lib/designs/items/CircleNode.js +1 -1
  179. package/lib/designs/items/CircularProgress.js +3 -2
  180. package/lib/designs/items/CompactCard.js +1 -1
  181. package/lib/designs/items/DoneList.js +1 -1
  182. package/lib/designs/items/HorizontalIconArrow.js +2 -2
  183. package/lib/designs/items/HorizontalIconLine.js +2 -2
  184. package/lib/designs/items/IconBadge.js +4 -3
  185. package/lib/designs/items/IndexedCard.js +1 -1
  186. package/lib/designs/items/LCornerCard.js +1 -1
  187. package/lib/designs/items/LetterCard.js +4 -3
  188. package/lib/designs/items/LinedText.js +6 -5
  189. package/lib/designs/items/PillBadge.js +2 -2
  190. package/lib/designs/items/PlainText.js +4 -4
  191. package/lib/designs/items/ProgressCard.js +4 -4
  192. package/lib/designs/items/QuarterCircular.js +1 -1
  193. package/lib/designs/items/QuarterSimpleCard.js +1 -1
  194. package/lib/designs/items/RibbonCard.js +2 -2
  195. package/lib/designs/items/RoundedRectNode.js +2 -2
  196. package/lib/designs/items/SimpleCircleNode.js +1 -1
  197. package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
  198. package/lib/designs/items/SimpleIllusItem.js +1 -1
  199. package/lib/designs/items/SimpleItem.js +3 -3
  200. package/lib/designs/items/SimpleVerticalArrow.js +2 -2
  201. package/lib/designs/items/UnderlineText.js +1 -1
  202. package/lib/designs/items/VerticalIconArrow.js +2 -2
  203. package/lib/designs/layouts/Align.js +22 -15
  204. package/lib/designs/layouts/Flex.js +23 -16
  205. package/lib/designs/structures/chart-bar.js +7 -5
  206. package/lib/designs/structures/chart-column.js +3 -2
  207. package/lib/designs/structures/chart-line.js +7 -5
  208. package/lib/designs/structures/chart-pie.d.ts +25 -0
  209. package/lib/designs/structures/chart-pie.js +186 -25
  210. package/lib/designs/structures/chart-wordcloud.js +5 -14
  211. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  212. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  213. package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  214. package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
  215. package/lib/designs/structures/compare-hierarchy-row.js +3 -2
  216. package/lib/designs/structures/compare-quadrant.js +2 -3
  217. package/lib/designs/structures/hierarchy-mindmap.js +19 -19
  218. package/lib/designs/structures/hierarchy-structure.js +1 -1
  219. package/lib/designs/structures/hierarchy-tree.js +15 -24
  220. package/lib/designs/structures/list-sector.js +5 -6
  221. package/lib/designs/structures/list-zigzag.js +2 -1
  222. package/lib/designs/structures/relation-dagre-flow.js +30 -35
  223. package/lib/designs/structures/relation-network.js +2 -2
  224. package/lib/designs/structures/sequence-funnel.js +1 -1
  225. package/lib/designs/structures/sequence-mountain.js +4 -4
  226. package/lib/designs/structures/sequence-pyramid.js +1 -1
  227. package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
  228. package/lib/designs/utils/color.js +8 -4
  229. package/lib/designs/utils/index.d.ts +1 -0
  230. package/lib/designs/utils/index.js +1 -0
  231. package/lib/designs/utils/item.js +3 -2
  232. package/lib/designs/utils/normalize-percent.d.ts +19 -0
  233. package/lib/designs/utils/normalize-percent.js +35 -0
  234. package/lib/editor/commands/Batch.js +21 -8
  235. package/lib/editor/commands/UpdateElement.js +25 -22
  236. package/lib/editor/commands/UpdateOptions.js +23 -10
  237. package/lib/editor/commands/UpdateText.js +24 -11
  238. package/lib/editor/interactions/brush-select.js +27 -13
  239. package/lib/editor/interactions/click-select.js +13 -3
  240. package/lib/editor/interactions/dblclick-edit-text.js +36 -20
  241. package/lib/editor/interactions/drag-element.js +23 -9
  242. package/lib/editor/interactions/hotkey-history.js +17 -7
  243. package/lib/editor/interactions/select-highlight.js +5 -9
  244. package/lib/editor/interactions/zoom-wheel.d.ts +3 -0
  245. package/lib/editor/interactions/zoom-wheel.js +45 -21
  246. package/lib/editor/managers/command.js +43 -25
  247. package/lib/editor/managers/interaction.js +46 -33
  248. package/lib/editor/managers/state.js +9 -3
  249. package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
  250. package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
  251. package/lib/editor/plugins/edit-bar/components/select.js +10 -8
  252. package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
  253. package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  254. package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  255. package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  256. package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  257. package/lib/editor/plugins/resize-element.js +6 -4
  258. package/lib/editor/utils/click-handler.js +6 -3
  259. package/lib/editor/utils/coordinate.js +2 -1
  260. package/lib/editor/utils/element.js +2 -1
  261. package/lib/editor/utils/event.js +2 -1
  262. package/lib/editor/utils/extension.js +1 -1
  263. package/lib/editor/utils/hotkey.js +2 -1
  264. package/lib/exporter/font.js +106 -90
  265. package/lib/exporter/png.js +49 -37
  266. package/lib/exporter/svg.js +55 -38
  267. package/lib/jsx/components/Ellipse.js +5 -4
  268. package/lib/jsx/components/Path.js +2 -4
  269. package/lib/jsx/components/Polygon.js +15 -6
  270. package/lib/jsx/components/Text.js +21 -41
  271. package/lib/jsx/renderer.js +15 -7
  272. package/lib/jsx/utils/bounds.js +18 -16
  273. package/lib/jsx/utils/children.js +2 -1
  274. package/lib/jsx/utils/clone.js +13 -2
  275. package/lib/jsx/utils/element.js +2 -1
  276. package/lib/options/parser.js +45 -46
  277. package/lib/renderer/composites/background.js +3 -2
  278. package/lib/renderer/composites/icon.js +14 -19
  279. package/lib/renderer/composites/illus.js +17 -22
  280. package/lib/renderer/composites/shape.js +4 -2
  281. package/lib/renderer/composites/svg.js +2 -1
  282. package/lib/renderer/composites/text.js +5 -3
  283. package/lib/renderer/fonts/loader.js +4 -3
  284. package/lib/renderer/fonts/registry.js +1 -1
  285. package/lib/renderer/palettes/utils.js +3 -2
  286. package/lib/renderer/renderer.js +7 -5
  287. package/lib/renderer/stylize/gradient.js +3 -2
  288. package/lib/renderer/stylize/pattern.js +15 -8
  289. package/lib/renderer/stylize/rough.js +1 -1
  290. package/lib/resource/load-tracker.js +22 -10
  291. package/lib/resource/loader.js +80 -67
  292. package/lib/resource/loaders/image.js +71 -59
  293. package/lib/resource/loaders/remote.js +26 -15
  294. package/lib/resource/loaders/search.js +38 -25
  295. package/lib/resource/utils/parser.js +2 -1
  296. package/lib/runtime/Infographic.js +26 -13
  297. package/lib/runtime/utils.js +5 -8
  298. package/lib/ssr/renderer.js +42 -35
  299. package/lib/syntax/index.js +19 -6
  300. package/lib/syntax/mapper.js +2 -2
  301. package/lib/templates/built-in.js +91 -269
  302. package/lib/templates/chart-pie.d.ts +2 -0
  303. package/lib/templates/chart-pie.js +90 -0
  304. package/lib/templates/hierarchy-mindmap.js +1 -5
  305. package/lib/templates/hierarchy-tree.js +1 -5
  306. package/lib/templates/relation-dagre-flow.js +4 -28
  307. package/lib/themes/generator.js +8 -14
  308. package/lib/utils/fetch.js +48 -35
  309. package/lib/utils/icon.js +1 -4
  310. package/lib/utils/is-browser.js +2 -2
  311. package/lib/utils/measure-text.js +2 -1
  312. package/lib/utils/padding.js +1 -1
  313. package/lib/utils/recognizer.js +2 -1
  314. package/lib/utils/text.js +14 -3
  315. package/lib/utils/viewbox.d.ts +20 -0
  316. package/lib/utils/viewbox.js +12 -0
  317. package/lib/version.d.ts +1 -1
  318. package/lib/version.js +1 -1
  319. package/package.json +1 -2
  320. package/src/designs/structures/chart-pie.tsx +259 -26
  321. package/src/designs/utils/index.ts +1 -0
  322. package/src/designs/utils/normalize-percent.ts +33 -0
  323. package/src/editor/interactions/zoom-wheel.ts +64 -22
  324. package/src/editor/managers/state.ts +10 -5
  325. package/src/templates/built-in.ts +2 -81
  326. package/src/templates/chart-pie.ts +89 -0
  327. package/src/utils/viewbox.ts +23 -0
  328. package/src/version.ts +1 -1
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.loadSearchResource = loadSearchResource;
4
13
  const constants_1 = require("../../constants");
@@ -6,15 +15,16 @@ const utils_1 = require("../../utils");
6
15
  const image_1 = require("./image");
7
16
  const remote_1 = require("./remote");
8
17
  const svg_1 = require("./svg");
9
- const queryIcon = async (query) => {
18
+ const queryIcon = (query) => __awaiter(void 0, void 0, void 0, function* () {
19
+ var _a;
10
20
  try {
11
21
  const params = new URLSearchParams({ text: query, topK: '1' });
12
22
  const url = `${constants_1.ICON_SERVICE_URL}?${params.toString()}`;
13
- const response = await (0, utils_1.fetchWithCache)(url);
23
+ const response = yield (0, utils_1.fetchWithCache)(url);
14
24
  if (!response.ok)
15
25
  return null;
16
- const result = await response.json();
17
- if (!result?.status || !Array.isArray(result.data?.data))
26
+ const result = yield response.json();
27
+ if (!(result === null || result === void 0 ? void 0 : result.status) || !Array.isArray((_a = result.data) === null || _a === void 0 ? void 0 : _a.data))
18
28
  return null;
19
29
  return result.data.data[0] || null;
20
30
  }
@@ -22,7 +32,7 @@ const queryIcon = async (query) => {
22
32
  console.error(`Failed to query icon for "${query}":`, error);
23
33
  return null;
24
34
  }
25
- };
35
+ });
26
36
  function isDataURI(resource) {
27
37
  return resource.startsWith('data:');
28
38
  }
@@ -30,26 +40,29 @@ function looksLikeSVG(resource) {
30
40
  const str = resource.trim();
31
41
  return str.startsWith('<svg') || str.startsWith('<symbol');
32
42
  }
33
- async function loadSearchResource(query, format) {
34
- if (!query)
35
- return null;
36
- const result = await queryIcon(query);
37
- if (!result)
38
- return null;
39
- if (looksLikeSVG(result))
40
- return (0, svg_1.loadSVGResource)(result);
41
- if (isDataURI(result)) {
42
- const mimeType = result.match(/^data:([^;]+)/)?.[1] || '';
43
- const isBase64 = result.includes(';base64,');
44
- if (mimeType === 'image/svg+xml' && !isBase64) {
45
- const commaIndex = result.indexOf(',');
46
- const svgText = commaIndex >= 0 ? result.slice(commaIndex + 1) : result;
47
- return (0, svg_1.loadSVGResource)(svgText);
48
- }
49
- if (mimeType === 'image/svg+xml' && format === 'svg' && isBase64) {
43
+ function loadSearchResource(query, format) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ var _a;
46
+ if (!query)
47
+ return null;
48
+ const result = yield queryIcon(query);
49
+ if (!result)
50
+ return null;
51
+ if (looksLikeSVG(result))
52
+ return (0, svg_1.loadSVGResource)(result);
53
+ if (isDataURI(result)) {
54
+ const mimeType = ((_a = result.match(/^data:([^;]+)/)) === null || _a === void 0 ? void 0 : _a[1]) || '';
55
+ const isBase64 = result.includes(';base64,');
56
+ if (mimeType === 'image/svg+xml' && !isBase64) {
57
+ const commaIndex = result.indexOf(',');
58
+ const svgText = commaIndex >= 0 ? result.slice(commaIndex + 1) : result;
59
+ return (0, svg_1.loadSVGResource)(svgText);
60
+ }
61
+ if (mimeType === 'image/svg+xml' && format === 'svg' && isBase64) {
62
+ return (0, image_1.loadImageBase64Resource)(result);
63
+ }
50
64
  return (0, image_1.loadImageBase64Resource)(result);
51
65
  }
52
- return (0, image_1.loadImageBase64Resource)(result);
53
- }
54
- return (0, remote_1.loadRemoteResource)(result, format);
66
+ return (0, remote_1.loadRemoteResource)(result, format);
67
+ });
55
68
  }
@@ -21,6 +21,7 @@ function inferFormatFromUrl(url) {
21
21
  return undefined;
22
22
  }
23
23
  function parseRefResource(resource) {
24
+ var _a;
24
25
  if (!resource.startsWith('ref:'))
25
26
  return null;
26
27
  const rest = resource.slice(4);
@@ -29,7 +30,7 @@ function parseRefResource(resource) {
29
30
  return null;
30
31
  let format;
31
32
  if (restParts.length > 1 && KNOWN_FORMATS.has(restParts[0].toLowerCase())) {
32
- format = restParts.shift()?.toLowerCase();
33
+ format = (_a = restParts.shift()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
33
34
  }
34
35
  const payload = restParts.join(':');
35
36
  if (!payload)
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -61,6 +70,7 @@ class Infographic {
61
70
  this.performRender();
62
71
  }
63
72
  performRender() {
73
+ var _a;
64
74
  const parsedOptions = this.parsedOptions;
65
75
  if (!(0, utils_2.isCompleteParsedInfographicOptions)(parsedOptions)) {
66
76
  this.emitter.emit('error', new Error('Incomplete options'));
@@ -70,8 +80,8 @@ class Infographic {
70
80
  const template = this.compose(parsedOptions);
71
81
  const renderer = new renderer_1.Renderer(parsedOptions, template);
72
82
  this.node = renderer.render();
73
- container?.replaceChildren(this.node);
74
- this.editor?.destroy();
83
+ container === null || container === void 0 ? void 0 : container.replaceChildren(this.node);
84
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.destroy();
75
85
  this.editor = undefined;
76
86
  if (this.options.editable) {
77
87
  this.editor = new editor_1.Editor(this.emitter, this.node, parsedOptions);
@@ -101,7 +111,7 @@ class Infographic {
101
111
  const Title = title.component;
102
112
  const Item = item.component;
103
113
  const Items = items.map((it) => it.component);
104
- const svg = (0, jsx_1.renderSVG)((0, jsx_runtime_1.jsx)(Structure, { data: data, Title: Title, Item: Item, Items: Items, options: parsedOptions, ...structureProps }));
114
+ const svg = (0, jsx_1.renderSVG)((0, jsx_runtime_1.jsx)(Structure, Object.assign({ data: data, Title: Title, Item: Item, Items: Items, options: parsedOptions }, structureProps)));
105
115
  const template = (0, utils_1.parseSVG)(svg);
106
116
  if (!template) {
107
117
  throw new Error('Failed to parse SVG template');
@@ -125,14 +135,16 @@ class Infographic {
125
135
  * @returns Data URL string of the exported infographic
126
136
  * @description This method need to be called after `render()` and in a browser environment.
127
137
  */
128
- async toDataURL(options) {
129
- if (!this.node) {
130
- throw new Error('Infographic is not rendered yet.');
131
- }
132
- if (options?.type === 'svg') {
133
- return await (0, exporter_1.exportToSVGString)(this.node, options);
134
- }
135
- return await (0, exporter_1.exportToPNGString)(this.node, options);
138
+ toDataURL(options) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ if (!this.node) {
141
+ throw new Error('Infographic is not rendered yet.');
142
+ }
143
+ if ((options === null || options === void 0 ? void 0 : options.type) === 'svg') {
144
+ return yield (0, exporter_1.exportToSVGString)(this.node, options);
145
+ }
146
+ return yield (0, exporter_1.exportToPNGString)(this.node, options);
147
+ });
136
148
  }
137
149
  on(event, listener) {
138
150
  this.emitter.on(event, listener);
@@ -141,8 +153,9 @@ class Infographic {
141
153
  this.emitter.off(event, listener);
142
154
  }
143
155
  destroy() {
144
- this.editor?.destroy();
145
- this.node?.remove();
156
+ var _a, _b;
157
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.destroy();
158
+ (_b = this.node) === null || _b === void 0 ? void 0 : _b.remove();
146
159
  this.node = null;
147
160
  this.rendered = false;
148
161
  this.emitter.emit('destroyed');
@@ -6,23 +6,20 @@ exports.isCompleteParsedInfographicOptions = isCompleteParsedInfographicOptions;
6
6
  const lodash_es_1 = require("lodash-es");
7
7
  const utils_1 = require("../utils");
8
8
  function mergeOptions(object, source) {
9
- const base = {
10
- ...object,
11
- ...source,
12
- };
9
+ const base = Object.assign(Object.assign({}, object), source);
13
10
  if (object.design || source.design) {
14
- base.design = { ...object.design, ...source.design };
11
+ base.design = Object.assign(Object.assign({}, object.design), source.design);
15
12
  }
16
13
  if (object.themeConfig || source.themeConfig) {
17
- base.themeConfig = { ...object.themeConfig, ...source.themeConfig };
14
+ base.themeConfig = Object.assign(Object.assign({}, object.themeConfig), source.themeConfig);
18
15
  }
19
16
  if (object.svg || source.svg) {
20
- base.svg = { ...object.svg, ...source.svg };
17
+ base.svg = Object.assign(Object.assign({}, object.svg), source.svg);
21
18
  }
22
19
  return base;
23
20
  }
24
21
  function cloneOptions(options) {
25
- const cloned = { ...options };
22
+ const cloned = Object.assign({}, options);
26
23
  if (cloned.data)
27
24
  cloned.data = (0, lodash_es_1.cloneDeep)(cloned.data);
28
25
  if (cloned.elements)
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.renderToString = renderToString;
4
13
  const exporter_1 = require("../exporter");
@@ -6,43 +15,41 @@ const renderer_1 = require("../renderer");
6
15
  const runtime_1 = require("../runtime");
7
16
  const utils_1 = require("../utils");
8
17
  const dom_shim_1 = require("./dom-shim");
9
- async function renderToString(options, init) {
10
- const { document } = (0, dom_shim_1.setupDOM)();
11
- const container = document.getElementById('container');
12
- let infographic;
13
- let timeoutId;
14
- try {
15
- infographic = new runtime_1.Infographic({
16
- ...init,
17
- container,
18
- editable: false,
19
- });
20
- const renderPromise = new Promise((resolve, reject) => {
21
- infographic.on('loaded', async ({ node }) => {
22
- try {
23
- const svg = await (0, exporter_1.exportToSVG)(node, { embedResources: true });
24
- resolve(svg.outerHTML);
25
- }
26
- catch (e) {
27
- reject(e);
28
- }
18
+ function renderToString(options, init) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const { document } = (0, dom_shim_1.setupDOM)();
21
+ const container = document.getElementById('container');
22
+ let infographic;
23
+ let timeoutId;
24
+ try {
25
+ infographic = new runtime_1.Infographic(Object.assign(Object.assign({}, init), { container, editable: false }));
26
+ const renderPromise = new Promise((resolve, reject) => {
27
+ infographic.on('loaded', (_a) => __awaiter(this, [_a], void 0, function* ({ node }) {
28
+ try {
29
+ const svg = yield (0, exporter_1.exportToSVG)(node, { embedResources: true });
30
+ resolve(svg.outerHTML);
31
+ }
32
+ catch (e) {
33
+ reject(e);
34
+ }
35
+ }));
36
+ });
37
+ const timeoutPromise = new Promise((_, reject) => {
38
+ timeoutId = setTimeout(() => {
39
+ reject(new Error('SSR render timeout'));
40
+ }, 10000);
29
41
  });
30
- });
31
- const timeoutPromise = new Promise((_, reject) => {
32
- timeoutId = setTimeout(() => {
33
- reject(new Error('SSR render timeout'));
34
- }, 10000);
35
- });
36
- infographic.render(options);
37
- const svg = await Promise.race([renderPromise, timeoutPromise]);
38
- return injectXMLStylesheet(svg);
39
- }
40
- finally {
41
- clearTimeout(timeoutId);
42
- if (infographic) {
43
- infographic.destroy();
42
+ infographic.render(options);
43
+ const svg = yield Promise.race([renderPromise, timeoutPromise]);
44
+ return injectXMLStylesheet(svg);
44
45
  }
45
- }
46
+ finally {
47
+ clearTimeout(timeoutId);
48
+ if (infographic) {
49
+ infographic.destroy();
50
+ }
51
+ }
52
+ });
46
53
  }
47
54
  function injectXMLStylesheet(svg) {
48
55
  const matched = svg.matchAll(/font-family="([\S ]+?)"/g);
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.parseSyntax = parseSyntax;
4
15
  const mapper_1 = require("./mapper");
@@ -6,11 +17,12 @@ const parser_1 = require("./parser");
6
17
  const relations_1 = require("./relations");
7
18
  const schema_1 = require("./schema");
8
19
  function normalizeItems(items) {
20
+ var _a;
9
21
  const seen = new Set();
10
22
  const normalized = [];
11
23
  for (let index = items.length - 1; index >= 0; index -= 1) {
12
24
  const item = items[index];
13
- const id = item.id ?? item.label;
25
+ const id = (_a = item.id) !== null && _a !== void 0 ? _a : item.label;
14
26
  if (!id) {
15
27
  normalized.push(item);
16
28
  continue;
@@ -38,10 +50,11 @@ function resolveTemplate(node, errors) {
38
50
  return undefined;
39
51
  }
40
52
  function parseSyntax(input) {
53
+ var _a;
41
54
  const { ast, errors } = (0, parser_1.parseSyntaxToAst)(input);
42
55
  const warnings = [];
43
56
  const options = {};
44
- const mergedEntries = { ...ast.entries };
57
+ const mergedEntries = Object.assign({}, ast.entries);
45
58
  const infographicNode = ast.entries.infographic;
46
59
  let templateFromInfographic;
47
60
  if (infographicNode && infographicNode.kind === 'object') {
@@ -90,9 +103,9 @@ function parseSyntax(input) {
90
103
  let relationsNode;
91
104
  let dataNodeForMapping = dataNode;
92
105
  if (dataNode.kind === 'object') {
93
- const { relations, ...rest } = dataNode.entries;
106
+ const _b = dataNode.entries, { relations } = _b, rest = __rest(_b, ["relations"]);
94
107
  relationsNode = relations;
95
- dataNodeForMapping = { ...dataNode, entries: rest };
108
+ dataNodeForMapping = Object.assign(Object.assign({}, dataNode), { entries: rest });
96
109
  }
97
110
  const data = (0, mapper_1.mapWithSchema)(dataNodeForMapping, schema_1.DataSchema, 'data', errors);
98
111
  if (data)
@@ -100,7 +113,7 @@ function parseSyntax(input) {
100
113
  if (relationsNode) {
101
114
  const parsed = (0, relations_1.parseRelationsNode)(relationsNode, errors, 'data.relations');
102
115
  if (parsed.relations.length > 0 || parsed.items.length > 0) {
103
- const current = (options.data ?? {});
116
+ const current = ((_a = options.data) !== null && _a !== void 0 ? _a : {});
104
117
  const existingItems = Array.isArray(current.items)
105
118
  ? current.items
106
119
  : [];
@@ -131,7 +144,7 @@ function parseSyntax(input) {
131
144
  if (themeNode) {
132
145
  const theme = (0, mapper_1.mapWithSchema)(themeNode, schema_1.ThemeSchema, 'theme', errors);
133
146
  if (theme && typeof theme === 'object') {
134
- const { type, ...rest } = theme;
147
+ const _c = theme, { type } = _c, rest = __rest(_c, ["type"]);
135
148
  if (typeof type === 'string' && type)
136
149
  options.theme = type;
137
150
  if (Object.keys(rest).length > 0) {
@@ -270,7 +270,7 @@ function mapWithSchema(node, schema, path, errors) {
270
270
  return result;
271
271
  }
272
272
  const inline = (0, parser_1.parseInlineKeyValue)(node.value);
273
- if (inline?.value !== undefined) {
273
+ if ((inline === null || inline === void 0 ? void 0 : inline.value) !== undefined) {
274
274
  if (schema.fields[inline.key]) {
275
275
  const value = mapWithSchema(createValueNode(inline.value, node.line), schema.fields[inline.key], `${path}.${inline.key}`, errors);
276
276
  if (value !== undefined)
@@ -297,7 +297,7 @@ function mapWithSchema(node, schema, path, errors) {
297
297
  }
298
298
  else {
299
299
  const inline = (0, parser_1.parseInlineKeyValue)(node.value);
300
- if (inline?.value !== undefined) {
300
+ if ((inline === null || inline === void 0 ? void 0 : inline.value) !== undefined) {
301
301
  if (schema.fields[inline.key]) {
302
302
  const value = mapWithSchema(createValueNode(inline.value, node.line), schema.fields[inline.key], `${path}.${inline.key}`, errors);
303
303
  if (value !== undefined && result[inline.key] === undefined) {