@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,825 @@
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.gfmToSlackBlocks = exports.gfmToSlackMrkdwn = exports.formatHeaderText = exports.cutSlackValue = exports.clampMrkdwn = exports.clampSlackText = exports.link = exports.slackLinkUrl = exports.isAbsoluteHttpUrl = exports.codeBlock = exports.code = exports.strike = exports.italic = exports.bold = exports.escapeMrkdwn = void 0;
10
+ // Slack mrkdwn helpers.
11
+ //
12
+ // Slack uses a flavour of Markdown called "mrkdwn" that differs from CommonMark
13
+ // in subtle ways: links are `<url|label>`, code uses single backticks (or
14
+ // fenced ```` ``` ```` blocks), and `&`, `<`, `>` must be HTML-escaped inside
15
+ // any text element. These helpers centralize the escaping so primitive
16
+ // renderers cannot accidentally emit a literal `<https://...>` that Slack
17
+ // would parse as auto-link with no label.
18
+ //
19
+ // See https://api.slack.com/reference/surfaces/formatting
20
+ const url_1 = require("../../validate/url");
21
+ const blocks_1 = require("./blocks");
22
+ const MRKDWN_ESCAPES = {
23
+ '&': '&amp;',
24
+ '<': '&lt;',
25
+ '>': '&gt;',
26
+ };
27
+ /**
28
+ * Escapes the three characters Slack treats as HTML in `mrkdwn` text.
29
+ *
30
+ * The formatting markers (`*`, `_`, `~`, `` ` ``) are left intact so callers
31
+ * can compose markdown with them. Wrap text in {@link code} when literal
32
+ * asterisks are needed.
33
+ */
34
+ const escapeMrkdwn = (value) => value.replace(/[&<>]/g, (match) => MRKDWN_ESCAPES[match] ?? match);
35
+ exports.escapeMrkdwn = escapeMrkdwn;
36
+ /** `text` escaped and wrapped in mrkdwn bold markers. */
37
+ const bold = (text) => `*${(0, exports.escapeMrkdwn)(text)}*`;
38
+ exports.bold = bold;
39
+ /** `text` escaped and wrapped in mrkdwn italic markers. */
40
+ const italic = (text) => `_${(0, exports.escapeMrkdwn)(text)}_`;
41
+ exports.italic = italic;
42
+ /** `text` escaped and wrapped in mrkdwn strikethrough markers. */
43
+ const strike = (text) => `~${(0, exports.escapeMrkdwn)(text)}~`;
44
+ exports.strike = strike;
45
+ /**
46
+ * Inline code span. Contents are not mrkdwn-escaped, since `<` and friends are
47
+ * literal inside a code span; only embedded backticks are demoted, to a
48
+ * modifier letter that cannot close the span.
49
+ */
50
+ const code = (text) => `\`${text.replace(/`/g, '\u02CB')}\``;
51
+ exports.code = code;
52
+ /**
53
+ * Fenced code block. Slack honours the triple-backtick fence but not a language
54
+ * hint. Embedded triple-backticks are demoted with a zero-width joiner so they
55
+ * cannot terminate the block early.
56
+ */
57
+ const codeBlock = (text) => `\`\`\`\n${text.replace(/```/g, '``\u200d`')}\n\`\`\``;
58
+ exports.codeBlock = codeBlock;
59
+ const URL_PARTS_RE = /^([a-z][a-z0-9+.-]*:(?:\/\/[^/?#]*)?)(.*)$/is;
60
+ // Letter, digit, and hyphen labels, with an optional DNS root dot.
61
+ const DNS_NAME_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*\.?$/i;
62
+ const IPV6_HOST_RE = /^\[[0-9a-f:.]+\]$/i;
63
+ const MALFORMED_ESCAPE_RE = /%(?![0-9a-f]{2})/i;
64
+ // `url` parsed, when its escapes are well formed and `URL` prints it as
65
+ // written up to the case of its scheme and authority and a `/` for an empty
66
+ // path.
67
+ const parsedAsWritten = (url) => {
68
+ if (MALFORMED_ESCAPE_RE.test(url)) {
69
+ return null;
70
+ }
71
+ let parsed;
72
+ try {
73
+ parsed = new URL(url);
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ const [, prefix, rest] = URL_PARTS_RE.exec(url) ?? [];
79
+ const [, printedPrefix, printedRest] = URL_PARTS_RE.exec(parsed.href) ?? [];
80
+ return prefix !== undefined &&
81
+ prefix.toLowerCase() === printedPrefix?.toLowerCase() &&
82
+ (printedRest === rest || printedRest === `/${rest}`)
83
+ ? parsed
84
+ : null;
85
+ };
86
+ /**
87
+ * Whether `url` is an `http:` or `https:` URL with a DNS or IPv6 host that
88
+ * `URL` prints as written, so nothing it repairs or encodes, such as a
89
+ * backslash, whitespace, or non-ASCII, passes.
90
+ */
91
+ const isAbsoluteHttpUrl = (url) => {
92
+ const parsed = parsedAsWritten(url);
93
+ return ((parsed?.protocol === 'http:' || parsed?.protocol === 'https:') &&
94
+ (DNS_NAME_RE.test(parsed.hostname) || IPV6_HOST_RE.test(parsed.hostname)));
95
+ };
96
+ exports.isAbsoluteHttpUrl = isAbsoluteHttpUrl;
97
+ // RFC 5322 dot-atom text, less `/`, `?`, `#`, and `%`.
98
+ const LOCAL_PART_RE = /^[a-z0-9!$&'*+=^_`{|}~-]+(?:\.[a-z0-9!$&'*+=^_`{|}~-]+)*$/i;
99
+ const isMailbox = (recipient) => {
100
+ const at = recipient.lastIndexOf('@');
101
+ return (at > 0 &&
102
+ LOCAL_PART_RE.test(recipient.slice(0, at)) &&
103
+ DNS_NAME_RE.test(recipient.slice(at + 1)));
104
+ };
105
+ const decoded = (value) => {
106
+ try {
107
+ return decodeURIComponent(value);
108
+ }
109
+ catch {
110
+ return null;
111
+ }
112
+ };
113
+ // Every comma-separated recipient before the query or fragment is a mailbox.
114
+ const isMailtoUrl = (url) => {
115
+ const [, recipients] = /^mailto:([^?#]*)/i.exec(url) ?? [];
116
+ return (recipients !== undefined &&
117
+ parsedAsWritten(url) !== null &&
118
+ recipients
119
+ .split(',')
120
+ .every((recipient) => isMailbox(decoded(recipient) ?? '')));
121
+ };
122
+ /**
123
+ * `href` when {@link sanitizeNavigationHref} passes it and it is an `http:` or
124
+ * `https:` URL with a host, or a `mailto:` of well-formed mailboxes; `null`
125
+ * otherwise. Slack has no page to resolve a relative URL against.
126
+ */
127
+ const slackLinkUrl = (href) => {
128
+ const url = (0, url_1.sanitizeNavigationHref)(href);
129
+ if (url === null) {
130
+ return null;
131
+ }
132
+ return (0, exports.isAbsoluteHttpUrl)(url) || isMailtoUrl(url) ? url : null;
133
+ };
134
+ exports.slackLinkUrl = slackLinkUrl;
135
+ /**
136
+ * Slack mrkdwn link, `<url|label>`, or a bare `<url>` when `label` is omitted.
137
+ *
138
+ * URL and label are both escaped so `&` and `>` cannot break Slack's link
139
+ * parser, and a `|` in the URL is percent-encoded so it cannot end the URL
140
+ * early. A URL {@link slackLinkUrl} rejects degrades to plain escaped text
141
+ * with no link.
142
+ */
143
+ const link = (url, label) => {
144
+ const sanitized = (0, exports.slackLinkUrl)(url);
145
+ if (!sanitized) {
146
+ return (0, exports.escapeMrkdwn)(label ?? url);
147
+ }
148
+ const safeUrl = (0, exports.escapeMrkdwn)(sanitized).replaceAll('|', '%7C');
149
+ if (!label) {
150
+ return `<${safeUrl}>`;
151
+ }
152
+ return `<${safeUrl}|${(0, exports.escapeMrkdwn)(label)}>`;
153
+ };
154
+ exports.link = link;
155
+ /**
156
+ * Truncates `value` to `max` UTF-16 code units at a grapheme boundary,
157
+ * appending an ellipsis when it had to cut. Pass a `SLACK_LIMITS` constant as
158
+ * the budget.
159
+ */
160
+ const clampSlackText = (value, max) => {
161
+ if (value.length <= max) {
162
+ return value;
163
+ }
164
+ const budget = max <= 1 ? max : max - 1;
165
+ let end = 0;
166
+ for (const { index, segment } of new Intl.Segmenter(undefined, {
167
+ granularity: 'grapheme',
168
+ }).segment(value)) {
169
+ if (index + segment.length > budget) {
170
+ break;
171
+ }
172
+ end = index + segment.length;
173
+ }
174
+ const head = value.slice(0, end);
175
+ return max <= 1 ? head : `${head.trimEnd()}…`;
176
+ };
177
+ exports.clampSlackText = clampSlackText;
178
+ // A `<…>` link or mention and an entity, each matched where it starts.
179
+ const LINK_TOKEN_RE = /<[^<>\n]*>/y;
180
+ const ENTITY_TOKEN_RE = /&(?:amp|lt|gt);/y;
181
+ // The end of the token `re` matches at `index`, or `undefined`.
182
+ const tokenEnd = (value, re, index) => {
183
+ re.lastIndex = index;
184
+ return re.test(value) ? re.lastIndex : undefined;
185
+ };
186
+ /**
187
+ * {@link clampSlackText} for `mrkdwn`: never cuts inside a `<…>` link or
188
+ * mention or an entity. Formatting marks are left as they fall; Slack prints an
189
+ * unclosed one as written.
190
+ */
191
+ const clampMrkdwn = (value, max) => {
192
+ const clamped = (0, exports.clampSlackText)(value, max);
193
+ if (clamped === value || max <= 1) {
194
+ return clamped;
195
+ }
196
+ // Entity first: a link holds no `<` of its own, so stepping back to its
197
+ // start cannot land inside an entity, while the reverse could.
198
+ let cut = clamped.length - 1;
199
+ const entity = value.lastIndexOf('&', cut - 1);
200
+ if (entity !== -1 && (tokenEnd(value, ENTITY_TOKEN_RE, entity) ?? 0) > cut) {
201
+ cut = entity;
202
+ }
203
+ const link = value.lastIndexOf('<', cut - 1);
204
+ if (link !== -1 && (tokenEnd(value, LINK_TOKEN_RE, link) ?? 0) > cut) {
205
+ cut = link;
206
+ }
207
+ return `${value.slice(0, cut).trimEnd()}…`;
208
+ };
209
+ exports.clampMrkdwn = clampMrkdwn;
210
+ /**
211
+ * `value` cut to `max` UTF-16 code units, never through a surrogate pair. For
212
+ * opaque values a host reads back, which an ellipsis would change.
213
+ */
214
+ const cutSlackValue = (value, max) => {
215
+ const cut = value.slice(0, max);
216
+ return /[\ud800-\udbff]$/.test(cut) ? cut.slice(0, -1) : cut;
217
+ };
218
+ exports.cutSlackValue = cutSlackValue;
219
+ /**
220
+ * Collapses whitespace and clamps to `SLACK_LIMITS.headerTextChars`. Header
221
+ * text is `plain_text`, so no markdown survives — do not pre-format it.
222
+ */
223
+ const formatHeaderText = (value) => (0, exports.clampSlackText)(value.replace(/\s+/g, ' ').trim(), blocks_1.SLACK_LIMITS.headerTextChars);
224
+ exports.formatHeaderText = formatHeaderText;
225
+ const ASCII_PUNCTUATION_RE = /[!-/:-@[-`{-~]/;
226
+ const NUMERIC_REFERENCE_RE = /&#(?:[xX]([0-9a-fA-F]{1,6})|(\d{1,7}));/y;
227
+ // micromark's rule: controls other than tab and line breaks, surrogates,
228
+ // noncharacters, and out-of-range values become U+FFFD.
229
+ const decodeCodePoint = (codePoint) => codePoint < 9 ||
230
+ codePoint === 11 ||
231
+ (codePoint > 13 && codePoint < 32) ||
232
+ (codePoint > 126 && codePoint < 160) ||
233
+ (codePoint > 55_295 && codePoint < 57_344) ||
234
+ (codePoint > 64_975 && codePoint < 65_008) ||
235
+ codePoint % 65_536 >= 65_534 ||
236
+ codePoint > 1_114_111
237
+ ? '�'
238
+ : String.fromCodePoint(codePoint);
239
+ const backtickRunEnd = (text, start) => {
240
+ let end = start;
241
+ while (text[end] === '`') {
242
+ end += 1;
243
+ }
244
+ return end;
245
+ };
246
+ // Every maximal backtick run's start, keyed by the run's length, in order.
247
+ const backtickRuns = (text) => {
248
+ const runs = new Map();
249
+ let start = text.indexOf('`');
250
+ while (start !== -1) {
251
+ const end = backtickRunEnd(text, start);
252
+ const starts = runs.get(end - start);
253
+ if (starts) {
254
+ starts.push(start);
255
+ }
256
+ else {
257
+ runs.set(end - start, [start]);
258
+ }
259
+ start = text.indexOf('`', end);
260
+ }
261
+ return runs;
262
+ };
263
+ const firstAtOrAfter = (sorted, from) => {
264
+ let low = 0;
265
+ let high = sorted.length;
266
+ while (low < high) {
267
+ const middle = Math.floor((low + high) / 2);
268
+ if (sorted[middle] < from) {
269
+ low = middle + 1;
270
+ }
271
+ else {
272
+ high = middle;
273
+ }
274
+ }
275
+ return sorted[low];
276
+ };
277
+ // Indexes `text`'s backtick runs once, on the first query.
278
+ const codeSpanCloser = (text) => {
279
+ let runs;
280
+ return (end, length) => {
281
+ runs ??= backtickRuns(text);
282
+ return firstAtOrAfter(runs.get(length) ?? [], end);
283
+ };
284
+ };
285
+ // CommonMark strips one space from each side of a span that is not all spaces.
286
+ const codeSpanText = (content) => /[^ ]/.test(content) && content.startsWith(' ') && content.endsWith(' ')
287
+ ? content.slice(1, -1)
288
+ : content;
289
+ // Resolves the backslash escapes and numeric character references a GFM
290
+ // serializer writes, which Slack would otherwise show literally, and leaves
291
+ // code spans as written.
292
+ const unescapeGfm = (text) => {
293
+ const closer = codeSpanCloser(text);
294
+ let out = '';
295
+ let index = 0;
296
+ while (index < text.length) {
297
+ const char = text[index];
298
+ const next = text[index + 1];
299
+ if (char === '\\' &&
300
+ next !== undefined &&
301
+ ASCII_PUNCTUATION_RE.test(next)) {
302
+ out += next;
303
+ index += 2;
304
+ continue;
305
+ }
306
+ if (char === '`') {
307
+ const fenceEnd = backtickRunEnd(text, index);
308
+ const close = closer(fenceEnd, fenceEnd - index);
309
+ const end = close === undefined ? fenceEnd : close + fenceEnd - index;
310
+ out += text.slice(index, end);
311
+ index = end;
312
+ continue;
313
+ }
314
+ if (char === '&') {
315
+ NUMERIC_REFERENCE_RE.lastIndex = index;
316
+ const reference = NUMERIC_REFERENCE_RE.exec(text);
317
+ if (reference) {
318
+ const [match, hex, decimal] = reference;
319
+ out += decodeCodePoint(hex === undefined ? Number(decimal) : parseInt(hex, 16));
320
+ index += match.length;
321
+ continue;
322
+ }
323
+ }
324
+ out += char;
325
+ index += 1;
326
+ }
327
+ return out;
328
+ };
329
+ // A link destination may be wrapped in angle brackets (`[x](<dest>)`).
330
+ const linkDestination = (dest) => unescapeGfm(dest.replace(/^<([^<>]*)>$/, '$1'));
331
+ // The code span whose opener starts at `open`, or `undefined`.
332
+ const codeSpanAt = (line, open, closer) => {
333
+ const fenceEnd = backtickRunEnd(line, open);
334
+ const close = closer(fenceEnd, fenceEnd - open);
335
+ return close === undefined
336
+ ? undefined
337
+ : {
338
+ index: open,
339
+ end: close + fenceEnd - open,
340
+ segment: {
341
+ kind: 'code',
342
+ text: codeSpanText(line.slice(fenceEnd, close)),
343
+ },
344
+ };
345
+ };
346
+ const regexFinder = (pattern, toSegment) => (line, from) => {
347
+ pattern.lastIndex = from;
348
+ const match = pattern.exec(line);
349
+ return (match && {
350
+ index: match.index,
351
+ end: match.index + match[0].length,
352
+ segment: toSegment(match),
353
+ });
354
+ };
355
+ const findCodeSpan = (line, from, closer) => {
356
+ let open = line.indexOf('`', from);
357
+ while (open !== -1) {
358
+ const span = codeSpanAt(line, open, closer);
359
+ if (span) {
360
+ return span;
361
+ }
362
+ open = line.indexOf('`', backtickRunEnd(line, open));
363
+ }
364
+ return null;
365
+ };
366
+ const WHITESPACE_RE = /\s/u;
367
+ const PUNCTUATION_RE = /[\p{P}\p{S}]/u;
368
+ // The line's edges count as whitespace.
369
+ const isSpace = (char) => char === undefined || WHITESPACE_RE.test(char);
370
+ const isPunctuation = (char) => char !== undefined && PUNCTUATION_RE.test(char);
371
+ // An odd run of backslashes escapes the character at `index`.
372
+ const isEscaped = (line, index) => {
373
+ let run = 0;
374
+ while (line[index - 1 - run] === '\\') {
375
+ run += 1;
376
+ }
377
+ return run % 2 === 1;
378
+ };
379
+ // GFM's flanking rules for a lone delimiter; `_` also cannot open or close
380
+ // inside a word.
381
+ const flanking = (line, index, delimiter) => {
382
+ // Whole code points, so an astral symbol such as an emoji is classified as one.
383
+ const trailing = line.charCodeAt(index - 1);
384
+ const before = index === 0
385
+ ? undefined
386
+ : trailing >= 0xdc00 && trailing <= 0xdfff && index >= 2
387
+ ? String.fromCodePoint(line.codePointAt(index - 2) ?? trailing)
388
+ : line[index - 1];
389
+ const next = line.codePointAt(index + 1);
390
+ const after = next === undefined ? undefined : String.fromCodePoint(next);
391
+ if (before === delimiter || after === delimiter) {
392
+ return { opens: false, closes: false };
393
+ }
394
+ const left = !isSpace(after) &&
395
+ (!isPunctuation(after) || isSpace(before) || isPunctuation(before));
396
+ const right = !isSpace(before) &&
397
+ (!isPunctuation(before) || isSpace(after) || isPunctuation(after));
398
+ return delimiter === '*'
399
+ ? { opens: left, closes: right }
400
+ : {
401
+ opens: left && (!right || isPunctuation(before)),
402
+ closes: right && (!left || isPunctuation(after)),
403
+ };
404
+ };
405
+ // The index past what starts at `index` when it is an escape or a code span,
406
+ // whose characters are never delimiters, or past one character otherwise.
407
+ const stepOver = (line, index, closer) => {
408
+ if (line[index] === '\\') {
409
+ return index + 2;
410
+ }
411
+ if (line[index] === '`') {
412
+ return codeSpanAt(line, index, closer)?.end ?? backtickRunEnd(line, index);
413
+ }
414
+ return index + 1;
415
+ };
416
+ const LINK_DESTINATION_RE = /\((<[^<>\n]*>|(?:\\.|[^\s()\\]|\([^()\s]*\))+)\)/y;
417
+ // A link, or an image, which degrades to a link to its source labelled with
418
+ // its alt text. The label may hold escapes and code spans but no bare bracket.
419
+ const findLink = (line, from, closer) => {
420
+ let open = line.indexOf('[', from);
421
+ while (open !== -1) {
422
+ let index = open + 1;
423
+ while (index < line.length && line[index] !== '[' && line[index] !== ']') {
424
+ index = stepOver(line, index, closer);
425
+ }
426
+ if (line[index] === ']') {
427
+ LINK_DESTINATION_RE.lastIndex = index + 1;
428
+ const destination = LINK_DESTINATION_RE.exec(line);
429
+ if (destination) {
430
+ const bang = line[open - 1] === '!' && !isEscaped(line, open - 1);
431
+ return {
432
+ index: bang ? open - 1 : open,
433
+ end: LINK_DESTINATION_RE.lastIndex,
434
+ segment: {
435
+ kind: 'link',
436
+ text: line.slice(open + 1, index),
437
+ url: destination[1] ?? '',
438
+ },
439
+ };
440
+ }
441
+ }
442
+ open = line.indexOf('[', index);
443
+ }
444
+ return null;
445
+ };
446
+ // Strong between `**` pairs whose body holds no `*` outside escapes and code.
447
+ const findBold = (line, from, closer) => {
448
+ let open = line.indexOf('**', from);
449
+ while (open !== -1) {
450
+ let index = open + 2;
451
+ while (index < line.length && line[index] !== '*') {
452
+ index = stepOver(line, index, closer);
453
+ }
454
+ if (index > open + 2 && line.startsWith('**', index)) {
455
+ return {
456
+ index: open,
457
+ end: index + 2,
458
+ segment: { kind: 'bold', text: line.slice(open + 2, index) },
459
+ };
460
+ }
461
+ open = line.indexOf('**', index > open + 2 ? index : open + 1);
462
+ }
463
+ return null;
464
+ };
465
+ // Emphasis between two lone `delimiter`s, in one forward pass: the first
466
+ // closer pairs with the nearest opener before it, and a delimiter that can
467
+ // do neither is text.
468
+ const emphasisFinder = (delimiter) => (line, from, closer) => {
469
+ let open = -1;
470
+ let index = from;
471
+ while (index < line.length) {
472
+ if (line[index] === '\\' || line[index] === '`') {
473
+ index = stepOver(line, index, closer);
474
+ continue;
475
+ }
476
+ if (line[index] === delimiter && !isEscaped(line, index)) {
477
+ const { opens, closes } = flanking(line, index, delimiter);
478
+ if (open !== -1 && closes) {
479
+ return {
480
+ index: open,
481
+ end: index + 1,
482
+ segment: { kind: 'italic', text: line.slice(open + 1, index) },
483
+ };
484
+ }
485
+ if (opens) {
486
+ open = index;
487
+ }
488
+ }
489
+ index += 1;
490
+ }
491
+ return null;
492
+ };
493
+ // In tie order. Each label, destination, or body stops at the first character
494
+ // that cannot continue it, so one search from a position is linear.
495
+ const INLINE_FINDERS = [
496
+ // A CommonMark backslash escape: any ASCII punctuation character.
497
+ regexFinder(/\\([!-/:-@[-`{-~])/g, ([, text = '']) => ({
498
+ kind: 'text',
499
+ text,
500
+ })),
501
+ findCodeSpan,
502
+ findLink,
503
+ findBold,
504
+ emphasisFinder('_'),
505
+ emphasisFinder('*'),
506
+ ];
507
+ // Tokenizes a single line of GFM into ordered inline segments. The earliest
508
+ // match wins; on a tie, the order of `INLINE_FINDERS` does. An escaped
509
+ // character is text and never a delimiter. Each finder's next match is reused
510
+ // until the cursor passes it, so a line is not rescanned per segment.
511
+ const tokenizeInline = (line) => {
512
+ const segments = [];
513
+ const closer = codeSpanCloser(line);
514
+ const found = new Map();
515
+ const nextMatch = (finder, cursor) => {
516
+ const cached = found.get(finder);
517
+ if (cached === null || (cached !== undefined && cached.index >= cursor)) {
518
+ return cached;
519
+ }
520
+ const match = finder(line, cursor, closer);
521
+ found.set(finder, match);
522
+ return match;
523
+ };
524
+ let cursor = 0;
525
+ while (cursor < line.length) {
526
+ let first;
527
+ for (const finder of INLINE_FINDERS) {
528
+ const match = nextMatch(finder, cursor);
529
+ if (match && (first === undefined || match.index < first.index)) {
530
+ first = match;
531
+ }
532
+ }
533
+ if (first === undefined) {
534
+ segments.push({ kind: 'text', text: line.slice(cursor) });
535
+ break;
536
+ }
537
+ if (first.index > cursor) {
538
+ segments.push({ kind: 'text', text: line.slice(cursor, first.index) });
539
+ }
540
+ segments.push(first.segment);
541
+ cursor = first.end;
542
+ // Backticks after an escaped one open a shorter run of their own.
543
+ if (line[cursor - 1] === '`' && line[cursor] === '`') {
544
+ const span = codeSpanAt(line, cursor, closer);
545
+ const end = span?.end ?? backtickRunEnd(line, cursor);
546
+ segments.push(span?.segment ?? { kind: 'text', text: line.slice(cursor, end) });
547
+ cursor = end;
548
+ }
549
+ }
550
+ return segments;
551
+ };
552
+ const renderInline = (line) => {
553
+ const segments = tokenizeInline(line);
554
+ return segments
555
+ .map((segment) => {
556
+ switch (segment.kind) {
557
+ case 'text':
558
+ return (0, exports.escapeMrkdwn)(unescapeGfm(segment.text));
559
+ case 'code':
560
+ // Code spans pass through with mrkdwn's single-backtick syntax, but
561
+ // we still need to neutralize any embedded backticks.
562
+ return (0, exports.code)(segment.text);
563
+ // The inner text is translated too, so `**a _b_**` nests.
564
+ case 'bold':
565
+ return `*${renderInline(segment.text)}*`;
566
+ case 'italic':
567
+ return `_${renderInline(segment.text)}_`;
568
+ case 'link':
569
+ return (0, exports.link)(linkDestination(segment.url ?? ''), plainInline(segment.text));
570
+ default: {
571
+ const unexpected = segment.kind;
572
+ return unexpected;
573
+ }
574
+ }
575
+ })
576
+ .join('');
577
+ };
578
+ // Inline GFM as its text alone, for a link label or a table cell, where
579
+ // mrkdwn formatting would show its markers.
580
+ const plainInline = (line) => tokenizeInline(line)
581
+ .map(({ kind, text }) => kind === 'text'
582
+ ? unescapeGfm(text)
583
+ : kind === 'code'
584
+ ? text
585
+ : plainInline(text))
586
+ .join('');
587
+ // GFM: up to three spaces of indent, and no backtick in the opener's info.
588
+ const FENCE_RE = /^ {0,3}(`{3,})[^`]*$/;
589
+ // Spaces and tabs only after it, plus the `\r` a CRLF line keeps.
590
+ const CLOSING_FENCE_RE = /^ {0,3}(`{3,})[ \t]*\r?$/;
591
+ // A closing fence is backticks alone, at least as long as the opening run.
592
+ const closesFence = (line, opening) => (CLOSING_FENCE_RE.exec(line)?.[1]?.length ?? 0) >= opening.length;
593
+ // At least one pipe, so a single-column table counts and a thematic break does not.
594
+ const TABLE_SEPARATOR_RE = /^(?=[^|]*\|)\s*(?!\s)\|?\s*:?-+:?\s*(?!\s)(\|\s*:?-+:?\s*(?!\s))*\|?\s*$/;
595
+ const TABLE_ROW_RE = /^\s*\|.*\|\s*$/;
596
+ const BLOCKQUOTE_RE = /^(>\s?)(.*)$/;
597
+ // An ATX heading's text without its closing `#` run, or `undefined`. An
598
+ // escaped `\#` is text, not part of the closing run.
599
+ const headingText = (line) => {
600
+ const text = /^#{1,6}[ \t]+(.*)$/.exec(line)?.[1]?.trimEnd();
601
+ if (text === undefined) {
602
+ return undefined;
603
+ }
604
+ const closing = /(?:^|[ \t])#+$/.exec(text);
605
+ const content = closing ? text.slice(0, closing.index).trimEnd() : text;
606
+ return content.length > 0 ? content : undefined;
607
+ };
608
+ // Splits a `| a | b |` row on its unescaped pipes into cell text, dropping the
609
+ // optional leading/trailing pipes. GFM unescapes `\|` before reading a cell,
610
+ // code spans included.
611
+ const splitPipeRow = (line) => {
612
+ const row = line.trim();
613
+ const cells = [];
614
+ let cell = '';
615
+ let endsWithPipe = false;
616
+ for (let index = 0; index < row.length; index += 1) {
617
+ const char = row[index];
618
+ const next = row[index + 1];
619
+ endsWithPipe = false;
620
+ if (char === '\\' && next !== undefined) {
621
+ cell += next === '|' ? '|' : `\\${next}`;
622
+ index += 1;
623
+ }
624
+ else if (char === '|') {
625
+ cells.push(cell);
626
+ cell = '';
627
+ endsWithPipe = true;
628
+ }
629
+ else {
630
+ cell += char;
631
+ }
632
+ }
633
+ if (!endsWithPipe) {
634
+ cells.push(cell);
635
+ }
636
+ if (row.startsWith('|')) {
637
+ cells.shift();
638
+ }
639
+ return cells.map((value) => plainInline(value.trim()));
640
+ };
641
+ /**
642
+ * Translates GFM into one Slack `mrkdwn` string:
643
+ *
644
+ * - Bold `**X**` to `*X*`, links `[L](U)` to `<U|L>`.
645
+ * - ATX headings to bold, since Slack renders no headings.
646
+ * - Pipe tables into a fenced code block, mrkdwn having no table syntax — the
647
+ * monospace alignment is all that survives. Prefer
648
+ * {@link gfmToSlackBlocks} when a native `table` block is acceptable.
649
+ *
650
+ * Free text is HTML-escaped (`&` `<` `>`) per Slack's rules; code spans and
651
+ * fenced blocks pass through untouched.
652
+ */
653
+ const gfmToSlackMrkdwn = (gfm) => {
654
+ const lines = gfm.split('\n');
655
+ const out = [];
656
+ let i = 0;
657
+ while (i < lines.length) {
658
+ const line = lines[i];
659
+ const opening = FENCE_RE.exec(line)?.[1];
660
+ if (opening !== undefined) {
661
+ // Fenced code block: copy the body verbatim. Slack honours the
662
+ // triple-backtick fence but ignores the language hint, so we strip it
663
+ // for cleanliness.
664
+ const body = [];
665
+ i += 1;
666
+ while (i < lines.length && !closesFence(lines[i], opening)) {
667
+ body.push(lines[i]);
668
+ i += 1;
669
+ }
670
+ out.push((0, exports.codeBlock)(body.join('\n')));
671
+ i += 1;
672
+ continue;
673
+ }
674
+ if (TABLE_ROW_RE.test(line) &&
675
+ i + 1 < lines.length &&
676
+ TABLE_SEPARATOR_RE.test(lines[i + 1])) {
677
+ // GFM pipe table: Slack mrkdwn cannot render tables, so we wrap the
678
+ // entire block in a code fence to preserve the column alignment that
679
+ // the markdown renderer worked hard to produce.
680
+ const tableLines = [];
681
+ while (i < lines.length && TABLE_ROW_RE.test(lines[i])) {
682
+ tableLines.push(lines[i]);
683
+ i += 1;
684
+ }
685
+ out.push((0, exports.codeBlock)(tableLines
686
+ .map((row) => TABLE_SEPARATOR_RE.test(row)
687
+ ? row
688
+ : `| ${splitPipeRow(row).join(' | ')} |`)
689
+ .join('\n')));
690
+ continue;
691
+ }
692
+ const heading = headingText(line);
693
+ if (heading !== undefined) {
694
+ // Headings have no first-class mrkdwn equivalent. Bolding the text keeps
695
+ // the visual hierarchy without inventing markup Slack would render as
696
+ // a literal `#`.
697
+ out.push((0, exports.bold)(unescapeGfm(heading)));
698
+ i += 1;
699
+ continue;
700
+ }
701
+ const blockquoteMatch = line.match(BLOCKQUOTE_RE);
702
+ if (blockquoteMatch) {
703
+ // Slack mrkdwn supports `>` blockquotes. Preserve the prefix verbatim
704
+ // and run only the body through inline transformation so that bold,
705
+ // italic, links, and emoji glyphs inside the quote still translate.
706
+ out.push(`${blockquoteMatch[1]}${renderInline(blockquoteMatch[2] ?? '')}`);
707
+ i += 1;
708
+ continue;
709
+ }
710
+ out.push(renderInline(line));
711
+ i += 1;
712
+ }
713
+ return out.join('\n');
714
+ };
715
+ exports.gfmToSlackMrkdwn = gfmToSlackMrkdwn;
716
+ // ---------------------------------------------------------------------------
717
+ // GFM -> Slack *block* translation.
718
+ const slackPreformattedBlock = (code) => ({
719
+ type: 'rich_text',
720
+ elements: [
721
+ {
722
+ type: 'rich_text_preformatted',
723
+ elements: [
724
+ {
725
+ type: 'text',
726
+ text: (0, exports.clampSlackText)(code, blocks_1.SLACK_LIMITS.sectionTextChars),
727
+ },
728
+ ],
729
+ },
730
+ ],
731
+ });
732
+ // Reads a GFM alignment marker (`:---`, `---:`, `:---:`) into a column align.
733
+ const parseColumnAlign = (marker) => {
734
+ const left = marker.startsWith(':');
735
+ const right = marker.endsWith(':');
736
+ if (left && right) {
737
+ return 'center';
738
+ }
739
+ return right ? 'right' : 'left';
740
+ };
741
+ const pipeTableToTableBlock = (lines) => {
742
+ const [headerLine, separatorLine, ...bodyLines] = lines;
743
+ const aligns = splitPipeRow(separatorLine ?? '').map(parseColumnAlign);
744
+ const rows = [splitPipeRow(headerLine ?? ''), ...bodyLines.map(splitPipeRow)]
745
+ .slice(0, blocks_1.SLACK_LIMITS.tableRows)
746
+ .map((cells) => cells
747
+ .slice(0, blocks_1.SLACK_LIMITS.tableColumns)
748
+ .map((value) => ({
749
+ type: 'raw_text',
750
+ text: value,
751
+ })));
752
+ return {
753
+ type: 'table',
754
+ rows,
755
+ column_settings: aligns
756
+ .slice(0, blocks_1.SLACK_LIMITS.tableColumns)
757
+ .map((align) => ({ align, is_wrapped: true })),
758
+ };
759
+ };
760
+ /**
761
+ * Translates GFM into structural Block Kit: prose runs as `section`, fenced
762
+ * code as `rich_text_preformatted`, pipe tables as a native `table` block.
763
+ *
764
+ * The markdown fallback for a primitive without a `slack` renderer whose
765
+ * markdown is a string; builder content goes through
766
+ * `markdownContentToSlackBlocks`. Preferred over {@link gfmToSlackMrkdwn},
767
+ * which collapses code and tables into
768
+ * a section-level fence that Slack and pixel-faithful previews render poorly.
769
+ */
770
+ const gfmToSlackBlocks = (gfm) => {
771
+ const lines = gfm.split('\n');
772
+ const blocks = [];
773
+ let prose = [];
774
+ const flushProse = () => {
775
+ while (prose.length > 0 && prose[0].trim() === '') {
776
+ prose.shift();
777
+ }
778
+ while (prose.length > 0 && prose[prose.length - 1].trim() === '') {
779
+ prose.pop();
780
+ }
781
+ if (prose.length === 0) {
782
+ return;
783
+ }
784
+ const text = (0, exports.clampMrkdwn)((0, exports.gfmToSlackMrkdwn)(prose.join('\n')), blocks_1.SLACK_LIMITS.sectionTextChars);
785
+ prose = [];
786
+ if (text.length > 0) {
787
+ blocks.push({ type: 'section', text: { type: 'mrkdwn', text } });
788
+ }
789
+ };
790
+ let i = 0;
791
+ while (i < lines.length) {
792
+ const line = lines[i];
793
+ const opening = FENCE_RE.exec(line)?.[1];
794
+ if (opening !== undefined) {
795
+ flushProse();
796
+ i += 1;
797
+ const code = [];
798
+ while (i < lines.length && !closesFence(lines[i], opening)) {
799
+ code.push(lines[i]);
800
+ i += 1;
801
+ }
802
+ i += 1; // Consume the closing fence.
803
+ blocks.push(slackPreformattedBlock(code.join('\n')));
804
+ continue;
805
+ }
806
+ if (TABLE_ROW_RE.test(line) &&
807
+ i + 1 < lines.length &&
808
+ TABLE_SEPARATOR_RE.test(lines[i + 1])) {
809
+ flushProse();
810
+ const tableLines = [];
811
+ while (i < lines.length && TABLE_ROW_RE.test(lines[i])) {
812
+ tableLines.push(lines[i]);
813
+ i += 1;
814
+ }
815
+ blocks.push(pipeTableToTableBlock(tableLines));
816
+ continue;
817
+ }
818
+ prose.push(line);
819
+ i += 1;
820
+ }
821
+ flushProse();
822
+ return blocks;
823
+ };
824
+ exports.gfmToSlackBlocks = gfmToSlackBlocks;
825
+ //# sourceMappingURL=format.js.map