@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,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ export { SLACK_LIMITS, bold, clampSlackText, code, codeBlock, createSlackAssetCollector, escapeMrkdwn, gfmToSlackBlocks, isSlackReachableImageUrl, italic, link, markdownContentToSlackBlocks, renderSlackEnvelope, slackLinkUrl, strike, } from '../render/slack/index.js';
8
+ //# sourceMappingURL=slack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../src/entries/slack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EA8CL,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,SAAS,EACT,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,MAAM,EACN,IAAI,EACJ,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,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\nexport {\n type SlackActionElement,\n type SlackActionsBlock,\n type SlackAssetCollector,\n type SlackAssetRequest,\n type SlackBlock,\n type SlackButtonElement,\n type SlackCheckboxesElement,\n type SlackContextBlock,\n type SlackDividerBlock,\n type SlackEnvelopeDispatcher,\n type SlackEnvelopeOptions,\n type SlackEnvelopeResult,\n type SlackFileReference,\n type SlackHeaderBlock,\n type SlackHeaderLevel,\n type SlackImageBlock,\n type SlackImageElement,\n type SlackMrkdwnTextObject,\n type SlackMultiStaticSelectElement,\n type SlackOptionGroup,\n type SlackOptionObject,\n type SlackOverflowElement,\n type SlackPlainTextObject,\n type SlackRadioButtonsElement,\n type SlackRawTextElement,\n type SlackRichTextBlock,\n type SlackRichTextBlockElement,\n type SlackRichTextInline,\n type SlackRichTextLink,\n type SlackRichTextList,\n type SlackRichTextPreformatted,\n type SlackRichTextQuote,\n type SlackRichTextSection,\n type SlackRichTextStyle,\n type SlackRichTextTag,\n type SlackRichTextText,\n type SlackSectionAccessory,\n type SlackSectionBlock,\n type SlackStaticSelectElement,\n type SlackTableBlock,\n type SlackTableCell,\n type SlackTableColumnSetting,\n type SlackTagColor,\n type SlackTextObject,\n type SlackVideoBlock,\n SLACK_LIMITS,\n bold,\n clampSlackText,\n code,\n codeBlock,\n createSlackAssetCollector,\n escapeMrkdwn,\n gfmToSlackBlocks,\n isSlackReachableImageUrl,\n italic,\n link,\n markdownContentToSlackBlocks,\n renderSlackEnvelope,\n slackLinkUrl,\n strike,\n} from '../render/slack';\n"]}
@@ -0,0 +1,2 @@
1
+ export { type TextEnvelopeDispatcher, type TextEnvelopeOptions, renderTextEnvelope, } from '../render/text/index.js';
2
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/entries/text.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ export { renderTextEnvelope, } from '../render/text/index.js';
8
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/entries/text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,kBAAkB,GACnB,MAAM,gBAAgB,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\nexport {\n type TextEnvelopeDispatcher,\n type TextEnvelopeOptions,\n renderTextEnvelope,\n} from '../render/text';\n"]}
@@ -0,0 +1,27 @@
1
+ import type { AnyPrimitivePack } from './primitive_pack.js';
2
+ /**
3
+ * What a runtime or a pack supports. Enhancement ids are open strings: each
4
+ * pack declares its own on {@link PrimitivePack.enhancements}, and a runtime
5
+ * reports the union.
6
+ */
7
+ export interface HostCapabilities<TEnhancement extends string = string> {
8
+ /** Primitive `type` values that can be dispatched. */
9
+ primitives: string[];
10
+ /** Render formats reachable, e.g. `html`, `slack`, `png`. */
11
+ formats: string[];
12
+ /** Progressive enhancements the packs declare, by id, which an HTML or React render may request. */
13
+ enhancements?: Partial<Record<TEnhancement, boolean>>;
14
+ }
15
+ /**
16
+ * Reports the primitive types and render formats a set of packs supports.
17
+ *
18
+ * `formats` is passed rather than derived because only the caller knows which
19
+ * surfaces exist: a runtime passes the surfaces it built, and a pack passes
20
+ * what it can produce through its own entry points — a `png` reachable only
21
+ * behind a host image binding is something no runtime can infer. `svg` in
22
+ * particular depends on a frame, which is a runtime input and not a pack's to
23
+ * report.
24
+ * @param formats Candidate formats this caller can reach.
25
+ */
26
+ export declare const describeCapabilities: (packs: readonly AnyPrimitivePack[], formats: readonly string[]) => HostCapabilities;
27
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/pack/capabilities.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,YAAY,SAAS,MAAM,GAAG,MAAM;IACpE,sDAAsD;IACtD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oGAAoG;IACpG,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,SAAS,gBAAgB,EAAE,EAClC,SAAS,SAAS,MAAM,EAAE,KACzB,gBAiBF,CAAC"}
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ /**
8
+ * Reports the primitive types and render formats a set of packs supports.
9
+ *
10
+ * `formats` is passed rather than derived because only the caller knows which
11
+ * surfaces exist: a runtime passes the surfaces it built, and a pack passes
12
+ * what it can produce through its own entry points — a `png` reachable only
13
+ * behind a host image binding is something no runtime can infer. `svg` in
14
+ * particular depends on a frame, which is a runtime input and not a pack's to
15
+ * report.
16
+ * @param formats Candidate formats this caller can reach.
17
+ */
18
+ export const describeCapabilities = (packs, formats) => {
19
+ const enhancementIds = packs.flatMap((pack) => pack.enhancements.map((definition) => definition.id));
20
+ return {
21
+ primitives: packs.flatMap((pack) => pack.primitives.map((definition) => definition.type)),
22
+ formats: [...formats],
23
+ ...(enhancementIds.length > 0
24
+ ? {
25
+ enhancements: Object.fromEntries(enhancementIds.map((id) => [id, true])),
26
+ }
27
+ : {}),
28
+ };
29
+ };
30
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/pack/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAkC,EAClC,OAA0B,EACR,EAAE;IACpB,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC5C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CACrD,CAAC;IACF,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CACrD;QACD,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QACrB,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;YAC3B,CAAC,CAAC;gBACE,YAAY,EAAE,MAAM,CAAC,WAAW,CAC9B,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CACvC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC,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// What a host can render, reported from packs rather than asserted by hand.\n//\n// Lives in the sdk so both the assembly layer and a pack import it from the\n// same place; a pack must not have to depend on the assembly layer for it.\n\nimport type { AnyPrimitivePack } from './primitive_pack';\n\n/**\n * What a runtime or a pack supports. Enhancement ids are open strings: each\n * pack declares its own on {@link PrimitivePack.enhancements}, and a runtime\n * reports the union.\n */\nexport interface HostCapabilities<TEnhancement extends string = string> {\n /** Primitive `type` values that can be dispatched. */\n primitives: string[];\n /** Render formats reachable, e.g. `html`, `slack`, `png`. */\n formats: string[];\n /** Progressive enhancements the packs declare, by id, which an HTML or React render may request. */\n enhancements?: Partial<Record<TEnhancement, boolean>>;\n}\n\n/**\n * Reports the primitive types and render formats a set of packs supports.\n *\n * `formats` is passed rather than derived because only the caller knows which\n * surfaces exist: a runtime passes the surfaces it built, and a pack passes\n * what it can produce through its own entry points — a `png` reachable only\n * behind a host image binding is something no runtime can infer. `svg` in\n * particular depends on a frame, which is a runtime input and not a pack's to\n * report.\n * @param formats Candidate formats this caller can reach.\n */\nexport const describeCapabilities = (\n packs: readonly AnyPrimitivePack[],\n formats: readonly string[]\n): HostCapabilities => {\n const enhancementIds = packs.flatMap((pack) =>\n pack.enhancements.map((definition) => definition.id)\n );\n return {\n primitives: packs.flatMap((pack) =>\n pack.primitives.map((definition) => definition.type)\n ),\n formats: [...formats],\n ...(enhancementIds.length > 0\n ? {\n enhancements: Object.fromEntries(\n enhancementIds.map((id) => [id, true])\n ),\n }\n : {}),\n };\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import type { AnyPrimitiveDefinition } from '../define/primitive_module.js';
2
+ import type { EnhancementDefinition } from './enhancements.js';
3
+ import type { AnyPrimitivePack } from './primitive_pack.js';
4
+ /**
5
+ * One flattened inventory owned by {@link composePacks}.
6
+ *
7
+ * `definitions` is a stable array identity, which is what the composition
8
+ * schema cache keys on — pass it through rather than flattening packs per call.
9
+ */
10
+ export interface ComposedPacks {
11
+ readonly definitions: readonly AnyPrimitiveDefinition[];
12
+ readonly enhancements: readonly EnhancementDefinition[];
13
+ readonly slackAssetTypes: ReadonlySet<string>;
14
+ }
15
+ /**
16
+ * Flattens `packs` into one inventory, rejecting cross-pack duplicate node
17
+ * types and duplicate enhancement ids. Every offender is named in one error,
18
+ * so a bad three-pack composition reports all three at once.
19
+ */
20
+ export declare const composePacks: (packs: readonly AnyPrimitivePack[]) => ComposedPacks;
21
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/pack/compose.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACxD,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACxD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,gBAAgB,EAAE,KACjC,aAuCF,CAAC"}
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ import { IsomerError } from '../composition/error.js';
8
+ /**
9
+ * Flattens `packs` into one inventory, rejecting cross-pack duplicate node
10
+ * types and duplicate enhancement ids. Every offender is named in one error,
11
+ * so a bad three-pack composition reports all three at once.
12
+ */
13
+ export const composePacks = (packs) => {
14
+ const typeOwners = new Map();
15
+ const enhancementOwners = new Map();
16
+ for (const pack of packs) {
17
+ for (const { type } of pack.primitives) {
18
+ typeOwners.set(type, [...(typeOwners.get(type) ?? []), pack.id]);
19
+ }
20
+ for (const { id } of pack.enhancements) {
21
+ enhancementOwners.set(id, [
22
+ ...(enhancementOwners.get(id) ?? []),
23
+ pack.id,
24
+ ]);
25
+ }
26
+ }
27
+ const repeated = [
28
+ ...new Set(packs
29
+ .map(({ id }) => id)
30
+ .filter((id, index, ids) => ids.indexOf(id) !== index)),
31
+ ];
32
+ if (repeated.length > 0) {
33
+ throw new IsomerError('DUPLICATE_PACK_ID', `composePacks: ${repeated.map((id) => `"${id}"`).join(', ')} names more than one pack; pack ids must be unique`);
34
+ }
35
+ assertUnique('DUPLICATE_PRIMITIVE_TYPE', 'primitive type', typeOwners);
36
+ assertUnique('DUPLICATE_ENHANCEMENT', 'enhancement', enhancementOwners);
37
+ return Object.freeze({
38
+ definitions: Object.freeze(packs.flatMap((pack) => [...pack.primitives])),
39
+ enhancements: Object.freeze(packs.flatMap((pack) => [...pack.enhancements])),
40
+ slackAssetTypes: new Set(packs.flatMap((pack) => [...pack.slackAssetTypes])),
41
+ });
42
+ };
43
+ const assertUnique = (code, noun, owners) => {
44
+ const duplicates = [...owners].filter(([, packs]) => packs.length > 1);
45
+ if (duplicates.length === 0) {
46
+ return;
47
+ }
48
+ throw new IsomerError(code, duplicates
49
+ .map(([key, packs]) => `${noun} "${key}" registered by ${packs.map((id) => `"${id}"`).join(' and ')}`)
50
+ .join('; '));
51
+ };
52
+ //# sourceMappingURL=compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/pack/compose.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 { IsomerError } from '../composition/error';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport type { EnhancementDefinition } from './enhancements';\nimport type { AnyPrimitivePack } from './primitive_pack';\n\n/**\n * One flattened inventory owned by {@link composePacks}.\n *\n * `definitions` is a stable array identity, which is what the composition\n * schema cache keys on — pass it through rather than flattening packs per call.\n */\nexport interface ComposedPacks {\n readonly definitions: readonly AnyPrimitiveDefinition[];\n readonly enhancements: readonly EnhancementDefinition[];\n readonly slackAssetTypes: ReadonlySet<string>;\n}\n\n/**\n * Flattens `packs` into one inventory, rejecting cross-pack duplicate node\n * types and duplicate enhancement ids. Every offender is named in one error,\n * so a bad three-pack composition reports all three at once.\n */\nexport const composePacks = (\n packs: readonly AnyPrimitivePack[]\n): ComposedPacks => {\n const typeOwners = new Map<string, string[]>();\n const enhancementOwners = new Map<string, string[]>();\n for (const pack of packs) {\n for (const { type } of pack.primitives) {\n typeOwners.set(type, [...(typeOwners.get(type) ?? []), pack.id]);\n }\n for (const { id } of pack.enhancements) {\n enhancementOwners.set(id, [\n ...(enhancementOwners.get(id) ?? []),\n pack.id,\n ]);\n }\n }\n const repeated = [\n ...new Set(\n packs\n .map(({ id }) => id)\n .filter((id, index, ids) => ids.indexOf(id) !== index)\n ),\n ];\n if (repeated.length > 0) {\n throw new IsomerError(\n 'DUPLICATE_PACK_ID',\n `composePacks: ${repeated.map((id) => `\"${id}\"`).join(', ')} names more than one pack; pack ids must be unique`\n );\n }\n assertUnique('DUPLICATE_PRIMITIVE_TYPE', 'primitive type', typeOwners);\n assertUnique('DUPLICATE_ENHANCEMENT', 'enhancement', enhancementOwners);\n\n return Object.freeze({\n definitions: Object.freeze(packs.flatMap((pack) => [...pack.primitives])),\n enhancements: Object.freeze(\n packs.flatMap((pack) => [...pack.enhancements])\n ),\n slackAssetTypes: new Set(\n packs.flatMap((pack) => [...pack.slackAssetTypes])\n ),\n });\n};\n\nconst assertUnique = (\n code: 'DUPLICATE_ENHANCEMENT' | 'DUPLICATE_PRIMITIVE_TYPE',\n noun: string,\n owners: ReadonlyMap<string, readonly string[]>\n): void => {\n const duplicates = [...owners].filter(([, packs]) => packs.length > 1);\n if (duplicates.length === 0) {\n return;\n }\n throw new IsomerError(\n code,\n duplicates\n .map(\n ([key, packs]) =>\n `${noun} \"${key}\" registered by ${packs.map((id) => `\"${id}\"`).join(' and ')}`\n )\n .join('; ')\n );\n};\n"]}
@@ -0,0 +1,65 @@
1
+ import type { ChildNodeWalker } from '../composition/body_node_base.js';
2
+ import type { PrimitiveNode } from '../composition/node.js';
3
+ /**
4
+ * A progressive enhancement any vocabulary pack may declare.
5
+ *
6
+ * Ids are open strings rather than a closed union so a second pack can
7
+ * register one without editing a shared type. Duplicate ids across packs in
8
+ * one runtime are rejected at construction.
9
+ */
10
+ export interface EnhancementDefinition {
11
+ /** What a renderer tests for via `context.enhancements`. Unique across a runtime's packs. */
12
+ id: string;
13
+ /**
14
+ * Whether this composition has anything for the enhancement to act on.
15
+ * Gating on content rather than the opt-in alone is what keeps a composition
16
+ * with no matching node from shipping the script.
17
+ *
18
+ * `walk` is the composition's child walker, so a match nested inside a
19
+ * container from another pack is still found.
20
+ */
21
+ appliesTo: (body: readonly PrimitiveNode[], walk: ChildNodeWalker) => boolean;
22
+ /**
23
+ * A function body with `root: Element`, the render's `.isomer` section, in
24
+ * scope. It runs in its own function, so a top-level `const` or `return`
25
+ * cannot reach another enhancement. Absent when the host drives the
26
+ * enhancement itself.
27
+ *
28
+ * It must not look for its root through `document.currentScript`, which is
29
+ * `null` inside a shadow root. It must address markup through `data-*`
30
+ * attributes rather than class names: class names are minified per render,
31
+ * and a selector written against one is a contract nothing checks. An event
32
+ * meant for the host sets `composed: true` as well as `bubbles: true`, or it
33
+ * stops at a shadow boundary.
34
+ */
35
+ script?: string;
36
+ /** Renders node anchors when resolved, for an enhancement that finds nodes with `findNodeElementPairs`. */
37
+ anchors?: true;
38
+ }
39
+ /**
40
+ * The `definitions` that apply to `body`, the first of each id, limited to
41
+ * `requested` ids when given. The HTML and React surfaces both resolve through
42
+ * it, so the two cannot disagree on which enhancements a render carries.
43
+ */
44
+ export declare const resolveEnhancements: (body: readonly PrimitiveNode[], walk: ChildNodeWalker, definitions: readonly EnhancementDefinition[], requested?: readonly string[]) => EnhancementDefinition[];
45
+ /**
46
+ * Wraps one script body in its own function, so its `const`s and a top-level
47
+ * `return` stay its own. Anything that joins script bodies scopes each first.
48
+ */
49
+ export declare const scopeScript: (body: string) => string;
50
+ /** Marks the `<script>` a `scripts: 'embedded'` render emits. */
51
+ export declare const EMBEDDED_SCRIPT_ATTRIBUTE = "data-isomer-script";
52
+ /**
53
+ * Runs a `scripts: 'host'` render's `js` against the
54
+ * `.isomer` section the host inserted.
55
+ *
56
+ * Needed wherever the HTML is inserted by the host rather than parsed with the
57
+ * page, including every shadow root: such a `<script>` never runs, and one
58
+ * that did would find no `document.currentScript`.
59
+ *
60
+ * Compiles with `new Function`, so a strict Content-Security-Policy must allow
61
+ * `'unsafe-eval'`. A host that cannot should render with `scripts: 'embedded'`
62
+ * into light DOM.
63
+ */
64
+ export declare const runEnhancementScript: (js: string, root: Element) => void;
65
+ //# sourceMappingURL=enhancements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhancements.d.ts","sourceRoot":"","sources":["../../src/pack/enhancements.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,6FAA6F;IAC7F,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC;IAC9E;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2GAA2G;IAC3G,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,SAAS,aAAa,EAAE,EAC9B,MAAM,eAAe,EACrB,aAAa,SAAS,qBAAqB,EAAE,EAC7C,YAAY,SAAS,MAAM,EAAE,KAC5B,qBAAqB,EAcvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,MAAoC,CAAC;AAEhF,iEAAiE;AACjE,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,MAAM,EAAE,MAAM,OAAO,KAAG,IAkBhE,CAAC"}
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ import { IsomerError } from '../composition/error.js';
8
+ /**
9
+ * The `definitions` that apply to `body`, the first of each id, limited to
10
+ * `requested` ids when given. The HTML and React surfaces both resolve through
11
+ * it, so the two cannot disagree on which enhancements a render carries.
12
+ */
13
+ export const resolveEnhancements = (body, walk, definitions, requested) => {
14
+ const wanted = requested && new Set(requested);
15
+ const ids = new Set();
16
+ return definitions.filter((definition) => {
17
+ if (ids.has(definition.id) ||
18
+ (wanted && !wanted.has(definition.id)) ||
19
+ !definition.appliesTo(body, walk)) {
20
+ return false;
21
+ }
22
+ ids.add(definition.id);
23
+ return true;
24
+ });
25
+ };
26
+ /**
27
+ * Wraps one script body in its own function, so its `const`s and a top-level
28
+ * `return` stay its own. Anything that joins script bodies scopes each first.
29
+ */
30
+ export const scopeScript = (body) => `(() => {\n${body}\n})();`;
31
+ /** Marks the `<script>` a `scripts: 'embedded'` render emits. */
32
+ export const EMBEDDED_SCRIPT_ATTRIBUTE = 'data-isomer-script';
33
+ /**
34
+ * Runs a `scripts: 'host'` render's `js` against the
35
+ * `.isomer` section the host inserted.
36
+ *
37
+ * Needed wherever the HTML is inserted by the host rather than parsed with the
38
+ * page, including every shadow root: such a `<script>` never runs, and one
39
+ * that did would find no `document.currentScript`.
40
+ *
41
+ * Compiles with `new Function`, so a strict Content-Security-Policy must allow
42
+ * `'unsafe-eval'`. A host that cannot should render with `scripts: 'embedded'`
43
+ * into light DOM.
44
+ */
45
+ export const runEnhancementScript = (js, root) => {
46
+ // Guards untyped callers; typed ones already handled `querySelector`'s null.
47
+ if (!root) {
48
+ throw new IsomerError('ENHANCEMENT_ROOT_MISSING', 'runEnhancementScript: no root element; pass the `.isomer` section the render produced');
49
+ }
50
+ if (root.querySelector(`script[${EMBEDDED_SCRIPT_ATTRIBUTE}]`)) {
51
+ console.warn("isomer: this HTML was rendered with scripts: 'embedded'; render with scripts: 'host' so its enhancements run once");
52
+ }
53
+ if (js) {
54
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval -- compiling the render's script is the point.
55
+ const run = new Function('root', js);
56
+ run(root);
57
+ }
58
+ };
59
+ //# sourceMappingURL=enhancements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhancements.js","sourceRoot":"","sources":["../../src/pack/enhancements.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAwCnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAA8B,EAC9B,IAAqB,EACrB,WAA6C,EAC7C,SAA6B,EACJ,EAAE;IAC3B,MAAM,MAAM,GAAG,SAAS,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACvC,IACE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtB,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACtC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EACjC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,SAAS,CAAC;AAEhF,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAE,IAAa,EAAQ,EAAE;IACtE,6EAA6E;IAC7E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,WAAW,CACnB,0BAA0B,EAC1B,uFAAuF,CACxF,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,yBAAyB,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,IAAI,CACV,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,EAAE,CAAC;QACP,6GAA6G;QAC7G,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAA4B,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,CAAC;IACZ,CAAC;AACH,CAAC,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\nimport type { ChildNodeWalker } from '../composition/body_node_base';\nimport { IsomerError } from '../composition/error';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A progressive enhancement any vocabulary pack may declare.\n *\n * Ids are open strings rather than a closed union so a second pack can\n * register one without editing a shared type. Duplicate ids across packs in\n * one runtime are rejected at construction.\n */\nexport interface EnhancementDefinition {\n /** What a renderer tests for via `context.enhancements`. Unique across a runtime's packs. */\n id: string;\n /**\n * Whether this composition has anything for the enhancement to act on.\n * Gating on content rather than the opt-in alone is what keeps a composition\n * with no matching node from shipping the script.\n *\n * `walk` is the composition's child walker, so a match nested inside a\n * container from another pack is still found.\n */\n appliesTo: (body: readonly PrimitiveNode[], walk: ChildNodeWalker) => boolean;\n /**\n * A function body with `root: Element`, the render's `.isomer` section, in\n * scope. It runs in its own function, so a top-level `const` or `return`\n * cannot reach another enhancement. Absent when the host drives the\n * enhancement itself.\n *\n * It must not look for its root through `document.currentScript`, which is\n * `null` inside a shadow root. It must address markup through `data-*`\n * attributes rather than class names: class names are minified per render,\n * and a selector written against one is a contract nothing checks. An event\n * meant for the host sets `composed: true` as well as `bubbles: true`, or it\n * stops at a shadow boundary.\n */\n script?: string;\n /** Renders node anchors when resolved, for an enhancement that finds nodes with `findNodeElementPairs`. */\n anchors?: true;\n}\n\n/**\n * The `definitions` that apply to `body`, the first of each id, limited to\n * `requested` ids when given. The HTML and React surfaces both resolve through\n * it, so the two cannot disagree on which enhancements a render carries.\n */\nexport const resolveEnhancements = (\n body: readonly PrimitiveNode[],\n walk: ChildNodeWalker,\n definitions: readonly EnhancementDefinition[],\n requested?: readonly string[]\n): EnhancementDefinition[] => {\n const wanted = requested && new Set(requested);\n const ids = new Set<string>();\n return definitions.filter((definition) => {\n if (\n ids.has(definition.id) ||\n (wanted && !wanted.has(definition.id)) ||\n !definition.appliesTo(body, walk)\n ) {\n return false;\n }\n ids.add(definition.id);\n return true;\n });\n};\n\n/**\n * Wraps one script body in its own function, so its `const`s and a top-level\n * `return` stay its own. Anything that joins script bodies scopes each first.\n */\nexport const scopeScript = (body: string): string => `(() => {\\n${body}\\n})();`;\n\n/** Marks the `<script>` a `scripts: 'embedded'` render emits. */\nexport const EMBEDDED_SCRIPT_ATTRIBUTE = 'data-isomer-script';\n\n/**\n * Runs a `scripts: 'host'` render's `js` against the\n * `.isomer` section the host inserted.\n *\n * Needed wherever the HTML is inserted by the host rather than parsed with the\n * page, including every shadow root: such a `<script>` never runs, and one\n * that did would find no `document.currentScript`.\n *\n * Compiles with `new Function`, so a strict Content-Security-Policy must allow\n * `'unsafe-eval'`. A host that cannot should render with `scripts: 'embedded'`\n * into light DOM.\n */\nexport const runEnhancementScript = (js: string, root: Element): void => {\n // Guards untyped callers; typed ones already handled `querySelector`'s null.\n if (!root) {\n throw new IsomerError(\n 'ENHANCEMENT_ROOT_MISSING',\n 'runEnhancementScript: no root element; pass the `.isomer` section the render produced'\n );\n }\n if (root.querySelector(`script[${EMBEDDED_SCRIPT_ATTRIBUTE}]`)) {\n console.warn(\n \"isomer: this HTML was rendered with scripts: 'embedded'; render with scripts: 'host' so its enhancements run once\"\n );\n }\n if (js) {\n // eslint-disable-next-line @typescript-eslint/no-implied-eval -- compiling the render's script is the point.\n const run = new Function('root', js) as (root: Element) => void;\n run(root);\n }\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export { type HostCapabilities, describeCapabilities } from './capabilities.js';
2
+ export { type ComposedPacks, composePacks } from './compose.js';
3
+ export { type EnhancementDefinition, scopeScript } from './enhancements.js';
4
+ export { type AnyPrimitivePack, type PackAuthoringOptions, type PackStyleAdapter, type PrimitiveGroup, type PrimitivePack, type PrimitivePackInput, definePrimitivePack, } from './primitive_pack.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pack/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,KAAK,qBAAqB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ export { describeCapabilities } from './capabilities.js';
8
+ export { composePacks } from './compose.js';
9
+ export { scopeScript } from './enhancements.js';
10
+ export { definePrimitivePack, } from './primitive_pack.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pack/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAyB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAsB,YAAY,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAA8B,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAOL,mBAAmB,GACpB,MAAM,kBAAkB,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\nexport { type HostCapabilities, describeCapabilities } from './capabilities';\nexport { type ComposedPacks, composePacks } from './compose';\nexport { type EnhancementDefinition, scopeScript } from './enhancements';\nexport {\n type AnyPrimitivePack,\n type PackAuthoringOptions,\n type PackStyleAdapter,\n type PrimitiveGroup,\n type PrimitivePack,\n type PrimitivePackInput,\n definePrimitivePack,\n} from './primitive_pack';\n"]}
@@ -0,0 +1,155 @@
1
+ import type { AnyPrimitiveDefinition, OptionalSurface, StyleHandle } from '../define/primitive_module.js';
2
+ import type { EnhancementDefinition } from './enhancements.js';
3
+ /**
4
+ * The authoring-schema material a pack contributes for its own primitives.
5
+ *
6
+ * A subset of `AuthoringJsonSchemaOptions`: `$id`, `title`, `description`, and
7
+ * `composition` describe the whole authoring schema a runtime builds, which is
8
+ * a host decision, not a pack one. `pack/` does not import `validate/` for
9
+ * this, so the shape is declared here rather than reused by reference.
10
+ */
11
+ export interface PackAuthoringOptions {
12
+ /** `$def` id to `description`, for this pack's own primitives. */
13
+ describe?: Readonly<Record<string, string>>;
14
+ /** `$defId.property` paths to drop, from this pack's own primitives. */
15
+ omitProperties?: readonly string[];
16
+ /** Headings an index catalog sorts this pack's primitives under, in order. */
17
+ groups?: readonly PrimitiveGroup[];
18
+ }
19
+ /** A titled set of primitive types, listed together in an index catalog. */
20
+ export interface PrimitiveGroup {
21
+ title: string;
22
+ types: readonly string[];
23
+ }
24
+ /**
25
+ * The HTML style-adapter hooks a pack may declare. Typed loosely here so `pack/` does not import `render/`.
26
+ */
27
+ export type PackStyleAdapter = {
28
+ /** See {@link PrimitivePackInput.styleCollector}. */
29
+ styleCollector?: string;
30
+ /** The hooks of `HTMLStyleAdapter` from `./html`, erased: a fresh collector per render, the context renderers receive, and the stylesheet the collector produced. */
31
+ createCollector: (...args: never[]) => object;
32
+ createRenderContext: (...args: never[]) => unknown;
33
+ renderStyles: (...args: never[]) => string;
34
+ /**
35
+ * Whether `handle` belongs to this adapter's stylesheet. Required for a runtime to combine several packs' CSS: without it their handles cannot be routed and the host must pick one adapter.
36
+ */
37
+ ownsHandle?: (handle: StyleHandle) => boolean;
38
+ };
39
+ /** What a pack author passes to {@link definePrimitivePack}. */
40
+ export interface PrimitivePackInput {
41
+ /** Stable identifier, used in capability reports and error messages. */
42
+ id: string;
43
+ /**
44
+ * The optional surfaces this pack's primitives implement.
45
+ *
46
+ * Only `slack`, and it stays optional per primitive: the dispatcher converts
47
+ * the mandatory markdown to Block Kit, so declaring it reports an intent
48
+ * rather than imposing a requirement. Omit it entirely for a pack that
49
+ * renders Slack through that fallback.
50
+ */
51
+ surfaces?: readonly OptionalSurface[];
52
+ /** This pack's vocabulary. Node types must be unique within it, or construction throws. */
53
+ primitives: readonly AnyPrimitiveDefinition[];
54
+ /**
55
+ * Progressive enhancements this pack's primitives can apply, by id.
56
+ *
57
+ * Declared by the pack because an enhancement is a fact about its
58
+ * vocabulary — a sortable table, a copyable code block — and a host
59
+ * composing packs it did not write cannot be expected to know the ids.
60
+ * The runtime flattens these across packs; duplicate ids are rejected.
61
+ */
62
+ enhancements?: readonly EnhancementDefinition[];
63
+ /**
64
+ * Types that render as a self-contained picture rather than as text.
65
+ *
66
+ * A channel that cannot draw them inline uploads an image instead: the Slack
67
+ * dispatcher swaps such a node for an `image` block and an upload request, so
68
+ * a chart arrives as a PNG rather than as a markdown approximation of one.
69
+ *
70
+ * Declared by the pack because it is a fact about the vocabulary, and a host
71
+ * composing packs it did not write cannot be expected to know it.
72
+ */
73
+ slackAssetTypes?: readonly string[];
74
+ /**
75
+ * Default HTML style adapter for this pack. A runtime that omits
76
+ * `styleAdapter` runs the packs' own adapters, combined when more than one
77
+ * pack declares one and each answers `ownsHandle`. Pass `styleAdapter` on
78
+ * the runtime to replace them all.
79
+ */
80
+ styleAdapter?: PackStyleAdapter;
81
+ /**
82
+ * Names the collector shape this pack's `collectStyles` hooks mutate, so a
83
+ * runtime can reject a pack paired with an adapter of a different tag.
84
+ * Defaults to `styleAdapter.styleCollector`; a pack with neither opts out of
85
+ * the check.
86
+ */
87
+ styleCollector?: string;
88
+ /**
89
+ * This pack's own contribution to the runtime's authoring JSON Schema.
90
+ *
91
+ * Merged across every composed pack, so a host does not hand-merge each
92
+ * pack's `describe`/`omitProperties` into one options object itself. The
93
+ * runtime-level `authoring` option is merged in last and wins on conflict.
94
+ */
95
+ authoring?: PackAuthoringOptions;
96
+ }
97
+ /**
98
+ * A pack as the runtime sees it.
99
+ *
100
+ * `TTheme` is the palette this pack's `react` renderers read as `env.theme`
101
+ * when drawn through the `svg` surface — a *lower bound* on whatever theme
102
+ * the runtime holding it supplies. It is carried by
103
+ * {@link PrimitivePack.__theme} rather than by any real field, because
104
+ * `primitives` is erased to `AnyPrimitiveDefinition[]` and a heterogeneous
105
+ * inventory has no single node type to be generic over.
106
+ *
107
+ * The bound is declared, not derived: nothing checks it against what the
108
+ * renderers actually read. State it at the definition as
109
+ * `definePrimitivePack<T>(input)`.
110
+ * Bare `PrimitivePack` requires nothing and fits any runtime; a slot that must
111
+ * hold packs of every palette is typed {@link AnyPrimitivePack}.
112
+ */
113
+ export interface PrimitivePack<TTheme = unknown> {
114
+ /** Unique among the packs a runtime composes, and used in error messages. */
115
+ readonly id: string;
116
+ /** See {@link PrimitivePackInput.surfaces}. */
117
+ readonly surfaces: readonly OptionalSurface[];
118
+ /** See {@link PrimitivePackInput.primitives}. */
119
+ readonly primitives: readonly AnyPrimitiveDefinition[];
120
+ /** Node types this pack owns, for duplicate detection across packs. */
121
+ readonly types: ReadonlySet<string>;
122
+ /** See {@link PrimitivePackInput.enhancements}. */
123
+ readonly enhancements: readonly EnhancementDefinition[];
124
+ /** See {@link PrimitivePackInput.slackAssetTypes}. */
125
+ readonly slackAssetTypes: ReadonlySet<string>;
126
+ /** See {@link PrimitivePackInput.styleAdapter}. */
127
+ readonly styleAdapter?: PackStyleAdapter;
128
+ /** See {@link PrimitivePackInput.styleCollector}. */
129
+ readonly styleCollector?: string;
130
+ /** See {@link PrimitivePackInput.authoring}. */
131
+ readonly authoring?: PackAuthoringOptions;
132
+ /**
133
+ * Phantom: never present at runtime, never read.
134
+ *
135
+ * A property rather than a method so `strictFunctionTypes` checks it
136
+ * contravariantly. A method signature is bivariant, which would let a pack
137
+ * needing richer tokens sit in a slot supplying fewer and then read a field
138
+ * nothing supplies — the exact failure this marker exists to prevent.
139
+ */
140
+ readonly __theme?: (theme: TTheme) => void;
141
+ }
142
+ /**
143
+ * A pack of any palette, for storage positions: `never` is assignable to every
144
+ * requirement, so a slot typed this way holds every pack.
145
+ */
146
+ export type AnyPrimitivePack = PrimitivePack<never>;
147
+ /**
148
+ * Builds a {@link PrimitivePack}.
149
+ *
150
+ * `TTheme` is the palette a frame must supply for this pack's nodes to be drawn
151
+ * on the `svg` surface: `definePrimitivePack<CoreTokens>(input)`. Omitted, it is
152
+ * `unknown`, which requires nothing.
153
+ */
154
+ export declare const definePrimitivePack: <TTheme = unknown>(input: PrimitivePackInput) => PrimitivePack<TTheme>;
155
+ //# sourceMappingURL=primitive_pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive_pack.d.ts","sourceRoot":"","sources":["../../src/pack/primitive_pack.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ // A primitive pack as a value: a vocabulary, and the optional surfaces every
8
+ // primitive in it implements. Additive: a runtime composes any number of packs,
9
+ // and nothing about a pack decides how a composition is framed.
10
+ import { IsomerError } from '../composition/error.js';
11
+ /**
12
+ * Builds a {@link PrimitivePack}.
13
+ *
14
+ * `TTheme` is the palette a frame must supply for this pack's nodes to be drawn
15
+ * on the `svg` surface: `definePrimitivePack<CoreTokens>(input)`. Omitted, it is
16
+ * `unknown`, which requires nothing.
17
+ */
18
+ export const definePrimitivePack = (input) => {
19
+ if (input.primitives.length === 0) {
20
+ throw new IsomerError('EMPTY_PACK', `primitive pack "${input.id}": at least one primitive is required`);
21
+ }
22
+ assertUniquePrimitiveTypes(input.id, input.primitives);
23
+ assertUniqueEnhancementIds(input.id, input.enhancements ?? []);
24
+ const types = new Set(input.primitives.map((definition) => definition.type));
25
+ assertGroupedOnce(input.id, input.authoring?.groups ?? [], types);
26
+ for (const type of input.slackAssetTypes ?? []) {
27
+ if (!types.has(type)) {
28
+ throw new IsomerError('UNKNOWN_PRIMITIVE_TYPE', `primitive pack "${input.id}": slackAssetTypes names primitive type "${type}", which the pack does not register`);
29
+ }
30
+ }
31
+ const styleCollector = input.styleCollector ?? input.styleAdapter?.styleCollector;
32
+ return {
33
+ id: input.id,
34
+ surfaces: input.surfaces ?? [],
35
+ primitives: input.primitives,
36
+ types,
37
+ enhancements: input.enhancements ?? [],
38
+ slackAssetTypes: new Set(input.slackAssetTypes ?? []),
39
+ ...(input.styleAdapter !== undefined
40
+ ? { styleAdapter: input.styleAdapter }
41
+ : {}),
42
+ ...(styleCollector !== undefined ? { styleCollector } : {}),
43
+ ...(input.authoring !== undefined ? { authoring: input.authoring } : {}),
44
+ };
45
+ };
46
+ /** Throws if `primitives` repeats a type. */
47
+ const assertUniquePrimitiveTypes = (id, primitives) => {
48
+ const seen = new Set();
49
+ for (const { type } of primitives) {
50
+ if (seen.has(type)) {
51
+ throw new IsomerError('DUPLICATE_PRIMITIVE_TYPE', `primitive pack "${id}": primitive type "${type}" registered twice`);
52
+ }
53
+ seen.add(type);
54
+ }
55
+ };
56
+ /** Throws if a group names a type outside `types`, or two groups share a type. */
57
+ const assertGroupedOnce = (id, groups, types) => {
58
+ const grouped = new Set();
59
+ for (const { title, types: members } of groups) {
60
+ for (const type of members) {
61
+ if (!types.has(type)) {
62
+ throw new IsomerError('UNKNOWN_PRIMITIVE_TYPE', `primitive pack "${id}": group "${title}" names primitive type "${type}", which the pack does not register`);
63
+ }
64
+ if (grouped.has(type)) {
65
+ throw new IsomerError('DUPLICATE_PRIMITIVE_TYPE', `primitive pack "${id}": primitive type "${type}" is in two groups`);
66
+ }
67
+ grouped.add(type);
68
+ }
69
+ }
70
+ };
71
+ /** Throws if this pack registers the same enhancement id twice. */
72
+ const assertUniqueEnhancementIds = (id, enhancements) => {
73
+ const seen = new Set();
74
+ for (const definition of enhancements) {
75
+ if (seen.has(definition.id)) {
76
+ throw new IsomerError('DUPLICATE_ENHANCEMENT', `primitive pack "${id}": enhancement "${definition.id}" registered twice`);
77
+ }
78
+ seen.add(definition.id);
79
+ }
80
+ };
81
+ //# sourceMappingURL=primitive_pack.js.map