@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
@@ -2,18 +2,25 @@
2
2
 
3
3
  /**
4
4
  * @file A project's `compilerOptions.paths` (tsconfig.json or jsconfig.json),
5
- * read and matched by TypeScript's rules, for `astryx experimental render`:
5
+ * read and matched by TypeScript's rules, for `astryx experimental render`.
6
+ * The config of a file is the nearest tsconfig.json (else jsconfig.json) in
7
+ * its folder or above, read through its `extends`; a config that does not
8
+ * include the file lends the referenced project that does, as a
9
+ * solution-style config (`"files": []` with `references`) does. Matching:
6
10
  * an exact key matches only itself; a key may hold one `*` anywhere, and the
7
11
  * longest matching prefix wins; a target may hold one `*`, which takes what
8
12
  * the key's `*` matched; targets are tried in order, and when none exists the
9
13
  * import resolves as a package. Only bare specifiers are matched. Targets
10
- * resolve from `baseUrl` (default: the config's folder).
14
+ * resolve from `baseUrl`, else from the folder of the config that writes
15
+ * `paths`.
11
16
  *
12
17
  * @position foundation/render — used by page-worker.mjs and embedded-imports.mjs
13
18
  */
14
19
 
15
20
  import * as fs from 'node:fs';
16
21
  import * as path from 'node:path';
22
+ import {conditionalExportTarget} from '../discovery/package-exports.mjs';
23
+ import {findNodeModulesPackage} from '../fs/paths.mjs';
17
24
 
18
25
  /**
19
26
  * @typedef {object} PathPattern
@@ -27,45 +34,323 @@ import * as path from 'node:path';
27
34
  /** Extensions an extensionless candidate may stand for, in resolution order. */
28
35
  const EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.mts', '.cts', '.json'];
29
36
 
37
+ /** The extensions the render's module loader tries for an extensionless import, in its order. */
38
+ export const LOAD_EXTENSIONS = ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.mts', '.cts', '.json'];
39
+
40
+ /** The config file names TypeScript looks for in a folder, in its order. */
41
+ const CONFIG_NAMES = ['tsconfig.json', 'jsconfig.json'];
42
+
43
+ /** What a config excludes when it names nothing to exclude. */
44
+ const DEFAULT_EXCLUDE = ['node_modules', 'bower_components', 'jspm_packages'];
45
+
46
+ /** @param {string} file */
47
+ const isFile = file => {
48
+ try {
49
+ return fs.statSync(file).isFile();
50
+ } catch {
51
+ return false;
52
+ }
53
+ };
54
+
30
55
  /**
31
- * The path patterns of the config in `dir` (tsconfig.json, else
32
- * jsconfig.json), or none. Comments and trailing commas are allowed.
33
- * @param {string} dir
34
- * @returns {PathPattern[] | null} null when neither file is there
56
+ * A config's JSON, with comments and trailing commas allowed, or null.
57
+ * @param {string} file
58
+ * @returns {any}
35
59
  */
36
- export function readPathsIn(dir) {
37
- for (const name of ['tsconfig.json', 'jsconfig.json']) {
38
- const file = path.join(dir, name);
39
- if (!fs.existsSync(file)) continue;
40
- try {
41
- const text = fs
42
- .readFileSync(file, 'utf8')
43
- .replace(/("(?:[^"\\]|\\.)*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, str) => str ?? '')
44
- .replace(/,(\s*[}\]])/g, '$1');
45
- const options = JSON.parse(text)?.compilerOptions ?? {};
46
- const base = path.resolve(dir, typeof options.baseUrl === 'string' ? options.baseUrl : '.');
47
- /** @type {PathPattern[]} */
48
- const out = [];
49
- for (const [key, targets] of Object.entries(options.paths ?? {})) {
50
- if (!Array.isArray(targets)) continue;
51
- const star = key.indexOf('*');
52
- if (star !== key.lastIndexOf('*')) continue;
53
- out.push({
54
- key,
55
- prefix: star === -1 ? key : key.slice(0, star),
56
- suffix: star === -1 ? '' : key.slice(star + 1),
57
- wildcard: star !== -1,
58
- targets: targets
59
- .filter(t => typeof t === 'string' && t.indexOf('*') === t.lastIndexOf('*'))
60
- .map(t => path.resolve(base, t)),
61
- });
62
- }
63
- return out;
64
- } catch {
65
- return [];
60
+ function readJsonc(file) {
61
+ try {
62
+ const text = fs
63
+ .readFileSync(file, 'utf8')
64
+ .replace(/("(?:[^"\\]|\\.)*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, str) => str ?? '')
65
+ .replace(/,(\s*[}\]])/g, '$1');
66
+ const json = JSON.parse(text);
67
+ return json && typeof json === 'object' && !Array.isArray(json) ? json : null;
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+
73
+ /** The conditions TypeScript matches in a package's `exports` for a config (`default` always matches). */
74
+ const CONFIG_CONDITIONS = ['require', 'types', 'node'];
75
+
76
+ /** @param {string} file */
77
+ const jsonFile = file => (isFile(file) ? file : isFile(`${file}.json`) ? `${file}.json` : null);
78
+
79
+ /**
80
+ * The config one installed copy of a package holds for a subpath (`''` for
81
+ * the package alone): where its `exports` send it, else the subpath as
82
+ * written, else the file its package.json names in `tsconfig`, else its
83
+ * `tsconfig.json`. A package's `main` is code, never its config.
84
+ * @param {string} packageDir
85
+ * @param {string} sub
86
+ * @returns {string | null}
87
+ */
88
+ function packageConfig(packageDir, sub) {
89
+ const pkg = readJsonc(path.join(packageDir, 'package.json')) ?? {};
90
+ if (pkg.exports !== undefined && pkg.exports !== null) {
91
+ const target = conditionalExportTarget(pkg.exports, sub ? `./${sub}` : '.', CONFIG_CONDITIONS);
92
+ return target === null ? null : jsonFile(path.join(packageDir, target));
93
+ }
94
+ if (sub) return jsonFile(path.join(packageDir, sub));
95
+ return jsonFile(path.join(packageDir, typeof pkg.tsconfig === 'string' ? pkg.tsconfig : 'tsconfig.json'));
96
+ }
97
+
98
+ /**
99
+ * The config file an `extends` entry names, from the folder of the config
100
+ * that writes it, as TypeScript finds it: a path (`.json` may be left off);
101
+ * or a package's config, from the nearest installed copy that holds it. A
102
+ * package's config is read where it really is, through any link, so what it
103
+ * names in turn resolves from there.
104
+ * @param {unknown} spec
105
+ * @param {string} fromDir
106
+ * @returns {string | null}
107
+ */
108
+ function extendedFile(spec, fromDir) {
109
+ if (typeof spec !== 'string' || !spec) return null;
110
+ if (spec.startsWith('.') || path.isAbsolute(spec)) return jsonFile(path.resolve(fromDir, spec));
111
+ const parts = spec.split('/');
112
+ const scoped = spec.startsWith('@');
113
+ const name = parts.slice(0, scoped ? 2 : 1).join('/');
114
+ const sub = parts.slice(scoped ? 2 : 1).join('/');
115
+ for (let from = fromDir; ; ) {
116
+ const found = findNodeModulesPackage(from, name);
117
+ if (!found) return null;
118
+ const file = packageConfig(found.packageDir, sub);
119
+ if (file) return fs.realpathSync(file);
120
+ const above = path.dirname(found.hostDir);
121
+ if (above === found.hostDir) return null;
122
+ from = above;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * @typedef {object} ReadConfig
128
+ * @property {Record<string, unknown>} options - Compiler options, the extending config's winning key by key.
129
+ * @property {string} baseUrlDir - The folder of the config that writes `baseUrl`.
130
+ * @property {string} pathsDir - The folder of the config that writes `paths`.
131
+ * @property {string | null} pathsFile - The config that writes `paths`, if any does.
132
+ * @property {{list: unknown[], dir: string} | null} files - `files`, from the nearest config that writes it, with that config's folder.
133
+ * @property {{list: unknown[], dir: string} | null} include - `include`, likewise.
134
+ * @property {{list: unknown[], dir: string} | null} exclude - `exclude`, likewise.
135
+ * @property {{path?: unknown}[]} references - The config's own `references`.
136
+ */
137
+
138
+ /**
139
+ * A config read through its `extends`, as TypeScript merges them: a later
140
+ * entry of a list wins over an earlier one, and the config itself over all.
141
+ * @param {string} file
142
+ * @param {Set<string>} [seen] configs on the way here, so a cycle ends
143
+ * @returns {ReadConfig | null}
144
+ */
145
+ function readConfig(file, seen = new Set()) {
146
+ if (seen.has(file)) return null;
147
+ const json = readJsonc(file);
148
+ if (!json) return null;
149
+ const dir = path.dirname(file);
150
+ // A jsconfig.json takes JavaScript files unless it says otherwise.
151
+ /** @type {Record<string, unknown>} */
152
+ const options = path.basename(file) === 'jsconfig.json' ? {allowJs: true} : {};
153
+ /** @type {ReadConfig} */
154
+ const config = {options, baseUrlDir: dir, pathsDir: dir, pathsFile: null, files: null, include: null, exclude: null, references: []};
155
+ const bases = Array.isArray(json.extends) ? json.extends : json.extends === undefined ? [] : [json.extends];
156
+ for (const spec of bases) {
157
+ const baseFile = extendedFile(spec, dir);
158
+ const base = baseFile ? readConfig(baseFile, new Set([...seen, file])) : null;
159
+ if (!base) continue;
160
+ Object.assign(config.options, base.options);
161
+ if ('baseUrl' in base.options) config.baseUrlDir = base.baseUrlDir;
162
+ if ('paths' in base.options) {
163
+ config.pathsDir = base.pathsDir;
164
+ config.pathsFile = base.pathsFile;
66
165
  }
166
+ for (const key of /** @type {const} */ (['files', 'include', 'exclude'])) config[key] = base[key] ?? config[key];
67
167
  }
68
- return null;
168
+ const own = json.compilerOptions && typeof json.compilerOptions === 'object' ? json.compilerOptions : {};
169
+ for (const [key, value] of Object.entries(own)) {
170
+ config.options[key] = value;
171
+ if (key === 'baseUrl') config.baseUrlDir = dir;
172
+ if (key === 'paths') {
173
+ config.pathsDir = dir;
174
+ config.pathsFile = file;
175
+ }
176
+ }
177
+ for (const key of /** @type {const} */ (['files', 'include', 'exclude'])) {
178
+ if (Array.isArray(json[key])) config[key] = {list: json[key], dir};
179
+ }
180
+ config.references = Array.isArray(json.references) ? json.references.filter((/** @type {unknown} */ ref) => ref !== null && typeof ref === 'object') : [];
181
+ return config;
182
+ }
183
+
184
+ /**
185
+ * A path a config writes, with `${configDir}` taken as the folder of the
186
+ * config the project reads, and resolved from `from`.
187
+ * @param {string} value
188
+ * @param {string} from
189
+ * @param {string} configDir
190
+ */
191
+ const configPath = (value, from, configDir) => path.resolve(from, value.split('${configDir}').join(configDir));
192
+
193
+ /**
194
+ * A TypeScript `include` or `exclude` pattern as a regular expression over
195
+ * absolute, `/`-separated paths: `*` matches within a folder name, `?` one
196
+ * character of one, and `**` any number of folders.
197
+ * @param {string} pattern absolute
198
+ */
199
+ function patternRegExp(pattern) {
200
+ const segments = pattern.split(path.sep).join('/').split('/');
201
+ const body = segments
202
+ .map((segment, i) =>
203
+ segment === '**'
204
+ ? '(?:/[^/]+)*'
205
+ : `${i === 0 ? '' : '/'}${segment
206
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
207
+ .replace(/\*/g, '[^/]*')
208
+ .replace(/\?/g, '[^/]')}`,
209
+ )
210
+ .join('');
211
+ return new RegExp(`^${body}$`, process.platform === 'win32' || process.platform === 'darwin' ? 'i' : '');
212
+ }
213
+
214
+ /**
215
+ * Whether a config takes `file` as one of its own, by TypeScript's rules: a
216
+ * `files` entry names it; or an `include` pattern matches it (a pattern
217
+ * whose last part has no wildcard and no extension names a folder and all
218
+ * below it), a wildcard matching only TypeScript files (and JavaScript ones
219
+ * with `allowJs`), and no `exclude` pattern matches it or a folder above it.
220
+ * @param {ReadConfig} config
221
+ * @param {string} configDir
222
+ * @param {string} file absolute
223
+ */
224
+ function includesFile(config, configDir, file) {
225
+ const at = file.split(path.sep).join('/');
226
+ const files = config.files;
227
+ if (files?.list.some(f => typeof f === 'string' && configPath(f, files.dir, configDir) === file)) return true;
228
+ const include = config.include ?? (files ? null : {list: ['**/*'], dir: configDir});
229
+ if (!include) return false;
230
+ const allowJs = config.options.allowJs === true;
231
+ const typed = /\.(?:tsx?|mts|cts)$/i.test(file) || (allowJs && /\.(?:jsx?|mjs|cjs)$/i.test(file));
232
+ const included = include.list.some(spec => {
233
+ if (typeof spec !== 'string') return false;
234
+ const absolute = configPath(spec, include.dir, configDir);
235
+ const last = path.basename(absolute);
236
+ if (/[*?]/.test(last)) return typed && patternRegExp(absolute).test(at);
237
+ if (path.extname(last)) return patternRegExp(absolute).test(at);
238
+ return typed && patternRegExp(path.join(absolute, '**', '*')).test(at);
239
+ });
240
+ if (!included) return false;
241
+ const exclude = config.exclude ?? {list: DEFAULT_EXCLUDE, dir: configDir};
242
+ return !exclude.list.some(spec => {
243
+ if (typeof spec !== 'string') return false;
244
+ const pattern = patternRegExp(configPath(spec, exclude.dir, configDir));
245
+ for (let d = at; d.includes('/'); d = d.slice(0, d.lastIndexOf('/'))) if (pattern.test(d)) return true;
246
+ return false;
247
+ });
248
+ }
249
+
250
+ /**
251
+ * The path patterns a read config gives.
252
+ * @param {ReadConfig} config
253
+ * @param {string} configDir the folder of the config the project reads
254
+ * @returns {PathPattern[]}
255
+ */
256
+ function patternsOf(config, configDir) {
257
+ const {paths, baseUrl} = config.options;
258
+ if (!paths || typeof paths !== 'object') return [];
259
+ const base = typeof baseUrl === 'string' ? configPath(baseUrl, config.baseUrlDir, configDir) : config.pathsDir;
260
+ /** @type {PathPattern[]} */
261
+ const out = [];
262
+ for (const [key, targets] of Object.entries(paths)) {
263
+ if (!Array.isArray(targets)) continue;
264
+ const star = key.indexOf('*');
265
+ if (star !== key.lastIndexOf('*')) continue;
266
+ out.push({
267
+ key,
268
+ prefix: star === -1 ? key : key.slice(0, star),
269
+ suffix: star === -1 ? '' : key.slice(star + 1),
270
+ wildcard: star !== -1,
271
+ targets: targets
272
+ .filter(t => typeof t === 'string' && t.indexOf('*') === t.lastIndexOf('*'))
273
+ .map(t => configPath(t, base, configDir)),
274
+ });
275
+ }
276
+ return out;
277
+ }
278
+
279
+ /**
280
+ * The config TypeScript reads for a file, which need not exist yet: the
281
+ * nearest tsconfig.json (else jsconfig.json) in its folder or above, read
282
+ * through `extends`. When that config does not take the file as its own, a
283
+ * project it references (at any depth) that does, as TypeScript finds a
284
+ * file's project behind a solution-style config; when none does, the nearest
285
+ * config still.
286
+ * @param {string} file absolute
287
+ * @returns {{file: string, config: ReadConfig} | null}
288
+ */
289
+ function configFor(file) {
290
+ /** @type {string | null} */
291
+ let nearest = null;
292
+ for (let d = path.dirname(file); !nearest; d = path.dirname(d)) {
293
+ nearest = CONFIG_NAMES.map(name => path.join(d, name)).find(isFile) ?? null;
294
+ if (path.dirname(d) === d) break;
295
+ }
296
+ if (!nearest) return null;
297
+ const visited = new Set();
298
+ /** @type {(configFile: string) => {file: string, config: ReadConfig} | null} */
299
+ const owning = configFile => {
300
+ if (visited.has(configFile)) return null;
301
+ visited.add(configFile);
302
+ const config = readConfig(configFile);
303
+ if (!config) return null;
304
+ const dir = path.dirname(configFile);
305
+ if (includesFile(config, dir, file)) return {file: configFile, config};
306
+ for (const ref of config.references) {
307
+ if (typeof ref.path !== 'string') continue;
308
+ const target = path.resolve(dir, ref.path);
309
+ const next = isFile(target) ? target : path.join(target, 'tsconfig.json');
310
+ const hit = isFile(next) ? owning(next) : null;
311
+ if (hit) return hit;
312
+ }
313
+ return null;
314
+ };
315
+ const found = owning(nearest);
316
+ if (found) return found;
317
+ // No project takes the file as its own: the nearest config still applies,
318
+ // as it always did for a page outside its `include`.
319
+ const config = readConfig(nearest);
320
+ return config ? {file: nearest, config} : null;
321
+ }
322
+
323
+ /**
324
+ * The path patterns that apply to a file, which need not exist yet: those of
325
+ * the config TypeScript reads for it (see configFor).
326
+ * @param {string} file absolute
327
+ * @returns {PathPattern[]}
328
+ */
329
+ export function pathsFor(file) {
330
+ const found = configFor(file);
331
+ return found ? patternsOf(found.config, path.dirname(found.file)) : [];
332
+ }
333
+
334
+ /**
335
+ * Where `paths` entries for a file belong: the config TypeScript reads for
336
+ * it, else a new `tsconfig.json` in `fallbackDir`; the folder the entries'
337
+ * targets resolve from there (its `baseUrl`, else that config's own folder,
338
+ * which writes the entries); and the patterns it has now, its own or
339
+ * inherited through `extends` (a `paths` of its own replaces inherited ones).
340
+ * @param {string} file absolute, which need not exist yet
341
+ * @param {string} fallbackDir absolute: where a project with no config would add one
342
+ * @returns {{config: string, base: string, current: PathPattern[]}}
343
+ */
344
+ export function pathsHomeFor(file, fallbackDir) {
345
+ const found = configFor(file);
346
+ if (!found) return {config: path.join(fallbackDir, 'tsconfig.json'), base: fallbackDir, current: []};
347
+ const configDir = path.dirname(found.file);
348
+ const {baseUrl} = found.config.options;
349
+ return {
350
+ config: found.file,
351
+ base: typeof baseUrl === 'string' ? configPath(baseUrl, found.config.baseUrlDir, configDir) : configDir,
352
+ current: patternsOf(found.config, configDir),
353
+ };
69
354
  }
70
355
 
71
356
  /**
@@ -103,9 +388,10 @@ export const candidatesOf = match => match.pattern.targets.map(t => t.replace('*
103
388
  * The file a candidate path stands for: itself, with an extension, or its
104
389
  * folder's index; null when none exists.
105
390
  * @param {string} candidate
391
+ * @param {readonly string[]} [extensions] the extensions to try, in order (default: TypeScript's)
106
392
  * @returns {string | null}
107
393
  */
108
- export function existingFile(candidate) {
394
+ export function existingFile(candidate, extensions = EXTENSIONS) {
109
395
  const isFile = (/** @type {string} */ f) => {
110
396
  try {
111
397
  return fs.statSync(f).isFile();
@@ -114,8 +400,8 @@ export function existingFile(candidate) {
114
400
  }
115
401
  };
116
402
  if (isFile(candidate)) return candidate;
117
- for (const ext of EXTENSIONS) if (isFile(candidate + ext)) return candidate + ext;
118
- for (const ext of EXTENSIONS) if (isFile(path.join(candidate, `index${ext}`))) return path.join(candidate, `index${ext}`);
403
+ for (const ext of extensions) if (isFile(candidate + ext)) return candidate + ext;
404
+ for (const ext of extensions) if (isFile(path.join(candidate, `index${ext}`))) return path.join(candidate, `index${ext}`);
119
405
  return null;
120
406
  }
121
407
 
@@ -86,6 +86,7 @@ export function allErrorCodes(): string[];
86
86
  * | 'ERR_FILE_EXISTS'
87
87
  * | 'ERR_PATH_TRAVERSAL'
88
88
  * | 'ERR_WRITE_FAILED'
89
+ * | 'ERR_READ_FAILED'
89
90
  * | 'ERR_THEME_INVALID'
90
91
  * | 'ERR_THEME_LOAD'
91
92
  * | 'ERR_THEME_STALE'
@@ -111,6 +112,7 @@ export function allErrorCodes(): string[];
111
112
  * | 'ERR_RENDER_FAILED'
112
113
  * | 'ERR_RENDER_NOT_ASTRYX'
113
114
  * | 'ERR_RENDER_SOURCE_DAMAGED'
115
+ * | 'ERR_RENDER_NEWER_FORMAT'
114
116
  * | 'ERR_THEME_BAD_VALUE'
115
117
  * | 'ERR_THEME_NO_MODE'
116
118
  * | 'ERR_THEME_UNKNOWN_PART'
@@ -134,4 +136,4 @@ export const ERROR_CODES: Readonly<Record<ErrorCode, ErrorCode>>;
134
136
  /**
135
137
  * Stable error-code string union. Append-only.
136
138
  */
137
- export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_THEME_STALE" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_NOT_CHECKED" | "ERR_THEME_BUSY" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
139
+ export type ErrorCode = ("ERR_UNKNOWN" | "ERR_UNKNOWN_COMMAND" | "ERR_UNKNOWN_SUBCOMMAND" | "ERR_INVALID_OPTION" | "ERR_INVALID_ARGUMENT" | "ERR_MISSING_ARGUMENT" | "ERR_INVALID_LANG" | "ERR_INVALID_DETAIL" | "ERR_NODE_VERSION" | "ERR_CORE_NOT_FOUND" | "ERR_CORE_INCOMPATIBLE" | "ERR_UNKNOWN_COMPONENT" | "ERR_UNKNOWN_HOOK" | "ERR_UNKNOWN_TOPIC" | "ERR_UNKNOWN_SECTION" | "ERR_UNKNOWN_CATEGORY" | "ERR_UNKNOWN_TEMPLATE" | "ERR_AMBIGUOUS_TEMPLATE" | "ERR_AMBIGUOUS_COMPONENT" | "ERR_AMBIGUOUS_THEME" | "ERR_UNKNOWN_THEME" | "ERR_INTEGRATION_ROOT_CONFLICT" | "ERR_INTEGRATION_EXPORT_CONFLICT" | "ERR_UNKNOWN_PACKAGE" | "ERR_UNKNOWN_AGENT" | "ERR_UNKNOWN_FEATURE" | "ERR_UNKNOWN_CODEMOD" | "ERR_CODEMOD_FAILED" | "ERR_CODEMOD_PROTECTED" | "ERR_CODEMOD_PROTECTION_SOURCE" | "ERR_NOT_FOUND" | "ERR_NO_DOC" | "ERR_NO_SHOWCASE" | "ERR_NO_SOURCE" | "ERR_INVALID_DOC" | "ERR_FILE_NOT_FOUND" | "ERR_FILE_EXISTS" | "ERR_PATH_TRAVERSAL" | "ERR_WRITE_FAILED" | "ERR_READ_FAILED" | "ERR_THEME_INVALID" | "ERR_THEME_LOAD" | "ERR_THEME_STALE" | "ERR_PALETTE_GENERATION" | "ERR_VERSION_DETECT" | "ERR_INVALID_VERSION" | "ERR_DEP_MISSING" | "ERR_GH_CLI" | "ERR_UNKNOWN_POST" | "ERR_FETCH_FAILED" | "ERR_LAYOUT_PARSE" | "ERR_LAYOUT_INVALID" | "ERR_UNCLASSIFIED_EXIT" | "ERR_SIGNAL_TERMINATED" | "ERR_VERSIONS_UNAVAILABLE" | "ERR_PROJECT_REQUIRED" | "ERR_RENDER_COMPILE" | "ERR_RENDER_NO_DEFAULT_EXPORT" | "ERR_RENDER_MISSING_DEPENDENCY" | "ERR_RENDER_BROWSER_API" | "ERR_RENDER_ASSET_TOO_LARGE" | "ERR_RENDER_TIMEOUT" | "ERR_RENDER_FAILED" | "ERR_RENDER_NOT_ASTRYX" | "ERR_RENDER_SOURCE_DAMAGED" | "ERR_RENDER_NEWER_FORMAT" | "ERR_THEME_BAD_VALUE" | "ERR_THEME_NO_MODE" | "ERR_THEME_UNKNOWN_PART" | "ERR_THEME_UNKNOWN_VARIANT" | "ERR_THEME_UNKNOWN_STATE" | "ERR_THEME_PRIVATE_TOKEN" | "ERR_THEME_UNKNOWN_TOKEN" | "ERR_THEME_NO_EFFECT" | "ERR_THEME_NOT_CHECKED" | "ERR_THEME_BUSY" | "ERR_THEME_UNKNOWN_THING" | "ERR_THEME_NOT_SET" | "ERR_THEME_NOTHING_TO_UNDO");
@@ -45,6 +45,7 @@ export type ErrorCode =
45
45
  | 'ERR_FILE_EXISTS'
46
46
  | 'ERR_PATH_TRAVERSAL'
47
47
  | 'ERR_WRITE_FAILED'
48
+ | 'ERR_READ_FAILED'
48
49
  | 'ERR_THEME_INVALID'
49
50
  | 'ERR_THEME_LOAD'
50
51
  | 'ERR_THEME_STALE'
@@ -207,6 +207,11 @@ export const doc = {
207
207
  value: 'ERR_WRITE_FAILED',
208
208
  description: 'Writing output files failed (and was rolled back).',
209
209
  },
210
+ {
211
+ value: 'ERR_READ_FAILED',
212
+ description:
213
+ 'An input file cannot be read: no permission on it or on a folder on its path, a folder or other entry that is not a regular file, or another error from the file system.',
214
+ },
210
215
 
211
216
  // Theme build
212
217
  {
@@ -349,7 +354,13 @@ export const doc = {
349
354
  value: 'ERR_RENDER_SOURCE_DAMAGED',
350
355
  stability: 'experimental',
351
356
  description:
352
- '`render --reverse` refused the received file, and nothing was written: its embedded source was removed (a file a render wrote, with no Astryx components left to rebuild from) or is damaged (not valid, or a file does not match its checksum), lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its own imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds: a dotfile or dot-folder, anything under node_modules, a package manifest, lockfile or tool configuration, a file a test, story or benchmark runner would run, or any kind but a page module, stylesheet, JSON file or image. Raised only by the experimental render command.',
357
+ '`render --reverse` refused the received file, and nothing was written: its embedded source was removed (a file a render wrote, with no Astryx components left to rebuild from), is cut short (also a file a render wrote that ends before it), or is damaged (not valid, a file does not match its checksum, or it names a CLI version that is not a release version), the page holds merge conflict markers, lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its own imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds: a dotfile or dot-folder, anything under node_modules, a package manifest, lockfile or tool configuration, a file a test, story or benchmark runner would run, or any kind but a module, stylesheet, JSON file or image. Raised only by the experimental render command.',
358
+ },
359
+ {
360
+ value: 'ERR_RENDER_NEWER_FORMAT',
361
+ stability: 'experimental',
362
+ description:
363
+ '`render --reverse` was given a file in a newer render format than this CLI reads. Nothing was written. The message names the version of the CLI that wrote the file, which reads it. Raised only by the experimental render command.',
353
364
  },
354
365
  {
355
366
  value: 'ERR_THEME_BAD_VALUE',
@@ -75,6 +75,7 @@
75
75
  * | 'ERR_FILE_EXISTS'
76
76
  * | 'ERR_PATH_TRAVERSAL'
77
77
  * | 'ERR_WRITE_FAILED'
78
+ * | 'ERR_READ_FAILED'
78
79
  * | 'ERR_THEME_INVALID'
79
80
  * | 'ERR_THEME_LOAD'
80
81
  * | 'ERR_THEME_STALE'
@@ -100,6 +101,7 @@
100
101
  * | 'ERR_RENDER_FAILED'
101
102
  * | 'ERR_RENDER_NOT_ASTRYX'
102
103
  * | 'ERR_RENDER_SOURCE_DAMAGED'
104
+ * | 'ERR_RENDER_NEWER_FORMAT'
103
105
  * | 'ERR_THEME_BAD_VALUE'
104
106
  * | 'ERR_THEME_NO_MODE'
105
107
  * | 'ERR_THEME_UNKNOWN_PART'
@@ -214,6 +216,8 @@ export const ERROR_CODES = Object.freeze({
214
216
  ERR_PATH_TRAVERSAL: 'ERR_PATH_TRAVERSAL',
215
217
  /** Writing output files failed (and was rolled back). */
216
218
  ERR_WRITE_FAILED: 'ERR_WRITE_FAILED',
219
+ /** An input file cannot be read: no permission on it or on a folder on its path, a folder or other entry that is not a regular file, or another error from the file system. */
220
+ ERR_READ_FAILED: 'ERR_READ_FAILED',
217
221
 
218
222
  // ── Theme build ──────────────────────────────────────────────────
219
223
  /** A theme definition or contributed theme descriptor is invalid. */
@@ -327,10 +331,16 @@ export const ERROR_CODES = Object.freeze({
327
331
  * carries a file a
328
332
  * render never embeds (a dotfile, node_modules, a manifest, lockfile or
329
333
  * tool configuration, a file a test, story or benchmark runner would run,
330
- * or any kind but a page module, stylesheet, JSON file or image). Nothing
334
+ * or any kind but a module, stylesheet, JSON file or image). Nothing
331
335
  * was written.
332
336
  */
333
337
  ERR_RENDER_SOURCE_DAMAGED: 'ERR_RENDER_SOURCE_DAMAGED',
338
+ /**
339
+ * `render --reverse` was given a file in a newer render format than this
340
+ * CLI reads. Nothing was written. The message names the CLI version that
341
+ * wrote the file, which reads it.
342
+ */
343
+ ERR_RENDER_NEWER_FORMAT: 'ERR_RENDER_NEWER_FORMAT',
334
344
  /**
335
345
  * A value does not fit what it sets: not a color for a color token, not a size for a size, a step (`more`/`less`) on something that is not a dial, or a word a dial does not take. Nothing was changed. Raised only by `experimental theme`.
336
346
  */
@@ -178,7 +178,7 @@ export const doc = {
178
178
  value: 'render.reverse',
179
179
  stability: 'experimental',
180
180
  description:
181
- 'A rendered file turned back into a page: `input`, `mode` (`embedded`: the embedded source written back byte for byte; `rebuilt`: rebuilt from Astryx markup, text and layout only), `output`, every file written (`files`), `exact`, the relative imports it did not carry (`missing`, when any), and for a rebuilt page `components`, `elements`, `unknown` and `omitted`. Experimental: may change or be removed in a patch release.',
181
+ 'A rendered file turned back into a page: `input`, `mode` (`embedded`: the embedded source written back byte for byte; `rebuilt`: rebuilt from Astryx markup, text and layout only), `output`, every file written (`files`), `exact`, the relative imports it did not carry (`missing`, when any), the path-alias imports no alias here names, with the `paths` entries they need and the config those belong in (`aliased`: `config`, `paths`, `imports`, when any), and for a rebuilt page `components`, `elements`, `unknown` and `omitted`. Experimental: may change or be removed in a patch release.',
182
182
  },
183
183
 
184
184
  // experimental icon (installed icon sets, AST-084): experimental values,
@@ -487,7 +487,7 @@ export const doc = {
487
487
  {
488
488
  value: 'integration.validate',
489
489
  description:
490
- 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. So are the examples a package ships: component_without_example (a published component no block shows with exampleFor and isShowcase: true, or names in alsoShowcaseFor), template_category (a category written as a path, such as components/X), showcase_not_standalone (a showcase importing server-only code or reading process.env past NODE_ENV) and template_asset_not_packed (a new URL(…, import.meta.url) asset missing, or left out by npm pack --dry-run). When npm cannot list the files, an asset no files entry can reach is still a note and any other is listed in exampleAssets ({status: checked, findings: [], unchecked}, only when it lists any) as {file, asset, reason}. Since 0.7.15, package_without_logo (logo.light in the integration file, or a logo.dark that is set, names no packed PNG, JPEG, WebP or shapes-only SVG of at most 512 KB in the package; package.json marketplace.logo is read when the integration file has no logo) and package_without_example (components, other than those component_without_example exempts, but no block with isShowcase: true and exampleFor, or alsoShowcaseFor; themes-, docs- or codemods-only packages need none) say what a catalog needs to list the package, as notes without next that fail no check under any flag; a logo npm cannot be asked about is listed in exampleAssets with the file that names it. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. For the package being authored, olderCliNotes ({file, kind: template | namespace, field, message}) lists each descriptor field a CLI before 0.7.4 refuses, such as stability on a template or namespace doc; it is present only when it has entries, and is never counted or fails a check.',
490
+ 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. So are the examples a package ships: component_without_example (a published component no block shows with exampleFor and isShowcase: true, or names in alsoShowcaseFor), template_category (a category written as a path, such as components/X), showcase_not_standalone (a showcase importing server-only code or reading process.env past NODE_ENV) and template_asset_not_packed (a new URL(…, import.meta.url) asset missing, or left out by npm pack --dry-run). When npm cannot list the files, an asset no files entry can reach is still a note and any other is listed in exampleAssets ({status: checked, findings: [], unchecked}, only when it lists any) as {file, asset, reason}. Since 0.7.15, package_without_logo (logo.light in the integration file, or a logo.dark that is set, names no packed PNG, JPEG, WebP or shapes-only SVG of at most 512 KB in the package; package.json marketplace.logo is read when the integration file has no logo) and package_without_example (components, other than those component_without_example exempts, but no block with isShowcase: true and exampleFor, or alsoShowcaseFor; themes-, docs- or codemods-only packages need none) say what a catalog needs to list the package, as notes without next that fail no check under any flag; a logo npm cannot be asked about is listed in exampleAssets with the file that names it. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. Each component example that is not kind setup but cannot run on its own, by the rule previewableExample in @astryxdesign/cli/authoring defines, is a next note with its fix in the message: example_does_not_compile, example_renders_nothing, example_undefined_name, example_server_only and example_import_unresolvable; exampleCode ({status: checked, findings: [], unchecked}, only when it lists any) lists as {file, example, reason} each example the check could not judge: its names, when the docs of Core or React cannot be read beside the package, or the example itself, when it cannot be read. For the package being authored, olderCliNotes ({file, kind: template | namespace, field, message}) lists each descriptor field a CLI before 0.7.4 refuses, such as stability on a template or namespace doc; it is present only when it has entries, and is never counted or fails a check.',
491
491
  },
492
492
  {
493
493
  value: 'integration.template-conflicts',
@@ -0,0 +1,14 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Compare two strings character by character without regard to case: first
6
+ * by each character's class, then by its code point. A string that is a
7
+ * prefix of another comes first. Strings that differ only in case put
8
+ * lowercase first. Equal only for identical strings. `toLowerCase` never
9
+ * reads the locale.
10
+ * @param {string} a
11
+ * @param {string} b
12
+ * @returns {number}
13
+ */
14
+ export function compareText(a: string, b: string): number;
@@ -0,0 +1,68 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A fixed text order for identifiers, names, paths and other machine
5
+ * text.
6
+ *
7
+ * @input two strings
8
+ * @output a negative number, zero, or a positive number, as `sort` expects
9
+ * @position Shared by every sort and tie-break whose order reaches a
10
+ * command's answer. `String.prototype.localeCompare` with no locale reads
11
+ * the host's locale, and with a full ICU build that locale moves names
12
+ * ("ch" in Czech, the Hawaiian alphabet). This order never reads a locale,
13
+ * so it is the same on every machine. For the names the CLI sorts it
14
+ * matches the order an English host gives. Pure, so browser-bundled code
15
+ * can use it.
16
+ */
17
+
18
+ /**
19
+ * Each character's class, in the order of the Unicode root collation's
20
+ * primary groups: spaces, then punctuation, then symbols, then digits, then
21
+ * letters, then everything else.
22
+ */
23
+ const CLASSES = [/\p{Z}/u, /\p{P}/u, /\p{S}/u, /\p{N}/u, /\p{L}/u];
24
+
25
+ /** @type {Map<number, number>} */
26
+ const classOf = new Map();
27
+
28
+ /** @param {number} code */
29
+ function characterClass(code) {
30
+ let value = classOf.get(code);
31
+ if (value === undefined) {
32
+ const char = String.fromCodePoint(code);
33
+ value = CLASSES.findIndex(pattern => pattern.test(char));
34
+ if (value < 0) value = CLASSES.length;
35
+ classOf.set(code, value);
36
+ }
37
+ return value;
38
+ }
39
+
40
+ /** @type {(a: string, b: string) => number} */
41
+ const byCodeUnits = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
42
+
43
+ /**
44
+ * Compare two strings character by character without regard to case: first
45
+ * by each character's class, then by its code point. A string that is a
46
+ * prefix of another comes first. Strings that differ only in case put
47
+ * lowercase first. Equal only for identical strings. `toLowerCase` never
48
+ * reads the locale.
49
+ * @param {string} a
50
+ * @param {string} b
51
+ * @returns {number}
52
+ */
53
+ export function compareText(a, b) {
54
+ const x = a.toLowerCase();
55
+ const y = b.toLowerCase();
56
+ let i = 0;
57
+ let j = 0;
58
+ while (i < x.length && j < y.length) {
59
+ const cx = /** @type {number} */ (x.codePointAt(i));
60
+ const cy = /** @type {number} */ (y.codePointAt(j));
61
+ if (cx !== cy) {
62
+ return characterClass(cx) - characterClass(cy) || cx - cy;
63
+ }
64
+ i += cx > 0xffff ? 2 : 1;
65
+ j += cy > 0xffff ? 2 : 1;
66
+ }
67
+ return x.length - i - (y.length - j) || byCodeUnits(b, a);
68
+ }