@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.22 → 2.2.0-next.23

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 (338) hide show
  1. package/custom-elements-manifest.config.mjs +2 -1
  2. package/custom-elements.json +312 -17
  3. package/llms/components/obc-accordion-card.md +141 -0
  4. package/llms/components/obc-accordion-item.md +90 -0
  5. package/llms/components/obc-advice-button.md +87 -0
  6. package/llms/components/obc-advice-floating-item.md +113 -0
  7. package/llms/components/obc-advice-menu-item.md +87 -0
  8. package/llms/components/obc-advice-message-item.md +138 -0
  9. package/llms/components/obc-alert-button-item.md +117 -0
  10. package/llms/components/obc-alert-button.md +134 -0
  11. package/llms/components/obc-alert-counter-item.md +74 -0
  12. package/llms/components/obc-alert-detail-page.md +45 -0
  13. package/llms/components/obc-alert-floating-item.md +53 -0
  14. package/llms/components/obc-alert-frame.md +142 -0
  15. package/llms/components/obc-alert-icon.md +79 -0
  16. package/llms/components/obc-alert-list-details-experimental.md +89 -0
  17. package/llms/components/obc-alert-list-details.md +38 -0
  18. package/llms/components/obc-alert-list-page-small.md +39 -0
  19. package/llms/components/obc-alert-list.md +37 -0
  20. package/llms/components/obc-alert-menu-item.md +128 -0
  21. package/llms/components/obc-alert-menu.md +115 -0
  22. package/llms/components/obc-alert-subsystem-button.md +88 -0
  23. package/llms/components/obc-alert-subsystem-counter.md +110 -0
  24. package/llms/components/obc-analog-threeway-valve.md +106 -0
  25. package/llms/components/obc-analog-valve.md +74 -0
  26. package/llms/components/obc-app-button.md +83 -0
  27. package/llms/components/obc-app-menu.md +69 -0
  28. package/llms/components/obc-area-graph.md +333 -0
  29. package/llms/components/obc-attachment-list-item.md +49 -0
  30. package/llms/components/obc-audio-output.md +59 -0
  31. package/llms/components/obc-audio-recording-item.md +91 -0
  32. package/llms/components/obc-automation-badge.md +66 -0
  33. package/llms/components/obc-automation-button-readout-stack.md +71 -0
  34. package/llms/components/obc-automation-button.md +86 -0
  35. package/llms/components/obc-automation-input-modal.md +48 -0
  36. package/llms/components/obc-automation-readout.md +32 -0
  37. package/llms/components/obc-automation-tank.md +156 -0
  38. package/llms/components/obc-azimuth-thruster-labeled.md +56 -0
  39. package/llms/components/obc-azimuth-thruster.md +80 -0
  40. package/llms/components/obc-badge-command.md +26 -0
  41. package/llms/components/obc-badge.md +151 -0
  42. package/llms/components/obc-bar-horizontal.md +123 -0
  43. package/llms/components/obc-bar-vertical.md +125 -0
  44. package/llms/components/obc-battery-icon.md +38 -0
  45. package/llms/components/obc-bearing-indicator.md +27 -0
  46. package/llms/components/obc-bipolar-transistor.md +64 -0
  47. package/llms/components/obc-breadcrumb.md +58 -0
  48. package/llms/components/obc-brilliance-menu.md +115 -0
  49. package/llms/components/obc-bus.md +64 -0
  50. package/llms/components/obc-button.md +110 -0
  51. package/llms/components/obc-calendar.md +91 -0
  52. package/llms/components/obc-capacitor.md +64 -0
  53. package/llms/components/obc-card.md +103 -0
  54. package/llms/components/obc-chart-object-vessel-button.md +103 -0
  55. package/llms/components/obc-chat-message.md +35 -0
  56. package/llms/components/obc-check-button.md +104 -0
  57. package/llms/components/obc-checkbox-item.md +95 -0
  58. package/llms/components/obc-checkbox-list.md +73 -0
  59. package/llms/components/obc-checkbox.md +97 -0
  60. package/llms/components/obc-circular-progress.md +36 -0
  61. package/llms/components/obc-clock.md +86 -0
  62. package/llms/components/obc-command-button.md +56 -0
  63. package/llms/components/obc-command-menu.md +135 -0
  64. package/llms/components/obc-communication-table.md +31 -0
  65. package/llms/components/obc-compass-flat.md +79 -0
  66. package/llms/components/obc-compass-indicator.md +61 -0
  67. package/llms/components/obc-compass-sector.md +110 -0
  68. package/llms/components/obc-compass.md +157 -0
  69. package/llms/components/obc-context-menu-input.md +191 -0
  70. package/llms/components/obc-converter.md +64 -0
  71. package/llms/components/obc-corner-line.md +29 -0
  72. package/llms/components/obc-current.md +79 -0
  73. package/llms/components/obc-damper.md +62 -0
  74. package/llms/components/obc-date-item.md +66 -0
  75. package/llms/components/obc-depth-actual.md +69 -0
  76. package/llms/components/obc-depth-indicator.md +31 -0
  77. package/llms/components/obc-depth-top-band.md +43 -0
  78. package/llms/components/obc-depth.md +94 -0
  79. package/llms/components/obc-diagnostic-button.md +71 -0
  80. package/llms/components/obc-diagnostic-menu.md +88 -0
  81. package/llms/components/obc-digital-threeway-valve.md +112 -0
  82. package/llms/components/obc-digital-valve.md +78 -0
  83. package/llms/components/obc-diodes.md +64 -0
  84. package/llms/components/obc-direction-line.md +28 -0
  85. package/llms/components/obc-divider.md +44 -0
  86. package/llms/components/obc-donut-chart.md +116 -0
  87. package/llms/components/obc-draft-trim.md +67 -0
  88. package/llms/components/obc-dropdown-button.md +99 -0
  89. package/llms/components/obc-electricity-battery.md +83 -0
  90. package/llms/components/obc-elevated-card-radio-group.md +103 -0
  91. package/llms/components/obc-elevated-card-radio.md +104 -0
  92. package/llms/components/obc-elevated-card.md +146 -0
  93. package/llms/components/obc-end-point-line.md +29 -0
  94. package/llms/components/obc-event-item.md +47 -0
  95. package/llms/components/obc-event-list.md +37 -0
  96. package/llms/components/obc-fan.md +68 -0
  97. package/llms/components/obc-filter-chip.md +91 -0
  98. package/llms/components/obc-filter.md +64 -0
  99. package/llms/components/obc-floating-item.md +125 -0
  100. package/llms/components/obc-form-container.md +45 -0
  101. package/llms/components/obc-form-footer-container.md +34 -0
  102. package/llms/components/obc-form-group.md +80 -0
  103. package/llms/components/obc-form-item.md +95 -0
  104. package/llms/components/obc-gauge-bar-indicator.md +46 -0
  105. package/llms/components/obc-gauge-generator.md +102 -0
  106. package/llms/components/obc-gauge-horizontal.md +169 -0
  107. package/llms/components/obc-gauge-motors-and-pumps.md +110 -0
  108. package/llms/components/obc-gauge-proportional.md +134 -0
  109. package/llms/components/obc-gauge-radial-indicator.md +76 -0
  110. package/llms/components/obc-gauge-radial.md +163 -0
  111. package/llms/components/obc-gauge-trend-indicator.md +53 -0
  112. package/llms/components/obc-gauge-trend.md +271 -0
  113. package/llms/components/obc-gauge-valve.md +114 -0
  114. package/llms/components/obc-gauge-vertical.md +169 -0
  115. package/llms/components/obc-gnss-skyplot.md +80 -0
  116. package/llms/components/obc-graph-mini.md +28 -0
  117. package/llms/components/obc-ground.md +64 -0
  118. package/llms/components/obc-heading-indicator.md +42 -0
  119. package/llms/components/obc-heading.md +106 -0
  120. package/llms/components/obc-heat-exchanger.md +80 -0
  121. package/llms/components/obc-heat-pump.md +79 -0
  122. package/llms/components/obc-heave-indicator.md +38 -0
  123. package/llms/components/obc-heave.md +60 -0
  124. package/llms/components/obc-horizontal-line.md +29 -0
  125. package/llms/components/obc-hydraulic-check-valve.md +36 -0
  126. package/llms/components/obc-hydraulic-separator.md +80 -0
  127. package/llms/components/obc-hydraulic-valve-4-3.md +71 -0
  128. package/llms/components/obc-hydraulic-valve-x-2.md +68 -0
  129. package/llms/components/obc-icon-button.md +117 -0
  130. package/llms/components/obc-icon-check-button.md +85 -0
  131. package/llms/components/obc-indicator-battery.md +69 -0
  132. package/llms/components/obc-indicator-engine.md +39 -0
  133. package/llms/components/obc-indicator-generator.md +59 -0
  134. package/llms/components/obc-indicator-graph.md +33 -0
  135. package/llms/components/obc-indicator-tank-atmospheric.md +69 -0
  136. package/llms/components/obc-input-chip.md +96 -0
  137. package/llms/components/obc-instrument-field.md +172 -0
  138. package/llms/components/obc-instrument-radial.md +77 -0
  139. package/llms/components/obc-integration-app-bar.md +41 -0
  140. package/llms/components/obc-integration-bar-dropdown.md +71 -0
  141. package/llms/components/obc-integration-bar.md +72 -0
  142. package/llms/components/obc-integration-button.md +62 -0
  143. package/llms/components/obc-integration-dropdown-button.md +75 -0
  144. package/llms/components/obc-integration-fleet-button.md +41 -0
  145. package/llms/components/obc-integration-tabs.md +28 -0
  146. package/llms/components/obc-integration-vessel-menu.md +58 -0
  147. package/llms/components/obc-integration-vessel-selector.md +32 -0
  148. package/llms/components/obc-keyboard-full.md +175 -0
  149. package/llms/components/obc-keyboard-numeric.md +77 -0
  150. package/llms/components/obc-line-cross.md +28 -0
  151. package/llms/components/obc-line-graph.md +164 -0
  152. package/llms/components/obc-line-overlap.md +28 -0
  153. package/llms/components/obc-logic.md +64 -0
  154. package/llms/components/obc-main-engine-indicator.md +55 -0
  155. package/llms/components/obc-main-engine.md +54 -0
  156. package/llms/components/obc-menu-button.md +158 -0
  157. package/llms/components/obc-message-menu-item.md +165 -0
  158. package/llms/components/obc-modal-window.md +139 -0
  159. package/llms/components/obc-mosfet.md +64 -0
  160. package/llms/components/obc-motor.md +73 -0
  161. package/llms/components/obc-navigation-item-group.md +82 -0
  162. package/llms/components/obc-navigation-item.md +138 -0
  163. package/llms/components/obc-navigation-menu.md +135 -0
  164. package/llms/components/obc-non-return-valve.md +79 -0
  165. package/llms/components/obc-notification-badge-button.md +87 -0
  166. package/llms/components/obc-notification-button.md +92 -0
  167. package/llms/components/obc-notification-floating-item.md +121 -0
  168. package/llms/components/obc-notification-menu-item.md +87 -0
  169. package/llms/components/obc-notification-message-item.md +127 -0
  170. package/llms/components/obc-number-input-field.md +97 -0
  171. package/llms/components/obc-pagination.md +95 -0
  172. package/llms/components/obc-pie-chart.md +120 -0
  173. package/llms/components/obc-pitch-indicator.md +39 -0
  174. package/llms/components/obc-pitch-roll-heave.md +86 -0
  175. package/llms/components/obc-pitch-roll-yaw.md +72 -0
  176. package/llms/components/obc-pitch-roll.md +63 -0
  177. package/llms/components/obc-pitch.md +81 -0
  178. package/llms/components/obc-pivot-item-group.md +79 -0
  179. package/llms/components/obc-pivot-item.md +75 -0
  180. package/llms/components/obc-poi-aton.md +68 -0
  181. package/llms/components/obc-poi-button-aton.md +54 -0
  182. package/llms/components/obc-poi-button-data.md +53 -0
  183. package/llms/components/obc-poi-button-vessel.md +55 -0
  184. package/llms/components/obc-poi-button.md +94 -0
  185. package/llms/components/obc-poi-card-header.md +90 -0
  186. package/llms/components/obc-poi-card.md +110 -0
  187. package/llms/components/obc-poi-controller.md +151 -0
  188. package/llms/components/obc-poi-data.md +72 -0
  189. package/llms/components/obc-poi-graphic-line.md +70 -0
  190. package/llms/components/obc-poi-group.md +85 -0
  191. package/llms/components/obc-poi-header.md +71 -0
  192. package/llms/components/obc-poi-layer-stack.md +85 -0
  193. package/llms/components/obc-poi-layer.md +110 -0
  194. package/llms/components/obc-poi-line.md +70 -0
  195. package/llms/components/obc-poi-object-aton.md +45 -0
  196. package/llms/components/obc-poi-object-data.md +48 -0
  197. package/llms/components/obc-poi-object-vessel.md +95 -0
  198. package/llms/components/obc-poi-object.md +82 -0
  199. package/llms/components/obc-poi-pointer.md +70 -0
  200. package/llms/components/obc-poi-selection-frame.md +66 -0
  201. package/llms/components/obc-poi-vessel.md +70 -0
  202. package/llms/components/obc-poi.md +140 -0
  203. package/llms/components/obc-polar-chart.md +126 -0
  204. package/llms/components/obc-position-deviation.md +84 -0
  205. package/llms/components/obc-pressure-reduction-valve.md +88 -0
  206. package/llms/components/obc-pressure-sustain-valve.md +85 -0
  207. package/llms/components/obc-progress-bar.md +102 -0
  208. package/llms/components/obc-progress-button.md +111 -0
  209. package/llms/components/obc-progress-indicator-dots.md +57 -0
  210. package/llms/components/obc-propulsion-azimuth-indicator.md +48 -0
  211. package/llms/components/obc-pump.md +76 -0
  212. package/llms/components/obc-radial-bar-chart.md +103 -0
  213. package/llms/components/obc-radio.md +82 -0
  214. package/llms/components/obc-rate-of-turn.md +95 -0
  215. package/llms/components/obc-readout-block.md +137 -0
  216. package/llms/components/obc-readout-list-item.md +142 -0
  217. package/llms/components/obc-readout-list.md +85 -0
  218. package/llms/components/obc-readout.md +169 -0
  219. package/llms/components/obc-resistor.md +64 -0
  220. package/llms/components/obc-rich-button.md +92 -0
  221. package/llms/components/obc-roll-indicator.md +38 -0
  222. package/llms/components/obc-roll.md +56 -0
  223. package/llms/components/obc-rot-indicator.md +32 -0
  224. package/llms/components/obc-rot-linear.md +68 -0
  225. package/llms/components/obc-rot-sector.md +125 -0
  226. package/llms/components/obc-router.md +64 -0
  227. package/llms/components/obc-rudder-indicator.md +54 -0
  228. package/llms/components/obc-rudder.md +112 -0
  229. package/llms/components/obc-ruler-pointer.md +57 -0
  230. package/llms/components/obc-scrollbar.md +57 -0
  231. package/llms/components/obc-sequence-card.md +119 -0
  232. package/llms/components/obc-sequence-connector.md +70 -0
  233. package/llms/components/obc-sequence-item.md +64 -0
  234. package/llms/components/obc-sequence-loading-spinner.md +70 -0
  235. package/llms/components/obc-sequence-modal.md +89 -0
  236. package/llms/components/obc-sequence-step.md +48 -0
  237. package/llms/components/obc-sequence-toolbar.md +108 -0
  238. package/llms/components/obc-slide-button.md +111 -0
  239. package/llms/components/obc-slider-double.md +137 -0
  240. package/llms/components/obc-slider.md +143 -0
  241. package/llms/components/obc-source.md +64 -0
  242. package/llms/components/obc-speed-arrows.md +39 -0
  243. package/llms/components/obc-speed-directions.md +66 -0
  244. package/llms/components/obc-speed-gauge.md +124 -0
  245. package/llms/components/obc-speed-indicator.md +37 -0
  246. package/llms/components/obc-split-button.md +144 -0
  247. package/llms/components/obc-start-stop-switch.md +126 -0
  248. package/llms/components/obc-status-indicator.md +30 -0
  249. package/llms/components/obc-stepper-box.md +90 -0
  250. package/llms/components/obc-surge-sway-yaw.md +95 -0
  251. package/llms/components/obc-switch.md +69 -0
  252. package/llms/components/obc-system-button.md +112 -0
  253. package/llms/components/obc-system-menu.md +67 -0
  254. package/llms/components/obc-tab-item.md +161 -0
  255. package/llms/components/obc-tab-row.md +151 -0
  256. package/llms/components/obc-tabbed-card.md +148 -0
  257. package/llms/components/obc-table-header-item.md +42 -0
  258. package/llms/components/obc-table.md +124 -0
  259. package/llms/components/obc-tag.md +41 -0
  260. package/llms/components/obc-text-input-field.md +94 -0
  261. package/llms/components/obc-textarea-field.md +186 -0
  262. package/llms/components/obc-textbox.md +80 -0
  263. package/llms/components/obc-three-way-line.md +29 -0
  264. package/llms/components/obc-thruster.md +64 -0
  265. package/llms/components/obc-title-container.md +81 -0
  266. package/llms/components/obc-toggle-button-group.md +184 -0
  267. package/llms/components/obc-toggle-button-option.md +126 -0
  268. package/llms/components/obc-toggle-button-three-state.md +38 -0
  269. package/llms/components/obc-toggle-button-vertical-group.md +142 -0
  270. package/llms/components/obc-toggle-button-vertical-option.md +110 -0
  271. package/llms/components/obc-toggle-switch.md +126 -0
  272. package/llms/components/obc-toggletip.md +135 -0
  273. package/llms/components/obc-tooltip.md +106 -0
  274. package/llms/components/obc-top-bar.md +194 -0
  275. package/llms/components/obc-top-view-propulsion.md +84 -0
  276. package/llms/components/obc-topbar-message-item.md +150 -0
  277. package/llms/components/obc-transformer.md +64 -0
  278. package/llms/components/obc-transmitter-button.md +101 -0
  279. package/llms/components/obc-transmitter-stack.md +79 -0
  280. package/llms/components/obc-transmitter.md +114 -0
  281. package/llms/components/obc-tree-navigation-group.md +69 -0
  282. package/llms/components/obc-tree-navigation-item.md +110 -0
  283. package/llms/components/obc-tree-navigation.md +73 -0
  284. package/llms/components/obc-tunnel-thruster.md +59 -0
  285. package/llms/components/obc-user-button.md +107 -0
  286. package/llms/components/obc-user-menu.md +154 -0
  287. package/llms/components/obc-valve-analog-three-way-icon.md +69 -0
  288. package/llms/components/obc-valve-analog-two-way-icon.md +39 -0
  289. package/llms/components/obc-velocity-projection-plot.md +34 -0
  290. package/llms/components/obc-vendor-button.md +63 -0
  291. package/llms/components/obc-vertical-line.md +33 -0
  292. package/llms/components/obc-watch-flat.md +54 -0
  293. package/llms/components/obc-watch.md +206 -0
  294. package/llms/components/obc-wind-indicator.md +52 -0
  295. package/llms/components/obc-wind-propulsion.md +92 -0
  296. package/llms/components/obc-wind.md +46 -0
  297. package/llms/docs/ar-poi-projection.md +36 -0
  298. package/llms/docs/automation-sequence-step-diagram-playground.md +13 -0
  299. package/llms/docs/building-blocks-advice.md +31 -0
  300. package/llms/docs/building-blocks-external-scale.md +138 -0
  301. package/llms/docs/building-blocks-setpoint.md +119 -0
  302. package/llms/docs/introduction-advice-system.md +161 -0
  303. package/llms/docs/introduction-getting-started.md +94 -0
  304. package/llms/docs/introduction-introduction.md +27 -0
  305. package/llms/docs/introduction-join-the-project.md +11 -0
  306. package/llms/docs/introduction-migration-guide-2-0-to-2-1.md +126 -0
  307. package/llms/docs/introduction-migration-guide-2-1-to-2-2.md +106 -0
  308. package/llms/docs/introduction-migration-guide.md +1063 -0
  309. package/llms/docs/palettes-categorical-colour.md +9 -0
  310. package/llms/llms-full.txt +28380 -0
  311. package/llms/llms.txt +368 -0
  312. package/package.json +12 -2
  313. package/script/cem-plugins/lifecycle.d.mts +6 -0
  314. package/script/cem-plugins/lifecycle.mjs +48 -0
  315. package/script/cem-plugins.test.ts +52 -1
  316. package/script/generate-llms-txt.ts +34 -0
  317. package/script/llms/channel.test.ts +69 -0
  318. package/script/llms/channel.ts +63 -0
  319. package/script/llms/generate.test.ts +143 -0
  320. package/script/llms/generate.ts +229 -0
  321. package/script/llms/manifest.test.ts +160 -0
  322. package/script/llms/manifest.ts +109 -0
  323. package/script/llms/markdown.test.ts +22 -0
  324. package/script/llms/markdown.ts +37 -0
  325. package/script/llms/mdx.test.ts +172 -0
  326. package/script/llms/mdx.ts +171 -0
  327. package/script/llms/render-component.test.ts +290 -0
  328. package/script/llms/render-component.ts +208 -0
  329. package/script/llms/render-guides.test.ts +105 -0
  330. package/script/llms/render-guides.ts +51 -0
  331. package/script/llms/render-llms-txt.test.ts +222 -0
  332. package/script/llms/render-llms-txt.ts +185 -0
  333. package/script/llms/sources.test.ts +118 -0
  334. package/script/llms/sources.ts +89 -0
  335. package/script/llms/stories.test.ts +193 -0
  336. package/script/llms/stories.ts +256 -0
  337. package/script/llms/types.ts +95 -0
  338. package/script/prepare-full-bundle.ts +1 -0
@@ -0,0 +1,109 @@
1
+ import fs from 'node:fs';
2
+ import type {
3
+ ComponentEntry,
4
+ Family,
5
+ FamilyId,
6
+ Manifest,
7
+ ManifestDeclaration,
8
+ } from './types.js';
9
+
10
+ export type {ComponentEntry, Manifest} from './types.js';
11
+
12
+ export const FAMILIES: readonly Family[] = [
13
+ {id: 'components', title: 'UI components'},
14
+ {
15
+ id: 'navigation-instruments',
16
+ title: 'Navigation instruments and indicators',
17
+ },
18
+ {id: 'bars-graphs', title: 'Charts'},
19
+ {id: 'building-blocks', title: 'Building blocks'},
20
+ {id: 'automation', title: 'Automation'},
21
+ {id: 'ar', title: 'Augmented reality'},
22
+ {id: 'integration-systems', title: 'Integration systems'},
23
+ {id: 'pages', title: 'Pages'},
24
+ ];
25
+
26
+ const FAMILY_IDS = new Set<string>(FAMILIES.map((f) => f.id));
27
+
28
+ export function readManifest(file: string): Manifest {
29
+ if (!fs.existsSync(file)) {
30
+ throw new Error(
31
+ 'custom-elements.json not found; run npm run analyze first'
32
+ );
33
+ }
34
+ return JSON.parse(fs.readFileSync(file, 'utf8')) as Manifest;
35
+ }
36
+
37
+ export function familyOf(modulePath: string): FamilyId | undefined {
38
+ const dir = modulePath.split('/')[1];
39
+ return dir && FAMILY_IDS.has(dir) ? (dir as FamilyId) : undefined;
40
+ }
41
+
42
+ /** Cuts after the first sentence, where the next one starts with a capital or a code span. */
43
+ export function firstSentence(text: string): string {
44
+ const m = /\.\s+(?=[A-Z`])/.exec(text);
45
+ return m ? text.slice(0, m.index + 1) : text;
46
+ }
47
+
48
+ const TAG_PREFIX = /^`<?obc-[\w-]+>?`\s*(?:[–—-]\s*)?/;
49
+ const NOT_A_SUMMARY = /^(#|```|@|\*\*TODO\(|TODO\()/;
50
+
51
+ export function summaryOf(description: string | undefined): string | undefined {
52
+ if (!description) return undefined;
53
+ const paragraph = description
54
+ .split(/\n\s*\n/)[0]
55
+ .split('\n')
56
+ .map((l) => l.trim())
57
+ .filter(Boolean)
58
+ .join(' ');
59
+ if (!paragraph || NOT_A_SUMMARY.test(paragraph)) return undefined;
60
+ const text = firstSentence(paragraph.replace(TAG_PREFIX, '')).trim();
61
+ return text ? text.replace(/[[\]|]/g, (c) => `\\${c}`) : undefined;
62
+ }
63
+
64
+ export function componentEntries(
65
+ manifest: Manifest,
66
+ warn: (msg: string) => void
67
+ ): ComponentEntry[] {
68
+ const entries: ComponentEntry[] = [];
69
+ for (const module of manifest.modules) {
70
+ for (const declaration of module.declarations ?? []) {
71
+ const tag = declaration.tagName;
72
+ if (!tag?.startsWith('obc-')) continue;
73
+ const family = familyOf(module.path);
74
+ if (!family) {
75
+ warn(
76
+ `llms.txt: ${tag} in ${module.path} is outside the families; skipped`
77
+ );
78
+ continue;
79
+ }
80
+ entries.push(toEntry(tag, family, module.path, declaration));
81
+ }
82
+ }
83
+ const order = new Map(FAMILIES.map((f, i) => [f.id, i]));
84
+ return entries.sort(
85
+ (a, b) =>
86
+ order.get(a.family)! - order.get(b.family)! || a.tag.localeCompare(b.tag)
87
+ );
88
+ }
89
+
90
+ function toEntry(
91
+ tag: string,
92
+ family: FamilyId,
93
+ modulePath: string,
94
+ declaration: ManifestDeclaration
95
+ ): ComponentEntry {
96
+ const {deprecated} = declaration;
97
+ return {
98
+ tag,
99
+ className: declaration.name ?? '',
100
+ modulePath,
101
+ family,
102
+ summary: summaryOf(declaration.description),
103
+ lifecycle: declaration.lifecycle,
104
+ deprecatedNote:
105
+ typeof deprecated === 'string' ? firstSentence(deprecated) : undefined,
106
+ description: declaration.description ?? '',
107
+ declaration,
108
+ };
109
+ }
@@ -0,0 +1,22 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {fenceState} from './markdown.js';
3
+
4
+ describe('fenceState', () => {
5
+ it('closes only on the opening character, at least as long', () => {
6
+ const f = fenceState();
7
+ expect(f.update('```md')).toBe(true);
8
+ expect(f.update('```~~~')).toBe(false);
9
+ expect(f.inFence).toBe(true);
10
+ expect(f.update('~~~')).toBe(false);
11
+ expect(f.update('``')).toBe(false);
12
+ expect(f.update('````')).toBe(true);
13
+ expect(f.inFence).toBe(false);
14
+ });
15
+
16
+ it('keeps a shorter fence of the same character inside', () => {
17
+ const f = fenceState();
18
+ f.update('````');
19
+ expect(f.update('```')).toBe(false);
20
+ expect(f.inFence).toBe(true);
21
+ });
22
+ });
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Fenced code tracking
3
+ *
4
+ * Markdown fences open with three or more backticks or tildes and close with
5
+ * the same character at least as many times; a shorter or different fence
6
+ * inside stays code. Every pass that must leave code alone shares this.
7
+ */
8
+ export interface FenceState {
9
+ readonly inFence: boolean;
10
+ /** Updates the state for `line`; true when the line is a fence delimiter. */
11
+ update(line: string): boolean;
12
+ }
13
+
14
+ export function fenceState(): FenceState {
15
+ let open: {char: string; length: number} | undefined;
16
+ return {
17
+ get inFence() {
18
+ return open !== undefined;
19
+ },
20
+ update(line) {
21
+ const m = /^\s*(`{3,}|~{3,})/.exec(line);
22
+ if (!m) return false;
23
+ const char = m[1][0];
24
+ const length = m[1].length;
25
+ if (!open) {
26
+ open = {char, length};
27
+ return true;
28
+ }
29
+ const closes = new RegExp(`^\\s*\\${open.char}{${open.length},}\\s*$`);
30
+ if (char === open.char && closes.test(line)) {
31
+ open = undefined;
32
+ return true;
33
+ }
34
+ return false;
35
+ },
36
+ };
37
+ }
@@ -0,0 +1,172 @@
1
+ import {describe, expect, it, vi} from 'vitest';
2
+ import {mdxToMarkdown, type MdxContext} from './mdx.js';
3
+
4
+ const ctx = (over: Partial<MdxContext> = {}): MdxContext => ({
5
+ readRaw: (p) => `<raw ${p}>`,
6
+ storyLink: () => undefined,
7
+ site: 'https://s',
8
+ vars: {
9
+ isStable: false,
10
+ STORYBOOK_STABLE_URL: 'https://stable',
11
+ STORYBOOK_DEVELOP_URL: 'https://dev',
12
+ },
13
+ warn: () => {},
14
+ ...over,
15
+ });
16
+
17
+ describe('mdxToMarkdown', () => {
18
+ it('drops imports and Meta, keeps the prose', () => {
19
+ const src = `import {Meta} from '@storybook/addon-docs/blocks';\n\n<Meta title="Introduction/X" />\n\n# X\n\nText.`;
20
+ expect(mdxToMarkdown(src, ctx())).toBe('# X\n\nText.');
21
+ });
22
+
23
+ it('handles a multi-line import', () => {
24
+ const src = `import {\n a,\n b,\n} from '../x.js';\n\n# X`;
25
+ expect(mdxToMarkdown(src, ctx())).toBe('# X');
26
+ });
27
+
28
+ it('ends an import at a trailing comment and never swallows prose', () => {
29
+ const src = `import {Meta} from '@storybook/addon-docs/blocks'; // docs blocks\n\n# X\n\nText.`;
30
+ expect(mdxToMarkdown(src, ctx())).toBe('# X\n\nText.');
31
+ });
32
+
33
+ it('keeps a blank line inside a multi-line import', () => {
34
+ const src = `import {\n Meta,\n\n Markdown,\n} from '@storybook/addon-docs/blocks';\n\n# X\n\nText.`;
35
+ expect(mdxToMarkdown(src, ctx())).toBe('# X\n\nText.');
36
+ });
37
+
38
+ it('rewrites Storybook links inside an expanded partial, leaving its code alone', () => {
39
+ const docsRoute = (id: string) =>
40
+ id === 'components-pump' ? 'https://s/components/obc-pump.md' : undefined;
41
+ const raw =
42
+ '| [Pump](?path=/docs/components-pump--docs) | `{min: 1}` |\n|---|---|\n\n```\n[x](?path=/story/a--b)\n```';
43
+ expect(
44
+ mdxToMarkdown(
45
+ `import t from './t.md?raw';\n\n<Markdown>{t}</Markdown>`,
46
+ ctx({readRaw: () => raw, docsRoute})
47
+ )
48
+ ).toBe(
49
+ '| [Pump](https://s/components/obc-pump.md) | `{min: 1}` |\n|---|---|\n\n```\n[x](?path=/story/a--b)\n```'
50
+ );
51
+ });
52
+
53
+ it('stops an unterminated import at the first blank line and warns', () => {
54
+ const warn = vi.fn();
55
+ expect(mdxToMarkdown(`import {\n a,\n\n# X`, ctx({warn}))).toBe('# X');
56
+ expect(warn).toHaveBeenCalledOnce();
57
+ });
58
+
59
+ it('maps a docs route to its generated page and leaves story routes on Storybook', () => {
60
+ const docsRoute = (id: string) =>
61
+ id === 'introduction-advice-system'
62
+ ? 'https://s/docs/introduction-advice-system.md'
63
+ : undefined;
64
+ expect(
65
+ mdxToMarkdown(
66
+ '[a](?path=/docs/introduction-advice-system--docs), [b](?path=/docs/unknown--docs), [c](?path=/story/x--y)',
67
+ ctx({docsRoute})
68
+ )
69
+ ).toBe(
70
+ '[a](https://s/docs/introduction-advice-system.md), [b](https://s/?path=/docs/unknown--docs), [c](https://s/?path=/story/x--y)'
71
+ );
72
+ });
73
+
74
+ it('normalises links and blank lines outside fenced code only', () => {
75
+ const src =
76
+ 'A\n\n\n\nB\n\n```md\n[x](?path=/story/x--y)\n\n\n\nkeep\n```\n\n~~~\n[y](?path=/story/x--y)\n~~~';
77
+ expect(mdxToMarkdown(src, ctx())).toBe(
78
+ 'A\n\nB\n\n```md\n[x](?path=/story/x--y)\n\n\n\nkeep\n```\n\n~~~\n[y](?path=/story/x--y)\n~~~'
79
+ );
80
+ });
81
+
82
+ it('inlines a Markdown raw partial', () => {
83
+ const src = `import categories from './x/categories.md?raw';\n\n## Categories\n\n<Markdown>{categories}</Markdown>`;
84
+ expect(
85
+ mdxToMarkdown(
86
+ src,
87
+ ctx({
88
+ readRaw: (p) => (p === './x/categories.md?raw' ? '| a |\n|---|' : ''),
89
+ })
90
+ )
91
+ ).toBe('## Categories\n\n| a |\n|---|');
92
+ });
93
+
94
+ it('replaces a Canvas with a story link and drops Controls', () => {
95
+ const src = `import * as S from '../src/a/a.stories';\n\n<Canvas of={S.Playground} sourceState="none" />\n\n<Controls of={S.Playground} />\n\nAfter.`;
96
+ const storyLink = vi.fn(
97
+ () => '[Story: A / Playground](https://s/?path=/story/a--playground)'
98
+ );
99
+ expect(mdxToMarkdown(src, ctx({storyLink}))).toBe(
100
+ '[Story: A / Playground](https://s/?path=/story/a--playground)\n\nAfter.'
101
+ );
102
+ expect(storyLink).toHaveBeenCalledWith('../src/a/a.stories', 'Playground');
103
+ });
104
+
105
+ it('drops a Canvas whose story cannot be resolved', () => {
106
+ const src = `import * as S from '../src/a/a.stories';\n\n<Canvas of={S.Gone} />\n\nAfter.`;
107
+ expect(mdxToMarkdown(src, ctx())).toBe('After.');
108
+ });
109
+
110
+ it('leaves fenced code alone, indented fences included', () => {
111
+ const src =
112
+ '```html\n<ObcPump></ObcPump>\nimport x from "y";\n<Meta title="no" />\n```\n\n1. Step\n\n ```vue\n <ObcTopBar></ObcTopBar>\n ```';
113
+ expect(mdxToMarkdown(src, ctx())).toBe(src);
114
+ });
115
+
116
+ it('absolutises Storybook path links', () => {
117
+ expect(
118
+ mdxToMarkdown(
119
+ '[a](?path=/story/x--y) and [b](?path=/docs/z--docs)',
120
+ ctx()
121
+ )
122
+ ).toBe(
123
+ '[a](https://s/?path=/story/x--y) and [b](https://s/?path=/docs/z--docs)'
124
+ );
125
+ });
126
+
127
+ it('resolves the channel expressions the Introduction page uses', () => {
128
+ const src = [
129
+ '{isStable ? (',
130
+ ' <div style={{padding: 1}}>',
131
+ ' <strong>Channel: Stable</strong>',
132
+ ' </div>',
133
+ ') : (',
134
+ ' <div>Develop</div>',
135
+ ')}',
136
+ '',
137
+ '- **<a href={STORYBOOK_STABLE_URL}>Stable Storybook</a>** {isStable && <em>(You are here)</em>} — quarterly.',
138
+ '- **<a href={STORYBOOK_DEVELOP_URL}>Develop Storybook</a>** {!isStable && <em>(You are here)</em>} — every merge.',
139
+ '',
140
+ "Jump to the {isStable ? 'develop' : 'stable'} build.",
141
+ ].join('\n');
142
+ expect(mdxToMarkdown(src, ctx())).toBe(
143
+ [
144
+ '- **[Stable Storybook](https://stable)** — quarterly.',
145
+ '- **[Develop Storybook](https://dev)** <em>(You are here)</em> — every merge.',
146
+ '',
147
+ 'Jump to the stable build.',
148
+ ].join('\n')
149
+ );
150
+ });
151
+
152
+ it('drops an unknown expression and warns', () => {
153
+ const warn = vi.fn();
154
+ expect(mdxToMarkdown('Count: {items.length} total.', ctx({warn}))).toBe(
155
+ 'Count: total.'
156
+ );
157
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('items.length'));
158
+ });
159
+
160
+ it('drops div wrappers around a partial', () => {
161
+ const warn = vi.fn();
162
+ const src = `import t from './t.md?raw';\n\n<div style={{overflowX: 'auto'}}>\n<Markdown>{t}</Markdown>\n</div>\n\nAfter.`;
163
+ expect(mdxToMarkdown(src, ctx({readRaw: () => '| a |', warn}))).toBe(
164
+ '| a |\n\nAfter.'
165
+ );
166
+ expect(warn).not.toHaveBeenCalled();
167
+ });
168
+
169
+ it('collapses runs of blank lines', () => {
170
+ expect(mdxToMarkdown('A\n\n\n\n\nB', ctx())).toBe('A\n\nB');
171
+ });
172
+ });
@@ -0,0 +1,171 @@
1
+ /**
2
+ * MDX page to markdown
3
+ *
4
+ * The `docs/*.mdx` pages are markdown with a few MDX constructs: imports, a
5
+ * `<Meta>`, `<Markdown>{partial}</Markdown>` for the `?raw` tables, a
6
+ * `<Canvas>` or `<Controls>` per embedded story, and on the Introduction
7
+ * page the channel banner and "you are here" markers. Each construct has
8
+ * one rule here; fenced code is passed through untouched because the
9
+ * migration guides quote framework markup there.
10
+ */
11
+ import {fenceState} from './markdown.js';
12
+
13
+ export interface MdxContext {
14
+ readRaw: (importPath: string) => string;
15
+ storyLink: (
16
+ storiesImportPath: string,
17
+ exportName: string
18
+ ) => string | undefined;
19
+ /** The generated page for a Storybook docs route id, when there is one. */
20
+ docsRoute?: (id: string) => string | undefined;
21
+ site: string;
22
+ vars: Record<string, string | boolean>;
23
+ warn: (msg: string) => void;
24
+ }
25
+
26
+ const IMPORT_START = /^import\b/;
27
+ const IMPORT_END =
28
+ /\bfrom\s+['"][^'"]+['"]\s*;?\s*(\/\/.*)?$|^import\s+['"][^'"]+['"]\s*;?\s*(\/\/.*)?$/;
29
+ const DEFAULT_IMPORT = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/;
30
+ const NAMESPACE_IMPORT = /^import\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]/;
31
+ const MARKDOWN_PARTIAL = /^\s*<Markdown>\{(\w+)\}<\/Markdown>\s*$/;
32
+ const CANVAS = /^\s*<Canvas\s+of=\{(\w+)\.(\w+)\}[^>]*\/>\s*$/;
33
+ const CONTROLS = /^\s*<Controls\b[^>]*\/>\s*$/;
34
+ const META = /^\s*<Meta\b[^>]*\/>\s*$/;
35
+ // Layout wrappers around a table or a banner; the markdown inside stands alone.
36
+ const DIV = /^\s*<\/?div\b[^>]*>\s*$/;
37
+
38
+ export function mdxToMarkdown(source: string, ctx: MdxContext): string {
39
+ const lines = source.split('\n');
40
+ const idents = new Map<string, string>();
41
+ const out: string[] = [];
42
+ const fence = fenceState();
43
+ // Prose keeps at most one blank line between blocks; code keeps its own.
44
+ const push = (line: string) => {
45
+ if (!fence.inFence && line === '' && out[out.length - 1] === '') return;
46
+ out.push(line);
47
+ };
48
+
49
+ for (let i = 0; i < lines.length; i++) {
50
+ const line = lines[i];
51
+ if (fence.update(line) || fence.inFence) {
52
+ out.push(line);
53
+ continue;
54
+ }
55
+ if (IMPORT_START.test(line)) {
56
+ let stmt = line;
57
+ // An import may wrap its bindings over blank lines; markdown that follows
58
+ // an unfinished one (a heading, a tag) is where the statement ends.
59
+ while (!IMPORT_END.test(stmt) && i + 1 < lines.length) {
60
+ const next = lines[i + 1].trim();
61
+ if (/^(#|<)/.test(next)) {
62
+ ctx.warn(`llms.txt: unterminated import dropped: ${line}`);
63
+ break;
64
+ }
65
+ i++;
66
+ if (next) stmt += ` ${next}`;
67
+ }
68
+ const m = NAMESPACE_IMPORT.exec(stmt) ?? DEFAULT_IMPORT.exec(stmt);
69
+ if (m) idents.set(m[1], m[2]);
70
+ continue;
71
+ }
72
+ if (META.test(line) || CONTROLS.test(line) || DIV.test(line)) continue;
73
+ if (/^\{/.test(line)) {
74
+ i = skipExpressionBlock(lines, i);
75
+ continue;
76
+ }
77
+ const partial = MARKDOWN_PARTIAL.exec(line);
78
+ if (partial) {
79
+ const path = idents.get(partial[1]);
80
+ if (path) {
81
+ const partial = fenceState();
82
+ for (const raw of ctx.readRaw(path).replace(/\n$/, '').split('\n')) {
83
+ const delimiter = partial.update(raw);
84
+ push(
85
+ delimiter || partial.inFence
86
+ ? raw
87
+ : outsideCodeSpans(raw, (text) => storybookLinks(text, ctx))
88
+ );
89
+ }
90
+ } else
91
+ ctx.warn(
92
+ `llms.txt: <Markdown>{${partial[1]}}</Markdown> has no import`
93
+ );
94
+ continue;
95
+ }
96
+ const canvas = CANVAS.exec(line);
97
+ if (canvas) {
98
+ const path = idents.get(canvas[1]);
99
+ const link = path && ctx.storyLink(path, canvas[2]);
100
+ if (link) push(link);
101
+ continue;
102
+ }
103
+ push(
104
+ outsideCodeSpans(line, (text) =>
105
+ storybookLinks(inlineExpressions(text, ctx), ctx)
106
+ )
107
+ );
108
+ }
109
+
110
+ return out.join('\n').replace(/^\n+|\n+$/g, '');
111
+ }
112
+
113
+ /** A docs route gets its generated page when there is one; every other `?path=` link becomes absolute. */
114
+ function storybookLinks(text: string, ctx: MdxContext): string {
115
+ return text
116
+ .replace(/\]\(\?path=\/docs\/([\w-]+)--docs\)/g, (whole, id) => {
117
+ const page = ctx.docsRoute?.(id);
118
+ return page ? `](${page})` : whole;
119
+ })
120
+ .replace(/\]\(\?path=/g, `](${ctx.site}/?path=`);
121
+ }
122
+
123
+ /** Index of the last line of a `{ … }` block that starts at `start`; the block is JSX chrome and is dropped. */
124
+ function skipExpressionBlock(lines: string[], start: number): number {
125
+ let depth = 0;
126
+ for (let i = start; i < lines.length; i++) {
127
+ for (const ch of lines[i]) {
128
+ if (ch === '{') depth++;
129
+ else if (ch === '}') depth--;
130
+ }
131
+ if (depth <= 0) return i;
132
+ }
133
+ return lines.length - 1;
134
+ }
135
+
136
+ function outsideCodeSpans(line: string, fn: (text: string) => string): string {
137
+ return line
138
+ .split(/(`[^`]*`)/)
139
+ .map((part) => (part.startsWith('`') ? part : fn(part)))
140
+ .join('');
141
+ }
142
+
143
+ const str = (v: string | boolean | undefined): string =>
144
+ typeof v === 'string' ? v : v === undefined ? '' : String(v);
145
+
146
+ function inlineExpressions(text: string, ctx: MdxContext): string {
147
+ const truthy = (not: string, name: string): boolean =>
148
+ not === '!' ? !ctx.vars[name] : Boolean(ctx.vars[name]);
149
+ return text
150
+ .replace(
151
+ /<a href=\{(\w+)\}>([^<]*)<\/a>/g,
152
+ (_, name, label) => `[${label}](${str(ctx.vars[name])})`
153
+ )
154
+ .replace(
155
+ /\s?\{\s*(!?)(\w+)\s*&&\s*([^{}]*?)\s*\}/g,
156
+ (_, not, name, inner) => (truthy(not, name) ? ` ${inner}` : '')
157
+ )
158
+ .replace(
159
+ /\{\s*(!?)(\w+)\s*\?\s*'([^']*)'\s*:\s*'([^']*)'\s*\}/g,
160
+ (_, not, name, a, b) => (truthy(not, name) ? a : b)
161
+ )
162
+ .replace(/\{\s*(\w+)\s*\}/g, (whole, name) =>
163
+ name in ctx.vars
164
+ ? str(ctx.vars[name])
165
+ : (ctx.warn(`llms.txt: dropped expression ${whole}`), '')
166
+ )
167
+ .replace(
168
+ /\{[^{}]*\}/g,
169
+ (whole) => (ctx.warn(`llms.txt: dropped expression ${whole}`), '')
170
+ );
171
+ }