@elastic/isomer-sdk 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/LICENSE.txt +93 -0
  2. package/NOTICE.txt +1861 -0
  3. package/README.md +58 -0
  4. package/THIRD_PARTY_LICENSES.md +957 -0
  5. package/dist/author/authored_fields.d.ts +103 -0
  6. package/dist/author/authored_fields.d.ts.map +1 -0
  7. package/dist/author/authored_fields.js +183 -0
  8. package/dist/author/authored_fields.js.map +1 -0
  9. package/dist/author/index.d.ts +5 -0
  10. package/dist/author/index.d.ts.map +1 -0
  11. package/dist/author/index.js +10 -0
  12. package/dist/author/index.js.map +1 -0
  13. package/dist/author/jsx.d.ts +21 -0
  14. package/dist/author/jsx.d.ts.map +1 -0
  15. package/dist/author/jsx.js +20 -0
  16. package/dist/author/jsx.js.map +1 -0
  17. package/dist/author/jsx_shim.d.ts +116 -0
  18. package/dist/author/jsx_shim.d.ts.map +1 -0
  19. package/dist/author/jsx_shim.js +353 -0
  20. package/dist/author/jsx_shim.js.map +1 -0
  21. package/dist/author/prompt.d.ts +58 -0
  22. package/dist/author/prompt.d.ts.map +1 -0
  23. package/dist/author/prompt.js +148 -0
  24. package/dist/author/prompt.js.map +1 -0
  25. package/dist/cjs/author/authored_fields.js +189 -0
  26. package/dist/cjs/author/authored_fields.js.map +1 -0
  27. package/dist/cjs/author/index.js +20 -0
  28. package/dist/cjs/author/index.js.map +1 -0
  29. package/dist/cjs/author/jsx.js +24 -0
  30. package/dist/cjs/author/jsx.js.map +1 -0
  31. package/dist/cjs/author/jsx_shim.js +359 -0
  32. package/dist/cjs/author/jsx_shim.js.map +1 -0
  33. package/dist/cjs/author/prompt.js +153 -0
  34. package/dist/cjs/author/prompt.js.map +1 -0
  35. package/dist/cjs/composition/action_event.js +9 -0
  36. package/dist/cjs/composition/action_event.js.map +1 -0
  37. package/dist/cjs/composition/body_node_base.js +105 -0
  38. package/dist/cjs/composition/body_node_base.js.map +1 -0
  39. package/dist/cjs/composition/composition.js +9 -0
  40. package/dist/cjs/composition/composition.js.map +1 -0
  41. package/dist/cjs/composition/error.js +72 -0
  42. package/dist/cjs/composition/error.js.map +1 -0
  43. package/dist/cjs/composition/index.js +31 -0
  44. package/dist/cjs/composition/index.js.map +1 -0
  45. package/dist/cjs/composition/map_nodes.js +85 -0
  46. package/dist/cjs/composition/map_nodes.js.map +1 -0
  47. package/dist/cjs/composition/named_color.js +20 -0
  48. package/dist/cjs/composition/named_color.js.map +1 -0
  49. package/dist/cjs/composition/node.js +9 -0
  50. package/dist/cjs/composition/node.js.map +1 -0
  51. package/dist/cjs/composition/one_line.js +23 -0
  52. package/dist/cjs/composition/one_line.js.map +1 -0
  53. package/dist/cjs/composition/structured_value.js +21 -0
  54. package/dist/cjs/composition/structured_value.js.map +1 -0
  55. package/dist/cjs/composition/validation_error.js +40 -0
  56. package/dist/cjs/composition/validation_error.js.map +1 -0
  57. package/dist/cjs/define/frame.js +32 -0
  58. package/dist/cjs/define/frame.js.map +1 -0
  59. package/dist/cjs/define/index.js +25 -0
  60. package/dist/cjs/define/index.js.map +1 -0
  61. package/dist/cjs/define/markdown_content.js +12 -0
  62. package/dist/cjs/define/markdown_content.js.map +1 -0
  63. package/dist/cjs/define/primitive_module.js +107 -0
  64. package/dist/cjs/define/primitive_module.js.map +1 -0
  65. package/dist/cjs/define/slack_assets.js +9 -0
  66. package/dist/cjs/define/slack_assets.js.map +1 -0
  67. package/dist/cjs/define/slack_blocks.js +9 -0
  68. package/dist/cjs/define/slack_blocks.js.map +1 -0
  69. package/dist/cjs/define/zod_format.js +122 -0
  70. package/dist/cjs/define/zod_format.js.map +1 -0
  71. package/dist/cjs/define/zod_helpers.js +26 -0
  72. package/dist/cjs/define/zod_helpers.js.map +1 -0
  73. package/dist/cjs/entries/html.js +12 -0
  74. package/dist/cjs/entries/html.js.map +1 -0
  75. package/dist/cjs/entries/index.js +75 -0
  76. package/dist/cjs/entries/index.js.map +1 -0
  77. package/dist/cjs/entries/markdown.js +14 -0
  78. package/dist/cjs/entries/markdown.js.map +1 -0
  79. package/dist/cjs/entries/react.js +20 -0
  80. package/dist/cjs/entries/react.js.map +1 -0
  81. package/dist/cjs/entries/slack.js +26 -0
  82. package/dist/cjs/entries/slack.js.map +1 -0
  83. package/dist/cjs/entries/text.js +12 -0
  84. package/dist/cjs/entries/text.js.map +1 -0
  85. package/dist/cjs/pack/capabilities.js +34 -0
  86. package/dist/cjs/pack/capabilities.js.map +1 -0
  87. package/dist/cjs/pack/compose.js +56 -0
  88. package/dist/cjs/pack/compose.js.map +1 -0
  89. package/dist/cjs/pack/enhancements.js +65 -0
  90. package/dist/cjs/pack/enhancements.js.map +1 -0
  91. package/dist/cjs/pack/index.js +18 -0
  92. package/dist/cjs/pack/index.js.map +1 -0
  93. package/dist/cjs/pack/primitive_pack.js +85 -0
  94. package/dist/cjs/pack/primitive_pack.js.map +1 -0
  95. package/dist/cjs/package.json +3 -0
  96. package/dist/cjs/render/anchors.js +167 -0
  97. package/dist/cjs/render/anchors.js.map +1 -0
  98. package/dist/cjs/render/context_view.js +54 -0
  99. package/dist/cjs/render/context_view.js.map +1 -0
  100. package/dist/cjs/render/format_display_value.js +143 -0
  101. package/dist/cjs/render/format_display_value.js.map +1 -0
  102. package/dist/cjs/render/format_number.js +46 -0
  103. package/dist/cjs/render/format_number.js.map +1 -0
  104. package/dist/cjs/render/html/enhancements.js +30 -0
  105. package/dist/cjs/render/html/enhancements.js.map +1 -0
  106. package/dist/cjs/render/html/envelope.js +218 -0
  107. package/dist/cjs/render/html/envelope.js.map +1 -0
  108. package/dist/cjs/render/html/index.js +12 -0
  109. package/dist/cjs/render/html/index.js.map +1 -0
  110. package/dist/cjs/render/index.js +25 -0
  111. package/dist/cjs/render/index.js.map +1 -0
  112. package/dist/cjs/render/layout_check.js +133 -0
  113. package/dist/cjs/render/layout_check.js.map +1 -0
  114. package/dist/cjs/render/markdown/builder.js +189 -0
  115. package/dist/cjs/render/markdown/builder.js.map +1 -0
  116. package/dist/cjs/render/markdown/envelope.js +33 -0
  117. package/dist/cjs/render/markdown/envelope.js.map +1 -0
  118. package/dist/cjs/render/markdown/format.js +190 -0
  119. package/dist/cjs/render/markdown/format.js.map +1 -0
  120. package/dist/cjs/render/markdown/index.js +15 -0
  121. package/dist/cjs/render/markdown/index.js.map +1 -0
  122. package/dist/cjs/render/measure_dom.js +61 -0
  123. package/dist/cjs/render/measure_dom.js.map +1 -0
  124. package/dist/cjs/render/payload.js +13 -0
  125. package/dist/cjs/render/payload.js.map +1 -0
  126. package/dist/cjs/render/primitive_dispatch.js +187 -0
  127. package/dist/cjs/render/primitive_dispatch.js.map +1 -0
  128. package/dist/cjs/render/react/content.js +44 -0
  129. package/dist/cjs/render/react/content.js.map +1 -0
  130. package/dist/cjs/render/react/enhancements.js +32 -0
  131. package/dist/cjs/render/react/enhancements.js.map +1 -0
  132. package/dist/cjs/render/react/index.js +15 -0
  133. package/dist/cjs/render/react/index.js.map +1 -0
  134. package/dist/cjs/render/slack/assets.js +45 -0
  135. package/dist/cjs/render/slack/assets.js.map +1 -0
  136. package/dist/cjs/render/slack/blocks.js +80 -0
  137. package/dist/cjs/render/slack/blocks.js.map +1 -0
  138. package/dist/cjs/render/slack/envelope.js +551 -0
  139. package/dist/cjs/render/slack/envelope.js.map +1 -0
  140. package/dist/cjs/render/slack/format.js +825 -0
  141. package/dist/cjs/render/slack/format.js.map +1 -0
  142. package/dist/cjs/render/slack/index.js +31 -0
  143. package/dist/cjs/render/slack/index.js.map +1 -0
  144. package/dist/cjs/render/slack/markdown_content.js +358 -0
  145. package/dist/cjs/render/slack/markdown_content.js.map +1 -0
  146. package/dist/cjs/render/text/envelope.js +21 -0
  147. package/dist/cjs/render/text/envelope.js.map +1 -0
  148. package/dist/cjs/render/text/index.js +12 -0
  149. package/dist/cjs/render/text/index.js.map +1 -0
  150. package/dist/cjs/testing/conformance.js +296 -0
  151. package/dist/cjs/testing/conformance.js.map +1 -0
  152. package/dist/cjs/testing/index.js +16 -0
  153. package/dist/cjs/testing/index.js.map +1 -0
  154. package/dist/cjs/testing/registration.js +140 -0
  155. package/dist/cjs/testing/registration.js.map +1 -0
  156. package/dist/cjs/validate/authoring_schema.js +296 -0
  157. package/dist/cjs/validate/authoring_schema.js.map +1 -0
  158. package/dist/cjs/validate/composition_schema.js +135 -0
  159. package/dist/cjs/validate/composition_schema.js.map +1 -0
  160. package/dist/cjs/validate/index.js +52 -0
  161. package/dist/cjs/validate/index.js.map +1 -0
  162. package/dist/cjs/validate/input_budget.js +156 -0
  163. package/dist/cjs/validate/input_budget.js.map +1 -0
  164. package/dist/cjs/validate/json_schema.js +72 -0
  165. package/dist/cjs/validate/json_schema.js.map +1 -0
  166. package/dist/cjs/validate/node_issues.js +65 -0
  167. package/dist/cjs/validate/node_issues.js.map +1 -0
  168. package/dist/cjs/validate/url.js +116 -0
  169. package/dist/cjs/validate/url.js.map +1 -0
  170. package/dist/cjs/validate/validation.js +208 -0
  171. package/dist/cjs/validate/validation.js.map +1 -0
  172. package/dist/cjs/validate/value_schemas.js +53 -0
  173. package/dist/cjs/validate/value_schemas.js.map +1 -0
  174. package/dist/composition/action_event.d.ts +13 -0
  175. package/dist/composition/action_event.d.ts.map +1 -0
  176. package/dist/composition/action_event.js +8 -0
  177. package/dist/composition/action_event.js.map +1 -0
  178. package/dist/composition/body_node_base.d.ts +71 -0
  179. package/dist/composition/body_node_base.d.ts.map +1 -0
  180. package/dist/composition/body_node_base.js +97 -0
  181. package/dist/composition/body_node_base.js.map +1 -0
  182. package/dist/composition/composition.d.ts +71 -0
  183. package/dist/composition/composition.d.ts.map +1 -0
  184. package/dist/composition/composition.js +8 -0
  185. package/dist/composition/composition.js.map +1 -0
  186. package/dist/composition/error.d.ts +60 -0
  187. package/dist/composition/error.d.ts.map +1 -0
  188. package/dist/composition/error.js +68 -0
  189. package/dist/composition/error.js.map +1 -0
  190. package/dist/composition/index.d.ts +11 -0
  191. package/dist/composition/index.d.ts.map +1 -0
  192. package/dist/composition/index.js +14 -0
  193. package/dist/composition/index.js.map +1 -0
  194. package/dist/composition/map_nodes.d.ts +16 -0
  195. package/dist/composition/map_nodes.d.ts.map +1 -0
  196. package/dist/composition/map_nodes.js +81 -0
  197. package/dist/composition/map_nodes.js.map +1 -0
  198. package/dist/composition/named_color.d.ts +9 -0
  199. package/dist/composition/named_color.d.ts.map +1 -0
  200. package/dist/composition/named_color.js +17 -0
  201. package/dist/composition/named_color.js.map +1 -0
  202. package/dist/composition/node.d.ts +11 -0
  203. package/dist/composition/node.d.ts.map +1 -0
  204. package/dist/composition/node.js +8 -0
  205. package/dist/composition/node.js.map +1 -0
  206. package/dist/composition/one_line.d.ts +7 -0
  207. package/dist/composition/one_line.d.ts.map +1 -0
  208. package/dist/composition/one_line.js +17 -0
  209. package/dist/composition/one_line.js.map +1 -0
  210. package/dist/composition/structured_value.d.ts +27 -0
  211. package/dist/composition/structured_value.d.ts.map +1 -0
  212. package/dist/composition/structured_value.js +18 -0
  213. package/dist/composition/structured_value.js.map +1 -0
  214. package/dist/composition/validation_error.d.ts +33 -0
  215. package/dist/composition/validation_error.d.ts.map +1 -0
  216. package/dist/composition/validation_error.js +35 -0
  217. package/dist/composition/validation_error.js.map +1 -0
  218. package/dist/define/frame.d.ts +166 -0
  219. package/dist/define/frame.d.ts.map +1 -0
  220. package/dist/define/frame.js +28 -0
  221. package/dist/define/frame.js.map +1 -0
  222. package/dist/define/index.d.ts +8 -0
  223. package/dist/define/index.d.ts.map +1 -0
  224. package/dist/define/index.js +11 -0
  225. package/dist/define/index.js.map +1 -0
  226. package/dist/define/markdown_content.d.ts +15 -0
  227. package/dist/define/markdown_content.d.ts.map +1 -0
  228. package/dist/define/markdown_content.js +9 -0
  229. package/dist/define/markdown_content.js.map +1 -0
  230. package/dist/define/primitive_module.d.ts +421 -0
  231. package/dist/define/primitive_module.d.ts.map +1 -0
  232. package/dist/define/primitive_module.js +101 -0
  233. package/dist/define/primitive_module.js.map +1 -0
  234. package/dist/define/slack_assets.d.ts +28 -0
  235. package/dist/define/slack_assets.d.ts.map +1 -0
  236. package/dist/define/slack_assets.js +8 -0
  237. package/dist/define/slack_assets.js.map +1 -0
  238. package/dist/define/slack_blocks.d.ts +234 -0
  239. package/dist/define/slack_blocks.d.ts.map +1 -0
  240. package/dist/define/slack_blocks.js +8 -0
  241. package/dist/define/slack_blocks.js.map +1 -0
  242. package/dist/define/zod_format.d.ts +33 -0
  243. package/dist/define/zod_format.d.ts.map +1 -0
  244. package/dist/define/zod_format.js +114 -0
  245. package/dist/define/zod_format.js.map +1 -0
  246. package/dist/define/zod_helpers.d.ts +10 -0
  247. package/dist/define/zod_helpers.d.ts.map +1 -0
  248. package/dist/define/zod_helpers.js +22 -0
  249. package/dist/define/zod_helpers.js.map +1 -0
  250. package/dist/entries/html.d.ts +3 -0
  251. package/dist/entries/html.d.ts.map +1 -0
  252. package/dist/entries/html.js +8 -0
  253. package/dist/entries/html.js.map +1 -0
  254. package/dist/entries/index.d.ts +6 -0
  255. package/dist/entries/index.d.ts.map +1 -0
  256. package/dist/entries/index.js +12 -0
  257. package/dist/entries/index.js.map +1 -0
  258. package/dist/entries/markdown.d.ts +3 -0
  259. package/dist/entries/markdown.d.ts.map +1 -0
  260. package/dist/entries/markdown.js +8 -0
  261. package/dist/entries/markdown.js.map +1 -0
  262. package/dist/entries/react.d.ts +5 -0
  263. package/dist/entries/react.d.ts.map +1 -0
  264. package/dist/entries/react.js +11 -0
  265. package/dist/entries/react.js.map +1 -0
  266. package/dist/entries/slack.d.ts +2 -0
  267. package/dist/entries/slack.d.ts.map +1 -0
  268. package/dist/entries/slack.js +8 -0
  269. package/dist/entries/slack.js.map +1 -0
  270. package/dist/entries/text.d.ts +2 -0
  271. package/dist/entries/text.d.ts.map +1 -0
  272. package/dist/entries/text.js +8 -0
  273. package/dist/entries/text.js.map +1 -0
  274. package/dist/pack/capabilities.d.ts +27 -0
  275. package/dist/pack/capabilities.d.ts.map +1 -0
  276. package/dist/pack/capabilities.js +30 -0
  277. package/dist/pack/capabilities.js.map +1 -0
  278. package/dist/pack/compose.d.ts +21 -0
  279. package/dist/pack/compose.d.ts.map +1 -0
  280. package/dist/pack/compose.js +52 -0
  281. package/dist/pack/compose.js.map +1 -0
  282. package/dist/pack/enhancements.d.ts +65 -0
  283. package/dist/pack/enhancements.d.ts.map +1 -0
  284. package/dist/pack/enhancements.js +59 -0
  285. package/dist/pack/enhancements.js.map +1 -0
  286. package/dist/pack/index.d.ts +5 -0
  287. package/dist/pack/index.d.ts.map +1 -0
  288. package/dist/pack/index.js +11 -0
  289. package/dist/pack/index.js.map +1 -0
  290. package/dist/pack/primitive_pack.d.ts +155 -0
  291. package/dist/pack/primitive_pack.d.ts.map +1 -0
  292. package/dist/pack/primitive_pack.js +81 -0
  293. package/dist/pack/primitive_pack.js.map +1 -0
  294. package/dist/render/anchors.d.ts +82 -0
  295. package/dist/render/anchors.d.ts.map +1 -0
  296. package/dist/render/anchors.js +153 -0
  297. package/dist/render/anchors.js.map +1 -0
  298. package/dist/render/context_view.d.ts +10 -0
  299. package/dist/render/context_view.d.ts.map +1 -0
  300. package/dist/render/context_view.js +49 -0
  301. package/dist/render/context_view.js.map +1 -0
  302. package/dist/render/format_display_value.d.ts +20 -0
  303. package/dist/render/format_display_value.d.ts.map +1 -0
  304. package/dist/render/format_display_value.js +137 -0
  305. package/dist/render/format_display_value.js.map +1 -0
  306. package/dist/render/format_number.d.ts +9 -0
  307. package/dist/render/format_number.d.ts.map +1 -0
  308. package/dist/render/format_number.js +42 -0
  309. package/dist/render/format_number.js.map +1 -0
  310. package/dist/render/html/enhancements.d.ts +10 -0
  311. package/dist/render/html/enhancements.d.ts.map +1 -0
  312. package/dist/render/html/enhancements.js +25 -0
  313. package/dist/render/html/enhancements.js.map +1 -0
  314. package/dist/render/html/envelope.d.ts +182 -0
  315. package/dist/render/html/envelope.d.ts.map +1 -0
  316. package/dist/render/html/envelope.js +214 -0
  317. package/dist/render/html/envelope.js.map +1 -0
  318. package/dist/render/html/index.d.ts +3 -0
  319. package/dist/render/html/index.d.ts.map +1 -0
  320. package/dist/render/html/index.js +8 -0
  321. package/dist/render/html/index.js.map +1 -0
  322. package/dist/render/index.d.ts +6 -0
  323. package/dist/render/index.d.ts.map +1 -0
  324. package/dist/render/index.js +11 -0
  325. package/dist/render/index.js.map +1 -0
  326. package/dist/render/layout_check.d.ts +43 -0
  327. package/dist/render/layout_check.d.ts.map +1 -0
  328. package/dist/render/layout_check.js +129 -0
  329. package/dist/render/layout_check.js.map +1 -0
  330. package/dist/render/markdown/builder.d.ts +48 -0
  331. package/dist/render/markdown/builder.d.ts.map +1 -0
  332. package/dist/render/markdown/builder.js +183 -0
  333. package/dist/render/markdown/builder.js.map +1 -0
  334. package/dist/render/markdown/envelope.d.ts +20 -0
  335. package/dist/render/markdown/envelope.d.ts.map +1 -0
  336. package/dist/render/markdown/envelope.js +29 -0
  337. package/dist/render/markdown/envelope.js.map +1 -0
  338. package/dist/render/markdown/format.d.ts +3 -0
  339. package/dist/render/markdown/format.d.ts.map +1 -0
  340. package/dist/render/markdown/format.js +186 -0
  341. package/dist/render/markdown/format.js.map +1 -0
  342. package/dist/render/markdown/index.d.ts +3 -0
  343. package/dist/render/markdown/index.d.ts.map +1 -0
  344. package/dist/render/markdown/index.js +9 -0
  345. package/dist/render/markdown/index.js.map +1 -0
  346. package/dist/render/measure_dom.d.ts +10 -0
  347. package/dist/render/measure_dom.d.ts.map +1 -0
  348. package/dist/render/measure_dom.js +57 -0
  349. package/dist/render/measure_dom.js.map +1 -0
  350. package/dist/render/payload.d.ts +16 -0
  351. package/dist/render/payload.d.ts.map +1 -0
  352. package/dist/render/payload.js +9 -0
  353. package/dist/render/payload.js.map +1 -0
  354. package/dist/render/primitive_dispatch.d.ts +72 -0
  355. package/dist/render/primitive_dispatch.d.ts.map +1 -0
  356. package/dist/render/primitive_dispatch.js +183 -0
  357. package/dist/render/primitive_dispatch.js.map +1 -0
  358. package/dist/render/react/content.d.ts +40 -0
  359. package/dist/render/react/content.d.ts.map +1 -0
  360. package/dist/render/react/content.js +39 -0
  361. package/dist/render/react/content.js.map +1 -0
  362. package/dist/render/react/enhancements.d.ts +15 -0
  363. package/dist/render/react/enhancements.d.ts.map +1 -0
  364. package/dist/render/react/enhancements.js +28 -0
  365. package/dist/render/react/enhancements.js.map +1 -0
  366. package/dist/render/react/index.d.ts +3 -0
  367. package/dist/render/react/index.d.ts.map +1 -0
  368. package/dist/render/react/index.js +9 -0
  369. package/dist/render/react/index.js.map +1 -0
  370. package/dist/render/slack/assets.d.ts +16 -0
  371. package/dist/render/slack/assets.d.ts.map +1 -0
  372. package/dist/render/slack/assets.js +40 -0
  373. package/dist/render/slack/assets.js.map +1 -0
  374. package/dist/render/slack/blocks.d.ts +72 -0
  375. package/dist/render/slack/blocks.d.ts.map +1 -0
  376. package/dist/render/slack/blocks.js +77 -0
  377. package/dist/render/slack/blocks.js.map +1 -0
  378. package/dist/render/slack/envelope.d.ts +52 -0
  379. package/dist/render/slack/envelope.d.ts.map +1 -0
  380. package/dist/render/slack/envelope.js +547 -0
  381. package/dist/render/slack/envelope.js.map +1 -0
  382. package/dist/render/slack/format.d.ts +95 -0
  383. package/dist/render/slack/format.d.ts.map +1 -0
  384. package/dist/render/slack/format.js +807 -0
  385. package/dist/render/slack/format.js.map +1 -0
  386. package/dist/render/slack/index.d.ts +6 -0
  387. package/dist/render/slack/index.d.ts.map +1 -0
  388. package/dist/render/slack/index.js +12 -0
  389. package/dist/render/slack/index.js.map +1 -0
  390. package/dist/render/slack/markdown_content.d.ts +11 -0
  391. package/dist/render/slack/markdown_content.d.ts.map +1 -0
  392. package/dist/render/slack/markdown_content.js +354 -0
  393. package/dist/render/slack/markdown_content.js.map +1 -0
  394. package/dist/render/text/envelope.d.ts +15 -0
  395. package/dist/render/text/envelope.d.ts.map +1 -0
  396. package/dist/render/text/envelope.js +17 -0
  397. package/dist/render/text/envelope.js.map +1 -0
  398. package/dist/render/text/index.d.ts +2 -0
  399. package/dist/render/text/index.d.ts.map +1 -0
  400. package/dist/render/text/index.js +8 -0
  401. package/dist/render/text/index.js.map +1 -0
  402. package/dist/testing/conformance.d.ts +140 -0
  403. package/dist/testing/conformance.d.ts.map +1 -0
  404. package/dist/testing/conformance.js +287 -0
  405. package/dist/testing/conformance.js.map +1 -0
  406. package/dist/testing/index.d.ts +3 -0
  407. package/dist/testing/index.d.ts.map +1 -0
  408. package/dist/testing/index.js +9 -0
  409. package/dist/testing/index.js.map +1 -0
  410. package/dist/testing/registration.d.ts +32 -0
  411. package/dist/testing/registration.d.ts.map +1 -0
  412. package/dist/testing/registration.js +103 -0
  413. package/dist/testing/registration.js.map +1 -0
  414. package/dist/validate/authoring_schema.d.ts +27 -0
  415. package/dist/validate/authoring_schema.d.ts.map +1 -0
  416. package/dist/validate/authoring_schema.js +291 -0
  417. package/dist/validate/authoring_schema.js.map +1 -0
  418. package/dist/validate/composition_schema.d.ts +80 -0
  419. package/dist/validate/composition_schema.d.ts.map +1 -0
  420. package/dist/validate/composition_schema.js +127 -0
  421. package/dist/validate/composition_schema.js.map +1 -0
  422. package/dist/validate/index.d.ts +9 -0
  423. package/dist/validate/index.d.ts.map +1 -0
  424. package/dist/validate/index.js +15 -0
  425. package/dist/validate/index.js.map +1 -0
  426. package/dist/validate/input_budget.d.ts +35 -0
  427. package/dist/validate/input_budget.d.ts.map +1 -0
  428. package/dist/validate/input_budget.js +151 -0
  429. package/dist/validate/input_budget.js.map +1 -0
  430. package/dist/validate/json_schema.d.ts +32 -0
  431. package/dist/validate/json_schema.d.ts.map +1 -0
  432. package/dist/validate/json_schema.js +68 -0
  433. package/dist/validate/json_schema.js.map +1 -0
  434. package/dist/validate/node_issues.d.ts +12 -0
  435. package/dist/validate/node_issues.d.ts.map +1 -0
  436. package/dist/validate/node_issues.js +61 -0
  437. package/dist/validate/node_issues.js.map +1 -0
  438. package/dist/validate/url.d.ts +50 -0
  439. package/dist/validate/url.d.ts.map +1 -0
  440. package/dist/validate/url.js +107 -0
  441. package/dist/validate/url.js.map +1 -0
  442. package/dist/validate/validation.d.ts +105 -0
  443. package/dist/validate/validation.d.ts.map +1 -0
  444. package/dist/validate/validation.js +200 -0
  445. package/dist/validate/validation.js.map +1 -0
  446. package/dist/validate/value_schemas.d.ts +53 -0
  447. package/dist/validate/value_schemas.d.ts.map +1 -0
  448. package/dist/validate/value_schemas.js +50 -0
  449. package/dist/validate/value_schemas.js.map +1 -0
  450. package/package.json +118 -5
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.rendersOnSurface = exports.isVisibleOnSurface = exports.someBodyNode = exports.childNodePath = exports.createChildNodeWalker = exports.BODY_NODE_SURFACES = void 0;
10
+ /** Every {@link SurfaceName}, for callers that iterate them. */
11
+ exports.BODY_NODE_SURFACES = [
12
+ 'react',
13
+ 'svg',
14
+ 'text',
15
+ 'markdown',
16
+ 'slack',
17
+ ];
18
+ /**
19
+ * Builds the {@link ChildNodeWalker} for one composition's inventory.
20
+ *
21
+ * Pass every pack's definitions: a walker missing one cannot see children of a
22
+ * container that pack defines, and a tree walk would stop at its boundary.
23
+ */
24
+ const createChildNodeWalker = (definitions) => {
25
+ const childrenByType = new Map();
26
+ const ownContentByType = new Map();
27
+ for (const definition of definitions) {
28
+ if (typeof definition.children === 'function') {
29
+ childrenByType.set(definition.type, definition.children);
30
+ }
31
+ if (typeof definition.hasOwnContent === 'function') {
32
+ ownContentByType.set(definition.type, definition.hasOwnContent);
33
+ }
34
+ }
35
+ const walk = ((node) => {
36
+ if (!node || typeof node !== 'object') {
37
+ return [];
38
+ }
39
+ const { type } = node;
40
+ if (typeof type !== 'string') {
41
+ return [];
42
+ }
43
+ return [...(childrenByType.get(type)?.(node) ?? [])];
44
+ });
45
+ walk.hasOwnContent = (node) => {
46
+ if (!node || typeof node !== 'object') {
47
+ return false;
48
+ }
49
+ const { type } = node;
50
+ if (typeof type !== 'string') {
51
+ return false;
52
+ }
53
+ return ownContentByType.get(type)?.(node) ?? false;
54
+ };
55
+ return walk;
56
+ };
57
+ exports.createChildNodeWalker = createChildNodeWalker;
58
+ /** Joins a parent path with a {@link ChildNodeRef.path} fragment. */
59
+ const childNodePath = (parent, child) => `${parent}.${child}`;
60
+ exports.childNodePath = childNodePath;
61
+ /**
62
+ * Whether any node visible on `surface` matches, descending through container
63
+ * children via `walk`. A node (or a container ancestor) hidden from `surface`
64
+ * is skipped along with its children.
65
+ *
66
+ * `walk` must span every pack in the composition: a walker built from one
67
+ * pack's definitions cannot see children of a container defined in another.
68
+ */
69
+ const someBodyNode = (nodes, surface, predicate, walk) => nodes.some((node) => {
70
+ if (!(0, exports.isVisibleOnSurface)(node, surface)) {
71
+ return false;
72
+ }
73
+ return (predicate(node) ||
74
+ (0, exports.someBodyNode)(walk(node).map((child) => child.node), surface, predicate, walk));
75
+ });
76
+ exports.someBodyNode = someBodyNode;
77
+ /** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */
78
+ const isVisibleOnSurface = (node, surface) => {
79
+ if (!node || typeof node !== 'object') {
80
+ return false;
81
+ }
82
+ const { surfaces } = node;
83
+ return !Array.isArray(surfaces) || surfaces.includes(surface);
84
+ };
85
+ exports.isVisibleOnSurface = isVisibleOnSurface;
86
+ /**
87
+ * Whether `node` puts anything on `surface` — itself or through a descendant.
88
+ *
89
+ * Stronger than {@link isVisibleOnSurface}: a container every one of whose
90
+ * children is hidden renders nothing, even though its own hint allows the
91
+ * surface. A hybrid container that also owns string fields declares
92
+ * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.
93
+ */
94
+ const rendersOnSurface = (node, surface, walk) => {
95
+ if (!(0, exports.isVisibleOnSurface)(node, surface)) {
96
+ return false;
97
+ }
98
+ const children = walk(node);
99
+ if (children.length === 0 || walk.hasOwnContent?.(node)) {
100
+ return true;
101
+ }
102
+ return children.some(({ node: child }) => (0, exports.rendersOnSurface)(child, surface, walk));
103
+ };
104
+ exports.rendersOnSurface = rendersOnSurface;
105
+ //# sourceMappingURL=body_node_base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body_node_base.js","sourceRoot":"","sources":["../../../src/composition/body_node_base.ts"],"names":[],"mappings":"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","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/**\n * The five surfaces a node renders on or is hidden from.\n *\n * Spelled out rather than derived as `keyof SurfaceMap<…>`: the keys never vary\n * with the pack types, and TypeScript can fail to prove a `keyof` over one\n * instantiation transfers to another, silently widening to `any`.\n */\nexport type SurfaceName = 'react' | 'svg' | 'text' | 'markdown' | 'slack';\n\n/** Every {@link SurfaceName}, for callers that iterate them. */\nexport const BODY_NODE_SURFACES: readonly SurfaceName[] = [\n 'react',\n 'svg',\n 'text',\n 'markdown',\n 'slack',\n];\n\n/** The two fields every primitive node carries, whatever its pack. */\nexport interface BodyNodeBase {\n /** Unique within a composition, which `validate` enforces and `parse` does not. */\n id?: string;\n /** Surfaces this node appears on. Absent means every surface. */\n surfaces?: SurfaceName[];\n}\n\n/**\n * A child node together with the field path locating it inside its parent, so\n * an error path can name the field a child actually lives under. A container\n * that returned bare nodes would leave every caller guessing the field name.\n */\nexport interface ChildNodeRef {\n /** Erased: one walker spans every pack's node types, so it can name none of them. */\n node: unknown;\n /** Relative to the parent, e.g. `items[0].node`, `items[2].description`. */\n path: string;\n}\n\n/**\n * Walks nested nodes and, for a hybrid container, reports whether the parent\n * still produces output of its own. A non-empty `children` result is the\n * complete source of rendered content unless\n * {@link ChildNodeWalker.hasOwnContent} is true for that node.\n */\nexport type ChildNodeWalker = ((node: unknown) => ChildNodeRef[]) & {\n hasOwnContent?(node: unknown): boolean;\n};\n\n/**\n * Builds the {@link ChildNodeWalker} for one composition's inventory.\n *\n * Pass every pack's definitions: a walker missing one cannot see children of a\n * container that pack defines, and a tree walk would stop at its boundary.\n */\nexport const createChildNodeWalker = (\n definitions: readonly {\n type: string;\n children?: unknown;\n hasOwnContent?: unknown;\n }[]\n): ChildNodeWalker => {\n const childrenByType = new Map<\n string,\n (node: unknown) => readonly ChildNodeRef[]\n >();\n const ownContentByType = new Map<string, (node: unknown) => boolean>();\n for (const definition of definitions) {\n if (typeof definition.children === 'function') {\n childrenByType.set(\n definition.type,\n definition.children as (node: unknown) => readonly ChildNodeRef[]\n );\n }\n if (typeof definition.hasOwnContent === 'function') {\n ownContentByType.set(\n definition.type,\n definition.hasOwnContent as (node: unknown) => boolean\n );\n }\n }\n const walk = ((node: unknown) => {\n if (!node || typeof node !== 'object') {\n return [];\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return [];\n }\n return [...(childrenByType.get(type)?.(node) ?? [])];\n }) as ChildNodeWalker;\n walk.hasOwnContent = (node) => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return false;\n }\n return ownContentByType.get(type)?.(node) ?? false;\n };\n return walk;\n};\n\n/** Joins a parent path with a {@link ChildNodeRef.path} fragment. */\nexport const childNodePath = (parent: string, child: string): string =>\n `${parent}.${child}`;\n\n/**\n * Whether any node visible on `surface` matches, descending through container\n * children via `walk`. A node (or a container ancestor) hidden from `surface`\n * is skipped along with its children.\n *\n * `walk` must span every pack in the composition: a walker built from one\n * pack's definitions cannot see children of a container defined in another.\n */\nexport const someBodyNode = (\n nodes: readonly unknown[],\n surface: SurfaceName,\n predicate: (node: unknown) => boolean,\n walk: ChildNodeWalker\n): boolean =>\n nodes.some((node) => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n return (\n predicate(node) ||\n someBodyNode(\n walk(node).map((child) => child.node),\n surface,\n predicate,\n walk\n )\n );\n });\n\n/** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */\nexport const isVisibleOnSurface = (\n node: unknown,\n surface: SurfaceName\n): boolean => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { surfaces } = node as { surfaces?: unknown };\n return !Array.isArray(surfaces) || surfaces.includes(surface);\n};\n\n/**\n * Whether `node` puts anything on `surface` — itself or through a descendant.\n *\n * Stronger than {@link isVisibleOnSurface}: a container every one of whose\n * children is hidden renders nothing, even though its own hint allows the\n * surface. A hybrid container that also owns string fields declares\n * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.\n */\nexport const rendersOnSurface = (\n node: unknown,\n surface: SurfaceName,\n walk: ChildNodeWalker\n): boolean => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n const children = walk(node);\n if (children.length === 0 || walk.hasOwnContent?.(node)) {\n return true;\n }\n return children.some(({ node: child }) =>\n rendersOnSurface(child, surface, walk)\n );\n};\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../../src/composition/composition.ts"],"names":[],"mappings":";AAAA;;;;;GAKG","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { RenderTheme } from './named_color';\nimport type { PrimitiveNode } from './node';\n\n/**\n * The wire format: one typed document that every surface renders from.\n *\n * Crosses process and vendor boundaries, so the JSON shape is the contract and\n * the TypeScript name is not: {@link Composition.type} reads `view`, the\n * discriminator an agent is prompted on.\n */\nexport interface Composition<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Root marker. Always `view`; see the note on {@link Composition}. */\n type: 'view';\n /**\n * Wire-format version. A literal rather than `number` so an unknown future\n * version cannot parse as valid, and optional with no default because absent\n * already means v1 — writing one in would rewrite stored documents.\n */\n version?: 1;\n title?: string;\n subtitle?: string;\n /** Light/dark preference, not a resolved value; `auto` resolves light. */\n theme?: RenderTheme;\n /** At least one node, which the schema enforces via `.min(1)`. */\n body: TNode[];\n meta?: CompositionMeta;\n}\n\n/**\n * Context a host may surface beside the render.\n *\n * Advisory and pass-through throughout: nothing here changes what the body\n * renders to, and the SDK reads none of it. Timestamps are plain strings by\n * convention ISO 8601, which the schema does not enforce — a host that parses\n * one should tolerate anything.\n */\nexport interface CompositionMeta {\n /** Origin of the composition itself, e.g. the agent or feature that composed it. */\n source?: string;\n /** When the composition was produced. */\n generatedAt?: string;\n /** Overrides the accessible name a surface derives from `title`. */\n ariaLabel?: string;\n /** Where the underlying data came from, as opposed to who composed it. */\n provenance?: {\n /** Data origin, e.g. an index or dataset name. */\n source?: string;\n /** The query that produced the data, for a host that offers \"show me how\". */\n query?: string;\n /** Service or connector that answered the query. */\n provider?: string;\n };\n /** How current the data is, for a host that shows an as-of or staleness badge. */\n freshness?: {\n /** When the data was current, which may precede `generatedAt`. */\n asOf?: string;\n /** Asserted by the producer rather than derived, so a host should prefer it to comparing `asOf`. */\n stale?: boolean;\n /** How long `asOf` stays current. Not range-checked. */\n ttlSeconds?: number;\n };\n /**\n * Set when the composition rendered anyway despite losing some data, so a\n * host can mark it incomplete rather than presenting it as whole.\n */\n partialFailure?: {\n /** True when some of the data behind the composition was lost before it rendered. */\n degraded?: boolean;\n /** Human-readable cause, safe to show a user. */\n reason?: string;\n };\n}\n"]}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.IsomerError = exports.ISOMER_ERROR_CODES = void 0;
10
+ /**
11
+ * Stable codes for {@link IsomerError}, {@link CompositionValidationError},
12
+ * and the runtime's `RegisteredViewInputError`. Hosts branch on `code`, not
13
+ * on `message`. Codes name the condition, not the throwing module: duplicate
14
+ * type at `definePrimitivePack`, `composePacks`, and `createIsomerRuntime` is the same
15
+ * `DUPLICATE_PRIMITIVE_TYPE`; the message names the layer.
16
+ */
17
+ exports.ISOMER_ERROR_CODES = {
18
+ AMBIGUOUS_FRAME: 'AMBIGUOUS_FRAME',
19
+ AMBIGUOUS_STYLE_ADAPTER: 'AMBIGUOUS_STYLE_ADAPTER',
20
+ AUTHOR_TYPE_MISMATCH: 'AUTHOR_TYPE_MISMATCH',
21
+ AUTHORED_SCHEMA_REUSED: 'AUTHORED_SCHEMA_REUSED',
22
+ COMPOSITION_INVALID: 'COMPOSITION_INVALID',
23
+ CYCLIC_COMPOSITION: 'CYCLIC_COMPOSITION',
24
+ DUPLICATE_AUTHORED_CHILD: 'DUPLICATE_AUTHORED_CHILD',
25
+ DUPLICATE_ENHANCEMENT: 'DUPLICATE_ENHANCEMENT',
26
+ DUPLICATE_PACK_ID: 'DUPLICATE_PACK_ID',
27
+ DUPLICATE_PRIMITIVE_TYPE: 'DUPLICATE_PRIMITIVE_TYPE',
28
+ DUPLICATE_VIEW: 'DUPLICATE_VIEW',
29
+ EMPTY_FRAMES: 'EMPTY_FRAMES',
30
+ EMPTY_PACK: 'EMPTY_PACK',
31
+ EMPTY_PACKS: 'EMPTY_PACKS',
32
+ EMPTY_PAGES: 'EMPTY_PAGES',
33
+ EMPTY_VOCABULARY: 'EMPTY_VOCABULARY',
34
+ ENHANCEMENT_ROOT_MISSING: 'ENHANCEMENT_ROOT_MISSING',
35
+ EXPECTED_AUTHOR_COMPONENT: 'EXPECTED_AUTHOR_COMPONENT',
36
+ EXPECTED_JSX_ELEMENT: 'EXPECTED_JSX_ELEMENT',
37
+ EXPECTED_TEXT_CHILDREN: 'EXPECTED_TEXT_CHILDREN',
38
+ INCOMPATIBLE_STYLE_COLLECTOR: 'INCOMPATIBLE_STYLE_COLLECTOR',
39
+ INPUT_NOT_PLAIN_DATA: 'INPUT_NOT_PLAIN_DATA',
40
+ INPUT_OVER_BUDGET: 'INPUT_OVER_BUDGET',
41
+ INVALID_BODY_NODE: 'INVALID_BODY_NODE',
42
+ INVALID_FRAME_BODY: 'INVALID_FRAME_BODY',
43
+ MISSING_AUTHORED_TEXT: 'MISSING_AUTHORED_TEXT',
44
+ MISSING_STYLE_ADAPTER: 'MISSING_STYLE_ADAPTER',
45
+ RESERVED_NODE_FIELD: 'RESERVED_NODE_FIELD',
46
+ UNEXPECTED_CHILDREN: 'UNEXPECTED_CHILDREN',
47
+ UNKNOWN_FRAME: 'UNKNOWN_FRAME',
48
+ UNKNOWN_PRIMITIVE_TYPE: 'UNKNOWN_PRIMITIVE_TYPE',
49
+ UNKNOWN_SURFACE: 'UNKNOWN_SURFACE',
50
+ UNKNOWN_VIEW: 'UNKNOWN_VIEW',
51
+ UNSUPPORTED_CHILD_PATH: 'UNSUPPORTED_CHILD_PATH',
52
+ VIEW_INPUT_INVALID: 'VIEW_INPUT_INVALID',
53
+ VOCABULARY_UNRESOLVED: 'VOCABULARY_UNRESOLVED',
54
+ };
55
+ /**
56
+ * Thrown for construction and authoring failures that are not a
57
+ * `CompositionValidationError`.
58
+ *
59
+ * Identify it by `name` and `code`, never `instanceof`: the SDK ships both
60
+ * ESM and CJS builds, so a host can hold two copies of this class and an
61
+ * identity check would miss one.
62
+ */
63
+ class IsomerError extends Error {
64
+ code;
65
+ constructor(code, message) {
66
+ super(message);
67
+ this.name = 'IsomerError';
68
+ this.code = code;
69
+ }
70
+ }
71
+ exports.IsomerError = IsomerError;
72
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/composition/error.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAG;IAChC,eAAe,EAAE,iBAAiB;IAClC,uBAAuB,EAAE,yBAAyB;IAClD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;IAC9C,iBAAiB,EAAE,mBAAmB;IACtC,wBAAwB,EAAE,0BAA0B;IACpD,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B,EAAE,8BAA8B;IAC5D,oBAAoB,EAAE,sBAAsB;IAC5C,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,sBAAsB,EAAE,wBAAwB;IAChD,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;CACtC,CAAC;AAMX;;;;;;;GAOG;AACH,MAAa,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,kCAQC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/**\n * Stable codes for {@link IsomerError}, {@link CompositionValidationError},\n * and the runtime's `RegisteredViewInputError`. Hosts branch on `code`, not\n * on `message`. Codes name the condition, not the throwing module: duplicate\n * type at `definePrimitivePack`, `composePacks`, and `createIsomerRuntime` is the same\n * `DUPLICATE_PRIMITIVE_TYPE`; the message names the layer.\n */\nexport const ISOMER_ERROR_CODES = {\n AMBIGUOUS_FRAME: 'AMBIGUOUS_FRAME',\n AMBIGUOUS_STYLE_ADAPTER: 'AMBIGUOUS_STYLE_ADAPTER',\n AUTHOR_TYPE_MISMATCH: 'AUTHOR_TYPE_MISMATCH',\n AUTHORED_SCHEMA_REUSED: 'AUTHORED_SCHEMA_REUSED',\n COMPOSITION_INVALID: 'COMPOSITION_INVALID',\n CYCLIC_COMPOSITION: 'CYCLIC_COMPOSITION',\n DUPLICATE_AUTHORED_CHILD: 'DUPLICATE_AUTHORED_CHILD',\n DUPLICATE_ENHANCEMENT: 'DUPLICATE_ENHANCEMENT',\n DUPLICATE_PACK_ID: 'DUPLICATE_PACK_ID',\n DUPLICATE_PRIMITIVE_TYPE: 'DUPLICATE_PRIMITIVE_TYPE',\n DUPLICATE_VIEW: 'DUPLICATE_VIEW',\n EMPTY_FRAMES: 'EMPTY_FRAMES',\n EMPTY_PACK: 'EMPTY_PACK',\n EMPTY_PACKS: 'EMPTY_PACKS',\n EMPTY_PAGES: 'EMPTY_PAGES',\n EMPTY_VOCABULARY: 'EMPTY_VOCABULARY',\n ENHANCEMENT_ROOT_MISSING: 'ENHANCEMENT_ROOT_MISSING',\n EXPECTED_AUTHOR_COMPONENT: 'EXPECTED_AUTHOR_COMPONENT',\n EXPECTED_JSX_ELEMENT: 'EXPECTED_JSX_ELEMENT',\n EXPECTED_TEXT_CHILDREN: 'EXPECTED_TEXT_CHILDREN',\n INCOMPATIBLE_STYLE_COLLECTOR: 'INCOMPATIBLE_STYLE_COLLECTOR',\n INPUT_NOT_PLAIN_DATA: 'INPUT_NOT_PLAIN_DATA',\n INPUT_OVER_BUDGET: 'INPUT_OVER_BUDGET',\n INVALID_BODY_NODE: 'INVALID_BODY_NODE',\n INVALID_FRAME_BODY: 'INVALID_FRAME_BODY',\n MISSING_AUTHORED_TEXT: 'MISSING_AUTHORED_TEXT',\n MISSING_STYLE_ADAPTER: 'MISSING_STYLE_ADAPTER',\n RESERVED_NODE_FIELD: 'RESERVED_NODE_FIELD',\n UNEXPECTED_CHILDREN: 'UNEXPECTED_CHILDREN',\n UNKNOWN_FRAME: 'UNKNOWN_FRAME',\n UNKNOWN_PRIMITIVE_TYPE: 'UNKNOWN_PRIMITIVE_TYPE',\n UNKNOWN_SURFACE: 'UNKNOWN_SURFACE',\n UNKNOWN_VIEW: 'UNKNOWN_VIEW',\n UNSUPPORTED_CHILD_PATH: 'UNSUPPORTED_CHILD_PATH',\n VIEW_INPUT_INVALID: 'VIEW_INPUT_INVALID',\n VOCABULARY_UNRESOLVED: 'VOCABULARY_UNRESOLVED',\n} as const;\n\n/** One of {@link ISOMER_ERROR_CODES}. */\nexport type IsomerErrorCode =\n (typeof ISOMER_ERROR_CODES)[keyof typeof ISOMER_ERROR_CODES];\n\n/**\n * Thrown for construction and authoring failures that are not a\n * `CompositionValidationError`.\n *\n * Identify it by `name` and `code`, never `instanceof`: the SDK ships both\n * ESM and CJS builds, so a host can hold two copies of this class and an\n * identity check would miss one.\n */\nexport class IsomerError extends Error {\n readonly code: IsomerErrorCode;\n\n constructor(code: IsomerErrorCode, message: string) {\n super(message);\n this.name = 'IsomerError';\n this.code = code;\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.formatValidationError = exports.CompositionValidationError = exports.STRUCTURED_VALUE_FORMATS = exports.quoteText = exports.oneLine = exports.nameText = exports.ALL_NAMED_COLORS = exports.mapCompositionNodes = exports.IsomerError = exports.ISOMER_ERROR_CODES = exports.someBodyNode = exports.isVisibleOnSurface = exports.createChildNodeWalker = exports.BODY_NODE_SURFACES = void 0;
10
+ var body_node_base_1 = require("./body_node_base");
11
+ Object.defineProperty(exports, "BODY_NODE_SURFACES", { enumerable: true, get: function () { return body_node_base_1.BODY_NODE_SURFACES; } });
12
+ Object.defineProperty(exports, "createChildNodeWalker", { enumerable: true, get: function () { return body_node_base_1.createChildNodeWalker; } });
13
+ Object.defineProperty(exports, "isVisibleOnSurface", { enumerable: true, get: function () { return body_node_base_1.isVisibleOnSurface; } });
14
+ Object.defineProperty(exports, "someBodyNode", { enumerable: true, get: function () { return body_node_base_1.someBodyNode; } });
15
+ var error_1 = require("./error");
16
+ Object.defineProperty(exports, "ISOMER_ERROR_CODES", { enumerable: true, get: function () { return error_1.ISOMER_ERROR_CODES; } });
17
+ Object.defineProperty(exports, "IsomerError", { enumerable: true, get: function () { return error_1.IsomerError; } });
18
+ var map_nodes_1 = require("./map_nodes");
19
+ Object.defineProperty(exports, "mapCompositionNodes", { enumerable: true, get: function () { return map_nodes_1.mapCompositionNodes; } });
20
+ var named_color_1 = require("./named_color");
21
+ Object.defineProperty(exports, "ALL_NAMED_COLORS", { enumerable: true, get: function () { return named_color_1.ALL_NAMED_COLORS; } });
22
+ var one_line_1 = require("./one_line");
23
+ Object.defineProperty(exports, "nameText", { enumerable: true, get: function () { return one_line_1.nameText; } });
24
+ Object.defineProperty(exports, "oneLine", { enumerable: true, get: function () { return one_line_1.oneLine; } });
25
+ Object.defineProperty(exports, "quoteText", { enumerable: true, get: function () { return one_line_1.quoteText; } });
26
+ var structured_value_1 = require("./structured_value");
27
+ Object.defineProperty(exports, "STRUCTURED_VALUE_FORMATS", { enumerable: true, get: function () { return structured_value_1.STRUCTURED_VALUE_FORMATS; } });
28
+ var validation_error_1 = require("./validation_error");
29
+ Object.defineProperty(exports, "CompositionValidationError", { enumerable: true, get: function () { return validation_error_1.CompositionValidationError; } });
30
+ Object.defineProperty(exports, "formatValidationError", { enumerable: true, get: function () { return validation_error_1.formatValidationError; } });
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/composition/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,mDAS0B;AAJxB,oHAAA,kBAAkB,OAAA;AAClB,uHAAA,qBAAqB,OAAA;AACrB,oHAAA,kBAAkB,OAAA;AAClB,8GAAA,YAAY,OAAA;AAGd,iCAAgF;AAAjD,2GAAA,kBAAkB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC9D,yCAAkD;AAAzC,gHAAA,mBAAmB,OAAA;AAC5B,6CAKuB;AADrB,+GAAA,gBAAgB,OAAA;AAGlB,uCAA0D;AAAjD,oGAAA,QAAQ,OAAA;AAAE,mGAAA,OAAO,OAAA;AAAE,qGAAA,SAAS,OAAA;AACrC,uDAK4B;AAD1B,4HAAA,wBAAwB,OAAA;AAE1B,uDAI4B;AAF1B,8HAAA,0BAA0B,OAAA;AAC1B,yHAAA,qBAAqB,OAAA","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nexport { type ActionEventRef } from './action_event';\nexport {\n type BodyNodeBase,\n type ChildNodeRef,\n type ChildNodeWalker,\n type SurfaceName,\n BODY_NODE_SURFACES,\n createChildNodeWalker,\n isVisibleOnSurface,\n someBodyNode,\n} from './body_node_base';\nexport { type Composition, type CompositionMeta } from './composition';\nexport { type IsomerErrorCode, ISOMER_ERROR_CODES, IsomerError } from './error';\nexport { mapCompositionNodes } from './map_nodes';\nexport {\n type NamedColor,\n type NamedColorPalette,\n type RenderTheme,\n ALL_NAMED_COLORS,\n} from './named_color';\nexport { type PrimitiveNode } from './node';\nexport { nameText, oneLine, quoteText } from './one_line';\nexport {\n type DisplayValue,\n type StructuredValue,\n type StructuredValueFormat,\n STRUCTURED_VALUE_FORMATS,\n} from './structured_value';\nexport {\n type ValidationError,\n CompositionValidationError,\n formatValidationError,\n} from './validation_error';\n"]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.mapCompositionNodes = void 0;
10
+ const error_1 = require("./error");
11
+ /** One dotted step of a child path: `field` or `field[index]`. */
12
+ const PATH_STEP = /^([A-Za-z_$][\w$]*)(?:\[(\d+)\])?$/;
13
+ const unsupportedPath = (path) => new error_1.IsomerError('UNSUPPORTED_CHILD_PATH', `mapCompositionNodes: cannot rewrite child at path "${path}"; expected dotted "field" or "field[index]" steps`);
14
+ /** `parent` with the value at `steps` replaced, every touched object and array copied. */
15
+ const withValueAt = (parent, steps, value, path) => {
16
+ const [step, ...rest] = steps;
17
+ const match = step === undefined ? null : PATH_STEP.exec(step);
18
+ if (!match || typeof parent !== 'object' || parent === null) {
19
+ throw unsupportedPath(path);
20
+ }
21
+ const field = match[1];
22
+ const record = parent;
23
+ if (match[2] === undefined) {
24
+ const next = rest.length === 0 ? value : withValueAt(record[field], rest, value, path);
25
+ return { ...record, [field]: next };
26
+ }
27
+ const index = Number(match[2]);
28
+ const current = record[field];
29
+ if (!Array.isArray(current)) {
30
+ throw unsupportedPath(path);
31
+ }
32
+ const array = [...current];
33
+ array[index] =
34
+ rest.length === 0 ? value : withValueAt(array[index], rest, value, path);
35
+ return { ...record, [field]: array };
36
+ };
37
+ /**
38
+ * Rebuilds `composition`'s body with `fn` applied to every node, including
39
+ * the nested children `walk` yields.
40
+ *
41
+ * Post-order: a container reaches `fn` after its children have been mapped,
42
+ * so `fn` sees the finished replacements in place. Build `walk` with
43
+ * {@link createChildNodeWalker} over every pack in the composition.
44
+ * A child path is the dotted `field` / `field[index]` form the SDK documents
45
+ * (`items[0].node`); any other shape throws `UNSUPPORTED_CHILD_PATH`.
46
+ * Walked without recursion, so depth is bounded by memory, not the call stack; a node nested in itself throws `CYCLIC_COMPOSITION`.
47
+ */
48
+ const mapCompositionNodes = (composition, walk, fn) => {
49
+ const mapNode = (root) => {
50
+ const open = new Set();
51
+ const stack = [];
52
+ const enter = (node) => {
53
+ if (open.has(node)) {
54
+ throw new error_1.IsomerError('CYCLIC_COMPOSITION', 'mapCompositionNodes: a node is nested in itself');
55
+ }
56
+ open.add(node);
57
+ stack.push({ node, children: walk(node), next: 0, result: node });
58
+ };
59
+ enter(root);
60
+ for (;;) {
61
+ const frame = stack[stack.length - 1];
62
+ const child = frame.children[frame.next];
63
+ if (child) {
64
+ enter(child.node);
65
+ continue;
66
+ }
67
+ stack.pop();
68
+ open.delete(frame.node);
69
+ const mapped = fn(frame.result);
70
+ const parent = stack[stack.length - 1];
71
+ if (!parent) {
72
+ return mapped;
73
+ }
74
+ const { path } = parent.children[parent.next];
75
+ parent.result = withValueAt(parent.result, path.split('.'), mapped, path);
76
+ parent.next += 1;
77
+ }
78
+ };
79
+ return {
80
+ ...composition,
81
+ body: composition.body.map((node) => mapNode(node)),
82
+ };
83
+ };
84
+ exports.mapCompositionNodes = mapCompositionNodes;
85
+ //# sourceMappingURL=map_nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map_nodes.js","sourceRoot":"","sources":["../../../src/composition/map_nodes.ts"],"names":[],"mappings":"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","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ChildNodeRef, ChildNodeWalker } from './body_node_base';\nimport type { Composition } from './composition';\nimport { IsomerError } from './error';\nimport type { PrimitiveNode } from './node';\n\n/** One dotted step of a child path: `field` or `field[index]`. */\nconst PATH_STEP = /^([A-Za-z_$][\\w$]*)(?:\\[(\\d+)\\])?$/;\n\nconst unsupportedPath = (path: string): IsomerError =>\n new IsomerError(\n 'UNSUPPORTED_CHILD_PATH',\n `mapCompositionNodes: cannot rewrite child at path \"${path}\"; expected dotted \"field\" or \"field[index]\" steps`\n );\n\n/** `parent` with the value at `steps` replaced, every touched object and array copied. */\nconst withValueAt = (\n parent: unknown,\n steps: readonly string[],\n value: unknown,\n path: string\n): unknown => {\n const [step, ...rest] = steps;\n const match = step === undefined ? null : PATH_STEP.exec(step);\n if (!match || typeof parent !== 'object' || parent === null) {\n throw unsupportedPath(path);\n }\n const field = match[1] as string;\n const record = parent as Record<string, unknown>;\n if (match[2] === undefined) {\n const next =\n rest.length === 0 ? value : withValueAt(record[field], rest, value, path);\n return { ...record, [field]: next };\n }\n const index = Number(match[2]);\n const current = record[field];\n if (!Array.isArray(current)) {\n throw unsupportedPath(path);\n }\n const array = [...(current as unknown[])];\n array[index] =\n rest.length === 0 ? value : withValueAt(array[index], rest, value, path);\n return { ...record, [field]: array };\n};\n\n/** A node being mapped: its children, how many are done, and its copy so far. */\ninterface Frame {\n node: PrimitiveNode;\n children: ChildNodeRef[];\n next: number;\n result: PrimitiveNode;\n}\n\n/**\n * Rebuilds `composition`'s body with `fn` applied to every node, including\n * the nested children `walk` yields.\n *\n * Post-order: a container reaches `fn` after its children have been mapped,\n * so `fn` sees the finished replacements in place. Build `walk` with\n * {@link createChildNodeWalker} over every pack in the composition.\n * A child path is the dotted `field` / `field[index]` form the SDK documents\n * (`items[0].node`); any other shape throws `UNSUPPORTED_CHILD_PATH`.\n * Walked without recursion, so depth is bounded by memory, not the call stack; a node nested in itself throws `CYCLIC_COMPOSITION`.\n */\nexport const mapCompositionNodes = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n composition: Composition<TNode>,\n walk: ChildNodeWalker,\n fn: (node: PrimitiveNode) => PrimitiveNode\n): Composition<TNode> => {\n const mapNode = (root: PrimitiveNode): PrimitiveNode => {\n const open = new Set<PrimitiveNode>();\n const stack: Frame[] = [];\n const enter = (node: PrimitiveNode) => {\n if (open.has(node)) {\n throw new IsomerError(\n 'CYCLIC_COMPOSITION',\n 'mapCompositionNodes: a node is nested in itself'\n );\n }\n open.add(node);\n stack.push({ node, children: walk(node), next: 0, result: node });\n };\n enter(root);\n for (;;) {\n const frame = stack[stack.length - 1]!;\n const child = frame.children[frame.next];\n if (child) {\n enter(child.node as PrimitiveNode);\n continue;\n }\n stack.pop();\n open.delete(frame.node);\n const mapped = fn(frame.result);\n const parent = stack[stack.length - 1];\n if (!parent) {\n return mapped;\n }\n const { path } = parent.children[parent.next]!;\n parent.result = withValueAt(\n parent.result,\n path.split('.'),\n mapped,\n path\n ) as PrimitiveNode;\n parent.next += 1;\n }\n };\n return {\n ...composition,\n body: composition.body.map((node) => mapNode(node) as TNode),\n };\n};\n"]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ALL_NAMED_COLORS = void 0;
10
+ /** Every {@link NamedColor}, and the source `namedColorSchema` derives from. */
11
+ exports.ALL_NAMED_COLORS = [
12
+ 'neutral',
13
+ 'primary',
14
+ 'accent',
15
+ 'success',
16
+ 'warning',
17
+ 'risk',
18
+ 'danger',
19
+ ];
20
+ //# sourceMappingURL=named_color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named_color.js","sourceRoot":"","sources":["../../../src/composition/named_color.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAMH,gFAAgF;AACnE,QAAA,gBAAgB,GAA0B;IACrD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,MAAM;IACN,QAAQ;CACT,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/** Portable color names shared by primitive packs and renderers. An exact subset of EUI's `NamedColor`. */\nexport type NamedColor =\n 'neutral' | 'primary' | 'accent' | 'success' | 'warning' | 'risk' | 'danger';\n\n/** Every {@link NamedColor}, and the source `namedColorSchema` derives from. */\nexport const ALL_NAMED_COLORS: readonly NamedColor[] = [\n 'neutral',\n 'primary',\n 'accent',\n 'success',\n 'warning',\n 'risk',\n 'danger',\n];\n\n/** Light/dark preference. `auto` resolves light wherever media queries are unavailable. */\nexport type RenderTheme = 'auto' | 'light' | 'dark';\n\n/** A pack's colors by name. Partial: an unmapped name falls back to the renderer's default. */\nexport type NamedColorPalette = Partial<Record<NamedColor, string>>;\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/composition/node.ts"],"names":[],"mappings":";AAAA;;;;;GAKG","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { BodyNodeBase } from './body_node_base';\n\n/**\n * One node in a `Composition`'s body, erased to its discriminator.\n *\n * A pack narrows `type` to its own literal union; the SDK holds this form\n * because a heterogeneous inventory has no single node type to name.\n */\nexport interface PrimitiveNode extends BodyNodeBase {\n type: string;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.nameText = exports.quoteText = exports.oneLine = void 0;
10
+ const LINE_TERMINATOR_RE = /[\r\n\u2028\u2029]/;
11
+ /** `text` on one line: each run of whitespace holding a line terminator becomes one space, and other whitespace stays as is. */
12
+ const oneLine = (text) => text.replace(/\s+/g, (run) => (LINE_TERMINATOR_RE.test(run) ? ' ' : run));
13
+ exports.oneLine = oneLine;
14
+ /** `text` as a JSON string on one line: `JSON.stringify` leaves U+2028 and U+2029 raw. */
15
+ const quoteText = (text) => JSON.stringify(text)
16
+ .replace(/\u2028/g, '\\u2028')
17
+ .replace(/\u2029/g, '\\u2029');
18
+ exports.quoteText = quoteText;
19
+ const PLAIN_NAME = /^[\w$-]+$/;
20
+ /** A name for a one-line message: as it is when plain, else as {@link quoteText} quotes it. */
21
+ const nameText = (name) => PLAIN_NAME.test(name) ? name : (0, exports.quoteText)(name);
22
+ exports.nameText = nameText;
23
+ //# sourceMappingURL=one_line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one_line.js","sourceRoot":"","sources":["../../../src/composition/one_line.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,gIAAgI;AACzH,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAC9C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAD/D,QAAA,OAAO,WACwD;AAE5E,0FAA0F;AACnF,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE,CAChD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KACjB,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;KAC7B,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAHtB,QAAA,SAAS,aAGa;AAEnC,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B,+FAA+F;AACxF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CAC/C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAC;AADpC,QAAA,QAAQ,YAC4B","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nconst LINE_TERMINATOR_RE = /[\\r\\n\\u2028\\u2029]/;\n\n/** `text` on one line: each run of whitespace holding a line terminator becomes one space, and other whitespace stays as is. */\nexport const oneLine = (text: string): string =>\n text.replace(/\\s+/g, (run) => (LINE_TERMINATOR_RE.test(run) ? ' ' : run));\n\n/** `text` as a JSON string on one line: `JSON.stringify` leaves U+2028 and U+2029 raw. */\nexport const quoteText = (text: string): string =>\n JSON.stringify(text)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n\nconst PLAIN_NAME = /^[\\w$-]+$/;\n\n/** A name for a one-line message: as it is when plain, else as {@link quoteText} quotes it. */\nexport const nameText = (name: string): string =>\n PLAIN_NAME.test(name) ? name : quoteText(name);\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.STRUCTURED_VALUE_FORMATS = void 0;
10
+ /** Format hints a {@link StructuredValue} may carry. */
11
+ exports.STRUCTURED_VALUE_FORMATS = [
12
+ 'number',
13
+ 'compact',
14
+ 'percent',
15
+ 'currency',
16
+ 'bytes',
17
+ 'duration',
18
+ 'date',
19
+ 'relativeTime',
20
+ ];
21
+ //# sourceMappingURL=structured_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structured_value.js","sourceRoot":"","sources":["../../../src/composition/structured_value.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wDAAwD;AAC3C,QAAA,wBAAwB,GAAG;IACtC,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;CACN,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/** Format hints a {@link StructuredValue} may carry. */\nexport const STRUCTURED_VALUE_FORMATS = [\n 'number',\n 'compact',\n 'percent',\n 'currency',\n 'bytes',\n 'duration',\n 'date',\n 'relativeTime',\n] as const;\n\n/** One of {@link STRUCTURED_VALUE_FORMATS}. */\nexport type StructuredValueFormat = (typeof STRUCTURED_VALUE_FORMATS)[number];\n\n/**\n * A raw quantity plus a format hint, so every surface renders the same string.\n *\n * Formatting happens once, in `formatDisplayValue`, rather than per renderer —\n * otherwise the text and Slack surfaces drift on rounding.\n */\nexport interface StructuredValue {\n /** Unformatted, in base units — a `percent` of `0.42` renders as 42%. */\n raw: number | string;\n /** How to render `raw`. Absent passes a string through and gives a number default formatting. */\n format?: StructuredValueFormat;\n /**\n * Fraction digits for numeric formats. `number`, `percent`, and `currency`\n * pad to it; omitted, `number` and `percent` keep at most two and `currency`\n * two. `compact` and `bytes` drop trailing zeros and keep one when omitted.\n */\n precision?: number;\n /** Three-letter currency code for `currency`; defaults to USD. */\n currency?: string;\n}\n\n/** A value-bearing field: preformatted prose, or a {@link StructuredValue} to format. */\nexport type DisplayValue = string | StructuredValue;\n"]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CompositionValidationError = exports.formatValidationError = void 0;
10
+ const error_1 = require("./error");
11
+ const one_line_1 = require("./one_line");
12
+ /** `<path> (in <nodeType>) <message>`, or the message alone for a root finding. */
13
+ const formatValidationError = ({ path, message, nodeType, }) => {
14
+ if (!path) {
15
+ return message;
16
+ }
17
+ return nodeType === undefined
18
+ ? `${path} ${message}`
19
+ : `${path} (in ${(0, one_line_1.nameText)(nodeType)}) ${message}`;
20
+ };
21
+ exports.formatValidationError = formatValidationError;
22
+ /**
23
+ * Thrown when a `Composition` fails validation, carrying every finding
24
+ * rather than only the first.
25
+ *
26
+ * Identify it by `name`, `code`, and `errors`, never `instanceof`: the SDK
27
+ * ships both ESM and CJS builds, so a host can hold two copies of this class
28
+ * and an identity check would miss one.
29
+ */
30
+ class CompositionValidationError extends Error {
31
+ code = error_1.ISOMER_ERROR_CODES.COMPOSITION_INVALID;
32
+ errors;
33
+ constructor(errors) {
34
+ super(`Invalid Composition:\n ${errors.map(exports.formatValidationError).join('\n ') || '(no detail)'}`);
35
+ this.name = 'CompositionValidationError';
36
+ this.errors = errors;
37
+ }
38
+ }
39
+ exports.CompositionValidationError = CompositionValidationError;
40
+ //# sourceMappingURL=validation_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation_error.js","sourceRoot":"","sources":["../../../src/composition/validation_error.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAmE;AACnE,yCAAsC;AAmBtC,mFAAmF;AAC5E,MAAM,qBAAqB,GAAG,CAAC,EACpC,IAAI,EACJ,OAAO,EACP,QAAQ,GACQ,EAAU,EAAE;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE;QACtB,CAAC,CAAC,GAAG,IAAI,QAAQ,IAAA,mBAAQ,EAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC;AAEF;;;;;;;GAOG;AACH,MAAa,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAG,0BAAkB,CAAC,mBAAmB,CAAC;IAC9C,MAAM,CAAoB;IAEnC,YAAY,MAAyB;QACnC,KAAK,CACH,2BACE,MAAM,CAAC,GAAG,CAAC,6BAAqB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,aACpD,EAAE,CACH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAbD,gEAaC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport { ISOMER_ERROR_CODES, type IsomerErrorCode } from './error';\nimport { nameText } from './one_line';\n\n/**\n * One fatal validation finding.\n *\n * `path` locates the offending value (`body[3].items[0].label`) and is empty\n * for a finding about the document as a whole. `message` is a predicate\n * (`is required`, `must be one of: a, b`) so the two read as one sentence\n * through {@link formatValidationError}.\n */\nexport interface ValidationError {\n path: string;\n message: string;\n /** The `type` of the innermost primitive node `path` lands in, when there is one. */\n nodeType?: string;\n /** Set only on a refusal from `checkInputBudget`: `INPUT_OVER_BUDGET` or `INPUT_NOT_PLAIN_DATA`. */\n code?: IsomerErrorCode;\n}\n\n/** `<path> (in <nodeType>) <message>`, or the message alone for a root finding. */\nexport const formatValidationError = ({\n path,\n message,\n nodeType,\n}: ValidationError): string => {\n if (!path) {\n return message;\n }\n return nodeType === undefined\n ? `${path} ${message}`\n : `${path} (in ${nameText(nodeType)}) ${message}`;\n};\n\n/**\n * Thrown when a `Composition` fails validation, carrying every finding\n * rather than only the first.\n *\n * Identify it by `name`, `code`, and `errors`, never `instanceof`: the SDK\n * ships both ESM and CJS builds, so a host can hold two copies of this class\n * and an identity check would miss one.\n */\nexport class CompositionValidationError extends Error {\n readonly code = ISOMER_ERROR_CODES.COMPOSITION_INVALID;\n readonly errors: ValidationError[];\n\n constructor(errors: ValidationError[]) {\n super(\n `Invalid Composition:\\n ${\n errors.map(formatValidationError).join('\\n ') || '(no detail)'\n }`\n );\n this.name = 'CompositionValidationError';\n this.errors = errors;\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.bindFrame = void 0;
10
+ /**
11
+ * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the
12
+ * palette per render and composing the generic body walk with the frame's own
13
+ * surround.
14
+ */
15
+ const bindFrame = (frame) => {
16
+ const themeFor = (mode) => mode === 'dark' ? frame.theme.dark : frame.theme.light;
17
+ return {
18
+ defaultWidth: frame.defaultWidth,
19
+ sizesFromNodeHeights: frame.sizesFromNodeHeights ?? true,
20
+ estimateHeight: (composition, dispatcher) => frame.estimateHeight(composition, dispatcher),
21
+ validateBody: (body) => frame.validateBody?.(body) ?? [],
22
+ resolveTheme: (mode) => themeFor(mode),
23
+ render: (composition, viewport, dispatcher) => {
24
+ const theme = themeFor(viewport.mode);
25
+ const { title, subtitle, theme: mode } = composition;
26
+ return frame.wrap({ title, subtitle, theme: mode }, composition.body.map((node, index) => dispatcher.renderSvg(node, `body-${index}`)), { ...viewport, theme });
27
+ },
28
+ renderNode: (node, dispatcher) => dispatcher.renderSvg(node, node.type),
29
+ };
30
+ };
31
+ exports.bindFrame = bindFrame;
32
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../../src/define/frame.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAyLH;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAS,KAAoB,EAAc,EAAE;IACpE,MAAM,QAAQ,GAAG,CAAC,IAA6B,EAAU,EAAE,CACzD,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;IACzD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,IAAI;QACxD,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAC1C,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC;QAC/C,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;QACxD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;YAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;YACrD,OAAO,KAAK,CAAC,IAAI,CACf,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAChC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,KAAK,EAAE,CAAC,CAC5C,EACD,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CACvB,CAAC;QACJ,CAAC;QACD,UAAU,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;KACxE,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// The frame an `svg` render is drawn inside, and the geometry that sizes it.\n// Frame is a runtime input, not a pack asset: vocabulary is additive, the\n// document is exclusive.\n\nimport type { ReactNode } from 'react';\n\nimport type { RenderTheme } from '../composition/named_color';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A frame's palette, per mode. An image has no media queries, so it must\n * commit to one; `auto` resolves light.\n */\nexport interface ThemePair<TTheme> {\n light: TTheme;\n dark: TTheme;\n}\n\n/**\n * Geometry and resolved theme a frame draws within.\n *\n * Named for the viewport rather than the frame because {@link Frame.wrap}\n * draws *a* frame within it; the two would otherwise read as the same thing.\n */\nexport interface FrameViewport<TTheme> {\n width: number;\n height: number;\n /** Resolved from {@link Frame.theme} for `mode`. */\n theme: TTheme;\n /** What the caller asked for, before resolution. `undefined` and `auto` both resolve light. */\n mode: RenderTheme | undefined;\n}\n\n/**\n * The two dispatcher methods a frame needs.\n *\n * The render context the nodes are drawn with is bound by the caller rather\n * than passed here: it carries the class-name resolution that pairs with the\n * stylesheet emitted alongside the frame's output, which is the surface's\n * concern and not the document's. Generic in `TNode` so a helper can be\n * written against a narrowed node union while the runtime holds the erased form.\n */\nexport interface FrameDispatcher<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Draws one node on the `svg` surface. `key` must be unique among its siblings. */\n renderSvg(node: TNode, key: string): ReactNode;\n /** The node's height in pixels; `0` when it is hidden from `svg` or its primitive declares no `metrics.svgHeight`. */\n estimateSvgHeight(node: TNode): number;\n}\n\n/**\n * What {@link Frame.wrap} is told about the composition it draws around.\n *\n * The body is withheld, and {@link bindFrame} copies only these fields into a\n * fresh value, so the surround cannot branch on a pack's node types.\n */\nexport interface FrameHeader {\n title?: string | undefined;\n subtitle?: string | undefined;\n /** The caller's preference, not a resolved palette. Use {@link FrameViewport.theme} to draw. */\n theme?: RenderTheme | undefined;\n}\n\n/** {@link FrameHeader} plus the body, for the sizing and validation hooks. */\nexport interface FrameComposition extends FrameHeader {\n /** Raw nodes, for measuring and checking only. {@link FrameBody} is what gets drawn. */\n body: PrimitiveNode[];\n}\n\n/**\n * Body nodes already rendered to elements, ready to be surrounded.\n *\n * Distinct from `Composition.body`, which is the raw {@link PrimitiveNode}\n * array a frame never sees.\n */\nexport type FrameBody = readonly ReactNode[];\n\n/**\n * A document an `svg` render can produce: its geometry, the surround it draws\n * around the body, and whatever it requires of a composition it is asked to\n * draw.\n *\n * A host registers frames with the runtime and picks one per render. That is\n * what lets one runtime serve a 760px card, a 1920x1080 slide, and a\n * host-branded variant of either from the same vocabulary — and what keeps a\n * vocabulary pack additive, since nothing about a primitive decides the frame.\n * A frame is named by the key a host registers it under, not by a field it\n * carries.\n */\nexport interface Frame<TTheme> {\n /** Width used when the caller passes none. */\n defaultWidth: number;\n /**\n * Whether {@link Frame.estimateHeight} sums per-node heights, and so\n * under-sizes the frame for a node whose primitive declares no\n * `metrics.svgHeight` — `dispatcher.estimateSvgHeight` returns `0` for those.\n *\n * Defaults to `true`, because the gap is silent and a frame that measures\n * nodes is the normal case. A fixed-size frame sets `false` once and stops\n * the missing `svgHeight` warning reporting a metric nothing reads.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * Palette per mode. Frame and palette vary independently — a branded card is\n * this geometry with a host's colors — so a host overrides one by spreading\n * this value rather than rebuilding anything.\n */\n theme: ThemePair<TTheme>;\n /**\n * Height for this body when the caller passes none, in the geometry this\n * document defines. See {@link Frame.sizesFromNodeHeights} for what it may\n * assume of the nodes.\n */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /**\n * What this document requires of a body. A slide document's\n * exactly-one-`slideFrame` rule is the example.\n *\n * Returned rather than thrown so a caller can decide what to do with it, but\n * note where it is *not* checked: composition validation is frame-agnostic,\n * and has to be, because the same composition can be valid in one frame and\n * not another. Only the `svg` surface consults this, on the frame a render\n * actually names, and raises before drawing. A host that wants the answer\n * earlier asks the frame directly.\n */\n validateBody?(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Draws the surround around the already-rendered body nodes, including a\n * title header if this document wants one.\n *\n * Takes the nodes as an array rather than a single `ReactNode` so a frame\n * that draws no surround can return its one root element — image layout\n * starts from a single element, and an array or a fragment is not one.\n *\n * Declared property-style, so it is checked contravariantly in `TTheme` under\n * `strictFunctionTypes`. A method signature is bivariant, which would admit a\n * frame needing a richer theme into a slot typed for a narrower one, where it\n * would read a token nothing supplies.\n */\n wrap: (\n header: FrameHeader,\n body: FrameBody,\n viewport: FrameViewport<TTheme>\n ) => ReactNode;\n}\n\n/**\n * A {@link Frame} as the runtime stores it, with its theme resolved away.\n *\n * The erasure is a closure rather than a type parameter because the runtime\n * dispatches nodes through one inventory keyed by node type, which has no\n * single theme to name. A runtime's frames are homogeneous in `TTheme`, so the\n * palette is known where it is resolved and only the resolved result is stored.\n */\nexport interface BoundFrame {\n readonly defaultWidth: number;\n /** See {@link Frame.sizesFromNodeHeights}; defaulted at binding. */\n readonly sizesFromNodeHeights: boolean;\n /** See {@link Frame.estimateHeight}. */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /** See {@link Frame.validateBody}; empty when this frame states no rule. */\n validateBody(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Resolves {@link Frame.theme} for `mode`, erased to `unknown` like the rest\n * of this type. Lets a caller hand the palette to a primitive's `env.theme`\n * without itself knowing `TTheme`.\n */\n resolveTheme(mode: RenderTheme | undefined): unknown;\n /** Renders the body and its surround at `viewport`'s geometry. */\n render(\n composition: FrameComposition,\n viewport: { width: number; height: number; mode: RenderTheme | undefined },\n dispatcher: FrameDispatcher\n ): ReactNode;\n /** One node, no surround. */\n renderNode(node: PrimitiveNode, dispatcher: FrameDispatcher): ReactNode;\n}\n\n/**\n * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the\n * palette per render and composing the generic body walk with the frame's own\n * surround.\n */\nexport const bindFrame = <TTheme>(frame: Frame<TTheme>): BoundFrame => {\n const themeFor = (mode: RenderTheme | undefined): TTheme =>\n mode === 'dark' ? frame.theme.dark : frame.theme.light;\n return {\n defaultWidth: frame.defaultWidth,\n sizesFromNodeHeights: frame.sizesFromNodeHeights ?? true,\n estimateHeight: (composition, dispatcher) =>\n frame.estimateHeight(composition, dispatcher),\n validateBody: (body) => frame.validateBody?.(body) ?? [],\n resolveTheme: (mode) => themeFor(mode),\n render: (composition, viewport, dispatcher) => {\n const theme = themeFor(viewport.mode);\n const { title, subtitle, theme: mode } = composition;\n return frame.wrap(\n { title, subtitle, theme: mode },\n composition.body.map((node, index) =>\n dispatcher.renderSvg(node, `body-${index}`)\n ),\n { ...viewport, theme }\n );\n },\n renderNode: (node, dispatcher) => dispatcher.renderSvg(node, node.type),\n };\n};\n"]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.z = exports.requiredString = exports.formatZodIssues = exports.declaredFieldsNote = exports.validateWithSchema = exports.unresolvedBodyNodeSchema = exports.definePrimitiveFor = exports.definePrimitive = exports.bodyNodeSurfacesSchema = exports.bodyNodeIdSchema = exports.bindFrame = void 0;
10
+ var frame_1 = require("./frame");
11
+ Object.defineProperty(exports, "bindFrame", { enumerable: true, get: function () { return frame_1.bindFrame; } });
12
+ var primitive_module_1 = require("./primitive_module");
13
+ Object.defineProperty(exports, "bodyNodeIdSchema", { enumerable: true, get: function () { return primitive_module_1.bodyNodeIdSchema; } });
14
+ Object.defineProperty(exports, "bodyNodeSurfacesSchema", { enumerable: true, get: function () { return primitive_module_1.bodyNodeSurfacesSchema; } });
15
+ Object.defineProperty(exports, "definePrimitive", { enumerable: true, get: function () { return primitive_module_1.definePrimitive; } });
16
+ Object.defineProperty(exports, "definePrimitiveFor", { enumerable: true, get: function () { return primitive_module_1.definePrimitiveFor; } });
17
+ Object.defineProperty(exports, "unresolvedBodyNodeSchema", { enumerable: true, get: function () { return primitive_module_1.unresolvedBodyNodeSchema; } });
18
+ Object.defineProperty(exports, "validateWithSchema", { enumerable: true, get: function () { return primitive_module_1.validateWithSchema; } });
19
+ var zod_format_1 = require("./zod_format");
20
+ Object.defineProperty(exports, "declaredFieldsNote", { enumerable: true, get: function () { return zod_format_1.declaredFieldsNote; } });
21
+ Object.defineProperty(exports, "formatZodIssues", { enumerable: true, get: function () { return zod_format_1.formatZodIssues; } });
22
+ var zod_helpers_1 = require("./zod_helpers");
23
+ Object.defineProperty(exports, "requiredString", { enumerable: true, get: function () { return zod_helpers_1.requiredString; } });
24
+ Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_helpers_1.z; } });
25
+ //# sourceMappingURL=index.js.map