@astryxdesign/cli 0.7.5-canary.f2dafed → 0.7.5-canary.f85473e

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 (270) hide show
  1. package/README.md +20 -20
  2. package/api/component/_adapter.mjs +16 -1
  3. package/api/component/component.test.mjs +31 -0
  4. package/api/discover/_adapter.d.mts +1 -1
  5. package/api/docs/_adapter.d.mts +5 -2
  6. package/api/docs/_adapter.mjs +24 -16
  7. package/api/docs/docs.test.mjs +18 -0
  8. package/api/docs/integrationDocs.test.mjs +2 -2
  9. package/api/experimental.d.mts +5 -0
  10. package/api/experimental.mjs +15 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/_adapter.d.mts +3 -2
  13. package/api/icon/_adapter.mjs +16 -3
  14. package/api/icon/_authoring.d.mts +5 -1
  15. package/api/icon/_authoring.mjs +478 -63
  16. package/api/icon/_options.d.mts +11 -0
  17. package/api/icon/_options.mjs +39 -4
  18. package/api/icon/_records.d.mts +19 -0
  19. package/api/icon/_records.mjs +25 -0
  20. package/api/icon/add/add.d.mts +3 -3
  21. package/api/icon/add/add.mjs +227 -14
  22. package/api/icon/all-or-nothing.test.mjs +283 -0
  23. package/api/icon/detail/detail.mjs +2 -13
  24. package/api/icon/error-codes.test.mjs +14 -7
  25. package/api/icon/icon.d.mts +2 -2
  26. package/api/icon/icon.doc.mjs +30 -2
  27. package/api/icon/icon.mjs +57 -8
  28. package/api/icon/icon.test.mjs +133 -1
  29. package/api/icon/icon.type.d.mts +126 -1
  30. package/api/icon/icon.type.mjs +67 -3
  31. package/api/icon/iconAdd.doc.mjs +22 -6
  32. package/api/icon/iconMap.doc.mjs +24 -8
  33. package/api/icon/iconNewDefinition.doc.mjs +2 -2
  34. package/api/icon/iconNewSet.doc.mjs +30 -2
  35. package/api/icon/iconUse.doc.mjs +4 -1
  36. package/api/icon/map/map.d.mts +4 -4
  37. package/api/icon/map/map.mjs +134 -9
  38. package/api/icon/new-definition/new-definition.mjs +6 -2
  39. package/api/icon/new-set/new-set.mjs +2 -2
  40. package/api/icon/new-set/new-set.test.mjs +60 -10
  41. package/api/icon/option-pairs.test.mjs +368 -0
  42. package/api/icon/search/search.d.mts +10 -0
  43. package/api/icon/search/search.mjs +55 -14
  44. package/api/icon/use/use.mjs +2 -13
  45. package/api/integration/add-helpers.d.mts +15 -1
  46. package/api/integration/add-helpers.mjs +1 -1
  47. package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
  48. package/api/integration/pack-check.mjs +10 -4
  49. package/api/integration/pack-check.test.mjs +5 -1
  50. package/api/integration/validate-integration.type.d.mts +3 -2
  51. package/api/integration/validate-integration.type.mjs +3 -2
  52. package/api/render/_adapter.d.mts +28 -0
  53. package/api/render/_adapter.mjs +540 -0
  54. package/api/render/render.d.mts +15 -0
  55. package/api/render/render.doc.d.mts +9 -0
  56. package/api/render/render.doc.mjs +112 -0
  57. package/api/render/render.mjs +113 -0
  58. package/api/render/render.test.mjs +1155 -0
  59. package/api/render/render.type.d.mts +74 -0
  60. package/api/render/render.type.mjs +64 -0
  61. package/api/search/_adapter.test.mjs +21 -2
  62. package/api/search/_result.d.mts +5 -5
  63. package/api/search/search.d.mts +1 -1
  64. package/api/template/template.mjs +3 -1
  65. package/api/template/template.type.d.mts +2 -1
  66. package/api/template/template.type.mjs +1 -1
  67. package/api/template/unknown-name.test.mjs +63 -0
  68. package/api/upgrade/_adapter.d.mts +47 -2
  69. package/api/upgrade/_adapter.mjs +58 -2
  70. package/api/upgrade/run/failure-receipt.test.mjs +212 -0
  71. package/api/upgrade/run/outcomes.test.mjs +646 -0
  72. package/api/upgrade/run/run.d.mts +36 -0
  73. package/api/upgrade/run/run.mjs +670 -44
  74. package/api/upgrade/upgrade.doc.mjs +4 -4
  75. package/api/upgrade/upgrade.mjs +19 -4
  76. package/api/upgrade/upgrade.type.d.mts +36 -1
  77. package/api/upgrade/upgrade.type.mjs +29 -4
  78. package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
  79. package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
  80. package/assets/codemods/integration-runner.mjs +8 -2
  81. package/assets/codemods/integration-runner.protection.test.mjs +53 -0
  82. package/assets/codemods/outcome.mjs +79 -0
  83. package/assets/codemods/outcome.test.mjs +40 -0
  84. package/assets/codemods/parse.mjs +94 -0
  85. package/assets/codemods/run-codemod.mjs +109 -5
  86. package/assets/codemods/runner.mjs +119 -13
  87. package/assets/codemods/transform-prop.mjs +99 -49
  88. package/assets/codemods/transform-prop.test.mjs +36 -1
  89. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
  90. package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
  91. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
  92. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
  93. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
  94. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
  95. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
  96. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
  97. package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
  98. package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
  99. package/assets/docs/tree/icon-sets.doc.mjs +50 -20
  100. package/assets/docs/tree/render-pages.doc.mjs +94 -0
  101. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  102. package/assets/icons/definitions/activity.doc.mjs +1 -1
  103. package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
  104. package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
  105. package/assets/icons/definitions/alignStart.doc.mjs +10 -0
  106. package/assets/icons/definitions/archive.doc.mjs +1 -1
  107. package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
  108. package/assets/icons/definitions/attach.doc.mjs +1 -1
  109. package/assets/icons/definitions/audio.doc.mjs +1 -1
  110. package/assets/icons/definitions/cart.doc.mjs +1 -1
  111. package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
  112. package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
  113. package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
  114. package/assets/icons/definitions/close.doc.mjs +1 -1
  115. package/assets/icons/definitions/collapse.doc.mjs +1 -1
  116. package/assets/icons/definitions/compose.doc.mjs +1 -1
  117. package/assets/icons/definitions/conversation.doc.mjs +1 -1
  118. package/assets/icons/definitions/copy.doc.mjs +1 -1
  119. package/assets/icons/definitions/cpu.doc.mjs +9 -0
  120. package/assets/icons/definitions/database.doc.mjs +1 -1
  121. package/assets/icons/definitions/desktop.doc.mjs +1 -1
  122. package/assets/icons/definitions/discount.doc.mjs +1 -1
  123. package/assets/icons/definitions/download.doc.mjs +1 -1
  124. package/assets/icons/definitions/emoji.doc.mjs +1 -1
  125. package/assets/icons/definitions/error.doc.mjs +1 -1
  126. package/assets/icons/definitions/expand.doc.mjs +1 -1
  127. package/assets/icons/definitions/experiment.doc.mjs +1 -1
  128. package/assets/icons/definitions/externalLink.doc.mjs +7 -1
  129. package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
  130. package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
  131. package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
  132. package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
  133. package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
  134. package/assets/icons/definitions/gitFork.doc.mjs +9 -0
  135. package/assets/icons/definitions/info.doc.mjs +1 -1
  136. package/assets/icons/definitions/location.doc.mjs +1 -1
  137. package/assets/icons/definitions/mention.doc.mjs +1 -1
  138. package/assets/icons/definitions/menu.doc.mjs +1 -1
  139. package/assets/icons/definitions/microphone.doc.mjs +1 -1
  140. package/assets/icons/definitions/mobile.doc.mjs +1 -1
  141. package/assets/icons/definitions/money.doc.mjs +1 -1
  142. package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
  143. package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
  144. package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
  145. package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
  146. package/assets/icons/definitions/panelRight.doc.mjs +10 -0
  147. package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
  148. package/assets/icons/definitions/redo.doc.mjs +1 -1
  149. package/assets/icons/definitions/refresh.doc.mjs +1 -1
  150. package/assets/icons/definitions/rotate.doc.mjs +9 -0
  151. package/assets/icons/definitions/scale.doc.mjs +10 -0
  152. package/assets/icons/definitions/search.doc.mjs +1 -1
  153. package/assets/icons/definitions/send.doc.mjs +1 -1
  154. package/assets/icons/definitions/settings.doc.mjs +1 -1
  155. package/assets/icons/definitions/star.doc.mjs +1 -1
  156. package/assets/icons/definitions/stop.doc.mjs +1 -1
  157. package/assets/icons/definitions/success.doc.mjs +1 -1
  158. package/assets/icons/definitions/textCase.doc.mjs +9 -0
  159. package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
  160. package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
  161. package/assets/icons/definitions/trendDown.doc.mjs +7 -1
  162. package/assets/icons/definitions/trendUp.doc.mjs +1 -1
  163. package/assets/icons/definitions/undo.doc.mjs +1 -1
  164. package/assets/icons/definitions/upload.doc.mjs +1 -1
  165. package/assets/icons/definitions/userAdd.doc.mjs +1 -1
  166. package/assets/icons/definitions/warning.doc.mjs +1 -1
  167. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
  168. package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
  169. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
  170. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
  171. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
  172. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
  173. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
  174. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
  175. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
  176. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
  177. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
  178. package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
  179. package/assets/templates/pages/library/page.tsx +1 -2
  180. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  181. package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
  182. package/authoring/codemod/type.ts +10 -0
  183. package/authoring/debug/parse.d.mts +2 -2
  184. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
  185. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
  186. package/authoring/doctypes/icon-set/parse.d.mts +1 -0
  187. package/authoring/doctypes/icon-set/parse.mjs +1 -0
  188. package/authoring/doctypes/icon-set/type.ts +5 -0
  189. package/authoring/doctypes/template/template.doc.mjs +1 -1
  190. package/authoring/doctypes/template/type.ts +2 -1
  191. package/clients/cli/commands/doctor.mjs +16 -17
  192. package/clients/cli/commands/experimental/icon.mjs +167 -35
  193. package/clients/cli/commands/experimental/index.mjs +2 -0
  194. package/clients/cli/commands/experimental/render.mjs +113 -0
  195. package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
  196. package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
  197. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
  198. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
  199. package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
  200. package/clients/cli/commands/experimental-render.doc.mjs +60 -0
  201. package/clients/cli/commands/experimental.doc.mjs +4 -2
  202. package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
  203. package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
  204. package/clients/cli/commands/icon.test.mjs +1 -1
  205. package/clients/cli/commands/template.mjs +4 -1
  206. package/clients/cli/commands/text-json-parity.test.mjs +46 -0
  207. package/clients/cli/commands/upgrade.doc.mjs +47 -2
  208. package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
  209. package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
  210. package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
  211. package/clients/cli/commands/upgrade.mjs +9 -2
  212. package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
  213. package/clients/cli/index.mjs +1 -0
  214. package/foundation/discovery/icon-set-checks.d.mts +43 -9
  215. package/foundation/discovery/icon-set-checks.mjs +296 -21
  216. package/foundation/discovery/icon-set-checks.test.mjs +125 -12
  217. package/foundation/discovery/icon-set-writer.d.mts +192 -3
  218. package/foundation/discovery/icon-set-writer.mjs +608 -34
  219. package/foundation/discovery/icon-set-writer.test.mjs +26 -0
  220. package/foundation/discovery/module-exports.mjs +82 -25
  221. package/foundation/discovery/module-exports.test.mjs +38 -1
  222. package/foundation/discovery/template-icons.d.mts +6 -0
  223. package/foundation/discovery/template-icons.mjs +98 -10
  224. package/foundation/discovery/template-icons.test.mjs +103 -0
  225. package/foundation/doc-compiler/doc-loads.test.mjs +20 -5
  226. package/foundation/doc-compiler/import.mjs +81 -8
  227. package/foundation/doc-compiler/read.d.mts +4 -3
  228. package/foundation/doc-compiler/read.mjs +15 -10
  229. package/foundation/doc-compiler/read.test.mjs +59 -1
  230. package/foundation/doc-compiler/tree.mjs +3 -1
  231. package/foundation/fs/module-loader.d.mts +3 -2
  232. package/foundation/fs/module-loader.mjs +3 -2
  233. package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
  234. package/foundation/fs/read-record.d.mts +27 -0
  235. package/foundation/fs/read-record.mjs +83 -15
  236. package/foundation/fs/read-record.test.mjs +88 -1
  237. package/foundation/render/assets.d.mts +31 -0
  238. package/foundation/render/assets.mjs +102 -0
  239. package/foundation/render/component-map.d.mts +52 -0
  240. package/foundation/render/component-map.mjs +141 -0
  241. package/foundation/render/css-cut.d.mts +29 -0
  242. package/foundation/render/css-cut.mjs +144 -0
  243. package/foundation/render/embedded-files.d.mts +28 -0
  244. package/foundation/render/embedded-files.mjs +108 -0
  245. package/foundation/render/embedded-imports.d.mts +61 -0
  246. package/foundation/render/embedded-imports.mjs +315 -0
  247. package/foundation/render/html-reader.d.mts +37 -0
  248. package/foundation/render/html-reader.mjs +121 -0
  249. package/foundation/render/page-worker.d.mts +7 -0
  250. package/foundation/render/page-worker.mjs +519 -0
  251. package/foundation/render/rebuild.d.mts +19 -0
  252. package/foundation/render/rebuild.mjs +269 -0
  253. package/foundation/render/render-page.d.mts +85 -0
  254. package/foundation/render/render-page.mjs +612 -0
  255. package/foundation/render/render.test.mjs +117 -0
  256. package/foundation/render/source-block.d.mts +52 -0
  257. package/foundation/render/source-block.mjs +106 -0
  258. package/foundation/response/base.d.ts +7 -0
  259. package/foundation/response/error-codes.d.mts +10 -1
  260. package/foundation/response/error-codes.doc.mjs +59 -2
  261. package/foundation/response/error-codes.mjs +62 -1
  262. package/foundation/response/json.d.mts +10 -3
  263. package/foundation/response/json.mjs +16 -4
  264. package/foundation/response/response-types.doc.mjs +39 -2
  265. package/foundation/text/string-utils.mjs +33 -0
  266. package/foundation/text/string-utils.test.mjs +17 -0
  267. package/foundation/text/suggest-order.d.mts +17 -3
  268. package/foundation/text/suggest-order.mjs +58 -13
  269. package/foundation/text/suggest-order.test.mjs +53 -0
  270. package/package.json +15 -9
@@ -0,0 +1,74 @@
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
+ export type RenderOptions = {
5
+ /**
6
+ * - Folder relative paths resolve from (default: process.cwd()).
7
+ */
8
+ cwd?: string | undefined;
9
+ /**
10
+ * - The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).
11
+ */
12
+ out?: string | undefined;
13
+ /**
14
+ * - Turn a rendered HTML file back into a page module.
15
+ */
16
+ reverse?: boolean | undefined;
17
+ /**
18
+ * - The rendered page's title (default: its first heading, else the file name). Rendering only.
19
+ */
20
+ title?: string | undefined;
21
+ /**
22
+ * - Replace the existing page module when reversing (never a protected file, and never a file other than the page, which always goes into a new folder). Rendering replaces an existing HTML file only when a render wrote it.
23
+ */
24
+ overwrite?: boolean | undefined;
25
+ };
26
+ /**
27
+ * Something the render noticed that may make the page differ from what its
28
+ * author meant.
29
+ */
30
+ export type RenderWarning = {
31
+ /**
32
+ * - What kind of problem.
33
+ */
34
+ code: "dropped-children" | "remote-asset" | "missing-asset" | "page-output" | "page-script" | "no-astryx-styles" | "chart-size" | "not-embedded";
35
+ /**
36
+ * - What happened and what to do, in one sentence.
37
+ */
38
+ message: string;
39
+ };
40
+ /**
41
+ * `astryx --json experimental render <page>`.
42
+ */
43
+ export type RenderPageResponse = {
44
+ type: "render.page";
45
+ data: {
46
+ input: string;
47
+ output: string;
48
+ bytes: number;
49
+ files: string[];
50
+ stylesheets: string[];
51
+ classes: number;
52
+ cssBytes: number;
53
+ images: number;
54
+ warnings: RenderWarning[];
55
+ };
56
+ };
57
+ /**
58
+ * `astryx --json experimental render --reverse <file.html>`.
59
+ */
60
+ export type RenderReverseResponse = {
61
+ type: "render.reverse";
62
+ data: {
63
+ input: string;
64
+ mode: "embedded" | "rebuilt";
65
+ output: string;
66
+ files: string[];
67
+ exact: boolean;
68
+ missing?: string[] | undefined;
69
+ components?: string[] | undefined;
70
+ elements?: number | undefined;
71
+ unknown?: string[] | undefined;
72
+ omitted?: string[] | undefined;
73
+ };
74
+ };
@@ -0,0 +1,64 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Colocated types for `astryx experimental render`: the source of truth
5
+ * for its response shapes.
6
+ *
7
+ * @position api/render — typedefs for api/render/render.mjs
8
+ */
9
+
10
+ /**
11
+ * @experimental May change or be removed in a patch release.
12
+ * @typedef {object} RenderOptions
13
+ * @property {string} [cwd] - Folder relative paths resolve from (default: process.cwd()).
14
+ * @property {string} [out] - The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).
15
+ * @property {boolean} [reverse] - Turn a rendered HTML file back into a page module.
16
+ * @property {string} [title] - The rendered page's title (default: its first heading, else the file name). Rendering only.
17
+ * @property {boolean} [overwrite] - Replace the existing page module when reversing (never a protected file, and never a file other than the page, which always goes into a new folder). Rendering replaces an existing HTML file only when a render wrote it.
18
+ */
19
+
20
+ /**
21
+ * Something the render noticed that may make the page differ from what its
22
+ * author meant.
23
+ * @experimental May change or be removed in a patch release.
24
+ * @typedef {object} RenderWarning
25
+ * @property {'dropped-children' | 'remote-asset' | 'missing-asset' | 'page-output' | 'page-script' | 'no-astryx-styles' | 'chart-size' | 'not-embedded'} code - What kind of problem.
26
+ * @property {string} message - What happened and what to do, in one sentence.
27
+ */
28
+
29
+ /**
30
+ * `astryx --json experimental render <page>`.
31
+ * @experimental May change or be removed in a patch release.
32
+ * @typedef {object} RenderPageResponse
33
+ * @property {'render.page'} type
34
+ * @property {object} data
35
+ * @property {string} data.input - The page module, relative to cwd when inside it.
36
+ * @property {string} data.output - The HTML file written.
37
+ * @property {number} data.bytes - Size of the HTML file.
38
+ * @property {string[]} data.files - Local files the page loaded (modules, stylesheets, images, JSON), relative to the folder that holds them all (the page's folder unless it imports from above it), page first; each is embedded so --reverse can give it back.
39
+ * @property {string[]} data.stylesheets - Package stylesheets that were cut to the rules the page uses and inlined.
40
+ * @property {number} data.classes - Distinct class names in the markup.
41
+ * @property {number} data.cssBytes - Size of the inlined CSS.
42
+ * @property {number} data.images - Local files inlined as data: URIs.
43
+ * @property {RenderWarning[]} data.warnings - Empty when nothing looked wrong.
44
+ */
45
+
46
+ /**
47
+ * `astryx --json experimental render --reverse <file.html>`.
48
+ * @experimental May change or be removed in a patch release.
49
+ * @typedef {object} RenderReverseResponse
50
+ * @property {'render.reverse'} type
51
+ * @property {object} data
52
+ * @property {string} data.input - The HTML file read.
53
+ * @property {'embedded' | 'rebuilt'} data.mode - `embedded`: the file carried its source, written back byte for byte. `rebuilt`: rebuilt from Astryx markup (text and layout only).
54
+ * @property {string} data.output - The page module written: `out`, or by default inside a new folder beside the HTML file named after it (`report.html` gives `report-restored/`).
55
+ * @property {string[]} data.files - Every file written, page first.
56
+ * @property {boolean} data.exact - Whether the page and every file it imports came back exactly as rendered.
57
+ * @property {string[]} [data.missing] - Embedded only: relative imports the file did not carry (files a render never embeds), so the restored page needs them before it renders.
58
+ * @property {string[]} [data.components] - Rebuilt only: the components the page uses.
59
+ * @property {number} [data.elements] - Rebuilt only: how many component elements were rebuilt.
60
+ * @property {string[]} [data.unknown] - Rebuilt only: Astryx class names no installed component claims; their content is kept as plain elements.
61
+ * @property {string[]} [data.omitted] - Rebuilt only: component kinds left out because the markup cannot give them back (such as icons).
62
+ */
63
+
64
+ export {};
@@ -85,7 +85,7 @@ describe('gatherCandidatesReused', () => {
85
85
  );
86
86
 
87
87
  it(
88
- 'gathers again when a file the gather read changes, in a linked package too',
88
+ 'gathers again when a file the gather read or imported changes, in a linked package too',
89
89
  async () => {
90
90
  // A consumer whose integration is a symlink to a package folder
91
91
  // elsewhere, as a workspace package is.
@@ -162,7 +162,26 @@ describe('gatherCandidatesReused', () => {
162
162
  // An edited file the gather read: the linked package's manifest.
163
163
  const later = new Date(Date.now() + 5_000);
164
164
  fs.utimesSync(path.join(pkg, 'package.json'), later, later);
165
- expect(await gatherCandidatesReused(options)).not.toBe(second);
165
+ const third = await gatherCandidatesReused(options);
166
+ expect(third).not.toBe(second);
167
+
168
+ // An edited doc the gather imported: the next gather reads its new
169
+ // content, not the module this process imported first.
170
+ fs.writeFileSync(
171
+ path.join(pkg, 'components', 'FancyGizmo.doc.mjs'),
172
+ `export default {
173
+ type: 'component',
174
+ name: 'FancyGizmo',
175
+ keywords: ['gizmo'],
176
+ usage: {description: 'A shinier part, now with sprockets.'},
177
+ props: [],
178
+ };\n`,
179
+ );
180
+ const fourth = await gatherCandidatesReused(options);
181
+ expect(fourth).not.toBe(third);
182
+ expect(
183
+ JSON.stringify(fourth.all.find(c => c.name === 'FancyGizmo')),
184
+ ).toContain('A shinier part, now with sprockets.');
166
185
  } finally {
167
186
  fs.rmSync(dir, {recursive: true, force: true});
168
187
  fs.rmSync(pkg, {recursive: true, force: true});
@@ -17,7 +17,7 @@
17
17
  * (spec AST-081 FR3).
18
18
  */
19
19
  export function toResult(c: Candidate, score: number, reason: string, matchedTerms: number, queryTerms: number, outside?: boolean): {
20
- domain: "component" | "hook" | "theme" | "doc" | "template";
20
+ domain: "template" | "component" | "hook" | "theme" | "doc";
21
21
  name: string;
22
22
  package: string | undefined;
23
23
  score: number;
@@ -26,7 +26,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
26
26
  } | {
27
27
  import: string | undefined;
28
28
  command: string;
29
- domain: "component" | "hook" | "theme" | "doc" | "template";
29
+ domain: "template" | "component" | "hook" | "theme" | "doc";
30
30
  name: string;
31
31
  package: string | undefined;
32
32
  score: number;
@@ -38,7 +38,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
38
38
  command: string;
39
39
  section?: string | undefined;
40
40
  name: string;
41
- domain: "component" | "hook" | "theme" | "doc" | "template";
41
+ domain: "template" | "component" | "hook" | "theme" | "doc";
42
42
  package: string | undefined;
43
43
  score: number;
44
44
  reason: string;
@@ -47,7 +47,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
47
47
  displayName: string | undefined;
48
48
  kind: "page" | "block" | undefined;
49
49
  command: string;
50
- domain: "component" | "hook" | "theme" | "doc" | "template";
50
+ domain: "template" | "component" | "hook" | "theme" | "doc";
51
51
  name: string;
52
52
  package: string | undefined;
53
53
  score: number;
@@ -56,7 +56,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
56
56
  } | {
57
57
  displayName: string | undefined;
58
58
  command: string;
59
- domain: "component" | "hook" | "theme" | "doc" | "template";
59
+ domain: "template" | "component" | "hook" | "theme" | "doc";
60
60
  name: string;
61
61
  package: string | undefined;
62
62
  score: number;
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export function search(query: string, options?: {
15
15
  cwd?: string | undefined;
16
- type?: "component" | "hook" | "theme" | "doc" | "template" | undefined;
16
+ type?: "template" | "component" | "hook" | "theme" | "doc" | undefined;
17
17
  limit?: number | undefined;
18
18
  }): Promise<import("./search.type.mjs").SearchResponse>;
19
19
  /**
@@ -190,7 +190,9 @@ export async function template(name, options = {}) {
190
190
  if (name && candidates.length === 0) {
191
191
  throw new AstryxError(
192
192
  `Unknown template "${name}"`,
193
- orderByAffinity(name, templates, t => [t.dirName, t.name]).map(t => ({
193
+ orderByAffinity(name, templates, t => [t.dirName, t.name], {
194
+ closest: true,
195
+ }).map(t => ({
194
196
  name: t.dirName,
195
197
  reason: `${t.type} template`,
196
198
  })),
@@ -131,7 +131,7 @@ export type TemplateIconsReport = {
131
131
  */
132
132
  reason: string;
133
133
  /**
134
- * Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares.
134
+ * Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares. `dropped` names the library's sizing props (`size`, `strokeWidth`, `absoluteStrokeWidth`) removed from the icon's elements: an icon set's icons take their size from CSS.
135
135
  */
136
136
  mapped: Array<{
137
137
  source: {
@@ -146,6 +146,7 @@ export type TemplateIconsReport = {
146
146
  export: string;
147
147
  };
148
148
  by: "match" | "definition";
149
+ dropped?: string[];
149
150
  }>;
150
151
  /**
151
152
  * Icons left as the template wrote them, with why, and a `likely` reviewed match as a suggestion when the project set has one. Every declared key is mapped or kept; `module` is null for a key the template does not import, and `export` is `default` for a default import and `*` for a namespace import.
@@ -96,7 +96,7 @@
96
96
  * @property {'selected' | 'none' | 'ambiguous' | 'missing' | 'withdrawn'} status The project's icon-set state.
97
97
  * @property {string | null} set The project's icon set as `<package>/<set>`, when selected.
98
98
  * @property {string} reason Why the project has that set, or none.
99
- * @property {Array<{source: {module: string, export: string}, target: {set: string, package: string, id: string, module: string, export: string}, by: 'match' | 'definition'}>} mapped Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares.
99
+ * @property {Array<{source: {module: string, export: string}, target: {set: string, package: string, id: string, module: string, export: string}, by: 'match' | 'definition', dropped?: string[]}>} mapped Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares. `dropped` names the library's sizing props (`size`, `strokeWidth`, `absoluteStrokeWidth`) removed from the icon's elements: an icon set's icons take their size from CSS.
100
100
  * @property {Array<{module: string | null, export: string, reason: string, suggestion?: {set: string, id: string, module: string, export: string, confidence: 'likely'}}>} kept Icons left as the template wrote them, with why, and a `likely` reviewed match as a suggestion when the project set has one. Every declared key is mapped or kept; `module` is null for a key the template does not import, and `export` is `default` for a default import and `*` for a namespace import.
101
101
  */
102
102
 
@@ -0,0 +1,63 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The suggestions an unknown template name prints: the closest
5
+ * templates first, and the list stops where the matches get weaker. A name
6
+ * that shares no word with any template still lists every template.
7
+ */
8
+
9
+ import {describe, it, expect} from 'vitest';
10
+ import * as path from 'node:path';
11
+ import {fileURLToPath} from 'node:url';
12
+ import {template} from './template.mjs';
13
+ import {nameWords} from '../../foundation/text/suggest-order.mjs';
14
+
15
+ const cwd = path.resolve(
16
+ path.dirname(fileURLToPath(import.meta.url)),
17
+ '../../../..',
18
+ );
19
+ const SLOW = 30_000;
20
+
21
+ /** @param {string} name */
22
+ async function suggested(name) {
23
+ const error = await template(name, {cwd}).catch(e => e);
24
+ expect(error.code).toBe('ERR_UNKNOWN_TEMPLATE');
25
+ return error.suggestions.map((/** @type {{name: string}} */ s) => s.name);
26
+ }
27
+
28
+ describe('unknown template suggestions', () => {
29
+ it(
30
+ 'lists only templates that carry the typed words when one carries them all',
31
+ async () => {
32
+ const all = await suggested('zzqx-nothing-like-it');
33
+ const near = await suggested('settings-panel');
34
+ expect(near.length).toBeGreaterThan(0);
35
+ expect(near.length).toBeLessThan(all.length);
36
+ for (const name of near.slice(1)) {
37
+ const words = nameWords(name);
38
+ expect(words).toContain('setting');
39
+ expect(words).toContain('panel');
40
+ }
41
+ },
42
+ SLOW,
43
+ );
44
+
45
+ it(
46
+ 'does not narrow the list on a one-letter word',
47
+ async () => {
48
+ const all = await suggested('zzqx-nothing-like-it');
49
+ expect(await suggested('a11y')).toHaveLength(all.length);
50
+ },
51
+ SLOW,
52
+ );
53
+
54
+ it(
55
+ 'lists every template when no template shares a word with the name',
56
+ async () => {
57
+ const all = await suggested('zzqx-nothing-like-it');
58
+ expect(new Set(all).size).toBe(all.length);
59
+ expect(all.length).toBeGreaterThan(100);
60
+ },
61
+ SLOW,
62
+ );
63
+ });
@@ -180,13 +180,42 @@ export function getCoreVersionManifests(from: string, to: string): Promise<CoreV
180
180
  export function ensureCodemodDeps({ installDeps }?: {
181
181
  installDeps?: boolean;
182
182
  }): Promise<boolean>;
183
+ /**
184
+ * @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
185
+ */
186
+ /**
187
+ * Wrap each core code and config transform so the non-failure outcomes it
188
+ * throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
189
+ * runner as errors. The wrapped transform leaves that file unchanged, exactly
190
+ * as the throw did. Project codemods keep their own contract. One wrapper per
191
+ * pass: the regeneration re-check takes a fresh one, so an outcome a hook
192
+ * resolved does not linger.
193
+ *
194
+ * @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
195
+ * @param {M[]} versionManifests
196
+ * @param {string} root project root; recorded files are relative to it
197
+ * @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
198
+ */
199
+ export function withCodemodOutcomes<M extends {
200
+ version: string;
201
+ transforms: Array<{
202
+ name: string;
203
+ transform: any;
204
+ meta?: {
205
+ codemodType?: string;
206
+ };
207
+ }>;
208
+ }>(versionManifests: M[], root: string): {
209
+ versionManifests: M[];
210
+ outcomes: CodemodOutcomeRecord[];
211
+ };
183
212
  /**
184
213
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
185
214
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
186
215
  * @param {CoreVersionManifest[]} versionManifests
187
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
216
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
188
217
  */
189
- export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, }: {
218
+ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, outcomes, }: {
190
219
  apply: boolean;
191
220
  path: string;
192
221
  codemod?: string;
@@ -198,6 +227,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
198
227
  };
199
228
  silent?: boolean;
200
229
  coversTarget?: boolean;
230
+ outcomes?: CodemodOutcomeRecord[];
201
231
  }): Promise<{
202
232
  totalFilesChanged: number;
203
233
  totalTransformsApplied: number;
@@ -206,6 +236,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
206
236
  writtenFiles: string[];
207
237
  stagedContents: Map<string, string>;
208
238
  protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
239
+ declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
209
240
  errors: Array<{
210
241
  file: string;
211
242
  codemod: string;
@@ -301,6 +332,7 @@ export function runIntegrationCodemodsStep(versionGroups: Array<{
301
332
  writtenFiles: string[];
302
333
  stagedContents: Map<string, string>;
303
334
  protectedFiles: import("../../authoring/codemod/type").CodemodRunResult["protectedFiles"];
335
+ declinedCandidates: NonNullable<import("../../authoring/codemod/type").CodemodRunResult["declinedCandidates"]>;
304
336
  errors: Array<{
305
337
  file: string;
306
338
  codemod: string;
@@ -347,4 +379,17 @@ export type AgentDocsRefreshPlan = {
347
379
  renderedBlock: string | null;
348
380
  summary: import("./upgrade.type.mjs").AgentDocsSummary;
349
381
  };
382
+ export type CodemodOutcomeRecord = {
383
+ kind: "manual";
384
+ file: string;
385
+ codemod: string;
386
+ message: string;
387
+ line?: number;
388
+ } | {
389
+ kind: "regenerate";
390
+ file: string;
391
+ codemod: string;
392
+ message: string;
393
+ commands: string[];
394
+ };
350
395
  import { inspectAgentDocs } from '../../foundation/agent-docs/agent-docs.mjs';
@@ -24,6 +24,7 @@ import {
24
24
  latestVersion,
25
25
  } from '../../assets/codemods/registry.mjs';
26
26
  import {runCodemods} from '../../assets/codemods/runner.mjs';
27
+ import {codemodOutcome} from '../../assets/codemods/outcome.mjs';
27
28
  import {
28
29
  discoverIntegrationCodemods,
29
30
  selectIntegrationCodemods,
@@ -141,7 +142,12 @@ export function relativeToOrigin(result, {cwd: root, origin}) {
141
142
  };
142
143
  }
143
144
  if (data.modifiedFiles) data.modifiedFiles = data.modifiedFiles.map(rebase);
144
- for (const key of ['protectedFiles', 'declinedCandidates', 'errors']) {
145
+ for (const key of [
146
+ 'protectedFiles',
147
+ 'declinedCandidates',
148
+ 'errors',
149
+ 'regenerate',
150
+ ]) {
145
151
  if (data[key]) {
146
152
  data[key] = data[key].map(
147
153
  (/** @type {{file: string, declarations?: string[]}} */ entry) => ({
@@ -599,11 +605,59 @@ export async function ensureCodemodDeps({installDeps} = {}) {
599
605
  return ensureJscodeshift({installDeps, silent: logger.silent});
600
606
  }
601
607
 
608
+ /**
609
+ * @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
610
+ */
611
+
612
+ /**
613
+ * Wrap each core code and config transform so the non-failure outcomes it
614
+ * throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
615
+ * runner as errors. The wrapped transform leaves that file unchanged, exactly
616
+ * as the throw did. Project codemods keep their own contract. One wrapper per
617
+ * pass: the regeneration re-check takes a fresh one, so an outcome a hook
618
+ * resolved does not linger.
619
+ *
620
+ * @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
621
+ * @param {M[]} versionManifests
622
+ * @param {string} root project root; recorded files are relative to it
623
+ * @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
624
+ */
625
+ export function withCodemodOutcomes(versionManifests, root) {
626
+ /** @type {CodemodOutcomeRecord[]} */
627
+ const outcomes = [];
628
+ const wrapped = versionManifests.map(manifest => ({
629
+ ...manifest,
630
+ transforms: manifest.transforms.map(entry => {
631
+ if (entry.meta?.codemodType === 'project') return entry;
632
+ const {transform, name} = entry;
633
+ return {
634
+ ...entry,
635
+ /** @param {{path: string, source: string}} file @param {unknown} api */
636
+ transform(file, api) {
637
+ try {
638
+ return transform(file, api);
639
+ } catch (err) {
640
+ const outcome = codemodOutcome(err);
641
+ if (!outcome) throw err;
642
+ outcomes.push({
643
+ ...outcome,
644
+ file: path.relative(root, file.path).split(path.sep).join('/'),
645
+ codemod: `core:${name}`,
646
+ });
647
+ return undefined;
648
+ }
649
+ },
650
+ };
651
+ }),
652
+ }));
653
+ return {versionManifests: /** @type {M[]} */ (wrapped), outcomes};
654
+ }
655
+
602
656
  /**
603
657
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
604
658
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
605
659
  * @param {CoreVersionManifest[]} versionManifests
606
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
660
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
607
661
  */
608
662
  export async function runCoreCodemods(
609
663
  versionManifests,
@@ -616,6 +670,7 @@ export async function runCoreCodemods(
616
670
  protection,
617
671
  silent,
618
672
  coversTarget,
673
+ outcomes,
619
674
  },
620
675
  ) {
621
676
  return runCodemods(versionManifests, {
@@ -627,6 +682,7 @@ export async function runCoreCodemods(
627
682
  root,
628
683
  protection,
629
684
  coversTarget,
685
+ outcomes,
630
686
  });
631
687
  }
632
688