@aussieljk/forkbook 0.0.0-stage → 0.0.1-2

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 (598) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +77 -2
  3. package/assets/addon-vitest/templates/vitest.config.4.template.ts +36 -0
  4. package/assets/browser/favicon-wrapper.svg +46 -0
  5. package/assets/browser/favicon.svg +1 -0
  6. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  7. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  8. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  9. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  10. package/assets/builder-vite/iframe.html +99 -0
  11. package/assets/create/rendererAssets/.eslintrc.json +16 -0
  12. package/assets/create/rendererAssets/common/Configure.mdx +388 -0
  13. package/assets/create/rendererAssets/common/assets/accessibility.png +0 -0
  14. package/assets/create/rendererAssets/common/assets/accessibility.svg +1 -0
  15. package/assets/create/rendererAssets/common/assets/addon-library.png +0 -0
  16. package/assets/create/rendererAssets/common/assets/assets.png +0 -0
  17. package/assets/create/rendererAssets/common/assets/avif-test-image.avif +0 -0
  18. package/assets/create/rendererAssets/common/assets/context.png +0 -0
  19. package/assets/create/rendererAssets/common/assets/discord.svg +1 -0
  20. package/assets/create/rendererAssets/common/assets/docs.png +0 -0
  21. package/assets/create/rendererAssets/common/assets/figma-plugin.png +0 -0
  22. package/assets/create/rendererAssets/common/assets/github.svg +1 -0
  23. package/assets/create/rendererAssets/common/assets/share.png +0 -0
  24. package/assets/create/rendererAssets/common/assets/styling.png +0 -0
  25. package/assets/create/rendererAssets/common/assets/testing.png +0 -0
  26. package/assets/create/rendererAssets/common/assets/theming.png +0 -0
  27. package/assets/create/rendererAssets/common/assets/tutorials.svg +1 -0
  28. package/assets/create/rendererAssets/common/assets/youtube.svg +1 -0
  29. package/assets/create/rendererAssets/common/button.css +30 -0
  30. package/assets/create/rendererAssets/common/header.css +32 -0
  31. package/assets/create/rendererAssets/common/page.css +68 -0
  32. package/assets/create/templates/react-native/index.expo.js +20 -0
  33. package/assets/create/templates/react-native/index.js +25 -0
  34. package/assets/docs/addon-backgrounds.gif +0 -0
  35. package/assets/docs/addon-controls-args-annotated.png +0 -0
  36. package/assets/docs/addon-controls-args-background-color.png +0 -0
  37. package/assets/docs/addon-controls-args-background-string.png +0 -0
  38. package/assets/docs/addon-controls-args-docs.png +0 -0
  39. package/assets/docs/addon-controls-args-logging.png +0 -0
  40. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  41. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  42. package/assets/docs/addon-controls-args-reflow.png +0 -0
  43. package/assets/docs/addon-controls-args-template.png +0 -0
  44. package/assets/docs/addon-controls-expanded.png +0 -0
  45. package/assets/docs/addon-controls-hero.gif +0 -0
  46. package/assets/docs/addon-controls-install.png +0 -0
  47. package/assets/docs/hero.gif +0 -0
  48. package/assets/docs/highlight.png +0 -0
  49. package/assets/docs/message-reference.png +0 -0
  50. package/assets/docs/viewport.png +0 -0
  51. package/assets/react-native/metro-env.d.ts +69 -0
  52. package/assets/server/addon.tsconfig.json +6 -0
  53. package/assets/server/base-preview-body.html +116 -0
  54. package/assets/server/base-preview-head.html +494 -0
  55. package/assets/server/openBrowser.applescript +94 -0
  56. package/assets/server/template.ejs +87 -0
  57. package/dist/.build-stamp +0 -0
  58. package/dist/_browser-chunks/Color-PCLE2J36.js +1025 -0
  59. package/dist/_browser-chunks/DocsRenderer-JXND3PVQ.js +10 -0
  60. package/dist/_browser-chunks/WithTooltip-XSQFTBMB.js +1619 -0
  61. package/dist/_browser-chunks/chunk-2JDQ35OA.js +247 -0
  62. package/dist/_browser-chunks/chunk-2JT76G3E.js +104 -0
  63. package/dist/_browser-chunks/chunk-2MEPHP35.js +17 -0
  64. package/dist/_browser-chunks/chunk-2SCZVUKW.js +24 -0
  65. package/dist/_browser-chunks/chunk-46Z7NGAS.js +41 -0
  66. package/dist/_browser-chunks/chunk-4ATQOMJB.js +30 -0
  67. package/dist/_browser-chunks/chunk-52CW7FF7.js +49 -0
  68. package/dist/_browser-chunks/chunk-5I7E4GMO.js +62 -0
  69. package/dist/_browser-chunks/chunk-5P4QA6MY.js +20 -0
  70. package/dist/_browser-chunks/chunk-5WMXI5GW.js +816 -0
  71. package/dist/_browser-chunks/chunk-66OCZ54D.js +2604 -0
  72. package/dist/_browser-chunks/chunk-6SXYJQST.js +253 -0
  73. package/dist/_browser-chunks/chunk-AYRF6EJB.js +36 -0
  74. package/dist/_browser-chunks/chunk-B4AUNNU4.js +156 -0
  75. package/dist/_browser-chunks/chunk-BCP2FFXF.js +369 -0
  76. package/dist/_browser-chunks/chunk-C3D4HEFY.js +3396 -0
  77. package/dist/_browser-chunks/chunk-CFAOWGL7.js +43 -0
  78. package/dist/_browser-chunks/chunk-CFWWCCZV.js +223 -0
  79. package/dist/_browser-chunks/chunk-CNED6RYH.js +18 -0
  80. package/dist/_browser-chunks/chunk-DRQKCCAG.js +136 -0
  81. package/dist/_browser-chunks/chunk-ECQ75MKQ.js +0 -0
  82. package/dist/_browser-chunks/chunk-EIYAKDGP.js +302 -0
  83. package/dist/_browser-chunks/chunk-ENKK74N4.js +12 -0
  84. package/dist/_browser-chunks/chunk-FENFYI4X.js +698 -0
  85. package/dist/_browser-chunks/chunk-FJGWSWL5.js +155 -0
  86. package/dist/_browser-chunks/chunk-FVSEPWWX.js +2810 -0
  87. package/dist/_browser-chunks/chunk-GNZY6LOW.js +10116 -0
  88. package/dist/_browser-chunks/chunk-IE4ULIOQ.js +14 -0
  89. package/dist/_browser-chunks/chunk-IMSF75WX.js +42 -0
  90. package/dist/_browser-chunks/chunk-IWQGIXJS.js +14 -0
  91. package/dist/_browser-chunks/chunk-JMC7AIKT.js +108 -0
  92. package/dist/_browser-chunks/chunk-JPUOQJUI.js +8 -0
  93. package/dist/_browser-chunks/chunk-JSBKXXXF.js +218 -0
  94. package/dist/_browser-chunks/chunk-JWSKPMPC.js +73 -0
  95. package/dist/_browser-chunks/chunk-JYVGARBG.js +2943 -0
  96. package/dist/_browser-chunks/chunk-KBK7GKBN.js +35 -0
  97. package/dist/_browser-chunks/chunk-KQ7CRO2B.js +108 -0
  98. package/dist/_browser-chunks/chunk-LAWXTSXK.js +18 -0
  99. package/dist/_browser-chunks/chunk-LE2LTDW3.js +14 -0
  100. package/dist/_browser-chunks/chunk-LEVSOOLQ.js +48 -0
  101. package/dist/_browser-chunks/chunk-LV5PIKV4.js +93 -0
  102. package/dist/_browser-chunks/chunk-MDOL7KML.js +56 -0
  103. package/dist/_browser-chunks/chunk-MFMDGWP6.js +34 -0
  104. package/dist/_browser-chunks/chunk-MLBOOZL4.js +67 -0
  105. package/dist/_browser-chunks/chunk-NQUD4B7H.js +91 -0
  106. package/dist/_browser-chunks/chunk-NULBREPZ.js +43 -0
  107. package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
  108. package/dist/_browser-chunks/chunk-OD6IBQCC.js +117 -0
  109. package/dist/_browser-chunks/chunk-ODVJ3XZJ.js +157 -0
  110. package/dist/_browser-chunks/chunk-OQWFVDIN.js +386 -0
  111. package/dist/_browser-chunks/chunk-OVH3USFB.js +20 -0
  112. package/dist/_browser-chunks/chunk-OZZPSYQR.js +14 -0
  113. package/dist/_browser-chunks/chunk-P6PK47TQ.js +1970 -0
  114. package/dist/_browser-chunks/chunk-PFRNG3UC.js +22 -0
  115. package/dist/_browser-chunks/chunk-PJSMZ27A.js +13 -0
  116. package/dist/_browser-chunks/chunk-QC4HFS6K.js +41 -0
  117. package/dist/_browser-chunks/chunk-QDXFODK4.js +274 -0
  118. package/dist/_browser-chunks/chunk-RBCHTR7C.js +28 -0
  119. package/dist/_browser-chunks/chunk-RMYQ3QN3.js +294 -0
  120. package/dist/_browser-chunks/chunk-RNTIV5CE.js +411 -0
  121. package/dist/_browser-chunks/chunk-RSPAQWVJ.js +80 -0
  122. package/dist/_browser-chunks/chunk-S6TK43XQ.js +836 -0
  123. package/dist/_browser-chunks/chunk-SC67XZST.js +18 -0
  124. package/dist/_browser-chunks/chunk-SFVA4SBT.js +683 -0
  125. package/dist/_browser-chunks/chunk-SZYFOQMT.js +25 -0
  126. package/dist/_browser-chunks/chunk-TBJCJXK4.js +18 -0
  127. package/dist/_browser-chunks/chunk-UMDO3KB7.js +205 -0
  128. package/dist/_browser-chunks/chunk-V2G23FV7.js +11 -0
  129. package/dist/_browser-chunks/chunk-V5M7Q4HT.js +88 -0
  130. package/dist/_browser-chunks/chunk-W5M6NPS3.js +198 -0
  131. package/dist/_browser-chunks/chunk-W7NE2JXW.js +84 -0
  132. package/dist/_browser-chunks/chunk-WGVAAM43.js +1110 -0
  133. package/dist/_browser-chunks/chunk-WHQRNHXD.js +8 -0
  134. package/dist/_browser-chunks/chunk-WOSOWBCA.js +12 -0
  135. package/dist/_browser-chunks/chunk-WZ7KR7SH.js +85 -0
  136. package/dist/_browser-chunks/chunk-YEKO6BHJ.js +20 -0
  137. package/dist/_browser-chunks/chunk-YI2IBIQS.js +7 -0
  138. package/dist/_browser-chunks/chunk-YTIT5NA5.js +1966 -0
  139. package/dist/_browser-chunks/chunk-ZEHRUHTA.js +6 -0
  140. package/dist/_browser-chunks/chunk-ZTQ5MEJ5.js +203 -0
  141. package/dist/_browser-chunks/matchers-YLBYSYAF.js +1263 -0
  142. package/dist/_browser-chunks/react-dom-client-4OHE3QDV.js +9 -0
  143. package/dist/_node-chunks/attached-runtime-I2G4WLJI.js +282 -0
  144. package/dist/_node-chunks/builder-manager-VVHYQXCH.js +1661 -0
  145. package/dist/_node-chunks/chunk-2BUPBPFB.js +82 -0
  146. package/dist/_node-chunks/chunk-2DSIDINN.js +884 -0
  147. package/dist/_node-chunks/chunk-2RU7BKEW.js +23 -0
  148. package/dist/_node-chunks/chunk-34EO2PUT.js +26 -0
  149. package/dist/_node-chunks/chunk-3BKIBF5S.js +3008 -0
  150. package/dist/_node-chunks/chunk-3SDUYDXH.js +98 -0
  151. package/dist/_node-chunks/chunk-3T4ZSNPH.js +662 -0
  152. package/dist/_node-chunks/chunk-3W7F2B7P.js +79 -0
  153. package/dist/_node-chunks/chunk-3Y6AAY5H.js +80 -0
  154. package/dist/_node-chunks/chunk-42UWAGPW.js +1193 -0
  155. package/dist/_node-chunks/chunk-4FEANXWU.js +1986 -0
  156. package/dist/_node-chunks/chunk-5DQFEZEA.js +40 -0
  157. package/dist/_node-chunks/chunk-6KEHV53S.js +1218 -0
  158. package/dist/_node-chunks/chunk-6LMWA44H.js +3837 -0
  159. package/dist/_node-chunks/chunk-6YKBRP72.js +20 -0
  160. package/dist/_node-chunks/chunk-7GUDZVRQ.js +110 -0
  161. package/dist/_node-chunks/chunk-B5J7Q7J4.js +21 -0
  162. package/dist/_node-chunks/chunk-BS2WMZMR.js +90 -0
  163. package/dist/_node-chunks/chunk-BSKFCWQD.js +47 -0
  164. package/dist/_node-chunks/chunk-BXVYT7SB.js +36 -0
  165. package/dist/_node-chunks/chunk-CCOTJ4FC.js +688 -0
  166. package/dist/_node-chunks/chunk-CQKMLL5J.js +33 -0
  167. package/dist/_node-chunks/chunk-CXRU72ET.js +63 -0
  168. package/dist/_node-chunks/chunk-DC7DKR5K.js +20 -0
  169. package/dist/_node-chunks/chunk-DHJFTB4K.js +25 -0
  170. package/dist/_node-chunks/chunk-DUR55DJJ.js +1094 -0
  171. package/dist/_node-chunks/chunk-E6YESGLX.js +7032 -0
  172. package/dist/_node-chunks/chunk-EHUNOMDD.js +52345 -0
  173. package/dist/_node-chunks/chunk-ET7PWEO7.js +298 -0
  174. package/dist/_node-chunks/chunk-EWOX7HPJ.js +20 -0
  175. package/dist/_node-chunks/chunk-F3ZFKBHY.js +844 -0
  176. package/dist/_node-chunks/chunk-FK7KGTV7.js +26 -0
  177. package/dist/_node-chunks/chunk-FPZB5OI7.js +35 -0
  178. package/dist/_node-chunks/chunk-FW2HQUBQ.js +25 -0
  179. package/dist/_node-chunks/chunk-FY6UXW6G.js +11 -0
  180. package/dist/_node-chunks/chunk-GEFQN7K3.js +499 -0
  181. package/dist/_node-chunks/chunk-GRBLDJCR.js +989 -0
  182. package/dist/_node-chunks/chunk-H32DYT6P.js +87 -0
  183. package/dist/_node-chunks/chunk-H4PPVMP5.js +23 -0
  184. package/dist/_node-chunks/chunk-HMP2G23X.js +25 -0
  185. package/dist/_node-chunks/chunk-ICPBH3E7.js +59 -0
  186. package/dist/_node-chunks/chunk-IDEL2J23.js +23 -0
  187. package/dist/_node-chunks/chunk-IK4FGZLR.js +223 -0
  188. package/dist/_node-chunks/chunk-JDXXX6LB.js +68 -0
  189. package/dist/_node-chunks/chunk-JGGFYIG5.js +5468 -0
  190. package/dist/_node-chunks/chunk-JPAZLYJ3.js +29 -0
  191. package/dist/_node-chunks/chunk-JZOO7GGC.js +48 -0
  192. package/dist/_node-chunks/chunk-KISMCCP5.js +4744 -0
  193. package/dist/_node-chunks/chunk-LCK4ZQKG.js +115 -0
  194. package/dist/_node-chunks/chunk-LO56I6E2.js +132 -0
  195. package/dist/_node-chunks/chunk-LXBD4UL4.js +104 -0
  196. package/dist/_node-chunks/chunk-MA24JW6C.js +7162 -0
  197. package/dist/_node-chunks/chunk-MK2KYAI6.js +5414 -0
  198. package/dist/_node-chunks/chunk-NDWKJ4CL.js +2102 -0
  199. package/dist/_node-chunks/chunk-NIBT7XDZ.js +168 -0
  200. package/dist/_node-chunks/chunk-NPO45IMH.js +33 -0
  201. package/dist/_node-chunks/chunk-OISX4AGQ.js +414 -0
  202. package/dist/_node-chunks/chunk-OUW6R7C3.js +26 -0
  203. package/dist/_node-chunks/chunk-OWNFOGTA.js +194 -0
  204. package/dist/_node-chunks/chunk-Q7QNUM5H.js +49 -0
  205. package/dist/_node-chunks/chunk-QEQLR22M.js +1877 -0
  206. package/dist/_node-chunks/chunk-RRN2V55B.js +45 -0
  207. package/dist/_node-chunks/chunk-RWFIFGO5.js +144 -0
  208. package/dist/_node-chunks/chunk-RXNJDRGO.js +209 -0
  209. package/dist/_node-chunks/chunk-RZMQ7S3L.js +92 -0
  210. package/dist/_node-chunks/chunk-SIEXZVCR.js +51 -0
  211. package/dist/_node-chunks/chunk-SLWQNBGO.js +2034 -0
  212. package/dist/_node-chunks/chunk-SVTBJ7Q3.js +35 -0
  213. package/dist/_node-chunks/chunk-SWO5CDYU.js +32 -0
  214. package/dist/_node-chunks/chunk-TD5PLLQG.js +121 -0
  215. package/dist/_node-chunks/chunk-TEQGGSP7.js +33 -0
  216. package/dist/_node-chunks/chunk-TFCEV2XX.js +155 -0
  217. package/dist/_node-chunks/chunk-TFEWM4E3.js +1073 -0
  218. package/dist/_node-chunks/chunk-TINO74G5.js +21 -0
  219. package/dist/_node-chunks/chunk-TNJIXE37.js +40 -0
  220. package/dist/_node-chunks/chunk-TWI4GVH7.js +19 -0
  221. package/dist/_node-chunks/chunk-U5W53R2J.js +1011 -0
  222. package/dist/_node-chunks/chunk-UBOGWBEA.js +148 -0
  223. package/dist/_node-chunks/chunk-UMUBKI6E.js +3787 -0
  224. package/dist/_node-chunks/chunk-UVINFLGY.js +56 -0
  225. package/dist/_node-chunks/chunk-V2DY426G.js +1133 -0
  226. package/dist/_node-chunks/chunk-VLOXOXXE.js +45 -0
  227. package/dist/_node-chunks/chunk-W4OMYLSP.js +1297 -0
  228. package/dist/_node-chunks/chunk-WAXVSN3O.js +18 -0
  229. package/dist/_node-chunks/chunk-WCULS5TP.js +3767 -0
  230. package/dist/_node-chunks/chunk-WNZ2UMFM.js +153 -0
  231. package/dist/_node-chunks/chunk-WZJF2OUH.js +74 -0
  232. package/dist/_node-chunks/chunk-XGIUVY52.js +611 -0
  233. package/dist/_node-chunks/chunk-XHL2LVBM.js +415 -0
  234. package/dist/_node-chunks/chunk-XI6B6P47.js +59 -0
  235. package/dist/_node-chunks/chunk-XLP2ZKXV.js +60 -0
  236. package/dist/_node-chunks/chunk-YCMRA6RX.js +95 -0
  237. package/dist/_node-chunks/chunk-YZFWBA5L.js +2700 -0
  238. package/dist/_node-chunks/chunk-ZMAMXQKP.js +4731 -0
  239. package/dist/_node-chunks/chunk-ZWBCQ4MJ.js +110 -0
  240. package/dist/_node-chunks/dist-VTSTZKUB.js +16 -0
  241. package/dist/_node-chunks/globby-OEMHPBFY.js +2884 -0
  242. package/dist/_node-chunks/jiti-NFX6UU74.js +3848 -0
  243. package/dist/_node-chunks/lib-MDVARD7W.js +366 -0
  244. package/dist/_node-chunks/local-runtime-NTKIN2QT.js +78 -0
  245. package/dist/_node-chunks/mdx-plugin-MWISDWDQ.js +5680 -0
  246. package/dist/_node-chunks/monorepo-LIRFMQXE.js +121 -0
  247. package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-CPDW4XTW.js +121 -0
  248. package/dist/_node-chunks/optimized-tests-HDOLR3EY.js +22 -0
  249. package/dist/_node-chunks/pattern-copy-play-EKHIUAU2.js +807 -0
  250. package/dist/_node-chunks/postinstallAddon-GYGMWDL6.js +20 -0
  251. package/dist/_node-chunks/rehype-external-links-BUN3HUCO.js +121 -0
  252. package/dist/_node-chunks/rehype-slug-PLADX223.js +52 -0
  253. package/dist/_node-chunks/relaxed-limits-GBHW6KIQ.js +117 -0
  254. package/dist/_node-chunks/run-KDTIZNSY.js +103 -0
  255. package/dist/_node-chunks/run-NL66VTNR.js +4532 -0
  256. package/dist/_node-chunks/session-id-KIIVOQLR.js +23 -0
  257. package/dist/_node-chunks/setup-MGC7BQO6.js +278 -0
  258. package/dist/_node-chunks/vitest.config.4.template-JH2THZFG.js +54 -0
  259. package/dist/actions/decorator.d.ts +7 -0
  260. package/dist/actions/decorator.js +43 -0
  261. package/dist/actions/index.d.ts +67 -0
  262. package/dist/actions/index.js +28 -0
  263. package/dist/addon-a11y/index.d.ts +52 -0
  264. package/dist/addon-a11y/index.js +16 -0
  265. package/dist/addon-a11y/manager.js +1429 -0
  266. package/dist/addon-a11y/preset.js +18 -0
  267. package/dist/addon-a11y/preview.d.ts +17 -0
  268. package/dist/addon-a11y/preview.js +15 -0
  269. package/dist/addon-docs/blocks.d.ts +1061 -0
  270. package/dist/addon-docs/blocks.js +2461 -0
  271. package/dist/addon-docs/index.d.ts +236 -0
  272. package/dist/addon-docs/index.js +16 -0
  273. package/dist/addon-docs/manager.js +90 -0
  274. package/dist/addon-docs/mdx-react-shim.d.ts +1 -0
  275. package/dist/addon-docs/mdx-react-shim.js +2 -0
  276. package/dist/addon-docs/preset.js +378 -0
  277. package/dist/addon-docs/preview.d.ts +4 -0
  278. package/dist/addon-docs/preview.js +7 -0
  279. package/dist/addon-links/index.d.ts +22 -0
  280. package/dist/addon-links/index.js +20 -0
  281. package/dist/addon-links/manager.js +14 -0
  282. package/dist/addon-links/preview.d.ts +6 -0
  283. package/dist/addon-links/preview.js +9 -0
  284. package/dist/addon-links/react/index.d.ts +25 -0
  285. package/dist/addon-links/react/index.js +52 -0
  286. package/dist/addon-mcp/preset.js +1345 -0
  287. package/dist/addon-mcp/preview.js +29 -0
  288. package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +1153 -0
  289. package/dist/addon-ondevice-actions/index.d.ts +4 -0
  290. package/dist/addon-ondevice-actions/index.js +7 -0
  291. package/dist/addon-ondevice-actions/register.js +7 -0
  292. package/dist/addon-ondevice-controls/index.d.ts +6 -0
  293. package/dist/addon-ondevice-controls/index.js +14 -0
  294. package/dist/addon-ondevice-controls/register.js +10 -0
  295. package/dist/addon-pseudo-states/index.d.ts +35 -0
  296. package/dist/addon-pseudo-states/index.js +15 -0
  297. package/dist/addon-pseudo-states/manager.js +53 -0
  298. package/dist/addon-pseudo-states/preview.d.ts +9 -0
  299. package/dist/addon-pseudo-states/preview.js +10 -0
  300. package/dist/addon-themes/index.d.ts +80 -0
  301. package/dist/addon-themes/index.js +104 -0
  302. package/dist/addon-themes/manager.js +97 -0
  303. package/dist/addon-themes/postinstall.js +33 -0
  304. package/dist/addon-themes/preview.d.ts +6 -0
  305. package/dist/addon-themes/preview.js +8 -0
  306. package/dist/addon-vitest/constants.d.ts +132 -0
  307. package/dist/addon-vitest/constants.js +66 -0
  308. package/dist/addon-vitest/index.d.ts +4 -0
  309. package/dist/addon-vitest/index.js +8 -0
  310. package/dist/addon-vitest/manager.js +665 -0
  311. package/dist/addon-vitest/node/coverage-reporter.js +1284 -0
  312. package/dist/addon-vitest/node/vitest.js +674 -0
  313. package/dist/addon-vitest/postinstall.js +24 -0
  314. package/dist/addon-vitest/preset.js +943 -0
  315. package/dist/addon-vitest/vitest-plugin/global-setup.js +162 -0
  316. package/dist/addon-vitest/vitest-plugin/index.d.ts +56 -0
  317. package/dist/addon-vitest/vitest-plugin/index.js +463 -0
  318. package/dist/addon-vitest/vitest-plugin/setup-file-with-project-annotations.js +9 -0
  319. package/dist/addon-vitest/vitest-plugin/setup-file.browser.4.js +20 -0
  320. package/dist/addon-vitest/vitest-plugin/setup-file.js +50 -0
  321. package/dist/addon-vitest/vitest-plugin/test-utils.js +128 -0
  322. package/dist/babel/index.d.ts +2301 -0
  323. package/dist/babel/index.js +61 -0
  324. package/dist/backgrounds/index.d.ts +6 -0
  325. package/dist/backgrounds/index.js +15 -0
  326. package/dist/bin/core.js +1705 -0
  327. package/dist/bin/dispatcher.js +43 -0
  328. package/dist/bin/loader.js +115 -0
  329. package/dist/builder-vite/index.d.ts +50 -0
  330. package/dist/builder-vite/index.js +245 -0
  331. package/dist/builder-vite/preset.js +27 -0
  332. package/dist/channels/index.d.ts +2 -0
  333. package/dist/channels/index.js +352 -0
  334. package/dist/chunk-B2t1tGRh.d.ts +284 -0
  335. package/dist/chunk-BCoJQE-f.d.ts +602 -0
  336. package/dist/chunk-BGkgZp-H.d.ts +214 -0
  337. package/dist/chunk-BTVrWliM.d.ts +115 -0
  338. package/dist/chunk-BXLImeLy.d.ts +197 -0
  339. package/dist/chunk-BfBzpgct.d.ts +916 -0
  340. package/dist/chunk-Bpi2tz-6.d.ts +511 -0
  341. package/dist/chunk-BxWufQms.d.ts +142 -0
  342. package/dist/chunk-C-bavsOH.d.ts +34 -0
  343. package/dist/chunk-C2p5r3Vt.d.ts +13001 -0
  344. package/dist/chunk-C6PAgHLT.d.ts +12 -0
  345. package/dist/chunk-CMeX4WRe.d.ts +179 -0
  346. package/dist/chunk-Ct9xd6IM.d.ts +65 -0
  347. package/dist/chunk-CwQKNaYL.d.ts +15 -0
  348. package/dist/chunk-D7DwV41f.d.ts +3622 -0
  349. package/dist/chunk-DEVFdzxR.d.ts +253 -0
  350. package/dist/chunk-DaVb55-_.d.ts +124 -0
  351. package/dist/chunk-DgRNfmj_.d.ts +40 -0
  352. package/dist/chunk-DoIGKY33.d.ts +666 -0
  353. package/dist/chunk-Dr3R0DXk.d.ts +40 -0
  354. package/dist/chunk-DtHByo32.d.ts +55 -0
  355. package/dist/chunk-Dw1z1Pki.d.ts +933 -0
  356. package/dist/chunk-DzuY9DXg.d.ts +79 -0
  357. package/dist/chunk-FjDVzZTj.d.ts +62 -0
  358. package/dist/chunk-Kt1tW-D1.d.ts +59 -0
  359. package/dist/chunk-XP8oHzpE.d.ts +6 -0
  360. package/dist/chunk-gCX81nOr.d.ts +61 -0
  361. package/dist/chunk-pcFXCimE.d.ts +741 -0
  362. package/dist/cli/index.d.ts +1174 -0
  363. package/dist/cli/index.js +5613 -0
  364. package/dist/cli/skills/content/index.d.ts +72 -0
  365. package/dist/cli/skills/content/index.js +335 -0
  366. package/dist/cli/tools/sdk/child-host.d.ts +61 -0
  367. package/dist/cli/tools/sdk/child-host.js +131 -0
  368. package/dist/cli/tools/sdk/index.d.ts +137 -0
  369. package/dist/cli/tools/sdk/index.js +44 -0
  370. package/dist/cli-commands/bin/index.js +25 -0
  371. package/dist/client-logger/index.d.ts +31 -0
  372. package/dist/client-logger/index.js +63 -0
  373. package/dist/common/index.d.ts +1103 -0
  374. package/dist/common/index.js +364 -0
  375. package/dist/components/index.d.ts +1924 -0
  376. package/dist/components/index.js +13759 -0
  377. package/dist/core-events/index.d.ts +155 -0
  378. package/dist/core-events/index.js +136 -0
  379. package/dist/core-server/index.d.ts +2200 -0
  380. package/dist/core-server/index.js +4165 -0
  381. package/dist/core-server/presets/common-manager.css +170 -0
  382. package/dist/core-server/presets/common-manager.js +4168 -0
  383. package/dist/core-server/presets/common-override-preset.js +81 -0
  384. package/dist/core-server/presets/common-preset.js +2187 -0
  385. package/dist/create/bin/index.js +23 -0
  386. package/dist/create/index.js +25 -0
  387. package/dist/csf/csf-utils.d.ts +2 -0
  388. package/dist/csf/csf-utils.js +19 -0
  389. package/dist/csf/index.d.ts +7 -0
  390. package/dist/csf/index.js +2142 -0
  391. package/dist/csf-tools/index.d.ts +1157 -0
  392. package/dist/csf-tools/index.js +736 -0
  393. package/dist/docs-tools/index.d.ts +197 -0
  394. package/dist/docs-tools/index.js +61 -0
  395. package/dist/highlight/index.d.ts +10 -0
  396. package/dist/highlight/index.js +15 -0
  397. package/dist/instrumenter/index.d.ts +113 -0
  398. package/dist/instrumenter/index.js +2595 -0
  399. package/dist/manager/_manager-chunks/globals-runtime-8HkdnU2F.js +6144 -0
  400. package/dist/manager/_manager-chunks/globals-runtime-BIKBO23x.js +3389 -0
  401. package/dist/manager/_manager-chunks/globals-runtime-BdGkqNEt.js +45 -0
  402. package/dist/manager/_manager-chunks/globals-runtime-BmphMP6z.js +1190 -0
  403. package/dist/manager/_manager-chunks/globals-runtime-BvM-NY2g.js +13307 -0
  404. package/dist/manager/_manager-chunks/globals-runtime-C02fvgcd.js +9243 -0
  405. package/dist/manager/_manager-chunks/globals-runtime-DkAPXCvc.js +9766 -0
  406. package/dist/manager/_manager-chunks/globals-runtime-DpNYC-qi.js +5564 -0
  407. package/dist/manager/_manager-chunks/globals-runtime-DtcOnYHR.js +5357 -0
  408. package/dist/manager/_manager-chunks/globals-runtime-DwFqpqya.js +722 -0
  409. package/dist/manager/_manager-chunks/globals-runtime-FC201B7s.js +6837 -0
  410. package/dist/manager/_manager-chunks/globals-runtime-Rp_zjGnh.js +121 -0
  411. package/dist/manager/_manager-chunks/globals-runtime-ZHrQFa3-.js +10463 -0
  412. package/dist/manager/_manager-chunks/globals-runtime-eLPTIfX-.js +7759 -0
  413. package/dist/manager/_manager-chunks/globals-runtime-qKvCZHFY.js +4468 -0
  414. package/dist/manager/_manager-chunks/globals-runtime-sGpNlIJ1.js +5102 -0
  415. package/dist/manager/_manager-chunks/runtime-B1L9TH89.js +452 -0
  416. package/dist/manager/_manager-chunks/runtime-BK0zF7FN.js +22 -0
  417. package/dist/manager/_manager-chunks/runtime-BhkT2CXl.js +1408 -0
  418. package/dist/manager/_manager-chunks/runtime-Bly6WJLN.js +998 -0
  419. package/dist/manager/_manager-chunks/runtime-D0UOWx0U.js +979 -0
  420. package/dist/manager/_manager-chunks/runtime-D94Vq3oR.js +4014 -0
  421. package/dist/manager/_manager-chunks/runtime-DMig8mT7.js +77 -0
  422. package/dist/manager/_manager-chunks/runtime-EITvVbkG.js +46 -0
  423. package/dist/manager/_manager-chunks/runtime-cp5pazY2.js +8936 -0
  424. package/dist/manager/_manager-chunks/runtime-eDVAYF7N.js +6860 -0
  425. package/dist/manager/_manager-chunks/runtime-i-PDAHLR.js +2493 -0
  426. package/dist/manager/globals-runtime.js +2 -0
  427. package/dist/manager/globals.d.ts +23 -0
  428. package/dist/manager/globals.js +26 -0
  429. package/dist/manager/manager-stores.d.ts +2 -0
  430. package/dist/manager/manager-stores.js +19 -0
  431. package/dist/manager/runtime.js +2 -0
  432. package/dist/manager-api/index.d.ts +2 -0
  433. package/dist/manager-api/index.js +3257 -0
  434. package/dist/manager-errors.d.ts +89 -0
  435. package/dist/manager-errors.js +20 -0
  436. package/dist/mcp/index.d.ts +270 -0
  437. package/dist/mcp/index.js +305 -0
  438. package/dist/mocking-utils/index.d.ts +689 -0
  439. package/dist/mocking-utils/index.js +521 -0
  440. package/dist/mocking-utils/mocker-runtime.js +1254 -0
  441. package/dist/nextjs-vite/config/preview.js +3 -0
  442. package/dist/nextjs-vite/export-mocks/cache/index.d.ts +25 -0
  443. package/dist/nextjs-vite/export-mocks/cache/index.js +29 -0
  444. package/dist/nextjs-vite/export-mocks/headers/index.d.ts +37 -0
  445. package/dist/nextjs-vite/export-mocks/headers/index.js +54 -0
  446. package/dist/nextjs-vite/export-mocks/link/index.d.ts +9 -0
  447. package/dist/nextjs-vite/export-mocks/link/index.js +59 -0
  448. package/dist/nextjs-vite/export-mocks/navigation/index.d.ts +28 -0
  449. package/dist/nextjs-vite/export-mocks/navigation/index.js +58 -0
  450. package/dist/nextjs-vite/export-mocks/router/index.d.ts +34 -0
  451. package/dist/nextjs-vite/export-mocks/router/index.js +63 -0
  452. package/dist/nextjs-vite/index.d.ts +92 -0
  453. package/dist/nextjs-vite/index.js +58 -0
  454. package/dist/nextjs-vite/node/index.d.ts +6 -0
  455. package/dist/nextjs-vite/node/index.js +20 -0
  456. package/dist/nextjs-vite/preset.js +648 -0
  457. package/dist/nextjs-vite/preview.d.ts +20 -0
  458. package/dist/nextjs-vite/preview.js +11 -0
  459. package/dist/nextjs-vite/vite-plugin/index.d.ts +6 -0
  460. package/dist/nextjs-vite/vite-plugin/index.js +19 -0
  461. package/dist/nextjs-vite-plugin/index.d.ts +28 -0
  462. package/dist/nextjs-vite-plugin/index.js +923 -0
  463. package/dist/nextjs-vite-plugin/mocks/storybook.global.js +29 -0
  464. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-context.js +8 -0
  465. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-default-loader.js +23 -0
  466. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-image.js +28 -0
  467. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-legacy-image.js +17 -0
  468. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/cache/index.js +29 -0
  469. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/dynamic/index.js +40 -0
  470. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/headers/index.js +55 -0
  471. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/link/index.js +63 -0
  472. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/navigation/index.js +71 -0
  473. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/router/index.js +74 -0
  474. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/rsc/server-only.js +7 -0
  475. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/safe-stable-stringify/index.js +13 -0
  476. package/dist/nextjs-vite-plugin/plugins/next-mocks/compatibility/draft-mode.compat.js +7 -0
  477. package/dist/node-logger/index.d.ts +495 -0
  478. package/dist/node-logger/index.js +42 -0
  479. package/dist/oxc-parser/index.d.ts +99 -0
  480. package/dist/oxc-parser/index.js +275 -0
  481. package/dist/oxc-parser/worker.js +37 -0
  482. package/dist/preview/_chunks/runtime-BIzIdDbb.js +10263 -0
  483. package/dist/preview/_chunks/runtime-BTPtVY1p.js +1102 -0
  484. package/dist/preview/_chunks/runtime-BZSnICCg.js +8484 -0
  485. package/dist/preview/_chunks/runtime-BdGkqNEt.js +45 -0
  486. package/dist/preview/_chunks/runtime-BwSxqk3t.js +63 -0
  487. package/dist/preview/_chunks/runtime-CqHxptiK.js +6143 -0
  488. package/dist/preview/_chunks/runtime-CsV4HZPV.js +5064 -0
  489. package/dist/preview/_chunks/runtime-CxZK_Ln3.js +284 -0
  490. package/dist/preview/_chunks/runtime-DZToXfvO.js +9767 -0
  491. package/dist/preview/_chunks/runtime-DrTjJkPY.js +3872 -0
  492. package/dist/preview/_chunks/runtime-DuHdxMFA.js +387 -0
  493. package/dist/preview/_chunks/runtime-iXdo8CR8.js +3635 -0
  494. package/dist/preview/_chunks/runtime-q3wt0e_N.js +6838 -0
  495. package/dist/preview/globals.d.ts +16 -0
  496. package/dist/preview/globals.js +20 -0
  497. package/dist/preview/runtime.js +6 -0
  498. package/dist/preview-api/index.d.ts +4 -0
  499. package/dist/preview-api/index.js +147 -0
  500. package/dist/preview-errors.d.ts +186 -0
  501. package/dist/preview-errors.js +56 -0
  502. package/dist/react/docgen/docgen-worker.js +38 -0
  503. package/dist/react/entry-preview-argtypes.js +9 -0
  504. package/dist/react/entry-preview-docs.js +12 -0
  505. package/dist/react/entry-preview-rsc.js +11 -0
  506. package/dist/react/entry-preview.js +21 -0
  507. package/dist/react/index.d.ts +119 -0
  508. package/dist/react/index.js +26 -0
  509. package/dist/react/preset.js +301 -0
  510. package/dist/react/preview.d.ts +2 -0
  511. package/dist/react/preview.js +11 -0
  512. package/dist/react-native/bin/get-stories.js +34 -0
  513. package/dist/react-native/index.d.ts +160 -0
  514. package/dist/react-native/index.js +1547 -0
  515. package/dist/react-native/metro/node.d.ts +83 -0
  516. package/dist/react-native/metro/node.js +21 -0
  517. package/dist/react-native/metro/withStorybook.d.ts +2269 -0
  518. package/dist/react-native/metro/withStorybook.js +138 -0
  519. package/dist/react-native/preview.d.ts +6 -0
  520. package/dist/react-native/preview.js +20 -0
  521. package/dist/react-native/scripts/generate.d.ts +22 -0
  522. package/dist/react-native/scripts/generate.js +18 -0
  523. package/dist/react-native/stub.js +20 -0
  524. package/dist/react-native-theming/index.d.ts +175 -0
  525. package/dist/react-native-theming/index.js +2591 -0
  526. package/dist/react-native-ui/index.d.ts +130 -0
  527. package/dist/react-native-ui/index.js +1448 -0
  528. package/dist/react-native-ui-common/index.d.ts +230 -0
  529. package/dist/react-native-ui-common/index.js +514 -0
  530. package/dist/react-vite/index.d.ts +4 -0
  531. package/dist/react-vite/index.js +8 -0
  532. package/dist/react-vite/node/index.d.ts +6 -0
  533. package/dist/react-vite/node/index.js +20 -0
  534. package/dist/react-vite/preset.d.ts +6 -0
  535. package/dist/react-vite/preset.js +21 -0
  536. package/dist/router/index.d.ts +141 -0
  537. package/dist/router/index.js +1217 -0
  538. package/dist/server-errors.d.ts +2 -0
  539. package/dist/server-errors.js +149 -0
  540. package/dist/shared/open-service/index.d.ts +3 -0
  541. package/dist/shared/open-service/index.js +115 -0
  542. package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +75 -0
  543. package/dist/shared/open-service/toolsets/docs/public.d.ts +1296 -0
  544. package/dist/shared/open-service/toolsets/docs/public.js +991 -0
  545. package/dist/telemetry/index.d.ts +314 -0
  546. package/dist/telemetry/index.js +103 -0
  547. package/dist/test/index.d.ts +158 -0
  548. package/dist/test/index.js +19421 -0
  549. package/dist/theming/create.d.ts +15 -0
  550. package/dist/theming/create.js +11 -0
  551. package/dist/theming/index.d.ts +54 -0
  552. package/dist/theming/index.js +511 -0
  553. package/dist/types/index.d.ts +2 -0
  554. package/dist/types/index.js +48 -0
  555. package/dist/viewport/index.d.ts +275 -0
  556. package/dist/viewport/index.js +21 -0
  557. package/package.json +1054 -4
  558. package/template/nextjs-vite/cli/.eslintrc.json +6 -0
  559. package/template/nextjs-vite/cli/js/Button.jsx +42 -0
  560. package/template/nextjs-vite/cli/js/Button.stories.js +49 -0
  561. package/template/nextjs-vite/cli/js/Configure.mdx +470 -0
  562. package/template/nextjs-vite/cli/js/Header.jsx +58 -0
  563. package/template/nextjs-vite/cli/js/Header.stories.js +30 -0
  564. package/template/nextjs-vite/cli/js/Page.jsx +68 -0
  565. package/template/nextjs-vite/cli/js/Page.stories.js +28 -0
  566. package/template/nextjs-vite/cli/ts/Button.stories.ts +54 -0
  567. package/template/nextjs-vite/cli/ts/Button.tsx +39 -0
  568. package/template/nextjs-vite/cli/ts/Configure.mdx +446 -0
  569. package/template/nextjs-vite/cli/ts/Header.stories.ts +34 -0
  570. package/template/nextjs-vite/cli/ts/Header.tsx +54 -0
  571. package/template/nextjs-vite/cli/ts/Page.stories.ts +33 -0
  572. package/template/nextjs-vite/cli/ts/Page.tsx +73 -0
  573. package/template/react/cli/.eslintrc.json +5 -0
  574. package/template/react/cli/js/Button.jsx +39 -0
  575. package/template/react/cli/js/Button.stories.js +49 -0
  576. package/template/react/cli/js/Header.jsx +56 -0
  577. package/template/react/cli/js/Header.stories.js +29 -0
  578. package/template/react/cli/js/Page.jsx +69 -0
  579. package/template/react/cli/js/Page.stories.js +28 -0
  580. package/template/react/cli/ts/Button.stories.ts +54 -0
  581. package/template/react/cli/ts/Button.tsx +37 -0
  582. package/template/react/cli/ts/Header.stories.ts +34 -0
  583. package/template/react/cli/ts/Header.tsx +56 -0
  584. package/template/react/cli/ts/Page.stories.ts +33 -0
  585. package/template/react/cli/ts/Page.tsx +73 -0
  586. package/template/react-vite/cli/.eslintrc.json +5 -0
  587. package/template/react-vite/cli/js/Button.jsx +39 -0
  588. package/template/react-vite/cli/js/Button.stories.js +49 -0
  589. package/template/react-vite/cli/js/Header.jsx +56 -0
  590. package/template/react-vite/cli/js/Header.stories.js +29 -0
  591. package/template/react-vite/cli/js/Page.jsx +69 -0
  592. package/template/react-vite/cli/js/Page.stories.js +28 -0
  593. package/template/react-vite/cli/ts/Button.stories.ts +54 -0
  594. package/template/react-vite/cli/ts/Button.tsx +37 -0
  595. package/template/react-vite/cli/ts/Header.stories.ts +34 -0
  596. package/template/react-vite/cli/ts/Header.tsx +56 -0
  597. package/template/react-vite/cli/ts/Page.stories.ts +33 -0
  598. package/template/react-vite/cli/ts/Page.tsx +73 -0
@@ -0,0 +1,2187 @@
1
+ import CJS_COMPAT_NODE_URL_ro17f80mg6k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_ro17f80mg6k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_ro17f80mg6k from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_ro17f80mg6k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_ro17f80mg6k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_ro17f80mg6k.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Forkbook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ getAiSetupRunId
14
+ } from "../../_node-chunks/chunk-NPO45IMH.js";
15
+ import {
16
+ REVIEW_EVENTS
17
+ } from "../../_node-chunks/chunk-TINO74G5.js";
18
+ import {
19
+ GitDiffProvider,
20
+ applyServicesPresetOnce,
21
+ createCompositionDocsSources,
22
+ createDocsToolset,
23
+ createLocalDocsAccess,
24
+ createStoriesToolset,
25
+ defineService,
26
+ docgenQueryStaticPath,
27
+ fullTestProviderStore,
28
+ getChangeDetectionReadiness,
29
+ getComponentCandidates,
30
+ getPreviewBuilder,
31
+ getRefsFromConfig,
32
+ getSyncedStatuses,
33
+ getWsToken,
34
+ loadManifests,
35
+ mapStaticDir,
36
+ parseStaticDir,
37
+ prependImportToSnippet,
38
+ registerModuleGraphService,
39
+ reviewToolset,
40
+ runStoryTests,
41
+ sendTelemetryError,
42
+ sourceUrlManifestProvider,
43
+ storyDocsQueryStaticPath
44
+ } from "../../_node-chunks/chunk-E6YESGLX.js";
45
+ import "../../_node-chunks/chunk-OISX4AGQ.js";
46
+ import "../../_node-chunks/chunk-XGIUVY52.js";
47
+ import "../../_node-chunks/chunk-TFCEV2XX.js";
48
+ import "../../_node-chunks/chunk-Q7QNUM5H.js";
49
+ import {
50
+ registerToolset
51
+ } from "../../_node-chunks/chunk-3Y6AAY5H.js";
52
+ import "../../_node-chunks/chunk-BSKFCWQD.js";
53
+ import "../../_node-chunks/chunk-ICPBH3E7.js";
54
+ import "../../_node-chunks/chunk-EWOX7HPJ.js";
55
+ import {
56
+ getComponentIdFromEntry,
57
+ getStoryImportPathFromEntry,
58
+ isEligibleStoryEntry,
59
+ selectComponentEntriesByComponentId
60
+ } from "../../_node-chunks/chunk-MK2KYAI6.js";
61
+ import "../../_node-chunks/chunk-IDEL2J23.js";
62
+ import "../../_node-chunks/chunk-BXVYT7SB.js";
63
+ import {
64
+ getService,
65
+ registerService
66
+ } from "../../_node-chunks/chunk-SLWQNBGO.js";
67
+ import "../../_node-chunks/chunk-4FEANXWU.js";
68
+ import "../../_node-chunks/chunk-TEQGGSP7.js";
69
+ import "../../_node-chunks/chunk-OWNFOGTA.js";
70
+ import "../../_node-chunks/chunk-HMP2G23X.js";
71
+ import "../../_node-chunks/chunk-3W7F2B7P.js";
72
+ import "../../_node-chunks/chunk-OUW6R7C3.js";
73
+ import "../../_node-chunks/chunk-SVTBJ7Q3.js";
74
+ import "../../_node-chunks/chunk-WNZ2UMFM.js";
75
+ import "../../_node-chunks/chunk-RRN2V55B.js";
76
+ import "../../_node-chunks/chunk-JDXXX6LB.js";
77
+ import {
78
+ invariant
79
+ } from "../../_node-chunks/chunk-34EO2PUT.js";
80
+ import {
81
+ importMetaResolve,
82
+ resolvePackageDir
83
+ } from "../../_node-chunks/chunk-F3ZFKBHY.js";
84
+ import "../../_node-chunks/chunk-TNJIXE37.js";
85
+ import {
86
+ OpenServiceDocgenMissingComponentError,
87
+ OpenServiceServicesAppliedTwiceError,
88
+ OpenServiceUnknownStoryIdsError
89
+ } from "../../_node-chunks/chunk-U5W53R2J.js";
90
+ import {
91
+ require_picocolors
92
+ } from "../../_node-chunks/chunk-2BUPBPFB.js";
93
+ import {
94
+ toStoryIndexPath
95
+ } from "../../_node-chunks/chunk-XLP2ZKXV.js";
96
+ import "../../_node-chunks/chunk-FW2HQUBQ.js";
97
+ import "../../_node-chunks/chunk-ZMAMXQKP.js";
98
+ import {
99
+ __commonJS,
100
+ __require,
101
+ __toESM
102
+ } from "../../_node-chunks/chunk-CXRU72ET.js";
103
+
104
+ // ../../node_modules/shell-quote/quote.js
105
+ var require_quote = __commonJS({
106
+ "../../node_modules/shell-quote/quote.js"(exports, module) {
107
+ "use strict";
108
+ var OPS = (
109
+ /** @type {const} */
110
+ [
111
+ "||",
112
+ "&&",
113
+ ";;&",
114
+ ";;",
115
+ ";&",
116
+ "|&",
117
+ "<(",
118
+ ">(",
119
+ "<<<",
120
+ "<<-",
121
+ "<<",
122
+ ">>",
123
+ ">&",
124
+ ">|",
125
+ "&>>",
126
+ "&>",
127
+ "<&",
128
+ "<>",
129
+ "&",
130
+ ";",
131
+ "(",
132
+ ")",
133
+ "|",
134
+ "<",
135
+ ">"
136
+ ]
137
+ ), LINE_TERMINATORS = /[\n\r\u2028\u2029]/, GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|~]/g;
138
+ module.exports = function(xs) {
139
+ var sawComment = !1;
140
+ return xs.map(function(s) {
141
+ if (sawComment && typeof s == "string" && LINE_TERMINATORS.test(s))
142
+ throw new TypeError("a token after a `comment` must not contain line terminators");
143
+ if (s === "")
144
+ return (
145
+ /** @type {const} */
146
+ "''"
147
+ );
148
+ if (s && typeof s == "object") {
149
+ if ("op" in s && s.op === "glob") {
150
+ if (typeof s.pattern != "string")
151
+ throw new TypeError("glob token requires a string `pattern`");
152
+ if (LINE_TERMINATORS.test(s.pattern))
153
+ throw new TypeError("glob `pattern` must not contain line terminators");
154
+ return s.pattern === "" ? (
155
+ /** @type {const} */
156
+ "''"
157
+ ) : s.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
158
+ }
159
+ if ("op" in s && typeof s.op == "string") {
160
+ if (OPS.indexOf(s.op) < 0)
161
+ throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
162
+ return s.op.replace(/[\s\S]/g, "\\$&");
163
+ }
164
+ if ("comment" in s && typeof s.comment == "string") {
165
+ if (LINE_TERMINATORS.test(s.comment))
166
+ throw new TypeError("`comment` must not contain line terminators");
167
+ return sawComment = !0, "#" + s.comment;
168
+ }
169
+ throw new TypeError("unrecognized object token shape");
170
+ }
171
+ return /'/.test(s) && /!/.test(s) ? "'" + s.replace(/'/g, `'"'"'`) + "'" : /["\s\\]/.test(s) && !/'/.test(s) ? "'" + s + "'" : /["'\s]/.test(s) ? '"' + s.replace(/(["\\$`])/g, "\\$1") + '"' : String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g, "$1\\$2");
172
+ }).join(" ");
173
+ };
174
+ }
175
+ });
176
+
177
+ // ../../node_modules/shell-quote/parse.js
178
+ var require_parse = __commonJS({
179
+ "../../node_modules/shell-quote/parse.js"(exports, module) {
180
+ "use strict";
181
+ var CONTROL = (
182
+ /** @type {const} */
183
+ "(?:" + /** @type {const} */
184
+ [
185
+ "\\|\\|",
186
+ "\\&(?:\\&|>>?)",
187
+ // `&&`, `&>`, and `&>>`
188
+ ";;\\&?",
189
+ // `;;` and `;;&`
190
+ "[;|]\\&",
191
+ // `;&` and `|&`
192
+ "\\<\\(",
193
+ "\\<\\<\\<",
194
+ "\\<\\<-",
195
+ "\\<\\<(?!\\()",
196
+ // `<<(` stays `<` and `<(`, as zsh reads it; other shells reject it
197
+ ">>",
198
+ ">[&|(]",
199
+ // `>&`, `>|`, and `>(`
200
+ "<[&>]",
201
+ // `<&` and `<>`
202
+ "[&;()|<>]"
203
+ ].join(
204
+ /** @type {const} */
205
+ "|"
206
+ ) + /** @type {const} */
207
+ ")"
208
+ ), controlRE = new RegExp("^" + CONTROL + "$"), META = (
209
+ /** @type {const} */
210
+ "|&;()<> \\t"
211
+ ), SINGLE_QUOTE = (
212
+ /** @type {const} */
213
+ "'([^']*?)'"
214
+ ), ANSI_C_BODY = "(?:\\\\[\\s\\S]|[^\\\\'])*?", ANSI_C_QUOTE = "\\$'" + ANSI_C_BODY + "'", ansiCAt = new RegExp("\\$'" + ANSI_C_BODY + "(?:(')|\\\\?$)", "g"), ANSI_C_LETTERS = "abeEfnrtv", ANSI_C_CHARS = `\x07\b\x1B\x1B\f
215
+ \r \v`, hash = /^#$/, SQ = (
216
+ /** @type {const} */
217
+ "'"
218
+ ), DQ = (
219
+ /** @type {const} */
220
+ '"'
221
+ ), DS = (
222
+ /** @type {const} */
223
+ "$"
224
+ ), TOKEN = "", mult = (
225
+ /** @type {const} */
226
+ 4294967296
227
+ );
228
+ for (i = 0; i < 4; i++)
229
+ TOKEN += (mult * Math.random()).toString(16);
230
+ var i, startsWithToken = new RegExp("^" + TOKEN);
231
+ function matchAll(s, r) {
232
+ for (var origIndex = r.lastIndex, matches = [], matchObj; matchObj = r.exec(s); )
233
+ matches[matches.length] = matchObj, r.lastIndex === matchObj.index && (r.lastIndex += 1);
234
+ return r.lastIndex = origIndex, matches;
235
+ }
236
+ function getVar(env2, pre, key) {
237
+ var r = typeof env2 == "function" ? env2(key) : env2[key];
238
+ return typeof r > "u" && key != "" ? r = "" : typeof r > "u" && (r = "$"), typeof r == "object" ? pre + TOKEN + JSON.stringify(r) + TOKEN : pre + r;
239
+ }
240
+ var ansiCEscape = /\\([0-7]{1,3}|x[\dA-Fa-f]{1,2}|u[\dA-Fa-f]{1,4}|U[\dA-Fa-f]{1,8}|c(?:\\\\|[\s\S])|[abeEfnrtv\\'"?])/g;
241
+ function expandAnsiCEscape(m, escape) {
242
+ var kind = escape.charAt(0);
243
+ if (kind === "c") {
244
+ var ctrl = escape.charAt(1);
245
+ return ctrl === "?" ? "\x7F" : String.fromCharCode(ctrl.charCodeAt(0) & 31);
246
+ }
247
+ if (kind === "x" || kind === "u" || kind === "U") {
248
+ var cp = parseInt(escape.slice(1), 16);
249
+ return cp > 1114111 ? m : String.fromCharCode.apply(null, cp > 65535 ? [55232 + (cp >> 10), 56320 + (cp & 1023)] : [cp]);
250
+ }
251
+ if (kind >= "0" && kind <= "7")
252
+ return String.fromCharCode(parseInt(escape, 8) & 255);
253
+ var letter = ANSI_C_LETTERS.indexOf(escape);
254
+ return letter < 0 ? escape : ANSI_C_CHARS.charAt(letter);
255
+ }
256
+ function expandAnsiC(body) {
257
+ return body.replace(ansiCEscape, expandAnsiCEscape).split("\0")[0];
258
+ }
259
+ function closesAnsiC(s, i2) {
260
+ return ansiCAt.lastIndex = i2, !!/** @type {RegExpExecArray} */
261
+ ansiCAt.exec(s)[1];
262
+ }
263
+ function parseInternal(string4, env2, opts) {
264
+ opts || (opts = {});
265
+ var BS = opts.escape || "\\", ifs = opts.splitUnquoted === !0 ? `
266
+ ` : typeof opts.splitUnquoted == "string" ? opts.splitUnquoted : "", BAREWORD = "(\\" + BS + `['"$\\` + BS + META + "]|\\$\\$|\\$(?!" + ANSI_C_QUOTE.slice(2) + `)|[^\\s'"$` + META + "])+", DOUBLE_QUOTE = '"(?:\\' + BS + '[\\s\\S]|[^"\\' + BS + '])*"', chunker = new RegExp([
267
+ "(" + CONTROL + ")",
268
+ // control chars
269
+ "(" + ANSI_C_QUOTE + "|" + BAREWORD + "|" + DOUBLE_QUOTE + "|" + SINGLE_QUOTE + ")+"
270
+ ].join("|"), "g"), matches = matchAll(string4, chunker);
271
+ if (matches.length === 0)
272
+ return [];
273
+ env2 || (env2 = {});
274
+ var commented = !1;
275
+ return matches.map(function(match) {
276
+ var s = match[0];
277
+ if (!s || commented)
278
+ return;
279
+ if (controlRE.test(s))
280
+ return (
281
+ /** @type {ControlOperator} */
282
+ { op: s }
283
+ );
284
+ var quote = !1, esc = !1, out = "", words = [], sawQuote = !1, pendingNw = null, isGlob = !1, i2;
285
+ function parseEnvVar() {
286
+ i2 += 1;
287
+ var varend, varname, char = s.charAt(i2);
288
+ if (char === "{") {
289
+ if (i2 += 1, s.charAt(i2) === "}")
290
+ throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
291
+ var depth = 1;
292
+ for (varend = i2; depth > 0 && varend < s.length; )
293
+ s.charAt(varend) === "{" && s.charAt(varend - 1) === "$" ? depth += 1 : s.charAt(varend) === "}" && (depth -= 1), varend += 1;
294
+ if (depth !== 0)
295
+ throw new Error("Bad substitution: " + s.slice(i2));
296
+ varend -= 1, varname = s.slice(i2, varend), i2 = varend;
297
+ } else if (/[*@#?$!-]/.test(char))
298
+ varname = char;
299
+ else {
300
+ var slicedFromI = s.slice(i2);
301
+ varend = slicedFromI.match(/[^\w\d_]/), varend ? (varname = slicedFromI.slice(0, varend.index), i2 += /** @type {number} */
302
+ varend.index - 1) : (varname = slicedFromI, i2 = s.length);
303
+ }
304
+ return getVar(
305
+ /** @type {NonNullable<typeof env>} */
306
+ env2,
307
+ "",
308
+ varname
309
+ );
310
+ }
311
+ function flushRun() {
312
+ if (pendingNw !== null) {
313
+ if (pendingNw === 0)
314
+ out !== "" && (words[words.length] = out, out = "");
315
+ else {
316
+ words[words.length] = out, out = "";
317
+ for (var fe = 1; fe < pendingNw; fe += 1)
318
+ words[words.length] = "";
319
+ }
320
+ pendingNw = null;
321
+ }
322
+ }
323
+ for (i2 = 0; i2 < s.length; i2++) {
324
+ var c = s.charAt(i2);
325
+ if (ifs && c !== DS && flushRun(), isGlob = isGlob || !quote && (c === "*" || c === "?"), esc)
326
+ out += c, esc = !1;
327
+ else if (quote)
328
+ c === quote ? quote = !1 : quote == SQ ? out += c : c === BS ? (i2 += 1, c = s.charAt(i2), c === DQ || c === BS || c === DS ? out += c : out += BS + c) : c === DS ? out += parseEnvVar() : out += c;
329
+ else if (c === DQ || c === SQ)
330
+ quote = c, sawQuote = !0;
331
+ else {
332
+ if (controlRE.test(c))
333
+ return (
334
+ /** @type {ControlOperator} */
335
+ { op: s }
336
+ );
337
+ if (hash.test(c)) {
338
+ commented = !0;
339
+ var commentObj = { comment: string4.slice(match.index + i2 + 1) };
340
+ return out.length ? (
341
+ /** @type {const} */
342
+ [out, commentObj]
343
+ ) : (
344
+ /** @type {const} */
345
+ [commentObj]
346
+ );
347
+ } else if (c === BS)
348
+ esc = !0;
349
+ else if (c === DS && s.charAt(i2 + 1) === SQ && closesAnsiC(s, i2))
350
+ flushRun(), sawQuote = !0, out += expandAnsiC(s.slice(i2 + 2, ansiCAt.lastIndex - 1)), i2 = ansiCAt.lastIndex - 1;
351
+ else if (c === DS) {
352
+ var value = parseEnvVar();
353
+ if (!ifs)
354
+ out += value;
355
+ else
356
+ for (var vi = 0; vi < value.length; vi += 1) {
357
+ var vc = value.charAt(vi);
358
+ ifs.indexOf(vc) < 0 ? (flushRun(), out += vc) : pendingNw === null ? pendingNw = vc === " " || vc === " " || vc === `
359
+ ` ? 0 : 1 : vc !== " " && vc !== " " && vc !== `
360
+ ` && (pendingNw += 1);
361
+ }
362
+ } else
363
+ out += c;
364
+ }
365
+ }
366
+ if (isGlob)
367
+ return (
368
+ /** @type {GlobPattern} */
369
+ { op: "glob", pattern: out }
370
+ );
371
+ if (ifs) {
372
+ if (pendingNw !== null && pendingNw > 0) {
373
+ words[words.length] = out, out = "";
374
+ for (var te = 1; te < pendingNw; te += 1)
375
+ words[words.length] = "";
376
+ }
377
+ return (out !== "" || sawQuote && words.length === 0) && (words[words.length] = out), words;
378
+ }
379
+ return out;
380
+ }).reduce(
381
+ function(prev, arg) {
382
+ return typeof arg > "u" || [].concat(arg).forEach(function(entry) {
383
+ prev[prev.length] = entry;
384
+ }), prev;
385
+ },
386
+ /** @type {ParseEntry[]} */
387
+ []
388
+ );
389
+ }
390
+ module.exports = function(s, env2, opts) {
391
+ var mapped = parseInternal(s, env2, opts);
392
+ return typeof env2 != "function" ? mapped : mapped.reduce(
393
+ function(acc, s2) {
394
+ if (typeof s2 == "object")
395
+ return acc[acc.length] = s2, acc;
396
+ var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
397
+ return xs.length === 1 ? (acc[acc.length] = xs[0], acc) : (xs.filter(Boolean).forEach(function(x) {
398
+ acc[acc.length] = startsWithToken.test(x) ? JSON.parse(x.split(TOKEN)[1]) : x;
399
+ }), acc);
400
+ },
401
+ /** @type {ParseEntry[]} */
402
+ []
403
+ );
404
+ };
405
+ }
406
+ });
407
+
408
+ // ../../node_modules/shell-quote/index.js
409
+ var require_shell_quote = __commonJS({
410
+ "../../node_modules/shell-quote/index.js"(exports) {
411
+ "use strict";
412
+ exports.quote = require_quote();
413
+ exports.parse = require_parse();
414
+ }
415
+ });
416
+
417
+ // ../../node_modules/launch-editor/editor-info/macos.js
418
+ var require_macos = __commonJS({
419
+ "../../node_modules/launch-editor/editor-info/macos.js"(exports, module) {
420
+ module.exports = {
421
+ "/Applications/Atom.app/Contents/MacOS/Atom": "atom",
422
+ "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta": "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta",
423
+ "/Applications/Brackets.app/Contents/MacOS/Brackets": "brackets",
424
+ "/Applications/Sublime Text.app/Contents/MacOS/Sublime Text": "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl",
425
+ "/Applications/Sublime Text.app/Contents/MacOS/sublime_text": "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl",
426
+ "/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2": "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl",
427
+ "/Applications/Sublime Text Dev.app/Contents/MacOS/Sublime Text": "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl",
428
+ "/Applications/Visual Studio Code.app/Contents/MacOS/Code": "code",
429
+ "/Applications/Visual Studio Code.app/Contents/MacOS/Electron": "code",
430
+ "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Code - Insiders": "code-insiders",
431
+ "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron": "code-insiders",
432
+ "/Applications/VSCodium.app/Contents/MacOS/Electron": "codium",
433
+ "/Applications/Cursor.app/Contents/MacOS/Cursor": "cursor",
434
+ "/Applications/Trae.app/Contents/MacOS/Electron": "trae",
435
+ "/Applications/Antigravity.app/Contents/MacOS/Electron": "antigravity",
436
+ "/Applications/AppCode.app/Contents/MacOS/appcode": "/Applications/AppCode.app/Contents/MacOS/appcode",
437
+ "/Applications/CLion.app/Contents/MacOS/clion": "/Applications/CLion.app/Contents/MacOS/clion",
438
+ "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea",
439
+ "/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea",
440
+ "/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea": "/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea",
441
+ "/Applications/PhpStorm.app/Contents/MacOS/phpstorm": "/Applications/PhpStorm.app/Contents/MacOS/phpstorm",
442
+ "/Applications/PyCharm.app/Contents/MacOS/pycharm": "/Applications/PyCharm.app/Contents/MacOS/pycharm",
443
+ "/Applications/PyCharm CE.app/Contents/MacOS/pycharm": "/Applications/PyCharm CE.app/Contents/MacOS/pycharm",
444
+ "/Applications/RubyMine.app/Contents/MacOS/rubymine": "/Applications/RubyMine.app/Contents/MacOS/rubymine",
445
+ "/Applications/WebStorm.app/Contents/MacOS/webstorm": "/Applications/WebStorm.app/Contents/MacOS/webstorm",
446
+ "/Applications/MacVim.app/Contents/MacOS/MacVim": "mvim",
447
+ "/Applications/GoLand.app/Contents/MacOS/goland": "/Applications/GoLand.app/Contents/MacOS/goland",
448
+ "/Applications/Rider.app/Contents/MacOS/rider": "/Applications/Rider.app/Contents/MacOS/rider",
449
+ "/Applications/Zed.app/Contents/MacOS/zed": "zed"
450
+ };
451
+ }
452
+ });
453
+
454
+ // ../../node_modules/launch-editor/editor-info/linux.js
455
+ var require_linux = __commonJS({
456
+ "../../node_modules/launch-editor/editor-info/linux.js"(exports, module) {
457
+ module.exports = {
458
+ atom: "atom",
459
+ Brackets: "brackets",
460
+ "code-insiders": "code-insiders",
461
+ code: "code",
462
+ vscodium: "vscodium",
463
+ codium: "codium",
464
+ cursor: "cursor",
465
+ trae: "trae",
466
+ antigravity: "antigravity",
467
+ emacs: "emacs",
468
+ gvim: "gvim",
469
+ idea: "idea",
470
+ "idea.sh": "idea",
471
+ phpstorm: "phpstorm",
472
+ "phpstorm.sh": "phpstorm",
473
+ pycharm: "pycharm",
474
+ "pycharm.sh": "pycharm",
475
+ rubymine: "rubymine",
476
+ "rubymine.sh": "rubymine",
477
+ sublime_text: "subl",
478
+ vim: "vim",
479
+ webstorm: "webstorm",
480
+ "webstorm.sh": "webstorm",
481
+ goland: "goland",
482
+ "goland.sh": "goland",
483
+ rider: "rider",
484
+ "rider.sh": "rider",
485
+ zed: "zed"
486
+ };
487
+ }
488
+ });
489
+
490
+ // ../../node_modules/launch-editor/editor-info/windows.js
491
+ var require_windows = __commonJS({
492
+ "../../node_modules/launch-editor/editor-info/windows.js"(exports, module) {
493
+ module.exports = [
494
+ "Brackets.exe",
495
+ "Code.exe",
496
+ "Code - Insiders.exe",
497
+ "VSCodium.exe",
498
+ "Cursor.exe",
499
+ "atom.exe",
500
+ "sublime_text.exe",
501
+ "notepad++.exe",
502
+ "clion.exe",
503
+ "clion64.exe",
504
+ "idea.exe",
505
+ "idea64.exe",
506
+ "phpstorm.exe",
507
+ "phpstorm64.exe",
508
+ "pycharm.exe",
509
+ "pycharm64.exe",
510
+ "rubymine.exe",
511
+ "rubymine64.exe",
512
+ "webstorm.exe",
513
+ "webstorm64.exe",
514
+ "goland.exe",
515
+ "goland64.exe",
516
+ "rider.exe",
517
+ "rider64.exe",
518
+ "Trae.exe",
519
+ "zed.exe",
520
+ "Antigravity.exe"
521
+ ];
522
+ }
523
+ });
524
+
525
+ // ../../node_modules/launch-editor/guess.js
526
+ var require_guess = __commonJS({
527
+ "../../node_modules/launch-editor/guess.js"(exports, module) {
528
+ var path = __require("path"), shellQuote = require_shell_quote(), childProcess = __require("child_process"), COMMON_EDITORS_MACOS = require_macos(), COMMON_EDITORS_LINUX = require_linux(), COMMON_EDITORS_WIN = require_windows();
529
+ function getEditorFromMacProcesses(output) {
530
+ let processNames = Object.keys(COMMON_EDITORS_MACOS), processList = output.split(`
531
+ `);
532
+ for (let i = 0; i < processNames.length; i++) {
533
+ let processName = processNames[i];
534
+ if (processList.includes(processName))
535
+ return COMMON_EDITORS_MACOS[processName];
536
+ let processNameWithoutApplications = processName.replace("/Applications", "");
537
+ if (output.indexOf(processNameWithoutApplications) !== -1) {
538
+ if (processName !== COMMON_EDITORS_MACOS[processName])
539
+ return COMMON_EDITORS_MACOS[processName];
540
+ let runningProcess = processList.find(
541
+ (procName) => procName.endsWith(processNameWithoutApplications)
542
+ );
543
+ if (runningProcess !== void 0)
544
+ return runningProcess;
545
+ }
546
+ }
547
+ }
548
+ function getEditorFromWindowsProcesses(output) {
549
+ let runningProcesses = output.split(`\r
550
+ `);
551
+ for (let i = 0; i < runningProcesses.length; i++) {
552
+ let fullProcessPath = runningProcesses[i].trim(), shortProcessName = path.win32.basename(fullProcessPath);
553
+ if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1)
554
+ return fullProcessPath;
555
+ }
556
+ }
557
+ function getEditorFromLinuxProcesses(output) {
558
+ let processNames = Object.keys(COMMON_EDITORS_LINUX);
559
+ for (let i = 0; i < processNames.length; i++) {
560
+ let processName = processNames[i];
561
+ if (output.indexOf(processName) !== -1)
562
+ return COMMON_EDITORS_LINUX[processName];
563
+ }
564
+ }
565
+ function guessEditor(specifiedEditor) {
566
+ if (specifiedEditor)
567
+ return shellQuote.parse(specifiedEditor);
568
+ if (process.env.LAUNCH_EDITOR)
569
+ return [process.env.LAUNCH_EDITOR];
570
+ if (process.versions.webcontainer)
571
+ return [process.env.EDITOR || "code"];
572
+ try {
573
+ if (process.platform === "darwin") {
574
+ let output = childProcess.execSync("ps x -o comm=", {
575
+ stdio: ["pipe", "pipe", "ignore"]
576
+ }).toString(), editor = getEditorFromMacProcesses(output);
577
+ if (editor !== void 0)
578
+ return [editor];
579
+ } else if (process.platform === "win32") {
580
+ let output = childProcess.execSync(
581
+ 'powershell -NoProfile -Command "[Console]::OutputEncoding=[Text.Encoding]::UTF8;Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
582
+ {
583
+ stdio: ["pipe", "pipe", "ignore"]
584
+ }
585
+ ).toString(), editor = getEditorFromWindowsProcesses(output);
586
+ if (editor !== void 0)
587
+ return [editor];
588
+ } else if (process.platform === "linux") {
589
+ let output = childProcess.execSync("ps x --no-heading -o comm --sort=comm", {
590
+ stdio: ["pipe", "pipe", "ignore"]
591
+ }).toString(), editor = getEditorFromLinuxProcesses(output);
592
+ if (editor !== void 0)
593
+ return [editor];
594
+ }
595
+ } catch {
596
+ }
597
+ return process.env.VISUAL ? [process.env.VISUAL] : process.env.EDITOR ? [process.env.EDITOR] : [null];
598
+ }
599
+ module.exports = guessEditor;
600
+ module.exports.getEditorFromMacProcesses = getEditorFromMacProcesses;
601
+ module.exports.getEditorFromWindowsProcesses = getEditorFromWindowsProcesses;
602
+ module.exports.getEditorFromLinuxProcesses = getEditorFromLinuxProcesses;
603
+ }
604
+ });
605
+
606
+ // ../../node_modules/launch-editor/get-args.js
607
+ var require_get_args = __commonJS({
608
+ "../../node_modules/launch-editor/get-args.js"(exports, module) {
609
+ var os = __require("os"), path = __require("path");
610
+ module.exports = function(editor, fileName, lineNumber, columnNumber = 1) {
611
+ if (fileName = path.resolve(fileName), process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release()) && (fileName = `./${path.relative("", fileName)}`), !lineNumber)
612
+ return [fileName];
613
+ switch (path.basename(editor).replace(/\.(exe|cmd|bat)$/i, "")) {
614
+ case "atom":
615
+ case "Atom":
616
+ case "Atom Beta":
617
+ case "subl":
618
+ case "sublime":
619
+ case "sublime_text":
620
+ case "wstorm":
621
+ case "charm":
622
+ case "zed":
623
+ return [`${fileName}:${lineNumber}:${columnNumber}`];
624
+ case "notepad++":
625
+ return ["-n" + lineNumber, "-c" + columnNumber, fileName];
626
+ case "vim":
627
+ case "mvim":
628
+ return [`+call cursor(${lineNumber}, ${columnNumber})`, fileName];
629
+ case "joe":
630
+ case "gvim":
631
+ return [`+${lineNumber}`, fileName];
632
+ case "emacs":
633
+ case "emacsclient":
634
+ return [`+${lineNumber}:${columnNumber}`, fileName];
635
+ case "rmate":
636
+ case "mate":
637
+ case "mine":
638
+ return ["--line", lineNumber, fileName];
639
+ case "code":
640
+ case "Code":
641
+ case "code-insiders":
642
+ case "Code - Insiders":
643
+ case "codium":
644
+ case "trae":
645
+ case "antigravity":
646
+ case "cursor":
647
+ case "vscodium":
648
+ case "VSCodium":
649
+ return ["-r", "-g", `${fileName}:${lineNumber}:${columnNumber}`];
650
+ case "appcode":
651
+ case "clion":
652
+ case "clion64":
653
+ case "idea":
654
+ case "idea64":
655
+ case "phpstorm":
656
+ case "phpstorm64":
657
+ case "pycharm":
658
+ case "pycharm64":
659
+ case "rubymine":
660
+ case "rubymine64":
661
+ case "webstorm":
662
+ case "webstorm64":
663
+ case "goland":
664
+ case "goland64":
665
+ case "rider":
666
+ case "rider64":
667
+ return ["--line", lineNumber, "--column", columnNumber, fileName];
668
+ }
669
+ return process.env.LAUNCH_EDITOR ? [fileName, lineNumber, columnNumber] : [fileName];
670
+ };
671
+ }
672
+ });
673
+
674
+ // ../../node_modules/launch-editor/construct-windows-launch-command.js
675
+ var require_construct_windows_launch_command = __commonJS({
676
+ "../../node_modules/launch-editor/construct-windows-launch-command.js"(exports, module) {
677
+ function escapeCmdArgs(cmdArgs) {
678
+ return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
679
+ }
680
+ function doubleQuoteIfNeeded(str) {
681
+ return str.includes("^") ? `^"${str}^"` : str.includes(" ") ? `"${str}"` : str;
682
+ }
683
+ function constructWindowsLaunchCommand(editor, args) {
684
+ if (args.some((arg) => /[\r\n]/.test(arg)))
685
+ throw new Error("Cannot launch an editor with an argument containing a line break");
686
+ if (args.some((arg) => arg.includes("%")))
687
+ throw new Error('Cannot launch an editor with an argument containing "%"');
688
+ return [editor, ...args.map(escapeCmdArgs)].map(doubleQuoteIfNeeded).join(" ");
689
+ }
690
+ module.exports = constructWindowsLaunchCommand;
691
+ }
692
+ });
693
+
694
+ // ../../node_modules/launch-editor/parse-file.js
695
+ var require_parse_file = __commonJS({
696
+ "../../node_modules/launch-editor/parse-file.js"(exports, module) {
697
+ var path = __require("path"), positionRE = /:(\d+)(:(\d+))?$/;
698
+ module.exports = function(file) {
699
+ file.startsWith("file://") && (file = __require("url").fileURLToPath(file));
700
+ let unresolvedFileName = file.replace(positionRE, ""), fileName = unresolvedFileName ? path.resolve(unresolvedFileName) : "", match = file.match(positionRE), lineNumber = match && match[1], columnNumber = match && match[3];
701
+ return {
702
+ fileName,
703
+ lineNumber,
704
+ columnNumber
705
+ };
706
+ };
707
+ }
708
+ });
709
+
710
+ // ../../node_modules/launch-editor/index.js
711
+ var require_launch_editor = __commonJS({
712
+ "../../node_modules/launch-editor/index.js"(exports, module) {
713
+ var fs = __require("fs"), path = __require("path"), colors = require_picocolors(), childProcess = __require("child_process"), guessEditor = require_guess(), getArgumentsForFile = require_get_args(), constructWindowsLaunchCommand = require_construct_windows_launch_command(), parseFile = require_parse_file();
714
+ function wrapErrorCallback(cb) {
715
+ return (fileName, errorMessage) => {
716
+ console.log(), console.log(colors.red("Could not open " + path.basename(fileName) + " in the editor.")), errorMessage && (errorMessage[errorMessage.length - 1] !== "." && (errorMessage += "."), console.log(colors.red("The editor process exited with an error: " + errorMessage))), console.log(), cb && cb(fileName, errorMessage);
717
+ };
718
+ }
719
+ function isTerminalEditor(editor) {
720
+ switch (editor) {
721
+ case "vim":
722
+ case "emacs":
723
+ case "nano":
724
+ return !0;
725
+ }
726
+ return !1;
727
+ }
728
+ var currentChildProcess = null;
729
+ function launchEditor(file, specifiedEditor, onErrorCallback) {
730
+ let { fileName, lineNumber, columnNumber } = parseFile(file);
731
+ if (typeof specifiedEditor == "function" && (onErrorCallback = specifiedEditor, specifiedEditor = void 0), onErrorCallback = wrapErrorCallback(onErrorCallback), process.platform === "win32" && fileName.startsWith("\\\\"))
732
+ return onErrorCallback(
733
+ fileName,
734
+ "UNC paths are not supported on Windows to avoid security issues. See https://github.com/vitejs/launch-editor/tree/main/packages/launch-editor#unc-paths-on-windows for details."
735
+ );
736
+ if (!fs.existsSync(fileName))
737
+ return;
738
+ let [editor, ...args] = guessEditor(specifiedEditor);
739
+ if (!editor) {
740
+ onErrorCallback(fileName, null);
741
+ return;
742
+ }
743
+ let extraArgs = getArgumentsForFile(editor, fileName, lineNumber, columnNumber);
744
+ args.push.apply(args, extraArgs);
745
+ let launchCommand;
746
+ if (process.platform === "win32")
747
+ try {
748
+ launchCommand = constructWindowsLaunchCommand(editor, args);
749
+ } catch (error) {
750
+ onErrorCallback(fileName, error.message);
751
+ return;
752
+ }
753
+ currentChildProcess && isTerminalEditor(editor) && currentChildProcess.kill("SIGKILL"), process.platform === "win32" ? currentChildProcess = childProcess.exec(launchCommand, {
754
+ stdio: "inherit",
755
+ shell: !0
756
+ }) : currentChildProcess = childProcess.spawn(editor, args, { stdio: "inherit" }), currentChildProcess.on("exit", function(errorCode) {
757
+ currentChildProcess = null, errorCode && onErrorCallback(fileName, "(code " + errorCode + ")");
758
+ }), currentChildProcess.on("error", function(error) {
759
+ let { code, message } = error;
760
+ code === "ENOENT" && (message = `${message} ('${editor}' command does not exist in 'PATH')`), onErrorCallback(fileName, message);
761
+ });
762
+ }
763
+ module.exports = launchEditor;
764
+ }
765
+ });
766
+
767
+ // src/core-server/presets/common-preset.ts
768
+ import { existsSync as existsSync2, realpathSync } from "node:fs";
769
+ import { readFile } from "node:fs/promises";
770
+ import {
771
+ JsPackageManagerFactory,
772
+ STORY_FILE_TEST_REGEXP,
773
+ getBabelPresetEnvMajor,
774
+ getDirectoryFromWorkingDir,
775
+ getPreviewBodyTemplate,
776
+ getPreviewHeadTemplate,
777
+ loadEnvs,
778
+ normalizeStories,
779
+ optionalEnvToBoolean,
780
+ removeAddon as removeAddonBase
781
+ } from "@aussieljk/forkbook/internal/common";
782
+ import { StoryIndexGenerator } from "@aussieljk/forkbook/internal/core-server";
783
+ import { loadCsf } from "@aussieljk/forkbook/internal/csf-tools";
784
+ import { logger as logger5 } from "@aussieljk/forkbook/internal/node-logger";
785
+ import { telemetry as telemetry7 } from "@aussieljk/forkbook/internal/telemetry";
786
+
787
+ // src/shared/open-service/services/extraction-service.server.ts
788
+ var toExtractionError = (error) => error instanceof Error ? { name: error.name, message: error.message } : { name: "Error", message: String(error) };
789
+ function subscribeExtractionServiceToModuleGraphChanges(definition, options) {
790
+ let runtime = getService(definition.id, {
791
+ internal: !0
792
+ }), moduleGraph = getService("core/module-graph", { internal: !0 }), query = runtime.queries[options.queryName], refreshComponent = (id) => runtime.commands[options.extractCommand]({ id }), refreshExtracted = async (componentIds) => {
793
+ let idsToRefresh = Array.from(componentIds).filter((id) => query.get({ id }) !== void 0);
794
+ idsToRefresh.length !== 0 && await Promise.all(idsToRefresh.map((id) => refreshComponent(id).catch(() => {
795
+ })));
796
+ };
797
+ moduleGraph.queries.latestStoryChanges.subscribe(void 0, async ({ data }) => {
798
+ if (!data || data.revision === 0)
799
+ return;
800
+ let changedStoryFiles = new Set(data.storyFiles), entries = Object.values((await options.getIndex()).entries), affectedEntries = changedStoryFiles.size === 0 ? entries : entries.filter((entry) => {
801
+ let storyFilePath = getStoryImportPathFromEntry(entry);
802
+ return storyFilePath && changedStoryFiles.has(toStoryIndexPath(storyFilePath, options.workingDir));
803
+ });
804
+ await refreshExtracted(new Set(affectedEntries.map(getComponentIdFromEntry)));
805
+ });
806
+ }
807
+ function registerExtractionService(definition, options) {
808
+ let { getIndex, provider, buildErrorPayload, queryName, extractCommand, extractAllCommand } = options;
809
+ invariant(
810
+ queryName in definition.queries,
811
+ `Extraction service "${definition.id}" has no query named "${queryName}".`
812
+ ), invariant(
813
+ extractCommand in definition.commands && extractAllCommand in definition.commands,
814
+ `Extraction service "${definition.id}" is missing command "${extractCommand}" or "${extractAllCommand}".`
815
+ );
816
+ let resolveInputs = async () => {
817
+ let entries = Object.values((await getIndex()).entries), storyEntries = Map.groupBy(entries.filter(isEligibleStoryEntry), getComponentIdFromEntry);
818
+ return new Map(
819
+ Array.from(selectComponentEntriesByComponentId(entries), ([id, entry]) => [
820
+ id,
821
+ { entry, storyEntries: storyEntries.get(id) ?? [] }
822
+ ])
823
+ );
824
+ }, resolveInput = async (id) => {
825
+ let input = (await resolveInputs()).get(id);
826
+ if (!input)
827
+ throw new OpenServiceDocgenMissingComponentError({ id });
828
+ return input;
829
+ }, writePayload = (state, id, payload) => {
830
+ payload ? state.components[id] = payload : delete state.components[id];
831
+ };
832
+ return registerService(definition, {
833
+ queries: {
834
+ [queryName]: {
835
+ staticInputs: async () => {
836
+ let inputs = await resolveInputs();
837
+ return Array.from(inputs.keys(), (id) => ({ id }));
838
+ }
839
+ }
840
+ },
841
+ commands: {
842
+ [extractCommand]: {
843
+ handler: async (input, ctx) => {
844
+ let payload = await provider(await resolveInput(input.id));
845
+ return ctx.self.setState((state) => writePayload(state, input.id, payload)), payload;
846
+ }
847
+ },
848
+ [extractAllCommand]: {
849
+ // Every component is resolved first and the state written once: one sync entry for the
850
+ // whole extraction instead of one per component.
851
+ handler: async (_input, ctx) => {
852
+ let inputs = await resolveInputs(), results = await Promise.all(
853
+ Array.from(inputs, async ([id, input]) => {
854
+ try {
855
+ return [id, await provider(input)];
856
+ } catch (error) {
857
+ return [
858
+ id,
859
+ buildErrorPayload({ id, entry: input.entry, error: toExtractionError(error) })
860
+ ];
861
+ }
862
+ })
863
+ );
864
+ ctx.self.setState((state) => {
865
+ for (let [id, payload] of results)
866
+ writePayload(state, id, payload);
867
+ });
868
+ }
869
+ }
870
+ }
871
+ });
872
+ }
873
+
874
+ // src/shared/open-service/services/docgen/definition.ts
875
+ import * as v from "valibot";
876
+ import { defineService as defineService2 } from "@aussieljk/forkbook/open-service";
877
+ var docgenInputSchema = v.object({ id: v.string() }), argTypesSchema = v.custom(
878
+ (value) => typeof value == "object" && value !== null && !Array.isArray(value)
879
+ ), docgenErrorSchema = v.object({
880
+ name: v.string(),
881
+ message: v.string()
882
+ }), docgenJsDocTagsSchema = v.record(v.string(), v.array(v.string())), docgenComponentFields = {
883
+ name: v.string(),
884
+ path: v.string(),
885
+ description: v.optional(v.string()),
886
+ summary: v.optional(v.string()),
887
+ jsDocTags: docgenJsDocTagsSchema,
888
+ argTypes: v.optional(argTypesSchema),
889
+ error: v.optional(docgenErrorSchema)
890
+ }, docgenSubcomponentFields = {
891
+ ...docgenComponentFields,
892
+ import: v.optional(v.string())
893
+ }, docgenSubcomponentSchema = v.looseObject(docgenSubcomponentFields), docgenPayloadSchema = v.looseObject({
894
+ id: v.string(),
895
+ ...docgenComponentFields,
896
+ subcomponents: v.optional(v.record(v.string(), docgenSubcomponentSchema))
897
+ }), docgenOutputSchema = v.optional(docgenPayloadSchema), docgenServiceDef = defineService2({
898
+ id: "core/docgen",
899
+ internal: !0,
900
+ description: "Component documentation (name, description, props, JSDoc tags) keyed by component id.",
901
+ initialState: { components: {} },
902
+ queries: {
903
+ docgen: {
904
+ description: "Returns the docgen payload for one component id, or undefined when not loaded.",
905
+ input: docgenInputSchema,
906
+ output: docgenOutputSchema,
907
+ handler: (input, ctx) => ctx.self.state.components[input.id],
908
+ load: async (input, ctx) => {
909
+ await ctx.self.commands.extractDocgen(input);
910
+ },
911
+ staticPath: (input) => docgenQueryStaticPath(input.id)
912
+ },
913
+ docgenForAllComponents: {
914
+ description: "Returns docgen payloads for every component in the story index.",
915
+ input: v.void(),
916
+ output: v.record(v.string(), docgenPayloadSchema),
917
+ handler: (_input, ctx) => ctx.self.state.components,
918
+ load: async (_input, ctx) => {
919
+ await ctx.self.commands.extractAllDocgen(void 0);
920
+ }
921
+ }
922
+ },
923
+ commands: {
924
+ extractDocgen: {
925
+ description: "Resolves the story entry for a component id, runs the registered provider chain, writes the result into state, and returns it (or undefined when no provider produced docgen).",
926
+ input: docgenInputSchema,
927
+ output: docgenOutputSchema
928
+ // Handler is supplied at registration time so it can close over the story index and the
929
+ // composed experimental_docgenProvider chain.
930
+ },
931
+ extractAllDocgen: {
932
+ description: "Extracts docgen for every component id in the story index by invoking `extractDocgen` for each.",
933
+ input: v.undefined(),
934
+ output: v.void()
935
+ // Handler is supplied at registration time so it can close over the story index.
936
+ }
937
+ }
938
+ });
939
+
940
+ // src/shared/open-service/services/docgen/server.ts
941
+ function registerDocgenService(options) {
942
+ return registerExtractionService(docgenServiceDef, {
943
+ getIndex: options.getIndex,
944
+ provider: ({ entry }) => options.docgenProvider({ entry }),
945
+ buildErrorPayload: ({ id, entry, error }) => ({
946
+ id,
947
+ name: entry.title,
948
+ path: getStoryImportPathFromEntry(entry) ?? entry.importPath,
949
+ jsDocTags: {},
950
+ error
951
+ }),
952
+ queryName: "docgen",
953
+ extractCommand: "extractDocgen",
954
+ extractAllCommand: "extractAllDocgen"
955
+ });
956
+ }
957
+ function subscribeDocgenToModuleGraphChanges(options) {
958
+ subscribeExtractionServiceToModuleGraphChanges(docgenServiceDef, {
959
+ ...options,
960
+ queryName: "docgen",
961
+ extractCommand: "extractDocgen"
962
+ });
963
+ }
964
+
965
+ // src/shared/open-service/services/docgen/worker/docgen-worker-client.ts
966
+ import { existsSync } from "node:fs";
967
+ import { fileURLToPath } from "node:url";
968
+ import { Worker } from "node:worker_threads";
969
+ import { logger } from "@aussieljk/forkbook/internal/node-logger";
970
+ var WORKER_SPECIFIER = "@aussieljk/forkbook/internal/docgen-worker", DEFAULT_TASK_TIMEOUT_MS = 12e4;
971
+ function errorLikeToError(errorLike) {
972
+ let error = new Error(errorLike.message);
973
+ return errorLike.name && (error.name = errorLike.name), errorLike.stack && (error.stack = errorLike.stack), error;
974
+ }
975
+ var DocgenWorker = class {
976
+ constructor(scriptPath, descriptors, taskTimeoutMs = DEFAULT_TASK_TIMEOUT_MS) {
977
+ this.taskTimeoutMs = taskTimeoutMs;
978
+ this.pending = /* @__PURE__ */ new Map();
979
+ this.rejectReady = () => {
980
+ };
981
+ this.nextId = 0;
982
+ this.served = !1;
983
+ this.worker = new Worker(scriptPath), this.worker.on("message", (msg) => this.handleMessage(msg)), this.worker.on("error", (error) => this.fail(error)), this.worker.on("exit", (code) => {
984
+ this.death || this.fail(new Error(`docgen worker exited unexpectedly with code ${code}`));
985
+ }), this.ready = new Promise((resolve2, reject) => {
986
+ this.rejectReady = reject;
987
+ let onMessage = (msg) => {
988
+ msg.type === "init" && (this.worker.off("message", onMessage), msg.error ? reject(errorLikeToError(msg.error)) : resolve2());
989
+ };
990
+ this.worker.on("message", onMessage);
991
+ }), this.ready.catch(() => {
992
+ }), this.ready.finally(() => this.keepProcessAliveWhileBusy()).catch(() => {
993
+ }), this.post({ type: "init", descriptors, logLevel: logger.getLogLevel() });
994
+ }
995
+ /**
996
+ * Whether a fresh worker would be worth spawning in this one's place.
997
+ *
998
+ * Only once it has served an extract: a worker that died without ever answering died of something
999
+ * a replacement would hit again, and respawning would rebuild a multi-second TypeScript program
1000
+ * per request to fail the same way.
1001
+ */
1002
+ get replaceable() {
1003
+ return this.death !== void 0 && this.served;
1004
+ }
1005
+ async extract(entry) {
1006
+ if (this.death)
1007
+ throw new Error(`docgen worker is no longer running: ${this.death.message}`, {
1008
+ cause: this.death
1009
+ });
1010
+ return await this.ready, new Promise((resolve2, reject) => {
1011
+ let id = this.nextId++, pending = { resolve: resolve2, reject };
1012
+ this.taskTimeoutMs > 0 && (pending.timer = setTimeout(() => {
1013
+ this.pending.delete(id), this.keepProcessAliveWhileBusy(), reject(new Error(`docgen worker extract ${id} timed out after ${this.taskTimeoutMs}ms`));
1014
+ }, this.taskTimeoutMs), pending.timer.unref?.()), this.pending.set(id, pending), this.keepProcessAliveWhileBusy(), this.post({ type: "extract", id, entry });
1015
+ });
1016
+ }
1017
+ keepProcessAliveWhileBusy() {
1018
+ this.pending.size > 0 ? this.worker.ref() : this.worker.unref();
1019
+ }
1020
+ post(msg) {
1021
+ this.worker.postMessage(msg);
1022
+ }
1023
+ handleMessage(msg) {
1024
+ if (msg.type !== "extract")
1025
+ return;
1026
+ let pending = this.pending.get(msg.id);
1027
+ pending && (pending.timer && clearTimeout(pending.timer), this.pending.delete(msg.id), this.served = !0, this.keepProcessAliveWhileBusy(), msg.error ? pending.reject(errorLikeToError(msg.error)) : pending.resolve(msg.payload));
1028
+ }
1029
+ fail(error) {
1030
+ this.death || (logger.warn(`docgen worker died, so component docs are unavailable: ${error.message}`), this.death = error, this.rejectReady(error), this.rejectAllPending(error), this.worker.terminate().catch(() => 0));
1031
+ }
1032
+ rejectAllPending(error) {
1033
+ for (let [, pending] of this.pending)
1034
+ pending.timer && clearTimeout(pending.timer), pending.reject(error);
1035
+ this.pending.clear(), this.worker.unref();
1036
+ }
1037
+ };
1038
+ function resolveWorkerScriptPath() {
1039
+ try {
1040
+ let scriptPath = fileURLToPath(importMetaResolve(WORKER_SPECIFIER));
1041
+ return existsSync(scriptPath) ? scriptPath : void 0;
1042
+ } catch {
1043
+ return;
1044
+ }
1045
+ }
1046
+ function createDocgenWorkerClient(descriptors) {
1047
+ let scriptPath = resolveWorkerScriptPath();
1048
+ if (!scriptPath) {
1049
+ logger.debug(
1050
+ "docgen worker disabled: compiled worker script not found (running from source without a build?)"
1051
+ );
1052
+ return;
1053
+ }
1054
+ let worker;
1055
+ return {
1056
+ async extract(entry) {
1057
+ return worker?.replaceable && (logger.debug("docgen worker died after serving requests; spawning a replacement"), worker = void 0), worker ??= new DocgenWorker(scriptPath, descriptors), worker.extract(entry);
1058
+ }
1059
+ };
1060
+ }
1061
+
1062
+ // src/shared/open-service/services/review/definition.ts
1063
+ import * as v2 from "valibot";
1064
+ var reviewCollectionSchema = v2.object({
1065
+ title: v2.pipe(v2.string(), v2.description("Collection title shown on the review page.")),
1066
+ rationale: v2.pipe(
1067
+ v2.string(),
1068
+ v2.description("Why this collection is relevant. Plain text, one or two sentences.")
1069
+ ),
1070
+ storyIds: v2.pipe(v2.array(v2.string()), v2.description("Story ids included in this collection."))
1071
+ }), reviewStateSchema = v2.object({
1072
+ title: v2.pipe(v2.string(), v2.description("Terse review title. Plain text.")),
1073
+ description: v2.pipe(
1074
+ v2.string(),
1075
+ v2.description(
1076
+ "Review scope and what to look for. Limited markdown: bold, italic, and inline code."
1077
+ )
1078
+ ),
1079
+ collections: v2.array(reviewCollectionSchema),
1080
+ changedFiles: v2.optional(
1081
+ v2.pipe(
1082
+ v2.array(v2.string()),
1083
+ v2.description(
1084
+ "Changed file paths, most central first. Pass an empty array when nothing changed."
1085
+ )
1086
+ )
1087
+ ),
1088
+ createdAt: v2.optional(v2.number()),
1089
+ stale: v2.optional(v2.boolean())
1090
+ }), reviewNavEntrySchema = v2.object({
1091
+ storyId: v2.pipe(v2.string(), v2.description("Story id of this navigation slot.")),
1092
+ collectionIndex: v2.pipe(
1093
+ v2.number(),
1094
+ v2.description("Index of the collection this slot belongs to.")
1095
+ )
1096
+ }), reviewServiceDef = defineService({
1097
+ id: "core/review",
1098
+ internal: !0,
1099
+ description: "Owns the current curated Forkbook review, its deferred update, and its staleness.",
1100
+ initialState: { current: null, pending: null },
1101
+ queries: {
1102
+ current: {
1103
+ description: "Returns the current review, or null when no review is active.",
1104
+ input: v2.undefined(),
1105
+ output: v2.nullable(reviewStateSchema),
1106
+ handler: (_input, ctx) => ctx.self.state.current
1107
+ },
1108
+ pending: {
1109
+ description: "Returns the deferred review update, or null when none is held.",
1110
+ input: v2.undefined(),
1111
+ output: v2.nullable(reviewStateSchema),
1112
+ handler: (_input, ctx) => ctx.self.state.pending
1113
+ },
1114
+ flattenedEntries: {
1115
+ description: "Returns the current review flattened into navigable story slots, walking collections in order (a story repeats when curated into several collections). Empty when no review is active.",
1116
+ input: v2.undefined(),
1117
+ output: v2.array(reviewNavEntrySchema),
1118
+ handler: (_input, ctx) => (ctx.self.state.current?.collections ?? []).flatMap(
1119
+ (collection, collectionIndex) => collection.storyIds.map((storyId) => ({ storyId, collectionIndex }))
1120
+ )
1121
+ },
1122
+ bannerKind: {
1123
+ description: "Returns which attention banner review surfaces should show: pending-update outranks stale, and once accepted the banner reflects the staleness of the accepted review; null when neither applies.",
1124
+ input: v2.undefined(),
1125
+ output: v2.nullable(v2.picklist(["pending-update", "stale"])),
1126
+ handler: (_input, ctx) => ctx.self.state.pending !== null ? "pending-update" : ctx.self.state.current?.stale ? "stale" : null
1127
+ }
1128
+ },
1129
+ commands: {
1130
+ setReview: {
1131
+ description: "Publishes a review and assigns its server creation time. Defers to pending while any review is current. Implemented by the server.",
1132
+ input: reviewStateSchema,
1133
+ output: v2.void()
1134
+ },
1135
+ acceptPending: {
1136
+ description: "Promotes the deferred review update to current. Implemented by the server.",
1137
+ input: v2.undefined(),
1138
+ output: v2.void()
1139
+ },
1140
+ markStale: {
1141
+ description: "Marks the current and pending reviews stale when the module graph changed after they were published. Implemented by the server.",
1142
+ input: v2.object({
1143
+ changedAt: v2.pipe(
1144
+ v2.number(),
1145
+ v2.description("When (unix ms) the newest module-graph change was made.")
1146
+ )
1147
+ }),
1148
+ output: v2.void()
1149
+ },
1150
+ dismissReview: {
1151
+ description: "Clears the current review and any deferred update. Implemented by the server.",
1152
+ input: v2.undefined(),
1153
+ output: v2.void()
1154
+ }
1155
+ }
1156
+ });
1157
+
1158
+ // src/shared/open-service/services/review/state-transitions.ts
1159
+ function toPlainReview(review) {
1160
+ return {
1161
+ ...review,
1162
+ collections: review.collections.map((collection) => ({
1163
+ ...collection,
1164
+ storyIds: [...collection.storyIds]
1165
+ })),
1166
+ ...review.changedFiles ? { changedFiles: [...review.changedFiles] } : {}
1167
+ };
1168
+ }
1169
+ function applyPublishedReview(state, review) {
1170
+ state.current === null ? (state.current = review, state.pending = null) : state.pending = review;
1171
+ }
1172
+ function applyAcceptPending(state) {
1173
+ state.pending !== null && (state.current = toPlainReview(state.pending), state.pending = null);
1174
+ }
1175
+ function applyMarkStale(state, { changedAt }) {
1176
+ let isOutdated = (review) => review?.createdAt !== void 0 && !review.stale && changedAt > review.createdAt;
1177
+ isOutdated(state.current) && (state.current = { ...toPlainReview(state.current), stale: !0 }), isOutdated(state.pending) && (state.pending = { ...toPlainReview(state.pending), stale: !0 });
1178
+ }
1179
+ function applyDismiss(state) {
1180
+ state.current = null, state.pending = null;
1181
+ }
1182
+
1183
+ // src/shared/open-service/services/review/server.ts
1184
+ function registerReviewService({ getIndex }) {
1185
+ return registerService(reviewServiceDef, {
1186
+ commands: {
1187
+ setReview: {
1188
+ handler: async (input, ctx) => {
1189
+ let { stale: _stale, createdAt: _createdAt, ...review } = input, storyIds = [
1190
+ ...new Set(review.collections.flatMap((collection) => collection.storyIds))
1191
+ ], index = await getIndex(), unknownIds = storyIds.filter((storyId) => index.entries[storyId]?.type !== "story");
1192
+ if (unknownIds.length > 0)
1193
+ throw new OpenServiceUnknownStoryIdsError({ unknownIds });
1194
+ ctx.self.setState((state) => {
1195
+ applyPublishedReview(state, { ...review, createdAt: Date.now() });
1196
+ });
1197
+ }
1198
+ },
1199
+ acceptPending: {
1200
+ handler: async (_input, ctx) => {
1201
+ ctx.self.setState((state) => {
1202
+ applyAcceptPending(state);
1203
+ });
1204
+ }
1205
+ },
1206
+ markStale: {
1207
+ handler: async (change, ctx) => {
1208
+ ctx.self.setState((state) => {
1209
+ applyMarkStale(state, change);
1210
+ });
1211
+ }
1212
+ },
1213
+ dismissReview: {
1214
+ handler: async (_input, ctx) => {
1215
+ ctx.self.setState((state) => {
1216
+ applyDismiss(state);
1217
+ });
1218
+ }
1219
+ }
1220
+ }
1221
+ });
1222
+ }
1223
+ function subscribeReviewToModuleGraphChanges() {
1224
+ let review = getService("core/review", { internal: !0 });
1225
+ getService("core/module-graph", { internal: !0 }).queries.graphChangedAt.subscribe(void 0, ({ data: changedAt }) => {
1226
+ changedAt !== void 0 && review.commands.markStale({ changedAt });
1227
+ });
1228
+ }
1229
+
1230
+ // src/shared/open-service/services/story-docs/definition.ts
1231
+ import * as v3 from "valibot";
1232
+ import { defineService as defineService3 } from "@aussieljk/forkbook/open-service";
1233
+ var storyDocsInputSchema = v3.object({ id: v3.string() }), storyDocsErrorSchema = v3.object({
1234
+ name: v3.string(),
1235
+ message: v3.string()
1236
+ }), storyDocSchema = v3.object({
1237
+ id: v3.string(),
1238
+ name: v3.string(),
1239
+ snippet: v3.optional(v3.string()),
1240
+ description: v3.optional(v3.string()),
1241
+ summary: v3.optional(v3.string()),
1242
+ warning: v3.optional(v3.string()),
1243
+ error: v3.optional(storyDocsErrorSchema)
1244
+ }), storyDocsPayloadSchema = v3.object({
1245
+ id: v3.string(),
1246
+ name: v3.string(),
1247
+ path: v3.string(),
1248
+ import: v3.optional(v3.string()),
1249
+ stories: v3.record(v3.string(), storyDocSchema),
1250
+ error: v3.optional(storyDocsErrorSchema)
1251
+ }), storyDocsOutputSchema = v3.optional(storyDocsPayloadSchema), storyDocsServiceDef = defineService3({
1252
+ id: "core/story-docs",
1253
+ internal: !0,
1254
+ description: "Story documentation (snippets, descriptions, imports) keyed by component id.",
1255
+ initialState: { components: {} },
1256
+ queries: {
1257
+ storyDocs: {
1258
+ description: "Returns the story-docs payload for one component id, or undefined when not loaded.",
1259
+ input: storyDocsInputSchema,
1260
+ output: storyDocsOutputSchema,
1261
+ handler: (input, ctx) => Object.hasOwn(ctx.self.state.components, input.id) ? ctx.self.state.components[input.id] : void 0,
1262
+ load: async (input, ctx) => {
1263
+ await ctx.self.commands.extractStoryDocs(input);
1264
+ },
1265
+ staticPath: (input) => storyDocsQueryStaticPath(input.id)
1266
+ },
1267
+ storyDocsForAllComponents: {
1268
+ description: "Returns story-docs payloads for every component in the story index.",
1269
+ input: v3.void(),
1270
+ output: v3.record(v3.string(), storyDocsPayloadSchema),
1271
+ handler: (_input, ctx) => ctx.self.state.components,
1272
+ load: async (_input, ctx) => {
1273
+ await ctx.self.commands.extractAllStoryDocs(void 0);
1274
+ }
1275
+ }
1276
+ },
1277
+ commands: {
1278
+ extractStoryDocs: {
1279
+ description: "Resolves the story entry for a component id, runs the registered provider chain, writes the result into state, and returns it (or undefined when no provider produced story docs).",
1280
+ input: storyDocsInputSchema,
1281
+ output: storyDocsOutputSchema
1282
+ },
1283
+ extractAllStoryDocs: {
1284
+ description: "Extracts story docs for every component id in the story index by invoking `extractStoryDocs` for each.",
1285
+ input: v3.undefined(),
1286
+ output: v3.void()
1287
+ }
1288
+ }
1289
+ });
1290
+
1291
+ // src/shared/open-service/services/story-docs/server.ts
1292
+ function storyDocFromFile(entry, result) {
1293
+ if (result.status === "rejected")
1294
+ return { id: entry.id, name: entry.name, error: toExtractionError(result.reason) };
1295
+ let story = result.value?.stories[entry.id];
1296
+ return story?.snippet === void 0 ? story : { ...story, snippet: prependImportToSnippet(result.value?.import, story.snippet) };
1297
+ }
1298
+ function withStoriesFromEveryFile(provider) {
1299
+ return async ({ entry, storyEntries }) => {
1300
+ let fileEntries = [
1301
+ ...new Map(storyEntries.map((storyEntry) => [storyEntry.importPath, storyEntry])).values()
1302
+ ];
1303
+ if (fileEntries.length < 2)
1304
+ return provider({ entry });
1305
+ let results = await Promise.allSettled(
1306
+ fileEntries.map((fileEntry) => provider({ entry: fileEntry }))
1307
+ ), resultByFile = Object.fromEntries(
1308
+ fileEntries.map((fileEntry, index) => [fileEntry.importPath, results[index]])
1309
+ ), selected = resultByFile[entry.importPath];
1310
+ if (selected.status === "rejected")
1311
+ throw selected.reason;
1312
+ if (!selected.value)
1313
+ return;
1314
+ let { import: _import, ...component } = selected.value;
1315
+ return {
1316
+ ...component,
1317
+ stories: Object.fromEntries(
1318
+ storyEntries.flatMap((storyEntry) => {
1319
+ let story = storyDocFromFile(storyEntry, resultByFile[storyEntry.importPath]);
1320
+ return story ? [[storyEntry.id, story]] : [];
1321
+ })
1322
+ )
1323
+ };
1324
+ };
1325
+ }
1326
+ function registerStoryDocsService(options) {
1327
+ return registerExtractionService(storyDocsServiceDef, {
1328
+ getIndex: options.getIndex,
1329
+ provider: withStoriesFromEveryFile(options.storyDocsProvider),
1330
+ buildErrorPayload: ({ id, entry, error }) => ({
1331
+ id,
1332
+ name: entry.title,
1333
+ path: getStoryImportPathFromEntry(entry) ?? entry.importPath,
1334
+ stories: {},
1335
+ error
1336
+ }),
1337
+ queryName: "storyDocs",
1338
+ extractCommand: "extractStoryDocs",
1339
+ extractAllCommand: "extractAllStoryDocs"
1340
+ });
1341
+ }
1342
+ function subscribeStoryDocsToModuleGraphChanges(options) {
1343
+ subscribeExtractionServiceToModuleGraphChanges(storyDocsServiceDef, {
1344
+ ...options,
1345
+ queryName: "storyDocs",
1346
+ extractCommand: "extractStoryDocs"
1347
+ });
1348
+ }
1349
+
1350
+ // src/core-server/presets/common-preset.ts
1351
+ import * as pathe from "pathe";
1352
+ import { isAbsolute as isAbsolute2, join as join4 } from "pathe";
1353
+ import { dedent } from "ts-dedent";
1354
+
1355
+ // src/core-server/server-channel/ai-setup-channel.ts
1356
+ import {
1357
+ AI_SETUP_ANALYTICS_REQUEST,
1358
+ AI_SETUP_ANALYTICS_RESPONSE
1359
+ } from "@aussieljk/forkbook/internal/core-events";
1360
+ import {
1361
+ getLastEvents,
1362
+ getStorybookMetadata,
1363
+ isStoryCreatedByAISetup,
1364
+ telemetry
1365
+ } from "@aussieljk/forkbook/internal/telemetry";
1366
+ import { logger as logger2 } from "@aussieljk/forkbook/internal/node-logger";
1367
+
1368
+ // src/core-server/utils/wait-for-idle-vitest.ts
1369
+ async function waitForIdleVitest(maxWaitMs = 1800 * 1e3, pollIntervalMs = 60 * 1e3) {
1370
+ let deadline = Date.now() + maxWaitMs;
1371
+ for (; Date.now() < deadline; ) {
1372
+ try {
1373
+ let state = fullTestProviderStore.getFullState();
1374
+ if (!Object.values(state).some((s) => s === "test-provider-state:running"))
1375
+ return !0;
1376
+ } catch {
1377
+ return !0;
1378
+ }
1379
+ await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
1380
+ }
1381
+ return !1;
1382
+ }
1383
+
1384
+ // src/core-server/server-channel/ai-setup-channel.ts
1385
+ function initAIAnalyticsChannel(channel, options, getStoryIndexGeneratorPromise) {
1386
+ return channel.on(AI_SETUP_ANALYTICS_REQUEST, async () => {
1387
+ let stats = {}, runId;
1388
+ try {
1389
+ let lastEvents = await getLastEvents(), lastAISetup = lastEvents?.["ai-setup"], lastSetupStoryScoringRun = lastEvents?.["ai-setup-final-scoring"];
1390
+ if (runId = await getAiSetupRunId(options.configDir), !lastAISetup || lastSetupStoryScoringRun && lastSetupStoryScoringRun.body.payload.runId === lastAISetup.body.payload.runId)
1391
+ return;
1392
+ let metadata = await getStorybookMetadata(options.configDir), isReactStorybook = metadata?.renderer?.includes("@aussieljk/forkbook/react"), hasVitestAddon = !!metadata?.addons && Object.keys(metadata.addons).some(
1393
+ (addonKey) => addonKey.includes("@aussieljk/forkbook/addon-vitest")
1394
+ );
1395
+ if (!isReactStorybook || !hasVitestAddon)
1396
+ return;
1397
+ if (!await waitForIdleVitest()) {
1398
+ logger2.debug("AI_SETUP_ANALYTICS_REQUEST timed out waiting for vitest to be available.");
1399
+ return;
1400
+ }
1401
+ let generatorPromise = getStoryIndexGeneratorPromise?.();
1402
+ if (!generatorPromise) {
1403
+ logger2.debug(
1404
+ "AI_SETUP_ANALYTICS_REQUEST could not proceed as the index generator is not ready."
1405
+ );
1406
+ return;
1407
+ }
1408
+ let indexAndStats = await (await generatorPromise).getIndexAndStats();
1409
+ if (!indexAndStats) {
1410
+ logger2.debug("AI_SETUP_ANALYTICS_REQUEST could not proceed as the index is not ready.");
1411
+ return;
1412
+ }
1413
+ let aiStoryFiles = /* @__PURE__ */ new Set(), aiStoryCount = 0;
1414
+ for (let entry of Object.values(indexAndStats.storyIndex.entries))
1415
+ isStoryCreatedByAISetup(entry) && (aiStoryFiles.add(entry.importPath), aiStoryCount++);
1416
+ if (aiStoryFiles.size > 0) {
1417
+ let aiTestRunResult = await runStoryTests([...aiStoryFiles]);
1418
+ telemetry("ai-setup-final-scoring", {
1419
+ stats: {
1420
+ fileCount: aiStoryFiles.size,
1421
+ storyCount: aiStoryCount,
1422
+ testRunDuration: aiTestRunResult.duration
1423
+ },
1424
+ runId,
1425
+ results: aiTestRunResult.summary,
1426
+ ...aiTestRunResult.runError ? { runError: aiTestRunResult.runError } : {}
1427
+ });
1428
+ } else
1429
+ telemetry("ai-setup-final-scoring", {
1430
+ stats: {
1431
+ fileCount: 0,
1432
+ storyCount: 0,
1433
+ testRunDuration: 0
1434
+ },
1435
+ runId,
1436
+ runError: "No stories found that were generated by ai setup"
1437
+ });
1438
+ } catch {
1439
+ telemetry("ai-setup-final-scoring", {
1440
+ stats,
1441
+ runId,
1442
+ runError: "Unknown error during AI story scoring"
1443
+ });
1444
+ } finally {
1445
+ channel.emit(AI_SETUP_ANALYTICS_RESPONSE);
1446
+ }
1447
+ }), channel;
1448
+ }
1449
+
1450
+ // src/core-server/server-channel/ghost-stories-channel.ts
1451
+ import {
1452
+ GHOST_STORIES_REQUEST,
1453
+ GHOST_STORIES_RESPONSE
1454
+ } from "@aussieljk/forkbook/internal/core-events";
1455
+ import {
1456
+ getLastEvents as getLastEvents2,
1457
+ getStorybookMetadata as getStorybookMetadata2,
1458
+ telemetry as telemetry2
1459
+ } from "@aussieljk/forkbook/internal/telemetry";
1460
+ var SkipGhostStoriesTelemetry = class extends Error {
1461
+ };
1462
+ function initGhostStoriesChannel(channel, options) {
1463
+ return channel.on(GHOST_STORIES_REQUEST, async () => {
1464
+ let stats = {}, aiSetupRunId = await getAiSetupRunId(options.configDir);
1465
+ try {
1466
+ await telemetry2("ghost-stories", async () => {
1467
+ try {
1468
+ let ghostRunStart = Date.now(), lastEvents = await getLastEvents2(), lastInit = lastEvents?.init, lastAISetup = lastEvents?.["ai-setup"], lastSetupStoryScoringRun = lastEvents?.["ai-setup-final-scoring"], lastGhostStoriesRun = lastEvents?.["ghost-stories"];
1469
+ if (!(lastAISetup ?? lastInit))
1470
+ throw new SkipGhostStoriesTelemetry();
1471
+ if (lastGhostStoriesRun && lastSetupStoryScoringRun.body.payload.runId === lastAISetup.body.payload.runId)
1472
+ throw new SkipGhostStoriesTelemetry();
1473
+ let metadata = await getStorybookMetadata2(options.configDir), isReactStorybook = metadata?.renderer?.includes("@aussieljk/forkbook/react"), hasVitestAddon = !!metadata?.addons && Object.keys(metadata.addons).some(
1474
+ (addonKey) => addonKey.includes("@aussieljk/forkbook/addon-vitest")
1475
+ );
1476
+ if (!isReactStorybook || !hasVitestAddon)
1477
+ throw new SkipGhostStoriesTelemetry();
1478
+ if (!await waitForIdleVitest())
1479
+ return {
1480
+ stats,
1481
+ aiSetupRunId,
1482
+ runError: "Vitest busy, couldn't run ghost stories"
1483
+ };
1484
+ let candidateAnalysisStart = Date.now(), candidatesResult = await getComponentCandidates();
1485
+ if (stats.candidateAnalysisDuration = Date.now() - candidateAnalysisStart, stats.globMatchCount = candidatesResult.globMatchCount, stats.analyzedCount = candidatesResult.analyzedCount ?? 0, stats.avgComplexity = candidatesResult.avgComplexity ?? 0, stats.candidateCount = candidatesResult.candidates.length, candidatesResult.error)
1486
+ return stats.totalRunDuration = Date.now() - ghostRunStart, {
1487
+ stats,
1488
+ aiSetupRunId,
1489
+ runError: candidatesResult.error
1490
+ };
1491
+ if (candidatesResult.candidates.length === 0)
1492
+ return stats.totalRunDuration = Date.now() - ghostRunStart, {
1493
+ stats,
1494
+ aiSetupRunId,
1495
+ runError: "No candidates found"
1496
+ };
1497
+ let testRunResult = await runStoryTests(candidatesResult.candidates, {
1498
+ ghostRun: !0
1499
+ });
1500
+ return stats.totalRunDuration = Date.now() - ghostRunStart, stats.testRunDuration = testRunResult.duration, testRunResult.runError ? {
1501
+ stats,
1502
+ aiSetupRunId,
1503
+ runError: testRunResult.runError
1504
+ } : {
1505
+ stats,
1506
+ aiSetupRunId,
1507
+ results: testRunResult.summary
1508
+ };
1509
+ } catch (error) {
1510
+ if (error instanceof SkipGhostStoriesTelemetry)
1511
+ throw error;
1512
+ return {
1513
+ stats,
1514
+ aiSetupRunId,
1515
+ runError: "Unknown error during ghost run"
1516
+ };
1517
+ }
1518
+ });
1519
+ } catch (error) {
1520
+ if (!(error instanceof SkipGhostStoriesTelemetry))
1521
+ throw error;
1522
+ } finally {
1523
+ channel.emit(GHOST_STORIES_RESPONSE);
1524
+ }
1525
+ }), channel;
1526
+ }
1527
+
1528
+ // src/core-server/server-channel/open-in-editor-channel.ts
1529
+ var import_launch_editor = __toESM(require_launch_editor(), 1);
1530
+ import {
1531
+ OPEN_IN_EDITOR_REQUEST,
1532
+ OPEN_IN_EDITOR_RESPONSE
1533
+ } from "@aussieljk/forkbook/internal/core-events";
1534
+ import { telemetry as telemetry3 } from "@aussieljk/forkbook/internal/telemetry";
1535
+ async function initOpenInEditorChannel(channel) {
1536
+ return channel.on(OPEN_IN_EDITOR_REQUEST, async (payload) => {
1537
+ let sendTelemetry = (data) => {
1538
+ telemetry3("open-in-editor", data);
1539
+ };
1540
+ try {
1541
+ let { file: targetFile, line, column } = payload;
1542
+ if (!targetFile)
1543
+ throw new Error("No file was provided to open");
1544
+ let location = typeof line == "number" ? `${targetFile}:${line}${typeof column == "number" ? `:${column}` : ""}` : targetFile;
1545
+ await new Promise((resolve2, reject) => {
1546
+ (0, import_launch_editor.default)(location, void 0, (_fileName, errorMessage) => {
1547
+ errorMessage ? reject(new Error(errorMessage)) : resolve2();
1548
+ });
1549
+ }), channel.emit(OPEN_IN_EDITOR_RESPONSE, {
1550
+ file: targetFile,
1551
+ line,
1552
+ column,
1553
+ error: null
1554
+ }), sendTelemetry({ success: !0 });
1555
+ } catch (e) {
1556
+ let error = e?.message || "Failed to open in editor";
1557
+ channel.emit(OPEN_IN_EDITOR_RESPONSE, {
1558
+ error,
1559
+ ...payload
1560
+ }), sendTelemetry({ success: !1, error });
1561
+ }
1562
+ }), channel;
1563
+ }
1564
+
1565
+ // src/core-server/server-channel/telemetry-channel.ts
1566
+ import {
1567
+ AI_PROMPT_NUDGE,
1568
+ PREVIEW_INITIALIZED,
1569
+ SHARE_ISOLATE_MODE,
1570
+ SIDEBAR_FILTER_CHANGED
1571
+ } from "@aussieljk/forkbook/internal/core-events";
1572
+ import {
1573
+ getLastEvents as getLastEvents3,
1574
+ getSessionId,
1575
+ telemetry as telemetry4
1576
+ } from "@aussieljk/forkbook/internal/telemetry";
1577
+ var makePayload = (userAgent, lastInit, sessionId) => {
1578
+ let payload = {
1579
+ userAgent,
1580
+ timeSinceInit: void 0
1581
+ };
1582
+ return sessionId && lastInit?.body?.sessionId === sessionId && (payload.timeSinceInit = Date.now() - lastInit.timestamp), payload;
1583
+ };
1584
+ function initTelemetryChannel(channel) {
1585
+ channel.on(PREVIEW_INITIALIZED, async ({ userAgent }) => {
1586
+ try {
1587
+ let sessionId = await getSessionId(), lastEvents = await getLastEvents3(), lastInit = lastEvents.init;
1588
+ if (!lastEvents["preview-first-load"]) {
1589
+ let payload = makePayload(userAgent, lastInit, sessionId);
1590
+ telemetry4("preview-first-load", payload);
1591
+ }
1592
+ } catch {
1593
+ }
1594
+ }), channel.on(SHARE_ISOLATE_MODE, async () => {
1595
+ telemetry4("share", { action: "isolate-mode-opened" });
1596
+ }), channel.on(SIDEBAR_FILTER_CHANGED, (payload) => {
1597
+ telemetry4("sidebar-filter", payload);
1598
+ }), channel.on(AI_PROMPT_NUDGE, async ({ id, origin }) => {
1599
+ telemetry4("ai-prompt-nudge", { id, origin });
1600
+ }), channel.on(REVIEW_EVENTS.PAGEVIEW, ({ page, reviewCreatedAt }) => {
1601
+ telemetry4("review", { action: "pageview", source: "mcp-review", page, reviewCreatedAt });
1602
+ });
1603
+ }
1604
+
1605
+ // src/core-server/utils/constants.ts
1606
+ import { join } from "pathe";
1607
+ var defaultStaticDirs = [
1608
+ {
1609
+ from: join(resolvePackageDir("@aussieljk/forkbook"), "assets/browser"),
1610
+ to: "/sb-common-assets"
1611
+ }
1612
+ ], defaultFavicon = join(
1613
+ resolvePackageDir("@aussieljk/forkbook"),
1614
+ "assets/browser/favicon.svg"
1615
+ );
1616
+
1617
+ // src/core-server/utils/save-story/save-story.ts
1618
+ import { writeFile } from "node:fs/promises";
1619
+ import { basename, isAbsolute, join as join2, relative } from "node:path";
1620
+ import { types as t4 } from "@aussieljk/forkbook/internal/babel";
1621
+ import { formatFileContent, getProjectRoot } from "@aussieljk/forkbook/internal/common";
1622
+ import {
1623
+ SAVE_STORY_REQUEST,
1624
+ SAVE_STORY_RESPONSE,
1625
+ STORY_RENDERED
1626
+ } from "@aussieljk/forkbook/internal/core-events";
1627
+ import { storyNameFromExport, toId } from "@aussieljk/forkbook/internal/csf/csf-utils";
1628
+ import { printCsf, readCsf } from "@aussieljk/forkbook/internal/csf-tools";
1629
+ import { logger as logger3 } from "@aussieljk/forkbook/internal/node-logger";
1630
+ import { isExampleStoryId, telemetry as telemetry5 } from "@aussieljk/forkbook/internal/telemetry";
1631
+
1632
+ // src/core-server/utils/save-story/duplicate-story-with-new-name.ts
1633
+ import { types as t, traverse } from "@aussieljk/forkbook/internal/babel";
1634
+
1635
+ // src/core-server/utils/save-story/utils.ts
1636
+ var SaveStoryError = class extends Error {
1637
+ };
1638
+
1639
+ // src/core-server/utils/save-story/duplicate-story-with-new-name.ts
1640
+ var duplicateStoryWithNewName = (csfFile, storyName, newStoryName) => {
1641
+ let node = csfFile._storyExports[storyName], cloned = t.cloneNode(node);
1642
+ if (!cloned)
1643
+ throw new SaveStoryError("cannot clone Node");
1644
+ let found = !1;
1645
+ if (traverse(cloned, {
1646
+ Identifier(path) {
1647
+ found || path.node.name === storyName && (found = !0, path.node.name = newStoryName);
1648
+ },
1649
+ ObjectProperty(path) {
1650
+ let key = path.get("key");
1651
+ key.isIdentifier() && key.node.name === "args" && path.remove();
1652
+ },
1653
+ noScope: !0
1654
+ }), !(t.isCallExpression(cloned.init) && t.isMemberExpression(cloned.init.callee) && t.isIdentifier(cloned.init.callee.property) && cloned.init.callee.property.name === "story") && (t.isArrowFunctionExpression(cloned.init) || t.isCallExpression(cloned.init)))
1655
+ throw new SaveStoryError("Creating a new story based on a CSF2 story is not supported");
1656
+ return traverse(csfFile._ast, {
1657
+ Program(path) {
1658
+ path.pushContainer(
1659
+ "body",
1660
+ t.exportNamedDeclaration(t.variableDeclaration("const", [cloned]))
1661
+ );
1662
+ }
1663
+ }), cloned;
1664
+ };
1665
+
1666
+ // src/core-server/utils/save-story/update-args-in-csf-file.ts
1667
+ import { types as t3, traverse as traverse2 } from "@aussieljk/forkbook/internal/babel";
1668
+
1669
+ // src/core-server/utils/save-story/valueToAST.ts
1670
+ import { parser, types as t2 } from "@aussieljk/forkbook/internal/babel";
1671
+ function valueToAST(literal) {
1672
+ if (literal === null)
1673
+ return t2.nullLiteral();
1674
+ switch (typeof literal) {
1675
+ case "function":
1676
+ return parser.parse(literal.toString(), {
1677
+ allowReturnOutsideFunction: !0,
1678
+ allowSuperOutsideMethod: !0
1679
+ }).program.body[0]?.expression;
1680
+ case "number":
1681
+ return t2.numericLiteral(literal);
1682
+ case "string":
1683
+ return t2.stringLiteral(literal);
1684
+ case "boolean":
1685
+ return t2.booleanLiteral(literal);
1686
+ case "undefined":
1687
+ return t2.identifier("undefined");
1688
+ default:
1689
+ return Array.isArray(literal) ? t2.arrayExpression(literal.map(valueToAST)) : t2.objectExpression(
1690
+ Object.keys(literal).filter((k) => typeof literal[k] < "u").map((k) => {
1691
+ let value = literal[k];
1692
+ return t2.objectProperty(t2.stringLiteral(k), valueToAST(value));
1693
+ })
1694
+ );
1695
+ }
1696
+ }
1697
+
1698
+ // src/core-server/utils/save-story/update-args-in-csf-file.ts
1699
+ var updateArgsInCsfFile = async (node, input) => {
1700
+ let found = !1, args = Object.fromEntries(
1701
+ Object.entries(input).map(([k, v4]) => {
1702
+ if (!t3.isValidIdentifier(k, !1))
1703
+ throw new SaveStoryError(`Invalid arg name: ${JSON.stringify(k)}`);
1704
+ return [k, valueToAST(v4)];
1705
+ })
1706
+ );
1707
+ if (!(t3.isCallExpression(node) && t3.isMemberExpression(node.callee) && t3.isIdentifier(node.callee.property) && node.callee.property.name === "story") && (t3.isArrowFunctionExpression(node) || t3.isCallExpression(node)))
1708
+ throw new SaveStoryError("Updating a CSF2 story is not supported");
1709
+ if (t3.isObjectExpression(node)) {
1710
+ let properties = node.properties, argsProperty = properties.find((property) => {
1711
+ if (t3.isObjectProperty(property)) {
1712
+ let key = property.key;
1713
+ return t3.isIdentifier(key) && key.name === "args";
1714
+ }
1715
+ return !1;
1716
+ });
1717
+ if (argsProperty) {
1718
+ if (t3.isObjectProperty(argsProperty)) {
1719
+ let a = argsProperty.value;
1720
+ if (t3.isObjectExpression(a)) {
1721
+ a.properties.forEach((p) => {
1722
+ if (t3.isObjectProperty(p)) {
1723
+ let key = p.key;
1724
+ t3.isIdentifier(key) && key.name in args && (p.value = args[key.name], delete args[key.name]);
1725
+ }
1726
+ });
1727
+ let remainder = Object.entries(args);
1728
+ Object.keys(args).length && remainder.forEach(([key, value]) => {
1729
+ a.properties.push(t3.objectProperty(t3.identifier(key), value));
1730
+ });
1731
+ }
1732
+ }
1733
+ } else
1734
+ properties.unshift(
1735
+ t3.objectProperty(
1736
+ t3.identifier("args"),
1737
+ t3.objectExpression(
1738
+ Object.entries(args).map(([key, value]) => t3.objectProperty(t3.identifier(key), value))
1739
+ )
1740
+ )
1741
+ );
1742
+ return;
1743
+ }
1744
+ traverse2(node, {
1745
+ ObjectExpression(path) {
1746
+ if (found)
1747
+ return;
1748
+ found = !0;
1749
+ let argsProperty = path.get("properties").find((property) => {
1750
+ if (property.isObjectProperty()) {
1751
+ let key = property.get("key");
1752
+ return key.isIdentifier() && key.node.name === "args";
1753
+ }
1754
+ return !1;
1755
+ });
1756
+ if (argsProperty) {
1757
+ if (argsProperty.isObjectProperty()) {
1758
+ let a = argsProperty.get("value");
1759
+ if (a.isObjectExpression()) {
1760
+ a.traverse({
1761
+ ObjectProperty(p) {
1762
+ let key = p.get("key");
1763
+ key.isIdentifier() && key.node.name in args && (p.get("value").replaceWith(args[key.node.name]), delete args[key.node.name]);
1764
+ },
1765
+ noScope: !0
1766
+ });
1767
+ let remainder = Object.entries(args);
1768
+ Object.keys(args).length && remainder.forEach(([key, value]) => {
1769
+ a.pushContainer("properties", t3.objectProperty(t3.identifier(key), value));
1770
+ });
1771
+ }
1772
+ }
1773
+ } else
1774
+ path.unshiftContainer(
1775
+ "properties",
1776
+ t3.objectProperty(
1777
+ t3.identifier("args"),
1778
+ t3.objectExpression(
1779
+ Object.entries(args).map(([key, value]) => t3.objectProperty(t3.identifier(key), value))
1780
+ )
1781
+ )
1782
+ );
1783
+ },
1784
+ noScope: !0
1785
+ });
1786
+ };
1787
+
1788
+ // src/core-server/utils/save-story/save-story.ts
1789
+ var parseArgs = (args) => JSON.parse(args, (_, value) => value === "__sb_empty_function_arg__" ? () => {
1790
+ } : value), removeExtraNewlines = (code, name) => {
1791
+ let anything = "([\\s\\S])", newline = "(\\r\\n|\\r|\\n)", closing = newline + "};" + newline, regex = new RegExp(
1792
+ // Looks for an export by the given name, considers the first closing brace on its own line
1793
+ // to be the end of the story definition.
1794
+ `^(?<before>${anything}*)(?<story>export const ${name} =${anything}+?${closing})(?<after>${anything}*)$`
1795
+ ), { before, story, after } = code.match(regex)?.groups || {};
1796
+ return story ? before + story.replaceAll(/(\r\n|\r|\n)(\r\n|\r|\n)([ \t]*[a-z0-9_]+): /gi, "$2$3:") + after : code;
1797
+ };
1798
+ function initializeSaveStory(channel, options) {
1799
+ channel.on(SAVE_STORY_REQUEST, async ({ id, payload }) => {
1800
+ let { csfId, importPath, args, name } = payload, newStoryId, newStoryName, sourceFileName, sourceFilePath, sourceStoryName;
1801
+ try {
1802
+ if (name && !t4.isValidIdentifier(name))
1803
+ throw new SaveStoryError(`Invalid story name: ${JSON.stringify(name)}`);
1804
+ sourceFileName = basename(importPath), sourceFilePath = join2(process.cwd(), importPath);
1805
+ let pathFromProjectRoot = relative(getProjectRoot(), sourceFilePath);
1806
+ if (isAbsolute(pathFromProjectRoot) || // Windows strips trailing dots from path segments, so `...` is not a plain name there.
1807
+ pathFromProjectRoot.split(/[\\/]/).some((segment) => /^\.{2,}$/.test(segment)))
1808
+ throw new SaveStoryError("Invalid importPath: must resolve within the project root.");
1809
+ let csf = await readCsf(sourceFilePath, {
1810
+ makeTitle: (userTitle) => userTitle || "myTitle"
1811
+ }), parsed = csf.parse(), stories = Object.entries(parsed._stories), [componentId, storyId] = csfId.split("--");
1812
+ newStoryName = name && storyNameFromExport(name), newStoryId = newStoryName && toId(componentId, newStoryName);
1813
+ let [storyName] = stories.find(([key, value]) => value.id.endsWith(`--${storyId}`)) || [];
1814
+ if (!storyName)
1815
+ throw new SaveStoryError("Source story not found.");
1816
+ if (name && csf.getStoryExport(name))
1817
+ throw new SaveStoryError("Story already exists.");
1818
+ sourceStoryName = storyNameFromExport(storyName), await updateArgsInCsfFile(
1819
+ name ? duplicateStoryWithNewName(parsed, storyName, name) : csf.getStoryExport(storyName),
1820
+ args ? parseArgs(args) : {}
1821
+ );
1822
+ let code = await formatFileContent(
1823
+ sourceFilePath,
1824
+ removeExtraNewlines(printCsf(csf).code, name || storyName)
1825
+ );
1826
+ await Promise.all([
1827
+ new Promise((resolve2) => {
1828
+ channel.on(STORY_RENDERED, resolve2), setTimeout(() => resolve2(channel.off(STORY_RENDERED, resolve2)), 3e3);
1829
+ }),
1830
+ writeFile(sourceFilePath, code)
1831
+ ]), channel.emit(SAVE_STORY_RESPONSE, {
1832
+ id,
1833
+ success: !0,
1834
+ payload: {
1835
+ csfId,
1836
+ newStoryId,
1837
+ newStoryName,
1838
+ newStoryExportName: name,
1839
+ sourceFileContent: code,
1840
+ sourceFileName,
1841
+ sourceStoryName,
1842
+ sourceStoryExportName: storyName
1843
+ },
1844
+ error: null
1845
+ }), isExampleStoryId(newStoryId ?? csfId) || await telemetry5("save-story", {
1846
+ action: name ? "createStory" : "updateStory",
1847
+ success: !0
1848
+ });
1849
+ } catch (error) {
1850
+ channel.emit(SAVE_STORY_RESPONSE, {
1851
+ id,
1852
+ success: !1,
1853
+ error: error instanceof SaveStoryError ? error.message : "Unknown error"
1854
+ }), logger3.error(
1855
+ `Error writing to ${sourceFilePath}:
1856
+ ${error.stack || error.message || error.toString()}`
1857
+ ), error instanceof SaveStoryError || await telemetry5("save-story", {
1858
+ action: name ? "createStory" : "updateStory",
1859
+ success: !1,
1860
+ error
1861
+ });
1862
+ }
1863
+ });
1864
+ }
1865
+
1866
+ // src/core-server/utils/whats-new.ts
1867
+ import { findConfigFile, loadMainConfig } from "@aussieljk/forkbook/internal/common";
1868
+ import {
1869
+ REQUEST_WHATS_NEW_DATA,
1870
+ RESULT_WHATS_NEW_DATA,
1871
+ SET_WHATS_NEW_CACHE,
1872
+ TELEMETRY_ERROR,
1873
+ TOGGLE_WHATS_NEW_NOTIFICATIONS
1874
+ } from "@aussieljk/forkbook/internal/core-events";
1875
+ import { readConfig, writeConfig } from "@aussieljk/forkbook/internal/csf-tools";
1876
+ import { logger as logger4 } from "@aussieljk/forkbook/internal/node-logger";
1877
+ import { telemetry as telemetry6 } from "@aussieljk/forkbook/internal/telemetry";
1878
+ var WHATS_NEW_CACHE = "whats-new-cache", WHATS_NEW_URL = "https://storybook.js.org/whats-new/v1";
1879
+ function initializeWhatsNew(channel, options) {
1880
+ channel.on(SET_WHATS_NEW_CACHE, async (data) => {
1881
+ let cache = await options.cache.get(WHATS_NEW_CACHE).catch((e) => (logger4.verbose(e), {}));
1882
+ await options.cache.set(WHATS_NEW_CACHE, { ...cache, ...data });
1883
+ }), channel.on(REQUEST_WHATS_NEW_DATA, async () => {
1884
+ try {
1885
+ let post = await fetch(WHATS_NEW_URL).then(async (response) => {
1886
+ if (response.ok)
1887
+ return response.json();
1888
+ throw response;
1889
+ }), disableWhatsNewNotifications = (await loadMainConfig({ configDir: options.configDir })).core?.disableWhatsNewNotifications === !0, cache = await options.cache.get(WHATS_NEW_CACHE) ?? {}, data = {
1890
+ ...post,
1891
+ status: "SUCCESS",
1892
+ postIsRead: post.url === cache.lastReadPost,
1893
+ showNotification: post.url !== cache.lastDismissedPost && post.url !== cache.lastReadPost,
1894
+ disableWhatsNewNotifications
1895
+ };
1896
+ channel.emit(RESULT_WHATS_NEW_DATA, { data });
1897
+ } catch (e) {
1898
+ logger4.verbose(e instanceof Error ? e.message : String(e)), channel.emit(RESULT_WHATS_NEW_DATA, {
1899
+ data: { status: "ERROR" }
1900
+ });
1901
+ }
1902
+ }), channel.on(
1903
+ TOGGLE_WHATS_NEW_NOTIFICATIONS,
1904
+ async ({ disableWhatsNewNotifications }) => {
1905
+ try {
1906
+ let mainPath = findConfigFile("main", options.configDir);
1907
+ invariant(mainPath, `unable to find Forkbook main file in ${options.configDir}`);
1908
+ let main = await readConfig(mainPath);
1909
+ if (!main._exportsObject)
1910
+ throw new Error(
1911
+ "Unable to parse Forkbook main file while trying to read 'core' property"
1912
+ );
1913
+ main.set(["core", "disableWhatsNewNotifications"], disableWhatsNewNotifications), await writeConfig(main, mainPath), await telemetry6("core-config", { disableWhatsNewNotifications });
1914
+ } catch (error) {
1915
+ invariant(error instanceof Error), await sendTelemetryError(error, "core-config", {
1916
+ cliOptions: options,
1917
+ presetOptions: {
1918
+ ...options,
1919
+ corePresets: [],
1920
+ overridePresets: []
1921
+ },
1922
+ skipPrompt: !0
1923
+ });
1924
+ }
1925
+ }
1926
+ ), channel.on(TELEMETRY_ERROR, async (error) => {
1927
+ await sendTelemetryError(error, "browser", {
1928
+ cliOptions: options,
1929
+ presetOptions: {
1930
+ ...options,
1931
+ corePresets: [],
1932
+ overridePresets: []
1933
+ },
1934
+ skipPrompt: !0
1935
+ });
1936
+ });
1937
+ }
1938
+
1939
+ // src/core-server/presets/common-preset.ts
1940
+ var interpolate = (string4, data = {}) => Object.entries(data).reduce((acc, [k, v4]) => acc.replace(new RegExp(`%${k}%`, "g"), v4), string4), staticDirs = async (values = []) => [
1941
+ ...defaultStaticDirs,
1942
+ ...values
1943
+ ], favicon = async (value, options) => {
1944
+ if (value)
1945
+ return value;
1946
+ let staticDirsValue = await options.presets.apply("staticDirs"), faviconPaths = (staticDirsValue ? staticDirsValue.map((dir) => typeof dir == "string" ? dir : `${dir.from}:${dir.to}`) : []).map((dir) => {
1947
+ let results = [], normalizedDir = staticDirsValue && !isAbsolute2(dir) ? getDirectoryFromWorkingDir({
1948
+ configDir: options.configDir,
1949
+ workingDir: process.cwd(),
1950
+ directory: dir
1951
+ }) : dir, { staticPath, targetEndpoint } = parseStaticDir(normalizedDir);
1952
+ return ["/favicon.svg", "/favicon.ico"].includes(targetEndpoint) && results.push(staticPath), targetEndpoint === "/" && (results.push(join4(staticPath, "favicon.svg")), results.push(join4(staticPath, "favicon.ico"))), results.filter((path) => existsSync2(path));
1953
+ }).reduce((l1, l2) => l1.concat(l2), []);
1954
+ return faviconPaths.length > 1 && logger5.debug(dedent`
1955
+ Looks like multiple favicons were detected. Using the first one.
1956
+
1957
+ ${faviconPaths.join(", ")}
1958
+ `), faviconPaths[0] || defaultFavicon;
1959
+ }, babel = async (_, options) => {
1960
+ let { presets } = options, babelDefault = await presets.apply("babelDefault", {}, options) ?? {}, presetConfig = {
1961
+ targets: {
1962
+ // This is the same browser supports that we use to bundle our manager and preview code.
1963
+ chrome: 100,
1964
+ safari: 15,
1965
+ firefox: 91
1966
+ }
1967
+ };
1968
+ return options?.features && "babelRemoveBugfixes" in options.features && options.features.babelRemoveBugfixes || (presetConfig.bugfixes = !0), {
1969
+ ...babelDefault,
1970
+ // This override makes sure that we will never transpile babel further down then the browsers that storybook supports.
1971
+ // This is needed to support the mount property of the context described here:
1972
+ // https://storybook.js.org/docs/writing-tests/interaction-testing#run-code-before-each-story-in-a-file
1973
+ overrides: [
1974
+ ...babelDefault?.overrides ?? [],
1975
+ {
1976
+ include: /\.(story|stories)\.[cm]?[jt]sx?$/,
1977
+ presets: [["@babel/preset-env", presetConfig]]
1978
+ }
1979
+ ]
1980
+ };
1981
+ }, title = (previous, options) => previous || options.packageJson?.name || !1, logLevel = (previous, options) => previous || options.loglevel || "info", previewHead = async (base, { configDir, presets }) => {
1982
+ let interpolations = await presets.apply("env");
1983
+ return getPreviewHeadTemplate(configDir, interpolations);
1984
+ }, env = async () => {
1985
+ let { raw } = await loadEnvs({ production: !0 });
1986
+ return raw;
1987
+ }, previewBody = async (base, { configDir, presets }) => {
1988
+ let interpolations = await presets.apply("env");
1989
+ return getPreviewBodyTemplate(configDir, interpolations);
1990
+ }, typescript = () => ({
1991
+ check: !1
1992
+ }), experimental_serverAPI = (extension, options) => {
1993
+ let removeAddon = removeAddonBase, packageManager = JsPackageManagerFactory.getPackageManager({
1994
+ configDir: options.configDir
1995
+ });
1996
+ return removeAddon = async (id, opts) => (await telemetry7("remove", { addon: id, source: "api" }), removeAddonBase(id, { ...opts, packageManager })), { ...extension, removeAddon };
1997
+ }, core = async (existing, options) => ({
1998
+ ...existing,
1999
+ channelOptions: {
2000
+ ...existing?.channelOptions ?? {},
2001
+ ...options.configType === "DEVELOPMENT" ? { wsToken: getWsToken() } : {}
2002
+ },
2003
+ disableTelemetry: options.disableTelemetry || optionalEnvToBoolean(process.env.FORKBOOK_DISABLE_TELEMETRY),
2004
+ enableCrashReports: options.enableCrashReports || optionalEnvToBoolean(process.env.FORKBOOK_ENABLE_CRASH_REPORTS)
2005
+ }), babelPresetEnvMajor = getBabelPresetEnvMajor(), features = async (existing, options) => ({
2006
+ ...existing,
2007
+ actions: !0,
2008
+ argTypeTargetsV7: !0,
2009
+ babelRemoveBugfixes: babelPresetEnvMajor ? babelPresetEnvMajor >= 8 : !1,
2010
+ backgrounds: !0,
2011
+ componentsManifest: !1,
2012
+ experimentalChunkedPreviewRuntime: !1,
2013
+ controls: !0,
2014
+ disallowImplicitActionsInRenderV8: !0,
2015
+ docgenServer: await options.presets.apply("isDocgenProviderEnabled", !1),
2016
+ highlight: !0,
2017
+ interactions: !0,
2018
+ measure: !0,
2019
+ outline: !0,
2020
+ viewport: !0
2021
+ }), csfIndexer = {
2022
+ test: STORY_FILE_TEST_REGEXP,
2023
+ createIndex: async (fileName, options) => {
2024
+ let code = (await readFile(fileName, "utf-8")).toString();
2025
+ return code.trim().length === 0 ? (logger5.debug(`The file ${fileName} is empty. Skipping indexing.`), []) : loadCsf(code, { ...options, fileName }).parse().indexInputs;
2026
+ }
2027
+ }, experimental_indexers = (existingIndexers) => [csfIndexer].concat(existingIndexers || []), frameworkOptions = async (_, options) => {
2028
+ let config = await options.presets.apply("framework");
2029
+ return typeof config == "string" ? {} : typeof config > "u" ? null : config.options;
2030
+ }, managerHead = async (_, options) => {
2031
+ let location = join4(options.configDir, "manager-head.html");
2032
+ if (existsSync2(location)) {
2033
+ let contents = readFile(location, { encoding: "utf8" }), interpolations = options.presets.apply("env");
2034
+ return interpolate(await contents, await interpolations);
2035
+ }
2036
+ return "";
2037
+ }, channelToken = async (value) => value, experimental_serverChannel = async (channel, options) => (initAIAnalyticsChannel(channel, options, () => storyIndexGeneratorPromise), initializeWhatsNew(channel, options), initializeSaveStory(channel, options), initGhostStoriesChannel(channel, options), initOpenInEditorChannel(channel), initTelemetryChannel(channel), channel), resolvedReact = async (existing) => {
2038
+ try {
2039
+ return {
2040
+ ...existing,
2041
+ react: resolvePackageDir("react"),
2042
+ reactDom: resolvePackageDir("react-dom")
2043
+ };
2044
+ } catch {
2045
+ return existing;
2046
+ }
2047
+ }, managerEntries = async (existing) => [
2048
+ pathe.join(
2049
+ resolvePackageDir("@aussieljk/forkbook"),
2050
+ "dist/core-server/presets/common-manager.js"
2051
+ ),
2052
+ ...existing || []
2053
+ ];
2054
+ async function getHeadlessChangeDetectionAdapter(options) {
2055
+ try {
2056
+ let core2 = await options.presets.apply("core", {});
2057
+ if (!core2?.builder)
2058
+ return;
2059
+ let resolvedPreviewBuilder = typeof core2.builder == "string" ? core2.builder : core2.builder.name;
2060
+ return await (await getPreviewBuilder(resolvedPreviewBuilder)).changeDetectionAdapter?.(options);
2061
+ } catch (error) {
2062
+ logger5.warn("Change detection: adapter initialisation failed"), logger5.debug(error instanceof Error ? error.stack ?? error.message : String(error));
2063
+ return;
2064
+ }
2065
+ }
2066
+ var devServerSubscriptions = [];
2067
+ globalThis.FORKBOOK_SERVICES_LOADED = globalThis.FORKBOOK_SERVICES_LOADED ?? !1;
2068
+ var services = async (_value, options) => {
2069
+ if (globalThis.FORKBOOK_SERVICES_LOADED)
2070
+ throw new OpenServiceServicesAppliedTwiceError();
2071
+ globalThis.FORKBOOK_SERVICES_LOADED = !0;
2072
+ let getIndex = () => options.presets.apply("storyIndexGenerator").then((generator) => generator.getIndex());
2073
+ registerModuleGraphService({
2074
+ channel: options.channel,
2075
+ getIndex,
2076
+ workingDir: process.cwd(),
2077
+ presets: options.presets,
2078
+ getAdapter: () => getHeadlessChangeDetectionAdapter(options),
2079
+ getChangeDetectionReadiness
2080
+ });
2081
+ let features2 = await options.presets.apply("features"), storyIndex = { getIndex }, gitDiffProvider = new GitDiffProvider(process.cwd());
2082
+ if (registerToolset(
2083
+ createStoriesToolset({
2084
+ storyIndex,
2085
+ git: {
2086
+ getRepoRoot: () => gitDiffProvider.getRepoRoot(),
2087
+ getChangedFiles: () => gitDiffProvider.getChangedFiles()
2088
+ },
2089
+ changeStatuses: { getAll: getSyncedStatuses },
2090
+ // Real paths, because git reports the repo root as one; on Windows the cwd can differ in case.
2091
+ storybookDirs: {
2092
+ configDir: realpathSync.native(pathe.resolve(options.configDir)),
2093
+ getStaticDirs: async () => (await options.presets.apply("staticDirs") ?? []).flatMap((staticDir) => {
2094
+ try {
2095
+ return [realpathSync.native(mapStaticDir(staticDir, options.configDir).staticPath)];
2096
+ } catch {
2097
+ return [];
2098
+ }
2099
+ })
2100
+ }
2101
+ })
2102
+ ), registerReviewService({
2103
+ getIndex
2104
+ }), devServerSubscriptions.push(subscribeReviewToModuleGraphChanges), registerToolset(reviewToolset), features2?.docgenServer) {
2105
+ let [docgenDescriptors, storyDocsProvider] = await Promise.all([
2106
+ options.presets.apply("experimental_docgenProvider", []),
2107
+ options.presets.apply(
2108
+ "experimental_storyDocsProvider",
2109
+ async () => {
2110
+ }
2111
+ )
2112
+ ]), docgenWorker = docgenDescriptors.length > 0 ? createDocgenWorkerClient(docgenDescriptors) : void 0;
2113
+ docgenWorker && (registerDocgenService({
2114
+ getIndex,
2115
+ docgenProvider: (input) => docgenWorker.extract(input.entry)
2116
+ }), devServerSubscriptions.push(
2117
+ () => subscribeDocgenToModuleGraphChanges({ getIndex, workingDir: process.cwd() })
2118
+ )), registerStoryDocsService({
2119
+ getIndex,
2120
+ storyDocsProvider
2121
+ }), devServerSubscriptions.push(
2122
+ () => subscribeStoryDocsToModuleGraphChanges({ getIndex, workingDir: process.cwd() })
2123
+ );
2124
+ }
2125
+ let localDocsAccess = createLocalDocsAccess({
2126
+ storyIndex,
2127
+ getManifests: () => loadManifests(options.presets)
2128
+ }), refs = await getRefsFromConfig(options);
2129
+ registerToolset(
2130
+ createDocsToolset(
2131
+ refs.length > 0 ? {
2132
+ sources: createCompositionDocsSources({
2133
+ sources: [{ id: "local", title: "Local" }, ...refs],
2134
+ manifestProvider: sourceUrlManifestProvider,
2135
+ localAccess: localDocsAccess
2136
+ })
2137
+ } : { docsAccess: localDocsAccess }
2138
+ )
2139
+ );
2140
+ }, experimental_devServer = async (app, options) => {
2141
+ await applyServicesPresetOnce(options.presets);
2142
+ for (let subscribe of devServerSubscriptions.splice(0))
2143
+ subscribe();
2144
+ return app;
2145
+ }, storyIndexGeneratorPromise, storyIndexGenerator = async (_, options) => storyIndexGeneratorPromise || (storyIndexGeneratorPromise = (async () => {
2146
+ let workingDir = process.cwd(), configDir = options.configDir, stories = await options.presets.apply("stories"), normalizedStories = normalizeStories(stories, {
2147
+ configDir,
2148
+ workingDir
2149
+ }), [indexers, docs, features2] = await Promise.all([
2150
+ options.presets.apply("experimental_indexers", []),
2151
+ options.presets.apply("docs"),
2152
+ options.presets.apply("features")
2153
+ ]), generator = new StoryIndexGenerator(normalizedStories, {
2154
+ workingDir,
2155
+ configDir,
2156
+ indexers,
2157
+ docs,
2158
+ features: features2,
2159
+ storySorts: await options.presets.apply("storySorts", [])
2160
+ });
2161
+ return await generator.initialize(), generator;
2162
+ })(), storyIndexGeneratorPromise);
2163
+ export {
2164
+ babel,
2165
+ channelToken,
2166
+ core,
2167
+ csfIndexer,
2168
+ env,
2169
+ experimental_devServer,
2170
+ experimental_indexers,
2171
+ experimental_serverAPI,
2172
+ experimental_serverChannel,
2173
+ favicon,
2174
+ features,
2175
+ frameworkOptions,
2176
+ logLevel,
2177
+ managerEntries,
2178
+ managerHead,
2179
+ previewBody,
2180
+ previewHead,
2181
+ resolvedReact,
2182
+ services,
2183
+ staticDirs,
2184
+ storyIndexGenerator,
2185
+ title,
2186
+ typescript
2187
+ };