@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f

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 (354) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +51 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +4 -3
  7. package/api/build/build.type.d.mts +2 -2
  8. package/api/build/build.type.mjs +3 -3
  9. package/api/build/kit/kind.d.mts +2 -1
  10. package/api/build/kit/kind.mjs +199 -10
  11. package/api/build/kit/kit.mjs +6 -4
  12. package/api/build/kit/rank.d.mts +4 -2
  13. package/api/build/kit/rank.mjs +125 -24
  14. package/api/build/kit/start.d.mts +5 -4
  15. package/api/build/kit/start.mjs +12 -8
  16. package/api/build/kit/weights.d.mts +39 -3
  17. package/api/build/kit/weights.json +1 -1
  18. package/api/build/kit/weights.mjs +340 -43
  19. package/api/build/kit/word-model.d.mts +23 -0
  20. package/api/build/kit/word-model.mjs +46 -0
  21. package/api/build/kit/words.d.mts +48 -0
  22. package/api/build/kit/words.mjs +90 -1
  23. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  24. package/api/component/list/list.d.mts +1 -1
  25. package/api/component/list/list.mjs +48 -6
  26. package/api/discover/_adapter.d.mts +1 -1
  27. package/api/discover/search/search.mjs +3 -2
  28. package/api/docs/_adapter.d.mts +26 -2
  29. package/api/docs/_adapter.mjs +219 -6
  30. package/api/docs/docs.d.mts +3 -0
  31. package/api/docs/docs.doc.mjs +7 -1
  32. package/api/docs/docs.mjs +12 -0
  33. package/api/docs/docs.type.d.mts +5 -0
  34. package/api/docs/docs.type.mjs +2 -0
  35. package/api/docs/node/node.mjs +1 -1
  36. package/api/doctor/_adapter.d.mts +27 -5
  37. package/api/doctor/_adapter.mjs +83 -10
  38. package/api/doctor/built-checks.mjs +40 -14
  39. package/api/doctor/doctor.d.mts +4 -3
  40. package/api/doctor/doctor.mjs +14 -7
  41. package/api/doctor/theme-checks.mjs +121 -17
  42. package/api/icon/_records.mjs +2 -1
  43. package/api/index.d.mts +2 -0
  44. package/api/index.mjs +2 -0
  45. package/api/integration/_adapter.d.mts +44 -0
  46. package/api/integration/_adapter.mjs +77 -1
  47. package/api/integration/authoring-checks.mjs +6 -6
  48. package/api/integration/example-scope.d.mts +14 -0
  49. package/api/integration/example-scope.mjs +44 -0
  50. package/api/integration/example-scope.type.d.mts +29 -0
  51. package/api/integration/example-scope.type.mjs +25 -0
  52. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  53. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  54. package/api/integration/validate-integration.mjs +19 -1
  55. package/api/integration/validate-integration.type.d.mts +9 -0
  56. package/api/integration/validate-integration.type.mjs +1 -1
  57. package/api/integration/validateIntegration.doc.mjs +1 -1
  58. package/api/render/_adapter.mjs +591 -195
  59. package/api/render/render.doc.mjs +11 -3
  60. package/api/render/render.type.d.mts +52 -0
  61. package/api/render/render.type.mjs +31 -1
  62. package/api/search/ORDERING.md +1 -1
  63. package/api/search/_adapter.d.mts +9 -0
  64. package/api/search/_adapter.mjs +85 -0
  65. package/api/search/_candidate-score.mjs +51 -32
  66. package/api/search/_fit-order.mjs +3 -3
  67. package/api/search/_gather-components.d.mts +3 -2
  68. package/api/search/_gather-components.mjs +12 -3
  69. package/api/search/_lexical.d.mts +5 -0
  70. package/api/search/_lexical.mjs +8 -2
  71. package/api/search/_result.d.mts +11 -9
  72. package/api/search/_result.mjs +4 -4
  73. package/api/search/_score.d.mts +6 -1
  74. package/api/search/_score.mjs +15 -3
  75. package/api/search/search-index.mjs +7 -1
  76. package/api/search/search.d.mts +1 -1
  77. package/api/theme/_adapter.mjs +12 -1
  78. package/api/theme/build/build.d.mts +75 -0
  79. package/api/theme/build/build.mjs +243 -58
  80. package/api/theme/build/font-warning.d.mts +7 -0
  81. package/api/theme/build/font-warning.mjs +17 -0
  82. package/api/theme/theme.type.d.mts +10 -0
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme-edit/_adapter.d.mts +63 -2
  85. package/api/theme-edit/_adapter.mjs +771 -57
  86. package/api/theme-edit/_check.d.mts +40 -22
  87. package/api/theme-edit/_check.mjs +2029 -336
  88. package/api/theme-edit/_color.d.mts +10 -0
  89. package/api/theme-edit/_color.mjs +49 -1
  90. package/api/theme-edit/_compiler.mjs +9 -0
  91. package/api/theme-edit/_context.d.mts +3 -3
  92. package/api/theme-edit/_context.mjs +111 -48
  93. package/api/theme-edit/_css.d.mts +14 -0
  94. package/api/theme-edit/_css.mjs +46 -1
  95. package/api/theme-edit/_edit.d.mts +18 -4
  96. package/api/theme-edit/_edit.mjs +1685 -155
  97. package/api/theme-edit/_how-commands.d.mts +65 -0
  98. package/api/theme-edit/_how-commands.mjs +633 -1
  99. package/api/theme-edit/_how-question.d.mts +84 -0
  100. package/api/theme-edit/_how-question.mjs +5124 -281
  101. package/api/theme-edit/_how.mjs +140 -29
  102. package/api/theme-edit/_marks.d.mts +31 -5
  103. package/api/theme-edit/_marks.mjs +57 -5
  104. package/api/theme-edit/_name-rule.d.mts +11 -0
  105. package/api/theme-edit/_name-rule.mjs +12 -0
  106. package/api/theme-edit/_normal.d.mts +257 -0
  107. package/api/theme-edit/_normal.mjs +1252 -0
  108. package/api/theme-edit/_palette.mjs +10 -4
  109. package/api/theme-edit/_parts.d.mts +10 -1
  110. package/api/theme-edit/_parts.mjs +179 -3
  111. package/api/theme-edit/_preview-app.d.mts +7 -1
  112. package/api/theme-edit/_preview-app.mjs +515 -148
  113. package/api/theme-edit/_preview.d.mts +100 -14
  114. package/api/theme-edit/_preview.mjs +549 -137
  115. package/api/theme-edit/_settings.d.mts +347 -30
  116. package/api/theme-edit/_settings.mjs +2971 -327
  117. package/api/theme-edit/_tables.d.mts +6 -0
  118. package/api/theme-edit/_tables.mjs +44 -1
  119. package/api/theme-edit/_vet.d.mts +18 -0
  120. package/api/theme-edit/_vet.mjs +32 -0
  121. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  122. package/api/theme-edit/theme-edit.type.mjs +4 -1
  123. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  124. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  125. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  126. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  128. package/api/upgrade/run/run.mjs +4 -3
  129. package/assets/codemods/integration-discovery.mjs +2 -1
  130. package/assets/codemods/run-codemod.mjs +87 -7
  131. package/assets/codemods/transforms/next/index.mjs +11 -1
  132. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  133. package/assets/component-list.generated.json +1 -0
  134. package/assets/docs/author-a-theme.doc.mjs +1 -0
  135. package/assets/docs/theme.doc.dense.mjs +2 -2
  136. package/assets/docs/theme.doc.mjs +1 -1
  137. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  138. package/assets/docs/tree/checks.doc.mjs +1 -1
  139. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  140. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -0
  142. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  143. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  144. package/assets/docs/use-a-theme.doc.mjs +1 -1
  145. package/assets/docs.generated.json +2 -2
  146. package/assets/search-catalog.generated.json +2 -0
  147. package/assets/self-audit.generated.json +1 -1
  148. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  149. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  150. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  151. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  152. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  153. package/assets/templates/components.generated.json +1 -1
  154. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  155. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  156. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  157. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  158. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  159. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  160. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  161. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  162. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  163. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  164. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  165. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  166. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  167. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  168. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  169. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  170. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  171. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  172. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  173. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  174. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  175. package/assets/templates/pages/ide/page.tsx +24 -2
  176. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  177. package/assets/templates/pages/library/template.doc.mjs +4 -1
  178. package/assets/templates/pages/login/template.doc.mjs +2 -1
  179. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  180. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  181. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  182. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  183. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  184. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  185. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  186. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  187. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  188. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  189. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  190. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  191. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  192. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  193. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  194. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  195. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  196. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  197. package/assets/theme.template.ts +6 -0
  198. package/authoring/debug/parse.d.mts +3 -3
  199. package/authoring/doctypes/_schema.d.mts +3 -3
  200. package/authoring/doctypes/command/command.doc.mjs +1 -1
  201. package/authoring/doctypes/component/categories.d.mts +37 -0
  202. package/authoring/doctypes/component/categories.mjs +54 -0
  203. package/authoring/doctypes/template/template.doc.mjs +1 -1
  204. package/authoring/doctypes/template/type.ts +9 -0
  205. package/authoring/example/example.doc.d.mts +12 -0
  206. package/authoring/example/example.doc.mjs +69 -0
  207. package/authoring/example/preview.d.mts +92 -0
  208. package/authoring/example/preview.mjs +994 -0
  209. package/authoring/example/type.ts +102 -0
  210. package/authoring/index.d.mts +1 -0
  211. package/authoring/index.d.ts +12 -0
  212. package/authoring/index.mjs +3 -1
  213. package/clients/cli/bin/astryx.mjs +6 -9
  214. package/clients/cli/build-id.generated.json +1 -1
  215. package/clients/cli/commands/component.doc.mjs +1 -1
  216. package/clients/cli/commands/component.mjs +22 -3
  217. package/clients/cli/commands/docs.doc.mjs +7 -1
  218. package/clients/cli/commands/docs.mjs +3 -1
  219. package/clients/cli/commands/doctor.mjs +32 -14
  220. package/clients/cli/commands/experimental/render.mjs +42 -1
  221. package/clients/cli/commands/experimental/theme.mjs +163 -28
  222. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  223. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  224. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  225. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  226. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  227. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  228. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  229. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  230. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  231. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  233. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  234. package/clients/cli/commands/search.doc.mjs +2 -1
  235. package/clients/cli/commands/search.mjs +6 -1
  236. package/clients/cli/commands/template.mjs +4 -2
  237. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  238. package/clients/cli/commands/theme.doc.mjs +1 -1
  239. package/clients/cli/commands/theme.mjs +209 -8
  240. package/clients/cli/commands/upgrade.mjs +42 -7
  241. package/clients/cli/index.mjs +1 -1
  242. package/clients/cli/lib/cli-error.mjs +2 -1
  243. package/clients/cli/lib/component-format.mjs +205 -98
  244. package/clients/cli/lib/hook-format.mjs +9 -19
  245. package/clients/cli/lib/json-shim.mjs +77 -21
  246. package/clients/cli/lib/manifest.mjs +3 -2
  247. package/clients/cli/manifest.generated.json +1 -1
  248. package/foundation/agent-docs/agent-docs.mjs +1 -1
  249. package/foundation/config/theme-state.d.mts +13 -1
  250. package/foundation/config/theme-state.mjs +47 -7
  251. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  252. package/foundation/discovery/component-discovery.d.mts +11 -0
  253. package/foundation/discovery/component-discovery.mjs +56 -8
  254. package/foundation/discovery/component-replacement.mjs +130 -1
  255. package/foundation/discovery/copied-passages.mjs +2 -1
  256. package/foundation/discovery/doc-types.mjs +4 -3
  257. package/foundation/discovery/entry-name-files.d.mts +43 -0
  258. package/foundation/discovery/entry-name-files.mjs +264 -0
  259. package/foundation/discovery/hook-discovery.d.mts +8 -2
  260. package/foundation/discovery/hook-discovery.mjs +22 -8
  261. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  262. package/foundation/discovery/icon-set-checks.mjs +2 -1
  263. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  264. package/foundation/discovery/integration-doc-files.mjs +2 -1
  265. package/foundation/discovery/package-exports.d.mts +10 -0
  266. package/foundation/discovery/package-exports.mjs +56 -3
  267. package/foundation/discovery/prop-drift.mjs +9 -9
  268. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  269. package/foundation/discovery/runner-allowlist.mjs +2 -0
  270. package/foundation/discovery/stored-component-list.d.mts +43 -0
  271. package/foundation/discovery/stored-component-list.mjs +90 -0
  272. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  273. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  274. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  275. package/foundation/discovery/stored-self-audit.mjs +38 -18
  276. package/foundation/discovery/template-adapter.d.mts +52 -0
  277. package/foundation/discovery/template-adapter.mjs +176 -12
  278. package/foundation/discovery/template-icons.mjs +2 -1
  279. package/foundation/discovery/theme-discovery.mjs +3 -2
  280. package/foundation/discovery/theme-imports.d.mts +14 -0
  281. package/foundation/discovery/theme-imports.mjs +43 -1
  282. package/foundation/discovery/theming-targets.mjs +3 -2
  283. package/foundation/doc-compiler/import.mjs +7 -1
  284. package/foundation/doc-compiler/inputs.mjs +3 -2
  285. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  286. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  287. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  288. package/foundation/env/semver.mjs +3 -1
  289. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  290. package/foundation/fonts/font-stylesheet.mjs +115 -0
  291. package/foundation/fs/cache-eviction.d.mts +21 -0
  292. package/foundation/fs/cache-eviction.mjs +73 -0
  293. package/foundation/fs/file-protection.mjs +4 -3
  294. package/foundation/fs/gather-cache.d.mts +25 -4
  295. package/foundation/fs/gather-cache.mjs +164 -55
  296. package/foundation/fs/jiti-cache.d.mts +19 -1
  297. package/foundation/fs/jiti-cache.mjs +130 -6
  298. package/foundation/fs/kept-tree.d.mts +60 -0
  299. package/foundation/fs/kept-tree.mjs +154 -0
  300. package/foundation/fs/listing-cache.d.mts +7 -0
  301. package/foundation/fs/listing-cache.mjs +10 -0
  302. package/foundation/fs/module-loader.d.mts +24 -2
  303. package/foundation/fs/module-loader.mjs +94 -21
  304. package/foundation/fs/paths.d.mts +18 -0
  305. package/foundation/fs/paths.mjs +15 -2
  306. package/foundation/identity/provider-identity.d.mts +6 -0
  307. package/foundation/identity/provider-identity.mjs +10 -1
  308. package/foundation/integrations/contribution-inventory.mjs +4 -3
  309. package/foundation/integrations/example-code.d.mts +63 -0
  310. package/foundation/integrations/example-code.mjs +416 -0
  311. package/foundation/integrations/public-imports.d.mts +9 -0
  312. package/foundation/integrations/public-imports.mjs +3 -2
  313. package/foundation/integrations/validate-contributions.mjs +17 -45
  314. package/foundation/render/embedded-files.d.mts +6 -0
  315. package/foundation/render/embedded-files.mjs +25 -5
  316. package/foundation/render/embedded-imports.d.mts +39 -7
  317. package/foundation/render/embedded-imports.mjs +66 -27
  318. package/foundation/render/file-header.d.mts +66 -0
  319. package/foundation/render/file-header.mjs +118 -0
  320. package/foundation/render/host-answer.d.mts +18 -0
  321. package/foundation/render/host-answer.mjs +46 -0
  322. package/foundation/render/host-exit.d.mts +1 -0
  323. package/foundation/render/host-exit.mjs +6 -1
  324. package/foundation/render/html-reader.d.mts +55 -2
  325. package/foundation/render/html-reader.mjs +145 -26
  326. package/foundation/render/markup-edits.d.mts +57 -0
  327. package/foundation/render/markup-edits.mjs +182 -0
  328. package/foundation/render/page-host.mjs +29 -12
  329. package/foundation/render/page-worker.mjs +121 -13
  330. package/foundation/render/picture-chrome.d.mts +4 -0
  331. package/foundation/render/picture-chrome.mjs +185 -0
  332. package/foundation/render/picture-playwright.d.mts +4 -0
  333. package/foundation/render/picture-playwright.mjs +34 -0
  334. package/foundation/render/rebuild.mjs +2 -1
  335. package/foundation/render/render-page.d.mts +35 -3
  336. package/foundation/render/render-page.mjs +316 -42
  337. package/foundation/render/source-block.d.mts +85 -6
  338. package/foundation/render/source-block.mjs +211 -20
  339. package/foundation/render/ts-paths.d.mts +69 -6
  340. package/foundation/render/ts-paths.mjs +326 -40
  341. package/foundation/response/error-codes.d.mts +3 -1
  342. package/foundation/response/error-codes.d.ts +1 -0
  343. package/foundation/response/error-codes.doc.mjs +12 -1
  344. package/foundation/response/error-codes.mjs +11 -1
  345. package/foundation/response/response-types.doc.mjs +2 -2
  346. package/foundation/text/compare-text.d.mts +14 -0
  347. package/foundation/text/compare-text.mjs +68 -0
  348. package/foundation/text/string-utils.d.mts +3 -2
  349. package/foundation/text/string-utils.mjs +18 -4
  350. package/foundation/text/suggest-order.d.mts +9 -0
  351. package/foundation/text/suggest-order.mjs +15 -1
  352. package/foundation/xle/expand.mjs +2 -1
  353. package/host/index.mjs +8 -6
  354. package/package.json +7 -6
@@ -13,6 +13,7 @@ import postcss from 'postcss';
13
13
  import {
14
14
  collectUnloadedFonts,
15
15
  discoverDoctorThemes,
16
+ themeIdentifier,
16
17
  discoverDoctorUnmigratedCopies,
17
18
  corePeerRange,
18
19
  findDoctorCoreDir,
@@ -32,15 +33,15 @@ import {
32
33
  resolveRecordedTheme,
33
34
  resolveThemeModule,
34
35
  SOURCE_EXTENSIONS,
36
+ doctorStylesheetImportFile,
37
+ fileMark,
38
+ generatedSourceCommand,
35
39
  isPrivateVarRefusal,
36
40
  missingThemePackage,
37
41
  packageInstallCommand,
38
42
  themeBuild,
39
43
  themeRecordOwner,
40
44
  validateThemePrivateInputs,
41
- GENERATED_MARKER,
42
- APP_COPY_MARK,
43
- EDITOR_GENERATED_MARK,
44
45
  } from './_adapter.mjs';
45
46
  import {
46
47
  getCliInvocation,
@@ -117,7 +118,15 @@ function refreshThemeCommand(projectDir, run, available, slug, owner) {
117
118
  }
118
119
  const source = theme
119
120
  ? relative(projectDir, path.join(theme.sourceDir, theme.entry))
120
- : projectPath(path.join(owner, slug, `${slug}Theme.ts`));
121
+ : projectPath(path.join(owner, slug, `${themeIdentifier(slug)}Theme.ts`));
122
+ // A source another command generates (its leading comment carries that
123
+ // command's mark), or a missing one that command writes: the fix is that
124
+ // command, which writes the source and its outputs together.
125
+ const by = generatedSourceCommand(path.resolve(projectDir, source));
126
+ if (by)
127
+ return /^astryx\s/.test(by)
128
+ ? `${run} ${by.replace(/^astryx\s+/, '')}; ${run} theme add ${slug}`
129
+ : `Rebuild ${projectPath(path.dirname(source))}/ with ${by}, then run ${run} theme add ${slug}`;
121
130
  return `${run} theme build ${source}; ${run} theme add ${slug}`;
122
131
  }
123
132
 
@@ -225,12 +234,7 @@ function sourceImportEvidence(root, generatedModule) {
225
234
  * @param {string} source
226
235
  */
227
236
  function generatedThemeFile(source) {
228
- const leading =
229
- /^\s*(?:\/\*[\s\S]*?\*\/|(?:\/\/[^\n]*(?:\n|$)\s*)+)/.exec(source)?.[0] ??
230
- '';
231
- return [GENERATED_MARKER, EDITOR_GENERATED_MARK, APP_COPY_MARK].some(m =>
232
- leading.includes(m),
233
- );
237
+ return fileMark(source) != null;
234
238
  }
235
239
 
236
240
  /**
@@ -447,19 +451,61 @@ function namedThemeFonts(files) {
447
451
  return new Set(names.values());
448
452
  }
449
453
 
450
- /** @param {string} css */
451
- function fontStylesheetEvidence(css) {
454
+ /**
455
+ * The families a font stylesheet loads with `@font-face`, following its
456
+ * local `@import`s (a relative file, or a package's stylesheet such as
457
+ * `@fontsource/inter/index.css`); `external` when it imports a URL
458
+ * (http, https, `//`), whose families doctor cannot read.
459
+ * @param {string} css
460
+ * @param {string} [file] the stylesheet's path, to resolve local imports
461
+ * @param {Set<string>} [seen]
462
+ */
463
+ function fontStylesheetEvidence(css, file, seen = new Set()) {
452
464
  const loaded = new Set();
453
465
  let external = false;
466
+ let unread = false;
454
467
  const root = postcss.parse(css);
455
468
  root.walkAtRules(atRule => {
456
- if (atRule.name.toLowerCase() === 'import') external = true;
469
+ if (atRule.name.toLowerCase() === 'import') {
470
+ const spec = [...doctorStylesheetImports(`@import ${atRule.params};`)][0];
471
+ if (!spec || /^(?:https?:)?\/\//i.test(spec)) {
472
+ external = true;
473
+ return;
474
+ }
475
+ const target = file ? doctorStylesheetImportFile(spec, file) : null;
476
+ if (!target) {
477
+ // A local import doctor cannot follow may load the font: it
478
+ // cannot prove it either way.
479
+ unread = true;
480
+ return;
481
+ }
482
+ if (seen.has(target)) return;
483
+ if (seen.size > 20) {
484
+ // Past the limit doctor follows, the rest is not proven either way.
485
+ unread = true;
486
+ return;
487
+ }
488
+ seen.add(target);
489
+ try {
490
+ const inner = fontStylesheetEvidence(
491
+ readTextFile(target),
492
+ target,
493
+ seen,
494
+ );
495
+ for (const name of inner.loaded) loaded.add(name);
496
+ external ||= inner.external;
497
+ unread ||= inner.unread;
498
+ } catch {
499
+ unread = true;
500
+ }
501
+ return;
502
+ }
457
503
  if (atRule.name.toLowerCase() !== 'font-face') return;
458
504
  atRule.walkDecls(/^font-family$/iu, declaration => {
459
505
  loaded.add(normalizeFontName(declaration.value).toLowerCase());
460
506
  });
461
507
  });
462
- return {loaded, external};
508
+ return {loaded, external, unread};
463
509
  }
464
510
 
465
511
  /** @param {import('postcss').Rule} rule @param {string} slug */
@@ -702,6 +748,9 @@ export async function themeImportWiring(cwd) {
702
748
  } catch {
703
749
  continue;
704
750
  }
751
+ // A file the CLI generates (a theme build, the editor's files) imports
752
+ // its base to extend it, never to render it: it wires nothing.
753
+ if (generatedThemeFile(source)) continue;
705
754
  const shown = relative(projectDir, file);
706
755
  const candidates = themes.filter(
707
756
  theme =>
@@ -718,6 +767,11 @@ export async function themeImportWiring(cwd) {
718
767
  path.extname(file) === '.css'
719
768
  ? doctorStylesheetImports(source)
720
769
  : moduleSpecifiers(source, {runtimeOnly: true});
770
+ // An import used only as a theme's `extends` (a theme source such
771
+ // as the editor's) renders nothing.
772
+ if (path.extname(file) !== '.css')
773
+ for (const from of extendOnlySpecifiers(parseModule(source)))
774
+ specifiers.delete(from);
721
775
  } catch {
722
776
  specifiers = new Set();
723
777
  }
@@ -1066,14 +1120,48 @@ export async function checkAppThemes(cwd) {
1066
1120
  label: 'Theme owners and built imports',
1067
1121
  status: 'fail',
1068
1122
  message: discoveryError.message,
1069
- fix: `${run} theme add <slug>`,
1123
+ // The added theme the broken folder holds, by its name.
1124
+ fix: (() => {
1125
+ const named = ownerEntries.find(([slug]) =>
1126
+ new RegExp(
1127
+ `(^|[\\s/"'(])${slug.replace(/[-]/g, '\\-')}([\\s/"').,:]|$)`,
1128
+ ).test(discoveryError.message),
1129
+ )?.[0];
1130
+ if (!named)
1131
+ return 'Fix or move what the message names, then run doctor again.';
1132
+ // A theme another command generates: that command writes it again
1133
+ // (its fix is no `theme build`).
1134
+ const owner = String(state.themes[named]);
1135
+ const fix = isLocalThemeOwner(owner)
1136
+ ? refreshThemeCommand(state.projectDir, run, [], named, owner)
1137
+ : null;
1138
+ return fix && !fix.includes(' theme build ')
1139
+ ? fix
1140
+ : `Fix or move what the message names, then run ${run} theme add ${named}`;
1141
+ })(),
1070
1142
  });
1071
1143
  } else if (resolutionProblems.length > 0) {
1072
1144
  checks.push({
1073
1145
  id: 'theme-owners',
1074
1146
  label: 'Theme owners and built imports',
1075
1147
  status: 'fail',
1076
- message: resolutionProblems.map(problem => problem.message).join(' '),
1148
+ message: resolutionProblems
1149
+ .map(problem =>
1150
+ // A theme another command generates is not rebuilt with `theme
1151
+ // build`: its fix names that command, so its message does not.
1152
+ refreshThemeCommand(
1153
+ state.projectDir,
1154
+ run,
1155
+ available,
1156
+ problem.slug,
1157
+ problem.owner,
1158
+ ).includes(' theme build ')
1159
+ ? problem.message
1160
+ : problem.message
1161
+ .replace(/\s*Run `[^`]*theme build[^`]*` and try again\./, '')
1162
+ .replace(/\s*Rebuild it with `[^`]*theme build[^`]*`\.?/, ''),
1163
+ )
1164
+ .join(' '),
1077
1165
  fix: resolutionProblems
1078
1166
  .map(problem =>
1079
1167
  refreshThemeCommand(
@@ -1231,8 +1319,14 @@ export async function checkAppThemes(cwd) {
1231
1319
  );
1232
1320
  if (!availableTheme) continue;
1233
1321
  try {
1322
+ const sourceFile = path.join(
1323
+ availableTheme.sourceDir,
1324
+ availableTheme.entry,
1325
+ );
1326
+ // Every added local theme is compared, a copy another command
1327
+ // generates included; only its fix names that command.
1234
1328
  const receipt = await themeBuild(
1235
- path.join(availableTheme.sourceDir, availableTheme.entry),
1329
+ sourceFile,
1236
1330
  {check: true},
1237
1331
  {cwd: state.projectDir, projectCore: true},
1238
1332
  );
@@ -1469,6 +1563,8 @@ export async function checkAppThemes(cwd) {
1469
1563
 
1470
1564
  const fontFailures = [];
1471
1565
  const externalFontWarnings = [];
1566
+ /** Families behind a local font import doctor could not follow. */
1567
+ const unreadFontWarnings = [];
1472
1568
  const missingFontWarnings = [];
1473
1569
  let generatedImports = null;
1474
1570
  try {
@@ -1509,6 +1605,7 @@ export async function checkAppThemes(cwd) {
1509
1605
  try {
1510
1606
  const evidence = fontStylesheetEvidence(
1511
1607
  readTextFile(theme.fontStylesheetFile),
1608
+ theme.fontStylesheetFile,
1512
1609
  );
1513
1610
  const missing = [...names].filter(
1514
1611
  name => !evidence.loaded.has(name.toLowerCase()),
@@ -1516,6 +1613,8 @@ export async function checkAppThemes(cwd) {
1516
1613
  if (missing.length === 0) continue;
1517
1614
  if (evidence.external) {
1518
1615
  externalFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
1616
+ } else if (evidence.unread) {
1617
+ unreadFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
1519
1618
  } else {
1520
1619
  fontFailures.push({theme, message: missing.join(', ')});
1521
1620
  }
@@ -1553,6 +1652,11 @@ export async function checkAppThemes(cwd) {
1553
1652
  );
1554
1653
  }
1555
1654
  }
1655
+ if (unreadFontWarnings.length > 0) {
1656
+ fontWarningMessages.push(
1657
+ `Font imports doctor could not follow prevent proof for ${unreadFontWarnings.join('; ')}.`,
1658
+ );
1659
+ }
1556
1660
  if (externalFontWarnings.length > 0) {
1557
1661
  fontWarningMessages.push(
1558
1662
  `External font imports prevent proof for ${externalFontWarnings.join('; ')}.`,
@@ -14,6 +14,7 @@
14
14
  import {AstryxError} from '../error.mjs';
15
15
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
16
16
  import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
17
+ import {compareText} from '../../foundation/text/compare-text.mjs';
17
18
  export {
18
19
  answeringMatches,
19
20
  iconRecord,
@@ -115,7 +116,7 @@ export function oneNamedSet(sets, withdrawn, selector) {
115
116
  export function closest(wanted, candidates, reason, max = 5) {
116
117
  return [...new Set(candidates)]
117
118
  .map(name => ({name, distance: levenshteinDistance(wanted, name)}))
118
- .sort((a, b) => a.distance - b.distance || a.name.localeCompare(b.name))
119
+ .sort((a, b) => a.distance - b.distance || compareText(a.name, b.name))
119
120
  .slice(0, max)
120
121
  .map(({name}) => ({name, reason}));
121
122
  }
package/api/index.d.mts CHANGED
@@ -23,6 +23,7 @@ export { doctor } from "./doctor/doctor.mjs";
23
23
  export { integrationAddTheme } from "./integration/add-theme.mjs";
24
24
  export { integrationPackCheck } from "./integration/pack-check.mjs";
25
25
  export { integrationCheck } from "./integration/check/check.mjs";
26
+ export { integrationExampleScope } from "./integration/example-scope.mjs";
26
27
  export { AstryxError } from "./error.mjs";
27
28
  export { logger } from "./logger.mjs";
28
29
  export * from "../foundation/response/batch.type.mjs";
@@ -45,6 +46,7 @@ export * from "./integration/pack-check.type.mjs";
45
46
  export * from "./integration/validate-integration.type.mjs";
46
47
  export * from "./integration/authoring-checks.type.mjs";
47
48
  export * from "./integration/integration-check.type.mjs";
49
+ export * from "./integration/example-scope.type.mjs";
48
50
  export type Logger = import("./logger.mjs").Logger;
49
51
  export { themeBuild, themeAdd, themeRemove, themeUse, themeEject, themeTemplate, themeList, themeListAvailable, themeListCopySources, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
50
52
  export { exportSearchIndex, rankSearchIndex } from "./search/search-index.mjs";
package/api/index.mjs CHANGED
@@ -75,6 +75,7 @@ export {
75
75
  integrationDocConflicts,
76
76
  } from './integration/authoring-checks.mjs';
77
77
  export {integrationCheck} from './integration/check/check.mjs';
78
+ export {integrationExampleScope} from './integration/example-scope.mjs';
78
79
  export {AstryxError} from './error.mjs';
79
80
  // The one shared logger: the `logger` instance side-effecting commands write
80
81
  // through, plus its generated `Logger` type. Part of the public surface so an
@@ -109,3 +110,4 @@ export * from './integration/pack-check.type.mjs';
109
110
  export * from './integration/validate-integration.type.mjs';
110
111
  export * from './integration/authoring-checks.type.mjs';
111
112
  export * from './integration/integration-check.type.mjs';
113
+ export * from './integration/example-scope.type.mjs';
@@ -66,6 +66,50 @@ export function integrationDocCommands(integration: any): Promise<import("../../
66
66
  * @returns {Promise<boolean>}
67
67
  */
68
68
  export function projectUsesIconSets(cwd: string): Promise<boolean>;
69
+ /**
70
+ * @typedef {object} LoadedExampleScope
71
+ * @property {boolean} found whether an integration manifest loaded
72
+ * @property {string | null} name
73
+ * @property {string | null} version
74
+ * @property {import('../../authoring/example/type.ts').ExampleScope | null} scope
75
+ * @property {string} [reason] why there is no scope
76
+ * @property {string} [incomplete] why names Core or React give were not read
77
+ */
78
+ /**
79
+ * The scope a package's component examples are read against: the local
80
+ * package rooted at `cwd` (no `pkg`), or a package installed beside it.
81
+ * Throws when `pkg` is not a bare package name.
82
+ * @param {string | undefined} pkg
83
+ * @param {string} cwd
84
+ * @returns {Promise<LoadedExampleScope>}
85
+ */
86
+ export function loadExampleScope(pkg: string | undefined, cwd: string): Promise<LoadedExampleScope>;
87
+ /**
88
+ * Each of the package's component examples that cannot run on its own, as a
89
+ * note with its fix, and the examples that could not be judged.
90
+ * @param {any} integration a loaded integration
91
+ */
92
+ export function integrationExampleCode(integration: any): Promise<{
93
+ notes: ExampleCodeNote[];
94
+ unchecked: ExampleCodeUnchecked[];
95
+ }>;
96
+ export type LoadedExampleScope = {
97
+ /**
98
+ * whether an integration manifest loaded
99
+ */
100
+ found: boolean;
101
+ name: string | null;
102
+ version: string | null;
103
+ scope: import("../../authoring/example/type.ts").ExampleScope | null;
104
+ /**
105
+ * why there is no scope
106
+ */
107
+ reason?: string | undefined;
108
+ /**
109
+ * why names Core or React give were not read
110
+ */
111
+ incomplete?: string | undefined;
112
+ };
69
113
  import { findCopiedPassages } from '../../foundation/discovery/copied-passages.mjs';
70
114
  import { findFluff } from '../../foundation/discovery/doc-fluff.mjs';
71
115
  import { findStrayPointers } from '../../foundation/discovery/stray-pointers.mjs';
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @file The integration subject's access to the environment (INV21): reading
5
5
  * one package's component docs and sources with the project's own TypeScript,
6
- * and its topics.
6
+ * its topics, and the scope its examples are read against.
7
7
  *
8
8
  * @input a loaded integration and the directory the command runs in
9
9
  * @output the reports the integration checks attach to their results
@@ -23,6 +23,15 @@ import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs
23
23
  import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';
24
24
  import {findDocCommands} from '../../foundation/discovery/runner-commands.mjs';
25
25
  import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
26
+ import {findPackageRoot} from '../../foundation/fs/paths.mjs';
27
+ import {
28
+ loadLocalIntegration,
29
+ resolveInstalledIntegrationDir,
30
+ } from '../../foundation/integrations/integrations.mjs';
31
+ import {
32
+ exampleCodeCheck,
33
+ exampleScopeFor,
34
+ } from '../../foundation/integrations/example-code.mjs';
26
35
 
27
36
  /**
28
37
  * Each component doc's props compared with the component's TypeScript props,
@@ -174,3 +183,70 @@ export async function projectUsesIconSets(cwd) {
174
183
  return false;
175
184
  }
176
185
  }
186
+
187
+ /**
188
+ * @typedef {object} LoadedExampleScope
189
+ * @property {boolean} found whether an integration manifest loaded
190
+ * @property {string | null} name
191
+ * @property {string | null} version
192
+ * @property {import('../../authoring/example/type.ts').ExampleScope | null} scope
193
+ * @property {string} [reason] why there is no scope
194
+ * @property {string} [incomplete] why names Core or React give were not read
195
+ */
196
+
197
+ /**
198
+ * The scope a package's component examples are read against: the local
199
+ * package rooted at `cwd` (no `pkg`), or a package installed beside it.
200
+ * Throws when `pkg` is not a bare package name.
201
+ * @param {string | undefined} pkg
202
+ * @param {string} cwd
203
+ * @returns {Promise<LoadedExampleScope>}
204
+ */
205
+ export async function loadExampleScope(pkg, cwd) {
206
+ const packageDir = pkg
207
+ ? resolveInstalledIntegrationDir(pkg, cwd)
208
+ : findPackageRoot(cwd);
209
+ /** @type {any} */
210
+ let integration = null;
211
+ /** @type {string | undefined} */
212
+ let reason;
213
+ if (packageDir) {
214
+ try {
215
+ integration = await loadLocalIntegration(packageDir);
216
+ } catch (err) {
217
+ reason = /** @type {Error} */ (err).message;
218
+ }
219
+ }
220
+ if (integration?.__loadError) reason = integration.__loadError;
221
+ if (!integration || reason) {
222
+ return {
223
+ found: false,
224
+ name: integration?.name ?? null,
225
+ version: integration?.version ?? null,
226
+ scope: null,
227
+ reason:
228
+ reason ??
229
+ (packageDir
230
+ ? `No astryx.integration.{ts,mjs,js} next to the package.json in ${packageDir}.`
231
+ : 'No package.json found.'),
232
+ };
233
+ }
234
+ const read = await exampleScopeFor(integration);
235
+ return {
236
+ found: true,
237
+ name: integration.name ?? null,
238
+ version: integration.version ?? null,
239
+ scope: read.scope,
240
+ ...(read.reason ? {reason: read.reason} : {}),
241
+ ...(read.incomplete ? {incomplete: read.incomplete} : {}),
242
+ };
243
+ }
244
+
245
+ /**
246
+ * Each of the package's component examples that cannot run on its own, as a
247
+ * note with its fix, and the examples that could not be judged.
248
+ * @param {any} integration a loaded integration
249
+ */
250
+ export function integrationExampleCode(integration) {
251
+ return exampleCodeCheck(integration);
252
+ }
@@ -58,6 +58,7 @@ import {
58
58
  import {rootProblem} from '../../foundation/integrations/validate-contributions.mjs';
59
59
  import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
60
60
  import {shellArg} from '../../foundation/text/shell-arg.mjs';
61
+ import {compareText} from '../../foundation/text/compare-text.mjs';
61
62
 
62
63
  /**
63
64
  * The provider ID a package without a name is checked under: a valid bare
@@ -215,7 +216,7 @@ async function templateConflicts(pkg, options) {
215
216
  }
216
217
  for (const matches of coreById.values()) {
217
218
  matches.sort((a, b) =>
218
- `${a.type}:${a.name}`.localeCompare(`${b.type}:${b.name}`),
219
+ compareText(`${a.type}:${a.name}`, `${b.type}:${b.name}`),
219
220
  );
220
221
  }
221
222
 
@@ -279,7 +280,8 @@ async function templateConflicts(pkg, options) {
279
280
  }
280
281
  }
281
282
  conflicts.sort((a, b) =>
282
- `${a.id}:${'relationship' in a ? a.relationship : ''}`.localeCompare(
283
+ compareText(
284
+ `${a.id}:${'relationship' in a ? a.relationship : ''}`,
283
285
  `${b.id}:${'relationship' in b ? b.relationship : ''}`,
284
286
  ),
285
287
  );
@@ -388,7 +390,7 @@ async function componentConflicts(pkg, options) {
388
390
  'If you keep it, always select it with --package.',
389
391
  command: `${run} component ${shellArg(component.name)} --package ${shellArg(name)}`,
390
392
  }))
391
- .sort((a, b) => a.name.localeCompare(b.name));
393
+ .sort((a, b) => compareText(a.name, b.name));
392
394
 
393
395
  return {
394
396
  type: 'integration.component-conflicts',
@@ -561,9 +563,7 @@ async function docConflicts(pkg, options) {
561
563
  }
562
564
  }
563
565
  findings.sort((a, b) =>
564
- `${a.topic}:${a.relationship}`.localeCompare(
565
- `${b.topic}:${b.relationship}`,
566
- ),
566
+ compareText(`${a.topic}:${a.relationship}`, `${b.topic}:${b.relationship}`),
567
567
  );
568
568
 
569
569
  // The same graph checks `astryx doctor` runs in a project: the namespaces
@@ -0,0 +1,14 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The scope a package's component examples are read against: the components
6
+ * it documents with their imports, the components and hooks Core documents,
7
+ * React's exports, the packages it declares, and its server-only modules and
8
+ * async components. `found` is false when no integration manifest loads.
9
+ *
10
+ * @param {string} [pkg] installed package name; omit for the package at cwd
11
+ * @param {import('./example-scope.type.mjs').IntegrationExampleScopeOptions} [options]
12
+ * @returns {Promise<import('./example-scope.type.mjs').IntegrationExampleScopeResponse>}
13
+ */
14
+ export function integrationExampleScope(pkg?: string, options?: import("./example-scope.type.mjs").IntegrationExampleScopeOptions): Promise<import("./example-scope.type.mjs").IntegrationExampleScopeResponse>;
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `integrationExampleScope()`: the scope Doctor reads a package's
5
+ * component examples against, as JSON a catalog can store.
6
+ * @input A package: the local one rooted at `cwd`, or one installed beside
7
+ * it by name.
8
+ * @output An `integration.example-scope` envelope: the package's identity and
9
+ * its ExampleScope, or why there is none.
10
+ * @position api/integration; the subject's adapter builds the scope with
11
+ * the `exampleScopeFor` that `validateIntegration` runs, so a preview tool
12
+ * that reads examples with it and `previewableExample` judges each one as
13
+ * Doctor does.
14
+ */
15
+
16
+ import {loadExampleScope} from './_adapter.mjs';
17
+ import {AstryxError} from '../error.mjs';
18
+ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
19
+
20
+ const TYPE = /** @type {const} */ ('integration.example-scope');
21
+
22
+ /**
23
+ * The scope a package's component examples are read against: the components
24
+ * it documents with their imports, the components and hooks Core documents,
25
+ * React's exports, the packages it declares, and its server-only modules and
26
+ * async components. `found` is false when no integration manifest loads.
27
+ *
28
+ * @param {string} [pkg] installed package name; omit for the package at cwd
29
+ * @param {import('./example-scope.type.mjs').IntegrationExampleScopeOptions} [options]
30
+ * @returns {Promise<import('./example-scope.type.mjs').IntegrationExampleScopeResponse>}
31
+ */
32
+ export async function integrationExampleScope(pkg, options = {}) {
33
+ const {cwd = process.cwd()} = options;
34
+ try {
35
+ return {type: TYPE, data: await loadExampleScope(pkg, cwd)};
36
+ } catch (err) {
37
+ if (!pkg) throw err;
38
+ throw new AstryxError(
39
+ /** @type {Error} */ (err).message,
40
+ [],
41
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
42
+ );
43
+ }
44
+ }
@@ -0,0 +1,29 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Options for `integrationExampleScope()`.
6
+ */
7
+ export type IntegrationExampleScopeOptions = {
8
+ /**
9
+ * the folder the local package or `node_modules` is
10
+ * found from
11
+ */
12
+ cwd?: string | undefined;
13
+ };
14
+ /**
15
+ * The scope a package's component examples are read against, as JSON. The
16
+ * shape is a contract: a release may add a field, and never renames, removes
17
+ * or retypes one, so a stored scope stays readable.
18
+ */
19
+ export type IntegrationExampleScopeResponse = {
20
+ type: "integration.example-scope";
21
+ data: {
22
+ found: boolean;
23
+ name: string | null;
24
+ version: string | null;
25
+ scope: import("../../authoring/example/type.ts").ExampleScope | null;
26
+ reason?: string;
27
+ incomplete?: string;
28
+ };
29
+ };
@@ -0,0 +1,25 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Colocated types for `integrationExampleScope()`, the scope a
5
+ * package's component examples are read against. `ExampleScope` itself is the
6
+ * authoring contract in `authoring/example/type.ts`.
7
+ */
8
+
9
+ /**
10
+ * Options for `integrationExampleScope()`.
11
+ * @typedef {object} IntegrationExampleScopeOptions
12
+ * @property {string} [cwd] the folder the local package or `node_modules` is
13
+ * found from
14
+ */
15
+
16
+ /**
17
+ * The scope a package's component examples are read against, as JSON. The
18
+ * shape is a contract: a release may add a field, and never renames, removes
19
+ * or retypes one, so a stored scope stays readable.
20
+ * @typedef {object} IntegrationExampleScopeResponse
21
+ * @property {'integration.example-scope'} type
22
+ * @property {{found: boolean, name: string | null, version: string | null, scope: import('../../authoring/example/type.ts').ExampleScope | null, reason?: string, incomplete?: string}} data
23
+ */
24
+
25
+ export {};
@@ -0,0 +1,11 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `integrationExampleScope()`. Colocated with the API
6
+ * function it documents; the shape source of truth stays in
7
+ * `example-scope.type.mjs` and `authoring/example/type.ts`.
8
+ * @position packages/cli/api/integration — function documentation
9
+ */
10
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
11
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;