@astryxdesign/cli 0.7.6-canary.f73623d → 0.7.6-canary.f899313

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 (498) hide show
  1. package/package.json +23 -10
  2. package/api/api-docs-parse.test.mjs +0 -47
  3. package/api/blog/_adapter.test.mjs +0 -183
  4. package/api/blog/blog.test.mjs +0 -144
  5. package/api/blog/detail/detail.test.mjs +0 -118
  6. package/api/blog/list/list.test.mjs +0 -81
  7. package/api/build/blocks/blocks.test.mjs +0 -238
  8. package/api/build/build.test.mjs +0 -569
  9. package/api/build/kit/answer.test.mjs +0 -108
  10. package/api/build/kit/rank.test.mjs +0 -380
  11. package/api/build/kit/weights.test.mjs +0 -286
  12. package/api/build/tree.test.mjs +0 -185
  13. package/api/component/component-replacement.test.mjs +0 -616
  14. package/api/component/component.test.mjs +0 -532
  15. package/api/component/doc-links.test.mjs +0 -419
  16. package/api/component/integration-export-name.test.mjs +0 -644
  17. package/api/component/integration-import-agreement.test.mjs +0 -474
  18. package/api/discover/_adapter.test.mjs +0 -839
  19. package/api/discover/_catalog-view.test.mjs +0 -129
  20. package/api/discover/_package-scanner.test.mjs +0 -117
  21. package/api/discover/detail/detail.test.mjs +0 -145
  22. package/api/discover/detail/doc/doc.test.mjs +0 -93
  23. package/api/discover/detail/item/item.test.mjs +0 -75
  24. package/api/discover/discover.test.mjs +0 -100
  25. package/api/discover/list/list.test.mjs +0 -107
  26. package/api/discover/search/search.test.mjs +0 -319
  27. package/api/docs/compiled-topics.test.mjs +0 -94
  28. package/api/docs/detail/section/section.test.mjs +0 -92
  29. package/api/docs/docOverlays.test.mjs +0 -189
  30. package/api/docs/docs-homes.test.mjs +0 -127
  31. package/api/docs/docs.depth.test.mjs +0 -134
  32. package/api/docs/docs.test.mjs +0 -315
  33. package/api/docs/guide-route-targets.test.mjs +0 -1002
  34. package/api/docs/index/index.test.mjs +0 -67
  35. package/api/docs/integration-tree.test.mjs +0 -616
  36. package/api/docs/integrationDocs.test.mjs +0 -546
  37. package/api/docs/namespace-section.test.mjs +0 -260
  38. package/api/docs/react-version-sync.test.mjs +0 -79
  39. package/api/docs/reference-blocks.test.mjs +0 -404
  40. package/api/docs/token-tables.test.mjs +0 -93
  41. package/api/doctor/built-checks.test.mjs +0 -537
  42. package/api/doctor/doctor.test.mjs +0 -1651
  43. package/api/doctor/icon-sets.test.mjs +0 -111
  44. package/api/doctor/release-checks.test.mjs +0 -156
  45. package/api/doctor/theme-checks.test.mjs +0 -884
  46. package/api/gap-report/gap-report.test.mjs +0 -1549
  47. package/api/hook/detail/detail.test.mjs +0 -53
  48. package/api/hook/detail/params/params.test.mjs +0 -39
  49. package/api/hook/hook.test.mjs +0 -75
  50. package/api/icon/all-or-nothing.test.mjs +0 -283
  51. package/api/icon/error-codes.test.mjs +0 -341
  52. package/api/icon/experimental-markers.test.mjs +0 -93
  53. package/api/icon/icon.test.mjs +0 -506
  54. package/api/icon/new-definition/new-definition.undo.test.mjs +0 -97
  55. package/api/icon/new-set/new-set.test.mjs +0 -398
  56. package/api/icon/option-pairs.test.mjs +0 -368
  57. package/api/init/init.test.mjs +0 -319
  58. package/api/init/remove/remove.test.mjs +0 -124
  59. package/api/init/user/user.test.mjs +0 -232
  60. package/api/integration/add-contribution.component-names.test.mjs +0 -186
  61. package/api/integration/add-contribution.test.mjs +0 -990
  62. package/api/integration/add-helpers.test.mjs +0 -161
  63. package/api/integration/add-theme.test.mjs +0 -676
  64. package/api/integration/authoring-checks.test.mjs +0 -1691
  65. package/api/integration/check/check.test.mjs +0 -538
  66. package/api/integration/doc-stability.test.mjs +0 -216
  67. package/api/integration/example-checks.no-npm.test.mjs +0 -140
  68. package/api/integration/example-checks.test.mjs +0 -776
  69. package/api/integration/integration-block-exports.test.mjs +0 -248
  70. package/api/integration/pack-check.component-replaces.test.mjs +0 -126
  71. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -149
  72. package/api/integration/pack-check.test.mjs +0 -2512
  73. package/api/integration/public-api.test.mjs +0 -21
  74. package/api/integration/template-conflict-compatibility.test.mjs +0 -73
  75. package/api/integration/validate-installed-icon-sets.test.mjs +0 -67
  76. package/api/integration/validate-integration-case-disk.test.mjs +0 -123
  77. package/api/integration/validate-integration-fixes.test.mjs +0 -1457
  78. package/api/integration/validate-integration-gaps.test.mjs +0 -2007
  79. package/api/integration/validate-integration.test.mjs +0 -835
  80. package/api/integration/validate-unread-theme-folders.test.mjs +0 -111
  81. package/api/json/envelope-types.test.mjs +0 -76
  82. package/api/json/parse.test.mjs +0 -76
  83. package/api/render/render.test.mjs +0 -1155
  84. package/api/search/_adapter.test.mjs +0 -192
  85. package/api/search/_doc-searcher.test.mjs +0 -36
  86. package/api/search/_entries.test.mjs +0 -48
  87. package/api/search/_main-searcher.test.mjs +0 -106
  88. package/api/search/_order.test.mjs +0 -72
  89. package/api/search/_template-searcher.test.mjs +0 -40
  90. package/api/search/search-return-type.test.mjs +0 -54
  91. package/api/search/search.domain-priority.test.mjs +0 -351
  92. package/api/search/search.family-members.test.mjs +0 -124
  93. package/api/search/search.family-word.test.mjs +0 -146
  94. package/api/search/search.integration-block.test.mjs +0 -100
  95. package/api/search/search.integration-check.test.mjs +0 -24
  96. package/api/search/search.test.mjs +0 -1007
  97. package/api/search/search.tie-order.test.mjs +0 -39
  98. package/api/search/tree.test.mjs +0 -66
  99. package/api/swizzle/_github.test.mjs +0 -53
  100. package/api/swizzle/copy/copy.test.mjs +0 -60
  101. package/api/swizzle/swizzle.test.mjs +0 -157
  102. package/api/template/cdn/cdn.test.mjs +0 -108
  103. package/api/template/checkout-wizard.test.mjs +0 -87
  104. package/api/template/copy/copy.receipt.test.mjs +0 -77
  105. package/api/template/copy/copy.test.mjs +0 -77
  106. package/api/template/data-token-fallbacks.test.mjs +0 -85
  107. package/api/template/discover-integration-templates.test.mjs +0 -56
  108. package/api/template/form-wizard-dialog.test.mjs +0 -47
  109. package/api/template/inline-wizard-template.test.mjs +0 -24
  110. package/api/template/list/list.test.mjs +0 -52
  111. package/api/template/show/show.test.mjs +0 -76
  112. package/api/template/table-filter-view-tabs.test.mjs +0 -45
  113. package/api/template/table-floating-bulk-actions.test.mjs +0 -66
  114. package/api/template/template-integration.test.mjs +0 -1274
  115. package/api/template/template-suffix.test.mjs +0 -286
  116. package/api/template/template.test.mjs +0 -222
  117. package/api/template/tokenizer-showcase.test.mjs +0 -47
  118. package/api/template/unknown-name.test.mjs +0 -63
  119. package/api/theme/add/add.test.mjs +0 -363
  120. package/api/theme/add/add.types.test.mjs +0 -150
  121. package/api/theme/build/build.adaptation-core-compat.test.mjs +0 -394
  122. package/api/theme/build/build.adaptation-enrollment.test.mjs +0 -219
  123. package/api/theme/build/build.core-on-demand.test.mjs +0 -113
  124. package/api/theme/build/build.family.test.mjs +0 -503
  125. package/api/theme/build/build.font-warning.test.mjs +0 -170
  126. package/api/theme/build/build.heading-core-compat.test.mjs +0 -68
  127. package/api/theme/build/build.icon-entry-variants.test.mjs +0 -134
  128. package/api/theme/build/build.icon-function-entries.test.mjs +0 -499
  129. package/api/theme/build/build.icon-lineage.test.mjs +0 -117
  130. package/api/theme/build/build.icon-preservation.test.mjs +0 -639
  131. package/api/theme/build/build.icon-variants.test.mjs +0 -105
  132. package/api/theme/build/build.icons-specifier.test.mjs +0 -149
  133. package/api/theme/build/build.packed-old-core.test.mjs +0 -1512
  134. package/api/theme/build/build.project-core.test.mjs +0 -220
  135. package/api/theme/build/build.public-component-vars.test.mjs +0 -151
  136. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  137. package/api/theme/build/build.rollback.test.mjs +0 -148
  138. package/api/theme/build/build.test.mjs +0 -1258
  139. package/api/theme/build/font-warning.test.mjs +0 -268
  140. package/api/theme/eject/eject.binary.test.mjs +0 -90
  141. package/api/theme/eject/eject.copy-compat.test.mjs +0 -168
  142. package/api/theme/eject/eject.rollback.test.mjs +0 -158
  143. package/api/theme/eject/eject.staging.test.mjs +0 -83
  144. package/api/theme/eject/eject.test.mjs +0 -160
  145. package/api/theme/integration-themes.test.mjs +0 -218
  146. package/api/theme/list/list.test.mjs +0 -271
  147. package/api/theme/palette/generate/generate.test.mjs +0 -445
  148. package/api/theme/palette/generate/generator.test.mjs +0 -385
  149. package/api/theme/palette/generate/preview.test.mjs +0 -55
  150. package/api/theme/remove/remove.test.mjs +0 -94
  151. package/api/theme/targets/targets.test.mjs +0 -91
  152. package/api/theme/template/template.test.mjs +0 -102
  153. package/api/theme/use/use.test.mjs +0 -98
  154. package/api/upgrade/list/list.test.mjs +0 -73
  155. package/api/upgrade/project-context.test.mjs +0 -272
  156. package/api/upgrade/provider-agreement.test.mjs +0 -152
  157. package/api/upgrade/registry/registry.test.mjs +0 -911
  158. package/api/upgrade/run/authoring-codemod-reachable.test.mjs +0 -99
  159. package/api/upgrade/run/cli-behind-core.test.mjs +0 -438
  160. package/api/upgrade/run/failure-receipt.test.mjs +0 -212
  161. package/api/upgrade/run/files-changed.test.mjs +0 -111
  162. package/api/upgrade/run/outcomes.test.mjs +0 -646
  163. package/api/upgrade/run/run.test.mjs +0 -511
  164. package/api/upgrade/upgrade.test.mjs +0 -594
  165. package/assets/codemods/__tests__/registry.test.mjs +0 -77
  166. package/assets/codemods/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -65
  167. package/assets/codemods/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -58
  168. package/assets/codemods/__tests__/rename-section-wash-to-muted.test.mjs +0 -103
  169. package/assets/codemods/__tests__/runner.symlinks.test.mjs +0 -205
  170. package/assets/codemods/__tests__/runner.test.mjs +0 -559
  171. package/assets/codemods/__tests__/runner.unparseable.test.mjs +0 -457
  172. package/assets/codemods/__tests__/toolbar-density-to-size.test.mjs +0 -69
  173. package/assets/codemods/__tests__/validation.test.mjs +0 -108
  174. package/assets/codemods/file-count.test.mjs +0 -163
  175. package/assets/codemods/integration-discovery.test.mjs +0 -360
  176. package/assets/codemods/integration-runner.protection.test.mjs +0 -206
  177. package/assets/codemods/outcome.test.mjs +0 -40
  178. package/assets/codemods/term-log.test.mjs +0 -80
  179. package/assets/codemods/transform-prop.test.mjs +0 -130
  180. package/assets/codemods/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -144
  181. package/assets/codemods/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -193
  182. package/assets/codemods/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -81
  183. package/assets/codemods/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -126
  184. package/assets/codemods/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -129
  185. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -126
  186. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -95
  187. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -109
  188. package/assets/codemods/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -44
  189. package/assets/codemods/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -110
  190. package/assets/codemods/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -71
  191. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -137
  192. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -161
  193. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -137
  194. package/assets/codemods/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -110
  195. package/assets/codemods/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -61
  196. package/assets/codemods/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -130
  197. package/assets/codemods/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -89
  198. package/assets/codemods/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -74
  199. package/assets/codemods/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -140
  200. package/assets/codemods/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -116
  201. package/assets/codemods/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -79
  202. package/assets/codemods/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -130
  203. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-badge-children-to-label.test.mjs +0 -46
  204. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -72
  205. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -98
  206. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -117
  207. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -75
  208. package/assets/codemods/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -275
  209. package/assets/codemods/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -85
  210. package/assets/codemods/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -327
  211. package/assets/codemods/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -98
  212. package/assets/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -460
  213. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -103
  214. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -61
  215. package/assets/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -123
  216. package/assets/codemods/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -104
  217. package/assets/codemods/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -120
  218. package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -574
  219. package/assets/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  220. package/assets/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  221. package/assets/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -112
  222. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -129
  223. package/assets/codemods/transforms/v0.2.0/__tests__/remove-tablist-orientation.test.mjs +0 -81
  224. package/assets/codemods/transforms/v0.2.1/__tests__/migrate-dialog-position-to-logical.test.mjs +0 -119
  225. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.e2e.test.mjs +0 -296
  226. package/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs +0 -139
  227. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-authoring-imports.test.mjs +0 -80
  228. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-grid-minchildwidth-to-columns.test.mjs +0 -82
  229. package/assets/codemods/transforms/v0.3.0/__tests__/next-codemods.test.mjs +0 -64
  230. package/assets/codemods/transforms/v0.3.0/__tests__/rename-authoring-doctypes.test.mjs +0 -94
  231. package/assets/codemods/transforms/v0.3.0/__tests__/rename-radiogroup-arialabel-to-label.test.mjs +0 -86
  232. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +0 -170
  233. package/assets/codemods/transforms/v0.4.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +0 -201
  234. package/assets/codemods/transforms/v0.4.0/__tests__/next-codemods.test.mjs +0 -154
  235. package/assets/codemods/transforms/v0.5.0/__tests__/next-codemods.test.mjs +0 -127
  236. package/assets/codemods/transforms/v0.6.0/__tests__/migrate-astryx-theme-selectors-to-data-attrs.test.mjs +0 -398
  237. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -270
  238. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -63
  239. package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -220
  240. package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +0 -129
  241. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -523
  242. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-field-input-styling.test.mjs +0 -108
  243. package/assets/codemods/transforms/v0.7.0/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -178
  244. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +0 -202
  245. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +0 -168
  246. package/assets/codemods/transforms/v0.7.2/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +0 -120
  247. package/assets/codemods/transforms/v0.7.5/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +0 -130
  248. package/authoring/_shared/errors.test.mjs +0 -49
  249. package/authoring/codemod/parse.test.mjs +0 -99
  250. package/authoring/config/debug-composition.test.mjs +0 -92
  251. package/authoring/config/parse.test.mjs +0 -121
  252. package/authoring/debug/parse.test.mjs +0 -187
  253. package/authoring/discover/parse.test.mjs +0 -158
  254. package/authoring/doctypes/doc-stability-types.test.mjs +0 -91
  255. package/authoring/doctypes/doctypes-new.test.mjs +0 -162
  256. package/authoring/doctypes/icon-definition/parse.test.mjs +0 -78
  257. package/authoring/doctypes/icon-set/icon-names.test.mjs +0 -26
  258. package/authoring/doctypes/icon-set/parse.test.mjs +0 -179
  259. package/authoring/doctypes/load-contract.test.mjs +0 -246
  260. package/authoring/doctypes/namespace/parse.test.mjs +0 -163
  261. package/authoring/doctypes/parse.test.mjs +0 -422
  262. package/authoring/doctypes/template/parse.test.mjs +0 -198
  263. package/authoring/gap-report/parse.test.mjs +0 -172
  264. package/authoring/integration/parse.test.mjs +0 -184
  265. package/authoring/shadcn/receipt.test.mjs +0 -187
  266. package/authoring/shadcn/source-variants.test.mjs +0 -120
  267. package/clients/cli/__tests__/cliManifest.test.ts +0 -37
  268. package/clients/cli/cli-command.test.mjs +0 -166
  269. package/clients/cli/cli-exit-codes.test.mjs +0 -163
  270. package/clients/cli/command-load-failure.test.mjs +0 -83
  271. package/clients/cli/command-result-coverage.test.mjs +0 -136
  272. package/clients/cli/commands/blog.test.mjs +0 -138
  273. package/clients/cli/commands/build-theme.adaptations.test.mjs +0 -773
  274. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -198
  275. package/clients/cli/commands/build-theme.batch-report.test.mjs +0 -349
  276. package/clients/cli/commands/build-theme.color-scheme.test.mjs +0 -136
  277. package/clients/cli/commands/build-theme.data-tokens.test.mjs +0 -92
  278. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  279. package/clients/cli/commands/build-theme.font-warning.test.mjs +0 -170
  280. package/clients/cli/commands/build-theme.icons-specifier.test.mjs +0 -350
  281. package/clients/cli/commands/build-theme.import-path.test.mjs +0 -103
  282. package/clients/cli/commands/build-theme.multi.test.mjs +0 -148
  283. package/clients/cli/commands/build-theme.outside-project.test.mjs +0 -140
  284. package/clients/cli/commands/build-theme.path-safety.test.mjs +0 -398
  285. package/clients/cli/commands/build-theme.prose.test.mjs +0 -103
  286. package/clients/cli/commands/build-theme.registry.test.mjs +0 -160
  287. package/clients/cli/commands/build-theme.variants.test.mjs +0 -560
  288. package/clients/cli/commands/build-theme.watch.test.mjs +0 -320
  289. package/clients/cli/commands/build.error-codes.test.mjs +0 -50
  290. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -54
  291. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  292. package/clients/cli/commands/build.text-fields.test.mjs +0 -81
  293. package/clients/cli/commands/cli-postinstall.test.mjs +0 -90
  294. package/clients/cli/commands/component-batch.test.mjs +0 -341
  295. package/clients/cli/commands/component-ownership.test.mjs +0 -384
  296. package/clients/cli/commands/component-package.test.mjs +0 -169
  297. package/clients/cli/commands/component-replacement.text.test.mjs +0 -316
  298. package/clients/cli/commands/component-resolution.test.mjs +0 -204
  299. package/clients/cli/commands/component.test.mjs +0 -612
  300. package/clients/cli/commands/debug-result-summary.test.mjs +0 -214
  301. package/clients/cli/commands/detail-levels.test.mjs +0 -145
  302. package/clients/cli/commands/dialog-adaptive-template.test.mjs +0 -24
  303. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -163
  304. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  305. package/clients/cli/commands/discover.icon-sets.test.mjs +0 -133
  306. package/clients/cli/commands/discover.no-source.test.mjs +0 -490
  307. package/clients/cli/commands/discover.sources.test.mjs +0 -292
  308. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  309. package/clients/cli/commands/docs.depth.test.mjs +0 -219
  310. package/clients/cli/commands/docs.test.mjs +0 -385
  311. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  312. package/clients/cli/commands/doctor-integration.test.mjs +0 -1483
  313. package/clients/cli/commands/doctor.test.mjs +0 -509
  314. package/clients/cli/commands/empty-argument.test.mjs +0 -16
  315. package/clients/cli/commands/external-showcase.test.mjs +0 -121
  316. package/clients/cli/commands/gap-report.test.mjs +0 -412
  317. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  318. package/clients/cli/commands/icon-authoring.test.mjs +0 -2845
  319. package/clients/cli/commands/icon-options-wiring.test.mjs +0 -158
  320. package/clients/cli/commands/icon-sets-guide.test.mjs +0 -186
  321. package/clients/cli/commands/icon.test.mjs +0 -96
  322. package/clients/cli/commands/import-hint-correctness.test.mjs +0 -293
  323. package/clients/cli/commands/init.behavior.test.mjs +0 -434
  324. package/clients/cli/commands/init.flag-help.test.mjs +0 -151
  325. package/clients/cli/commands/init.next-steps.test.mjs +0 -41
  326. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  327. package/clients/cli/commands/integration-authoring.test.mjs +0 -288
  328. package/clients/cli/commands/integration-check.test.mjs +0 -522
  329. package/clients/cli/commands/integration-real-world.test.mjs +0 -661
  330. package/clients/cli/commands/interactive-guard.test.mjs +0 -143
  331. package/clients/cli/commands/json-contract.test.mjs +0 -216
  332. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  333. package/clients/cli/commands/option-pair-refusals.test.mjs +0 -37
  334. package/clients/cli/commands/outside-project.test.mjs +0 -874
  335. package/clients/cli/commands/search.test.mjs +0 -514
  336. package/clients/cli/commands/setup-nudge.test.mjs +0 -280
  337. package/clients/cli/commands/silent-success-refusals.test.mjs +0 -15
  338. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -137
  339. package/clients/cli/commands/swizzle.routing.test.mjs +0 -342
  340. package/clients/cli/commands/template-cdn.behavior.test.mjs +0 -113
  341. package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
  342. package/clients/cli/commands/template.flag-help.test.mjs +0 -124
  343. package/clients/cli/commands/template.icons.test.mjs +0 -132
  344. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  345. package/clients/cli/commands/template.path-safety.test.mjs +0 -82
  346. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  347. package/clients/cli/commands/template.test.mjs +0 -62
  348. package/clients/cli/commands/text-json-parity.test.mjs +0 -850
  349. package/clients/cli/commands/theme-add-lifecycle.test.mjs +0 -228
  350. package/clients/cli/commands/theme-list.behavior.test.mjs +0 -51
  351. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -154
  352. package/clients/cli/commands/theme-targets.behavior.test.mjs +0 -84
  353. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -97
  354. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -101
  355. package/clients/cli/commands/upgrade.config-ordering.test.mjs +0 -342
  356. package/clients/cli/commands/upgrade.file-protection.test.mjs +0 -404
  357. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -221
  358. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -89
  359. package/clients/cli/commands/upgrade.integration-policy.test.mjs +0 -581
  360. package/clients/cli/commands/upgrade.older-cli.test.mjs +0 -160
  361. package/clients/cli/commands/upgrade.outcomes.test.mjs +0 -350
  362. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +0 -97
  363. package/clients/cli/commands/upgrade.test.mjs +0 -361
  364. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +0 -67
  365. package/clients/cli/commands/write-failure.test.mjs +0 -175
  366. package/clients/cli/e2e-smoke.test.mjs +0 -162
  367. package/clients/cli/error-envelope-code.test.mjs +0 -38
  368. package/clients/cli/formatters/index.test.mjs +0 -262
  369. package/clients/cli/latest-version-env.test.mjs +0 -50
  370. package/clients/cli/lib/cli-error.test.mjs +0 -206
  371. package/clients/cli/lib/component-format.test.mjs +0 -246
  372. package/clients/cli/lib/define-command.test.mjs +0 -103
  373. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -85
  374. package/clients/cli/lib/exit-codes.test.mjs +0 -111
  375. package/clients/cli/lib/hook-format.test.mjs +0 -35
  376. package/clients/cli/lib/json-shim.test.mjs +0 -268
  377. package/clients/cli/lib/manifest.test.mjs +0 -346
  378. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  379. package/clients/cli/lib/resolve-theme.test.mjs +0 -543
  380. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +0 -1550
  381. package/foundation/agent-docs/agent-docs.test.mjs +0 -1937
  382. package/foundation/agent-docs/app-theme-workflow.test.mjs +0 -16
  383. package/foundation/agent-docs/computer-agent-text.test.mjs +0 -699
  384. package/foundation/config/config-cache.test.mjs +0 -83
  385. package/foundation/config/config-writer.test.mjs +0 -84
  386. package/foundation/config/integration-debug.test.mjs +0 -218
  387. package/foundation/config/project-themes.test.mjs +0 -119
  388. package/foundation/config/project.test.mjs +0 -931
  389. package/foundation/config/theme-private-vars.test.mjs +0 -76
  390. package/foundation/config/theme-state.test.mjs +0 -182
  391. package/foundation/debug/debug-fields.test.mjs +0 -327
  392. package/foundation/debug/integration-handlers.test.mjs +0 -267
  393. package/foundation/debug/on-event.test.mjs +0 -643
  394. package/foundation/debug/privacy-contract.test.mjs +0 -195
  395. package/foundation/debug/redact.test.mjs +0 -534
  396. package/foundation/discovery/authoring-self-docs.test.mjs +0 -202
  397. package/foundation/discovery/authoring-surface.test.mjs +0 -392
  398. package/foundation/discovery/cli-self-docs.test.mjs +0 -396
  399. package/foundation/discovery/component-discovery.export-names.test.mjs +0 -832
  400. package/foundation/discovery/component-discovery.importpath.test.mjs +0 -59
  401. package/foundation/discovery/component-discovery.test.mjs +0 -336
  402. package/foundation/discovery/component-loader.test.mjs +0 -190
  403. package/foundation/discovery/component-replacement.test.mjs +0 -520
  404. package/foundation/discovery/componentDocOverlay.test.mjs +0 -159
  405. package/foundation/discovery/copied-passages.test.mjs +0 -124
  406. package/foundation/discovery/doc-consistency.test.mjs +0 -347
  407. package/foundation/discovery/doc-fluff.test.mjs +0 -142
  408. package/foundation/discovery/doc-types.test.mjs +0 -774
  409. package/foundation/discovery/docs-discovery.test.mjs +0 -707
  410. package/foundation/discovery/docs-section-key.test.mjs +0 -246
  411. package/foundation/discovery/hook-discovery.test.mjs +0 -216
  412. package/foundation/discovery/icon-set-checks.test.mjs +0 -1018
  413. package/foundation/discovery/icon-set-discovery.test.mjs +0 -320
  414. package/foundation/discovery/icon-set-writer.test.mjs +0 -26
  415. package/foundation/discovery/integration-doc-files.test.mjs +0 -275
  416. package/foundation/discovery/module-exports.test.mjs +0 -209
  417. package/foundation/discovery/package-tsconfig.test.mjs +0 -210
  418. package/foundation/discovery/prop-drift.test.mjs +0 -2337
  419. package/foundation/discovery/runner-commands.test.mjs +0 -131
  420. package/foundation/discovery/stray-pointers.test.mjs +0 -92
  421. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -284
  422. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  423. package/foundation/discovery/template-adapter.test.mjs +0 -223
  424. package/foundation/discovery/template-conflict-release.test.mjs +0 -40
  425. package/foundation/discovery/template-icons.test.mjs +0 -560
  426. package/foundation/discovery/template-needs.test.mjs +0 -306
  427. package/foundation/discovery/theme-discovery.test.mjs +0 -775
  428. package/foundation/discovery/theme-imports.test.mjs +0 -173
  429. package/foundation/discovery/theming-targets.test.mjs +0 -328
  430. package/foundation/discovery/type-match.test.mjs +0 -169
  431. package/foundation/discovery/type-text.test.mjs +0 -196
  432. package/foundation/discovery/unresolved-references.test.mjs +0 -567
  433. package/foundation/doc-compiler/bundle.test.mjs +0 -266
  434. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -714
  435. package/foundation/doc-compiler/doc-loads.test.mjs +0 -1762
  436. package/foundation/doc-compiler/doc-syntax.test.mjs +0 -383
  437. package/foundation/doc-compiler/inputs.test.mjs +0 -298
  438. package/foundation/doc-compiler/links.test.mjs +0 -285
  439. package/foundation/doc-compiler/lower-doc.test.mjs +0 -495
  440. package/foundation/doc-compiler/read.test.mjs +0 -380
  441. package/foundation/doc-compiler/split-topic-keywords.test.mjs +0 -74
  442. package/foundation/doc-compiler/tree.test.mjs +0 -691
  443. package/foundation/env/cli-command.test.mjs +0 -129
  444. package/foundation/env/node-version.test.mjs +0 -103
  445. package/foundation/env/package-manager.global.test.mjs +0 -66
  446. package/foundation/env/package-manager.test.mjs +0 -910
  447. package/foundation/env/search-path.test.mjs +0 -122
  448. package/foundation/env/semver.test.mjs +0 -111
  449. package/foundation/env/user-dirs.test.mjs +0 -72
  450. package/foundation/env/user-settings.test.mjs +0 -64
  451. package/foundation/fs/file-protection.test.mjs +0 -250
  452. package/foundation/fs/listing-cache.test.mjs +0 -88
  453. package/foundation/fs/module-loader.stdout.test.mjs +0 -333
  454. package/foundation/fs/module-loader.test.mjs +0 -410
  455. package/foundation/fs/path-safety.test.mjs +0 -222
  456. package/foundation/fs/paths.test.mjs +0 -725
  457. package/foundation/fs/publish-file-eperm-mutation.test.mjs +0 -64
  458. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +0 -142
  459. package/foundation/fs/publish-file.test.mjs +0 -136
  460. package/foundation/fs/read-record.test.mjs +0 -164
  461. package/foundation/identity/provider-identity.test.mjs +0 -254
  462. package/foundation/integrations/autolink.test.mjs +0 -430
  463. package/foundation/integrations/cli-peer-version.test.mjs +0 -354
  464. package/foundation/integrations/cli-requirement.test.mjs +0 -383
  465. package/foundation/integrations/computer-integrations.test.mjs +0 -292
  466. package/foundation/integrations/contribution-inventory.test.mjs +0 -420
  467. package/foundation/integrations/integration-warnings.test.mjs +0 -191
  468. package/foundation/integrations/integrations.test.mjs +0 -818
  469. package/foundation/integrations/manifest-writer.test.mjs +0 -271
  470. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
  471. package/foundation/integrations/provider-ledger.test.mjs +0 -275
  472. package/foundation/integrations/provider-resolution.test.mjs +0 -369
  473. package/foundation/integrations/public-imports.test.mjs +0 -1818
  474. package/foundation/release/cache.test.mjs +0 -923
  475. package/foundation/release/choose.test.mjs +0 -427
  476. package/foundation/release/global-state.test.mjs +0 -381
  477. package/foundation/release/handoff.e2e.test.mjs +0 -278
  478. package/foundation/release/notices.test.mjs +0 -586
  479. package/foundation/release/project.test.mjs +0 -288
  480. package/foundation/render/render.test.mjs +0 -117
  481. package/foundation/response/error-codes.test.mjs +0 -297
  482. package/foundation/response/json-contract.test.mjs +0 -235
  483. package/foundation/response/json-serialize.test.mjs +0 -66
  484. package/foundation/response/response-types.doc.test.mjs +0 -278
  485. package/foundation/route/route.test.mjs +0 -153
  486. package/foundation/runtime/hosted-runtime.test.mjs +0 -403
  487. package/foundation/runtime/package-set.test.mjs +0 -432
  488. package/foundation/text/copyright-header.test.mjs +0 -58
  489. package/foundation/text/levenshtein.test.mjs +0 -53
  490. package/foundation/text/string-utils.test.mjs +0 -175
  491. package/foundation/text/suggest-order.test.mjs +0 -312
  492. package/foundation/xle/browser-imports.test.mjs +0 -74
  493. package/foundation/xle/expand.test.mjs +0 -54
  494. package/foundation/xle/print.test.mjs +0 -50
  495. package/foundation/xle/registry.test.mjs +0 -28
  496. package/foundation/xle/xle.test.mjs +0 -382
  497. package/host/door-conformance.test.mjs +0 -274
  498. package/host/index.test.mjs +0 -302
@@ -1,1512 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `theme build` from a PACKED CLI resolving a genuinely older core.
5
- *
6
- * The unit-level sibling (build.adaptation-core-compat.test.mjs) drives
7
- * `themeBuild()` directly. This one reproduces the pairing a consumer actually
8
- * has: the CLI's published file set installed under
9
- * `node_modules/@astryxdesign/cli`, next to a `node_modules/@astryxdesign/core`
10
- * that behaves like the published 0.5.4. Nothing is mocked; the CLI binary runs
11
- * in its own process and resolves core the way Node does, which is the layer
12
- * the regression lived in (`astryx theme build` failed with ERR_CORE_NOT_FOUND
13
- * for every theme, adaptations or not).
14
- *
15
- * The old core is adaptation-BLIND, not "the current core minus one export".
16
- * Its `defineTheme` does what 0.5.4's did: it never reads `adaptations`, and
17
- * the theme it returns carries no adaptation metadata at all. That is what
18
- * makes the source analysis load-bearing — the resolved object is silent about
19
- * adaptations the author wrote, so a build that trusted it would emit CSS with
20
- * every rule missing. Its `./theme` entry exports exactly 0.5.4's surface,
21
- * which really does include `generateOnMediaCSS` and `dataTokenDefaults`; the
22
- * only capability it lacks is `generateAdaptationCSS`.
23
- *
24
- * On outputs: the CSS is compared with old and current cores, and must match.
25
- * The generated JS module is NOT: a current core resolves normalized
26
- * `__adaptations` metadata onto every theme and the module serializes it, so a
27
- * plain theme's `.js` legitimately differs between the two. That drift is
28
- * asserted rather than wished away — it is also why `theme build --check`
29
- * against outputs committed with a current core reports drift on an older one.
30
- */
31
-
32
- import {afterAll, beforeAll, describe, expect, it} from 'vitest';
33
- import {execFileSync} from 'node:child_process';
34
- import * as fs from 'node:fs';
35
- import * as os from 'node:os';
36
- import * as path from 'node:path';
37
- import {fileURLToPath} from 'node:url';
38
-
39
- import {findInstalledPackage} from '../../../foundation/fs/paths.mjs';
40
- import {CLI_VERSION} from '../../../test-utils/release-fixtures.mjs';
41
-
42
- const HERE = path.dirname(fileURLToPath(import.meta.url));
43
- const REPO_ROOT = path.resolve(HERE, '../../../../..');
44
- const CLI_PKG = path.join(REPO_ROOT, 'packages/cli');
45
- const CORE_DIST = path.join(REPO_ROOT, 'packages/core/dist');
46
- const CORE_THEME_ENTRY = path.join(CORE_DIST, 'theme/index.js');
47
-
48
- /** The CLI's published file set (packages/cli package.json `files`). */
49
- const PACKED_DIRS = ['clients', 'api', 'assets', 'authoring', 'foundation'];
50
- /** Runtime dependencies the packed CLI resolves from its install root. */
51
- const RUNTIME_DEPS = [
52
- '@babel/parser',
53
- 'commander',
54
- 'ignore',
55
- 'jiti',
56
- 'jscodeshift',
57
- 'zod',
58
- ];
59
-
60
- // Both Cores carry the packed CLI's own version: a run through the bin in a
61
- // project whose Core is another release is handed to that release (spec
62
- // AST-081 FR2), so the old surface is told apart by what it exports, not by
63
- // its version.
64
- const OLD_CORE_VERSION = CLI_VERSION;
65
- const CURRENT_CORE_VERSION = CLI_VERSION;
66
- const TSC_BIN = path.join(REPO_ROOT, 'node_modules/typescript/bin/tsc');
67
-
68
- /**
69
- * A core that predates ordered adaptations.
70
- *
71
- * `defineTheme` is adaptation-blind on both sides: `adaptations` never reaches
72
- * the resolver, and no adaptation metadata comes back out — including through
73
- * `extends`, which is how 0.5.4 behaved for a base theme it did not understand.
74
- * It also predates retained `__axes` metadata: generative axes still produce
75
- * root tokens, but the resolved theme does not expose the inputs for a later
76
- * current-core child to complete a partial adaptation axis from. Everything
77
- * else is the real generator, so a CSS difference between this core and a
78
- * current one can only come from the CLI's own branching.
79
- *
80
- * The export list is 0.5.4's `./theme` surface. `generateOnMediaCSS` and
81
- * `dataTokenDefaults` are on it deliberately: they exist in 0.5.4, and
82
- * pretending otherwise would test a core that never shipped.
83
- */
84
- const OLD_CORE_THEME_MODULE = `import {defineTheme as resolveTheme} from ${JSON.stringify(
85
- CORE_THEME_ENTRY,
86
- )};
87
-
88
- export {
89
- generateThemeCSS,
90
- generateThemeRules,
91
- generateThemeRulesSplit,
92
- generateOnMediaCSS,
93
- isDefinedTheme,
94
- tokenDefaults,
95
- dataTokenDefaults,
96
- } from ${JSON.stringify(CORE_THEME_ENTRY)};
97
-
98
- /** Strip every adaptation field and retained axis metadata; this core has no concept of them. */
99
- function blind(value) {
100
- if (!value || typeof value !== 'object') return value;
101
- const {adaptations, __adaptations, __adaptationRules, __axes, ...rest} = value;
102
- if (rest.extends) rest.extends = blind(rest.extends);
103
- return rest;
104
- }
105
-
106
- export function defineTheme(input) {
107
- return blind(resolveTheme(blind(input)));
108
- }
109
- `;
110
-
111
- /** A current core: the whole surface, adaptations included. */
112
- const CURRENT_CORE_THEME_MODULE = `export * from ${JSON.stringify(
113
- CORE_THEME_ENTRY,
114
- )};\n`;
115
-
116
- let root;
117
- let consumer;
118
- let corePkg;
119
-
120
- /**
121
- * Mirror a directory as a tree of symlinks to its entries, so the fixture can
122
- * replace ONE file of a large built package without copying the rest.
123
- * @param {string} from
124
- * @param {string} to
125
- * @param {string[]} [except] - entry names to skip
126
- */
127
- function linkEntries(from, to, except = []) {
128
- fs.mkdirSync(to, {recursive: true});
129
- for (const entry of fs.readdirSync(from)) {
130
- if (except.includes(entry)) continue;
131
- fs.symlinkSync(path.join(from, entry), path.join(to, entry));
132
- }
133
- }
134
-
135
- /**
136
- * Install one of the two cores under the fixture's `node_modules`. The version
137
- * moves with the surface so generated provenance headers differ exactly as
138
- * they would between two real releases.
139
- * @param {'old' | 'current'} surface
140
- */
141
- function useCore(surface) {
142
- const old = surface === 'old';
143
- fs.writeFileSync(
144
- path.join(corePkg, 'package.json'),
145
- `${JSON.stringify(
146
- {
147
- name: '@astryxdesign/core',
148
- version: old ? OLD_CORE_VERSION : CURRENT_CORE_VERSION,
149
- type: 'module',
150
- exports: {
151
- '.': './dist/index.js',
152
- './theme': './dist/theme/index.js',
153
- './*': './dist/*/index.js',
154
- },
155
- },
156
- null,
157
- 2,
158
- )}\n`,
159
- );
160
- fs.writeFileSync(
161
- path.join(corePkg, 'dist/theme/index.js'),
162
- old ? OLD_CORE_THEME_MODULE : CURRENT_CORE_THEME_MODULE,
163
- );
164
- }
165
-
166
- /**
167
- * Install a theme package under the fixture's `node_modules`, shaped like a
168
- * published Astryx theme: a `./built` subpath exporting the module
169
- * `generateBuiltModule` writes.
170
- * @param {string} name - Package name.
171
- * @param {string} exportName - The theme's export name.
172
- * @param {string} adaptationsLiteral - The `__adaptations` object source.
173
- * @param {{esmOnly?: boolean}} [options] - `esmOnly` publishes an `exports`
174
- * map with only an `import` condition, which `require` resolution rejects.
175
- */
176
- function installThemePackage(
177
- name,
178
- exportName,
179
- adaptationsLiteral,
180
- options = {},
181
- ) {
182
- const pkgRoot = path.join(root, 'node_modules', name);
183
- fs.mkdirSync(path.join(pkgRoot, 'dist'), {recursive: true});
184
- const builtFile = options.esmOnly ? 'built.mjs' : 'built.js';
185
- fs.writeFileSync(
186
- path.join(pkgRoot, 'package.json'),
187
- `${JSON.stringify(
188
- {
189
- name,
190
- version: '0.5.4',
191
- type: 'module',
192
- ...(options.esmOnly
193
- ? {exports: {'./built': {import: `./dist/${builtFile}`}}}
194
- : {
195
- main: './dist/source.js',
196
- exports: {
197
- '.': './dist/source.js',
198
- './built': './dist/built.js',
199
- },
200
- }),
201
- },
202
- null,
203
- 2,
204
- )}\n`,
205
- );
206
- fs.writeFileSync(
207
- path.join(pkgRoot, 'dist', builtFile),
208
- `export const ${exportName} = {
209
- name: '${exportName}',
210
- __built: true,
211
- tokens: {'--color-surface': '#eee'},
212
- __adaptations: ${adaptationsLiteral},
213
- };
214
- `,
215
- );
216
- if (!options.esmOnly) {
217
- fs.writeFileSync(
218
- path.join(pkgRoot, 'dist/source.js'),
219
- `export {${exportName}} from './built.js';\n`,
220
- );
221
- }
222
- }
223
-
224
- /**
225
- * Install a package whose SOURCE calls `defineTheme` at load time, rather than
226
- * shipping a built object literal. Its core import must resolve to the wrapped
227
- * one for its author's adaptations to be observable at all.
228
- * @param {string} name
229
- * @param {string} exportName
230
- * @param {string} adaptationsSource - Source for the `adaptations:` entry, or ''.
231
- * @param {{cjs?: boolean, tla?: boolean}} [options]
232
- */
233
- function installSourcePackage(
234
- name,
235
- exportName,
236
- adaptationsSource,
237
- options = {},
238
- ) {
239
- const pkgRoot = path.join(root, 'node_modules', name);
240
- fs.mkdirSync(path.join(pkgRoot, 'src'), {recursive: true});
241
- const entry = options.cjs ? 'src/index.cjs' : 'src/index.mjs';
242
- fs.writeFileSync(
243
- path.join(pkgRoot, 'package.json'),
244
- `${JSON.stringify(
245
- {
246
- name,
247
- version: '0.5.4',
248
- ...(options.cjs ? {} : {type: 'module'}),
249
- main: `./${entry}`,
250
- exports: {'.': `./${entry}`},
251
- },
252
- null,
253
- 2,
254
- )}\n`,
255
- );
256
- fs.writeFileSync(
257
- path.join(pkgRoot, entry),
258
- options.cjs
259
- ? `const {defineTheme} = require('@astryxdesign/core/theme');
260
- exports.${exportName} = defineTheme({
261
- name: '${exportName}',
262
- tokens: {'--color-surface': '#eee'},
263
- ${adaptationsSource}
264
- });
265
- `
266
- : `import {defineTheme} from '@astryxdesign/core/theme';
267
- ${options.tla ? `const surface = await Promise.resolve('#eee');\n` : ''}export const ${exportName} = defineTheme({
268
- name: '${exportName}',
269
- tokens: {'--color-surface': ${options.tla ? 'surface' : "'#eee'"}},
270
- ${adaptationsSource}
271
- });
272
- `,
273
- );
274
- }
275
-
276
- /**
277
- * @param {string | string[]} themeFile
278
- * @param {string[]} [extraArgs]
279
- * @returns {{status: number, envelope: any}}
280
- */
281
- function buildTheme(themeFile, extraArgs = []) {
282
- const bin = path.join(
283
- root,
284
- 'node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs',
285
- );
286
- try {
287
- // A packed CLI outside any project's package.json reads as installed for
288
- // the computer, so it gets a home folder of its own: nothing it keeps for
289
- // the computer lands in the real one.
290
- const home = path.join(root, 'home');
291
- const env = {
292
- ...process.env,
293
- HOME: home,
294
- USERPROFILE: home,
295
- XDG_CONFIG_HOME: path.join(home, '.config'),
296
- XDG_CACHE_HOME: path.join(home, '.cache'),
297
- NO_UPDATE_NOTIFIER: '1',
298
- };
299
- // prettier-ignore
300
- const stdout = execFileSync(process.execPath, [bin, 'theme', 'build', ...(Array.isArray(themeFile) ? themeFile : [themeFile]), ...extraArgs, '--json'], {cwd: consumer, encoding: 'utf8', env, stdio: ['ignore', 'pipe', 'pipe']});
301
- return {status: 0, envelope: JSON.parse(stdout)};
302
- } catch (error) {
303
- const e = /** @type {any} */ (error);
304
- return {status: e.status ?? 1, envelope: JSON.parse(String(e.stdout))};
305
- }
306
- }
307
-
308
- /**
309
- * Generated content with only its leading `@generated` provenance header
310
- * removed. Split on the FIRST close marker: a generated JS module has a second
311
- * block comment of its own, and cutting at every marker would compare nothing
312
- * but that comment.
313
- */
314
- function bodyOf(file) {
315
- const content = fs.readFileSync(path.join(consumer, file), 'utf8');
316
- const end = content.indexOf('*/\n');
317
- return end === -1 ? content : content.slice(end + 3);
318
- }
319
-
320
- /** @param {string} name @param {string} source */
321
- function theme(name, source) {
322
- fs.writeFileSync(path.join(consumer, name), source);
323
- return name;
324
- }
325
-
326
- /** @param {string} base */
327
- function outputsExist(base) {
328
- return ['css', 'js', 'd.ts'].some(ext =>
329
- fs.existsSync(path.join(consumer, `${base}.${ext}`)),
330
- );
331
- }
332
-
333
- /** Type-check the shipped template against 0.5.4's pre-adaptation input. */
334
- function typecheckShippedTemplateAgainstCore054() {
335
- const fixture = path.join(consumer, 'template-core-0.5.4');
336
- fs.rmSync(fixture, {recursive: true, force: true});
337
- fs.mkdirSync(fixture, {recursive: true});
338
-
339
- const template = fs
340
- .readFileSync(path.join(CLI_PKG, 'assets/theme.template.ts'), 'utf8')
341
- .replace("from '@astryxdesign/core/theme';", "from './core-0.5.4.js';");
342
- fs.writeFileSync(path.join(fixture, 'theme.template.ts'), template);
343
-
344
- // Core 0.5.4's DefineThemeInput field set, with each field retaining its real
345
- // type from Core. Keeping the keys explicit prevents a future Core field from
346
- // making this compatibility fixture silently more permissive.
347
- fs.writeFileSync(
348
- path.join(fixture, 'core-0.5.4.d.ts'),
349
- `import type {
350
- DefineThemeInput as CurrentDefineThemeInput,
351
- DefinedTheme,
352
- } from '@astryxdesign/core/theme';
353
- export type DefineThemeInput = Pick<
354
- CurrentDefineThemeInput,
355
- | 'name'
356
- | 'extends'
357
- | 'typography'
358
- | 'motion'
359
- | 'radius'
360
- | 'color'
361
- | 'tokens'
362
- | 'localTokens'
363
- | 'components'
364
- | 'icons'
365
- | 'indicators'
366
- | 'syntax'
367
- | 'onDark'
368
- | 'onLight'
369
- >;
370
- export declare function defineTheme(input: DefineThemeInput): DefinedTheme;
371
- `,
372
- );
373
- fs.writeFileSync(
374
- path.join(fixture, 'tsconfig.json'),
375
- `${JSON.stringify(
376
- {
377
- compilerOptions: {
378
- target: 'ES2022',
379
- module: 'ESNext',
380
- moduleResolution: 'Bundler',
381
- strict: true,
382
- skipLibCheck: true,
383
- noEmit: true,
384
- },
385
- include: ['theme.template.ts', 'core-0.5.4.d.ts'],
386
- },
387
- null,
388
- 2,
389
- )}\n`,
390
- );
391
-
392
- try {
393
- execFileSync(
394
- process.execPath,
395
- [TSC_BIN, '--project', path.join(fixture, 'tsconfig.json')],
396
- {cwd: fixture, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe']},
397
- );
398
- return {ok: true, output: ''};
399
- } catch (error) {
400
- const e = /** @type {any} */ (error);
401
- return {ok: false, output: `${e.stdout ?? ''}${e.stderr ?? ''}`};
402
- }
403
- }
404
-
405
- const ADAPTATIONS = `{
406
- widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536},
407
- rules: [
408
- {when: {pointer: 'coarse'}, value: {tokens: {'--size-element-md': '44px'}}},
409
- ],
410
- }`;
411
-
412
- const MALFORMED_ADAPTATIONS = [
413
- ['rules-string', `{rules: 'invalid'}`],
414
- ['rules-null', `{rules: null}`],
415
- ['rules-object', `{rules: {invalid: true}}`],
416
- ['points-array', `{widthBreakpoints: []}`],
417
- ['points-null', `{widthBreakpoints: null}`],
418
- ];
419
-
420
- beforeAll(() => {
421
- // The `node` project's globalSetup builds core before any worker forks; a
422
- // missing dist here means that contract broke, not that this test is
423
- // optional.
424
- expect(
425
- fs.existsSync(CORE_THEME_ENTRY),
426
- 'packages/core must be built before this suite (vitest.global-setup.node.mjs)',
427
- ).toBe(true);
428
-
429
- root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-packed-old-core-'));
430
- consumer = path.join(root, 'app');
431
- fs.mkdirSync(consumer, {recursive: true});
432
- const modules = path.join(root, 'node_modules');
433
-
434
- // The packed CLI, as published.
435
- const cli = path.join(modules, '@astryxdesign/cli');
436
- fs.mkdirSync(cli, {recursive: true});
437
- for (const dir of PACKED_DIRS) {
438
- fs.cpSync(path.join(CLI_PKG, dir), path.join(cli, dir), {recursive: true});
439
- }
440
- fs.mkdirSync(path.join(cli, 'scripts'), {recursive: true});
441
- fs.copyFileSync(
442
- path.join(CLI_PKG, 'scripts/postinstall.mjs'),
443
- path.join(cli, 'scripts/postinstall.mjs'),
444
- );
445
- fs.copyFileSync(
446
- path.join(CLI_PKG, 'package.json'),
447
- path.join(cli, 'package.json'),
448
- );
449
-
450
- // Its runtime dependencies, resolved from the install root like a real one.
451
- // Found from the CLI package rather than the repo root: only a hoisted
452
- // node_modules puts a package's own dependencies at the workspace root.
453
- for (const dep of RUNTIME_DEPS) {
454
- const installed = findInstalledPackage(CLI_PKG, dep);
455
- if (!installed) throw new Error(`${dep} is not installed under ${CLI_PKG}`);
456
- const target = path.join(modules, dep);
457
- fs.mkdirSync(path.dirname(target), {recursive: true});
458
- fs.symlinkSync(fs.realpathSync(installed), target);
459
- }
460
-
461
- // The installed core. Real built implementations behind a swappable
462
- // `./theme` entry; component docs live in `src` in the published package
463
- // too, and the theme build reads them to validate component overrides.
464
- corePkg = path.join(modules, '@astryxdesign/core');
465
- fs.mkdirSync(corePkg, {recursive: true});
466
- fs.symlinkSync(
467
- path.join(REPO_ROOT, 'packages/core/src'),
468
- path.join(corePkg, 'src'),
469
- );
470
- linkEntries(CORE_DIST, path.join(corePkg, 'dist'), ['theme']);
471
- linkEntries(path.join(CORE_DIST, 'theme'), path.join(corePkg, 'dist/theme'), [
472
- 'index.js',
473
- ]);
474
- useCore('old');
475
-
476
- // Two installed theme packages, shaped like a published one: a `./built`
477
- // subpath exporting a built theme module. The plain one carries the default
478
- // no-op width map every shipped built theme has; the adaptive one carries
479
- // rules. Both are resolved by bare specifier, from the consumer's file.
480
- installThemePackage(
481
- '@fixture/theme-plain',
482
- 'plainPackageTheme',
483
- `{widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536}, rules: []}`,
484
- );
485
- installThemePackage(
486
- '@fixture/theme-adaptive',
487
- 'adaptivePackageTheme',
488
- `{
489
- widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536},
490
- rules: [{when: {contrast: 'more'}, value: {tokens: {'--color-border': '#000'}}}],
491
- }`,
492
- );
493
- // ESM-only `exports` maps: `require` resolution throws
494
- // ERR_PACKAGE_PATH_NOT_EXPORTED on these, the loader resolves them fine.
495
- installThemePackage(
496
- '@fixture/theme-esm',
497
- 'esmAdaptiveTheme',
498
- `{widthBreakpoints: {sm: 600, md: 900, lg: 1200, xl: 1500, '2xl': 1800}, rules: []}`,
499
- {esmOnly: true},
500
- );
501
- installThemePackage(
502
- '@fixture/theme-esm-plain',
503
- 'esmPlainTheme',
504
- `{widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536}, rules: []}`,
505
- {esmOnly: true},
506
- );
507
- // A CommonJS package artifact.
508
- const cjsRoot = path.join(root, 'node_modules/@fixture/theme-cjs');
509
- fs.mkdirSync(cjsRoot, {recursive: true});
510
- fs.writeFileSync(
511
- path.join(cjsRoot, 'package.json'),
512
- `${JSON.stringify({name: '@fixture/theme-cjs', version: '0.5.4', main: './index.js'}, null, 2)}\n`,
513
- );
514
- fs.writeFileSync(
515
- path.join(cjsRoot, 'index.js'),
516
- `exports.cjsPackageTheme = {
517
- name: 'cjs-base',
518
- __built: true,
519
- tokens: {'--color-surface': '#eee'},
520
- __adaptations: {widthBreakpoints: {sm: 600, md: 900, lg: 1200, xl: 1500, '2xl': 1800}, rules: []},
521
- };
522
- `,
523
- );
524
-
525
- theme(
526
- 'plain.ts',
527
- `import {defineTheme} from '@astryxdesign/core/theme';
528
- export const plainTheme = defineTheme({
529
- name: 'plain',
530
- tokens: {'--color-background': '#fff'},
531
- components: {button: {base: {borderRadius: '4px'}}},
532
- });
533
- `,
534
- );
535
- theme(
536
- 'adaptive.ts',
537
- `import {defineTheme} from '@astryxdesign/core/theme';
538
- export const adaptiveTheme = defineTheme({
539
- name: 'adaptive',
540
- tokens: {'--color-background': '#fff'},
541
- adaptations: ${ADAPTATIONS},
542
- });
543
- `,
544
- );
545
- theme(
546
- 'shorthand.ts',
547
- `import {defineTheme} from '@astryxdesign/core/theme';
548
- const adaptations = ${ADAPTATIONS};
549
- export const shorthandTheme = defineTheme({
550
- name: 'shorthand',
551
- tokens: {'--color-background': '#fff'},
552
- adaptations,
553
- });
554
- `,
555
- );
556
- theme(
557
- 'shared-config.ts',
558
- `export const sharedConfig = {adaptations: ${ADAPTATIONS}};\n`,
559
- );
560
- theme(
561
- 'spread.ts',
562
- `import {defineTheme} from '@astryxdesign/core/theme';
563
- import {sharedConfig} from './shared-config';
564
- export const spreadTheme = defineTheme({
565
- name: 'spread',
566
- tokens: {'--color-background': '#fff'},
567
- ...sharedConfig,
568
- });
569
- `,
570
- );
571
- theme(
572
- 'adaptive-base.ts',
573
- `import {defineTheme} from '@astryxdesign/core/theme';
574
- export const adaptiveBase = defineTheme({
575
- name: 'adaptive-base',
576
- tokens: {'--color-background': '#fff'},
577
- adaptations: ${ADAPTATIONS},
578
- });
579
- `,
580
- );
581
- theme(
582
- 'extending.ts',
583
- `import {defineTheme} from '@astryxdesign/core/theme';
584
- import {adaptiveBase} from './adaptive-base';
585
- export const extendingTheme = defineTheme({
586
- name: 'extending',
587
- tokens: {'--color-accent': '#09f'},
588
- extends: adaptiveBase,
589
- });
590
- `,
591
- );
592
- // Zero rules, but a CUSTOM width map: no CSS, yet real semantics an older
593
- // core drops (built metadata, AppShell breakpoint names, extends).
594
- theme(
595
- 'breakpoints-only.ts',
596
- `import {defineTheme} from '@astryxdesign/core/theme';
597
- export const breakpointsOnlyTheme = defineTheme({
598
- name: 'breakpoints-only',
599
- tokens: {'--color-background': '#fff'},
600
- adaptations: {
601
- widthBreakpoints: {sm: 600, md: 900, lg: 1200, xl: 1500, '2xl': 1800},
602
- rules: [],
603
- },
604
- });
605
- `,
606
- );
607
- theme(
608
- 'no-op-adaptations.ts',
609
- `import {defineTheme} from '@astryxdesign/core/theme';
610
- export const noOpAdaptationsTheme = defineTheme({
611
- name: 'no-op-adaptations',
612
- tokens: {'--color-background': '#fff'},
613
- adaptations: {
614
- widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536},
615
- rules: [],
616
- },
617
- });
618
- `,
619
- );
620
- for (const [name, adaptations] of MALFORMED_ADAPTATIONS) {
621
- theme(
622
- `malformed-${name}.ts`,
623
- `import {defineTheme} from '@astryxdesign/core/theme';
624
- export const malformedTheme = defineTheme({
625
- name: 'malformed-${name}',
626
- tokens: {'--color-background': '#fff'},
627
- adaptations: ${adaptations},
628
- });
629
- `,
630
- );
631
- }
632
- // Extends a real INSTALLED theme package whose built artifact carries only
633
- // the default no-op width map — the documented pattern, and what every
634
- // shipped theme's `/built` subpath actually looks like. Must keep building.
635
- theme(
636
- 'extends-package.ts',
637
- `import {defineTheme} from '@astryxdesign/core/theme';
638
- import {plainPackageTheme} from '@fixture/theme-plain/built';
639
- export const extendsPackageTheme = defineTheme({
640
- name: 'extends-package',
641
- tokens: {'--color-accent': '#09f'},
642
- extends: plainPackageTheme,
643
- });
644
- `,
645
- );
646
- // Same shape, but the installed package's built artifact carries rules.
647
- theme(
648
- 'extends-adaptive-package.ts',
649
- `import {defineTheme} from '@astryxdesign/core/theme';
650
- import {adaptivePackageTheme} from '@fixture/theme-adaptive/built';
651
- export const extendsAdaptivePackageTheme = defineTheme({
652
- name: 'extends-adaptive-package',
653
- tokens: {'--color-accent': '#09f'},
654
- extends: adaptivePackageTheme,
655
- });
656
- `,
657
- );
658
- // Negative control: the word is everywhere, the declaration is nowhere.
659
- theme(
660
- 'commented.ts',
661
- `import {defineTheme} from '@astryxdesign/core/theme';
662
- /**
663
- * No adaptations here. A future revision might add:
664
- * adaptations: {rules: [{when: {pointer: 'coarse'}, value: {}}]}
665
- */
666
- // adaptations: {widthBreakpoints: {sm: 600}, rules: []},
667
- const note = 'adaptations: none';
668
- export const commentedTheme = defineTheme({
669
- name: 'commented',
670
- tokens: {'--color-background': '#fff'},
671
- components: {button: {base: {borderRadius: '4px'}}},
672
- /* adaptations: {rules: [{when: {pointer: 'coarse'}, value: {}}]}, */
673
- });
674
- export {note};
675
- `,
676
- );
677
- // Re-export barrel — the shape every shipped theme's `src/source.ts` has.
678
- theme(
679
- 'reexported-theme.ts',
680
- `import {defineTheme} from '@astryxdesign/core/theme';
681
- export const reexportedTheme = defineTheme({
682
- name: 'reexport',
683
- tokens: {'--color-background': '#fff'},
684
- adaptations: ${ADAPTATIONS},
685
- });
686
- `,
687
- );
688
- theme('reexport.ts', `export {reexportedTheme} from './reexported-theme';\n`);
689
- theme(
690
- 'plain-reexported-theme.ts',
691
- `import {defineTheme} from '@astryxdesign/core/theme';
692
- export const plainReexportedTheme = defineTheme({
693
- name: 'plain-reexport',
694
- tokens: {'--color-background': '#fff'},
695
- components: {button: {base: {borderRadius: '4px'}}},
696
- });
697
- `,
698
- );
699
- theme(
700
- 'plain-reexport.ts',
701
- `export {plainReexportedTheme} from './plain-reexported-theme';\n`,
702
- );
703
- theme(
704
- 'star-reexported-theme.ts',
705
- `import {defineTheme} from '@astryxdesign/core/theme';
706
- export const starReexportedTheme = defineTheme({
707
- name: 'star-reexport',
708
- tokens: {'--color-background': '#fff'},
709
- adaptations: ${ADAPTATIONS},
710
- });
711
- `,
712
- );
713
- theme('star-reexport.ts', `export * from './star-reexported-theme';\n`);
714
- // Local factory wrapper.
715
- theme(
716
- 'factory.ts',
717
- `import {defineTheme} from '@astryxdesign/core/theme';
718
- const makeTheme = input => defineTheme({...input, tokens: {'--color-background': '#fff'}});
719
- export const factoryTheme = makeTheme({name: 'factory', adaptations: ${ADAPTATIONS}});
720
- `,
721
- );
722
- theme(
723
- 'plain-factory.ts',
724
- `import {defineTheme} from '@astryxdesign/core/theme';
725
- const makeTheme = input => defineTheme({...input, tokens: {'--color-background': '#fff'}});
726
- export const plainFactoryTheme = makeTheme({name: 'plain-factory'});
727
- `,
728
- );
729
- // A theme whose only export the analysis cannot read at all.
730
- theme(
731
- 'unreadable.ts',
732
- `import {defineTheme} from '@astryxdesign/core/theme';
733
- const build = () => defineTheme({name: 'unreadable', tokens: {}, adaptations: ${ADAPTATIONS}});
734
- export const unreadableTheme = [build()][0];
735
- `,
736
- );
737
- // Extends an ESM-only installed package: `require` cannot resolve its
738
- // `exports` map, the loader can.
739
- theme(
740
- 'extends-esm-package.ts',
741
- `import {defineTheme} from '@astryxdesign/core/theme';
742
- import {esmAdaptiveTheme} from '@fixture/theme-esm/built';
743
- export const extendsEsmTheme = defineTheme({
744
- name: 'extends-esm-package',
745
- tokens: {'--color-accent': '#09f'},
746
- extends: esmAdaptiveTheme,
747
- });
748
- `,
749
- );
750
- theme(
751
- 'extends-esm-plain-package.ts',
752
- `import {defineTheme} from '@astryxdesign/core/theme';
753
- import {esmPlainTheme} from '@fixture/theme-esm-plain/built';
754
- export const extendsEsmPlainTheme = defineTheme({
755
- name: 'extends-esm-plain-package',
756
- tokens: {'--color-accent': '#09f'},
757
- extends: esmPlainTheme,
758
- });
759
- `,
760
- );
761
- // A runtime BRANCH decides whether adaptations are used. No static reading
762
- // of the source can answer this; watching the call does.
763
- theme(
764
- 'branch.ts',
765
- `import {defineTheme} from '@astryxdesign/core/theme';
766
- const wanted = ['a', 'daptive'].join('') === 'adaptive';
767
- export const branchTheme = defineTheme({
768
- name: 'branch',
769
- tokens: {'--color-background': '#fff'},
770
- ...(wanted ? {adaptations: ${ADAPTATIONS}} : {}),
771
- });
772
- `,
773
- );
774
- theme(
775
- 'branch-plain.ts',
776
- `import {defineTheme} from '@astryxdesign/core/theme';
777
- const wanted = ['a', 'daptive'].join('') === 'nope';
778
- export const branchPlainTheme = defineTheme({
779
- name: 'branch-plain',
780
- tokens: {'--color-background': '#fff'},
781
- ...(wanted ? {adaptations: ${ADAPTATIONS}} : {}),
782
- });
783
- `,
784
- );
785
- // Object-SPREAD of a base theme rather than `extends:` — the case a WeakMap
786
- // alone would lose, since a spread makes a brand-new object.
787
- theme(
788
- 'spread-base.ts',
789
- `import {defineTheme} from '@astryxdesign/core/theme';
790
- import {adaptiveBase} from './adaptive-base';
791
- export const spreadBaseTheme = defineTheme({
792
- ...adaptiveBase,
793
- name: 'spread-base',
794
- });
795
- `,
796
- );
797
- theme(
798
- 'plain-base.ts',
799
- `import {defineTheme} from '@astryxdesign/core/theme';
800
- export const plainBase = defineTheme({
801
- name: 'plain-base',
802
- tokens: {'--color-background': '#fff'},
803
- });
804
- `,
805
- );
806
- theme(
807
- 'spread-plain-base.ts',
808
- `import {defineTheme} from '@astryxdesign/core/theme';
809
- import {plainBase} from './plain-base';
810
- export const spreadPlainBaseTheme = defineTheme({
811
- ...plainBase,
812
- name: 'spread-plain-base',
813
- });
814
- `,
815
- );
816
- // Direct `extends` of a raw object literal, no import at all.
817
- theme(
818
- 'direct-extends.ts',
819
- `import {defineTheme} from '@astryxdesign/core/theme';
820
- export const directExtendsTheme = defineTheme({
821
- name: 'direct-extends',
822
- tokens: {'--color-accent': '#09f'},
823
- extends: {name: 'inline-base', tokens: {}, adaptations: ${ADAPTATIONS}},
824
- });
825
- `,
826
- );
827
- // Imported from the package ROOT rather than the `/theme` subpath.
828
- theme(
829
- 'root-import.ts',
830
- `import {defineTheme} from '@astryxdesign/core';
831
- export const rootImportTheme = defineTheme({
832
- name: 'root-import',
833
- tokens: {'--color-background': '#fff'},
834
- adaptations: ${ADAPTATIONS},
835
- });
836
- `,
837
- );
838
- theme(
839
- 'root-import-plain.ts',
840
- `import {defineTheme} from '@astryxdesign/core';
841
- export const rootImportPlainTheme = defineTheme({
842
- name: 'root-import-plain',
843
- tokens: {'--color-background': '#fff'},
844
- });
845
- `,
846
- );
847
- // A CommonJS installed base package.
848
- theme(
849
- 'extends-cjs-package.ts',
850
- `import {defineTheme} from '@astryxdesign/core/theme';
851
- import {cjsPackageTheme} from '@fixture/theme-cjs';
852
- export const extendsCjsTheme = defineTheme({
853
- name: 'extends-cjs-package',
854
- tokens: {'--color-accent': '#09f'},
855
- extends: cjsPackageTheme,
856
- });
857
- `,
858
- );
859
- // An adaptive theme sitting UNUSED beside the selected plain one. Only the
860
- // selected theme's lineage may decide; this must build.
861
- theme(
862
- 'unused-sibling.ts',
863
- `import {defineTheme} from '@astryxdesign/core/theme';
864
- export const unusedAdaptive = defineTheme({
865
- name: 'unused-adaptive',
866
- tokens: {},
867
- adaptations: ${ADAPTATIONS},
868
- });
869
- export default defineTheme({
870
- name: 'unused-sibling',
871
- tokens: {'--color-background': '#fff'},
872
- components: {button: {base: {borderRadius: '4px'}}},
873
- });
874
- `,
875
- );
876
- // Same, one module away: the import graph carries an adaptive theme the
877
- // selected one never uses.
878
- theme(
879
- 'unused-imported.ts',
880
- `import {defineTheme} from '@astryxdesign/core/theme';
881
- import {adaptiveBase} from './adaptive-base';
882
- export const unusedImportedTheme = defineTheme({
883
- name: 'unused-imported',
884
- tokens: {'--color-background': String(typeof adaptiveBase === 'object' ? '#fff' : '#000')},
885
- });
886
- `,
887
- );
888
- // Installed packages whose SOURCE calls defineTheme at runtime, rather than
889
- // shipping a built object literal. Their `defineTheme` must be the wrapped
890
- // one — a package resolving its own real core would erase the author's
891
- // adaptations where nothing can see it.
892
- installSourcePackage(
893
- '@fixture/theme-src-adaptive',
894
- 'srcAdaptiveTheme',
895
- `adaptations: {
896
- widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536},
897
- rules: [{when: {pointer: 'coarse'}, value: {tokens: {'--size-element-md': '44px'}}}],
898
- },`,
899
- );
900
- installSourcePackage('@fixture/theme-src-plain', 'srcPlainTheme', '');
901
- installSourcePackage(
902
- '@fixture/theme-src-cjs-adaptive',
903
- 'srcCjsAdaptiveTheme',
904
- `adaptations: {
905
- widthBreakpoints: {sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536},
906
- rules: [{when: {motion: 'reduce'}, value: {tokens: {'--motion-fast': '0ms'}}}],
907
- },`,
908
- {cjs: true},
909
- );
910
-
911
- theme(
912
- 'extends-src-package.ts',
913
- `import {defineTheme} from '@astryxdesign/core/theme';
914
- import {srcAdaptiveTheme} from '@fixture/theme-src-adaptive';
915
- export const extendsSrcTheme = defineTheme({
916
- name: 'extends-src-package',
917
- tokens: {'--color-accent': '#09f'},
918
- extends: srcAdaptiveTheme,
919
- });
920
- `,
921
- );
922
- theme(
923
- 'extends-src-plain-package.ts',
924
- `import {defineTheme} from '@astryxdesign/core/theme';
925
- import {srcPlainTheme} from '@fixture/theme-src-plain';
926
- export const extendsSrcPlainTheme = defineTheme({
927
- name: 'extends-src-plain-package',
928
- tokens: {'--color-accent': '#09f'},
929
- extends: srcPlainTheme,
930
- });
931
- `,
932
- );
933
- theme(
934
- 'extends-src-cjs-package.ts',
935
- `import {defineTheme} from '@astryxdesign/core/theme';
936
- import {srcCjsAdaptiveTheme} from '@fixture/theme-src-cjs-adaptive';
937
- export const extendsSrcCjsTheme = defineTheme({
938
- name: 'extends-src-cjs-package',
939
- tokens: {'--color-accent': '#09f'},
940
- extends: srcCjsAdaptiveTheme,
941
- });
942
- `,
943
- );
944
- // Imports a NON-theme export from the package root. Mapping the root to the
945
- // theme namespace would delete it and break this build.
946
- theme(
947
- 'root-only-export.ts',
948
- `import {defineTheme} from '@astryxdesign/core/theme';
949
- import {Button} from '@astryxdesign/core';
950
- export const rootOnlyExportTheme = defineTheme({
951
- name: 'root-only-export',
952
- tokens: {'--color-background': typeof Button === 'undefined' ? 'MISSING' : '#fff'},
953
- });
954
- `,
955
- );
956
-
957
- // A source theme with every generative axis and no adaptation intent. An old
958
- // core resolves its tokens but retains no `__axes`; the packed CLI must carry
959
- // the captured authoring metadata into the built artifact so a current-core
960
- // child can complete a partial adaptation axis source-equivalently.
961
- theme(
962
- 'axis-base.ts',
963
- `import {defineTheme} from '@astryxdesign/core/theme';
964
- export const axisBase = defineTheme({
965
- name: 'axis-base',
966
- typography: {scale: {base: 15, ratio: 1.2}},
967
- color: {accent: '#0064E0', neutralStyle: 'warm', contrast: 'high'},
968
- radius: {base: 6, multiplier: 1},
969
- motion: {fast: 120, medium: 300, slow: 700, ratio: 0.75},
970
- });
971
- `,
972
- );
973
- theme(
974
- 'axis-roundtrip-child.ts',
975
- `import {defineTheme} from '@astryxdesign/core/theme';
976
- import {axisBaseTheme} from './axis-base.js';
977
- export const axisRoundTripChild = defineTheme({
978
- name: 'axis-child',
979
- extends: axisBaseTheme,
980
- adaptations: {
981
- rules: [{when: {pointer: 'coarse'}, value: {radius: {multiplier: 2}}}],
982
- },
983
- });
984
- `,
985
- );
986
- theme(
987
- 'axis-source-child.ts',
988
- `import {defineTheme} from '@astryxdesign/core/theme';
989
- import {axisBase} from './axis-base.ts';
990
- export const axisSourceChild = defineTheme({
991
- name: 'axis-child',
992
- extends: axisBase,
993
- adaptations: {
994
- rules: [{when: {pointer: 'coarse'}, value: {radius: {multiplier: 2}}}],
995
- },
996
- });
997
- `,
998
- );
999
-
1000
- // ── Top-level await: forces the DEGRADED load path ────────────────────
1001
- // The sync loader cannot evaluate TLA, so the load falls back to the async
1002
- // import. The entry's own `defineTheme` still routes through the wrapped
1003
- // core there, so a self-contained theme stays fully observed and must build.
1004
- // What the async path loses is TRANSPILING installed packages, so a package
1005
- // SOURCE on that path resolves its own core and escapes observation.
1006
- theme(
1007
- 'tla-entry.ts',
1008
- `import {defineTheme} from '@astryxdesign/core/theme';
1009
- const accent = await Promise.resolve('#09f');
1010
- export const tlaEntryTheme = defineTheme({
1011
- name: 'tla-entry',
1012
- tokens: {'--color-accent': accent},
1013
- components: {button: {base: {borderRadius: '4px'}}},
1014
- });
1015
- `,
1016
- );
1017
- theme(
1018
- 'tla-entry-adaptive.ts',
1019
- `import {defineTheme} from '@astryxdesign/core/theme';
1020
- const accent = await Promise.resolve('#09f');
1021
- export const tlaEntryAdaptiveTheme = defineTheme({
1022
- name: 'tla-entry-adaptive',
1023
- tokens: {'--color-accent': accent},
1024
- adaptations: ${ADAPTATIONS},
1025
- });
1026
- `,
1027
- );
1028
- theme(
1029
- 'tla-sibling-helper.mjs',
1030
- `export const accent = await Promise.resolve('#09f');\n`,
1031
- );
1032
- theme(
1033
- 'tla-sibling.ts',
1034
- `import {defineTheme} from '@astryxdesign/core/theme';
1035
- import {accent} from './tla-sibling-helper.mjs';
1036
- export const tlaSiblingTheme = defineTheme({
1037
- name: 'tla-sibling',
1038
- tokens: {'--color-accent': accent},
1039
- components: {button: {base: {borderRadius: '4px'}}},
1040
- });
1041
- `,
1042
- );
1043
- theme(
1044
- 'tla-sibling-base.ts',
1045
- `import {defineTheme} from '@astryxdesign/core/theme';
1046
- import {accent} from './tla-sibling-helper.mjs';
1047
- export const tlaSiblingBase = defineTheme({
1048
- name: 'tla-sibling-base-inner',
1049
- tokens: {'--color-surface': accent},
1050
- adaptations: ${ADAPTATIONS},
1051
- });
1052
- `,
1053
- );
1054
- theme(
1055
- 'tla-sibling-adaptive.ts',
1056
- `import {defineTheme} from '@astryxdesign/core/theme';
1057
- import {tlaSiblingBase} from './tla-sibling-base';
1058
- export const tlaSiblingAdaptiveTheme = defineTheme({
1059
- name: 'tla-sibling-adaptive',
1060
- tokens: {'--color-accent': '#09f'},
1061
- extends: tlaSiblingBase,
1062
- });
1063
- `,
1064
- );
1065
- // The genuinely escaped case: a TLA theme extending an installed package's
1066
- // SOURCE, which the async path never transpiles, so its own core resolves
1067
- // unwrapped and this core erases its adaptations unobserved.
1068
- theme(
1069
- 'tla-dependency.ts',
1070
- `import {defineTheme} from '@astryxdesign/core/theme';
1071
- import {srcPlainTheme} from '@fixture/theme-src-plain';
1072
- const accent = await Promise.resolve('#09f');
1073
- export const tlaDependencyTheme = defineTheme({
1074
- name: 'tla-dependency',
1075
- tokens: {'--color-accent': accent},
1076
- extends: srcPlainTheme,
1077
- });
1078
- `,
1079
- );
1080
- // TLA with nothing unobservable in the lineage: degraded, but every member
1081
- // is either recorded or carries its own metadata, so it must still build.
1082
- theme(
1083
- 'tla-self-contained.ts',
1084
- `import {defineTheme} from '@astryxdesign/core/theme';
1085
- const accent = await Promise.resolve('#09f');
1086
- export const tlaSelfContainedTheme = defineTheme({
1087
- name: 'tla-self-contained',
1088
- tokens: {'--color-accent': accent},
1089
- });
1090
- `,
1091
- );
1092
- // A genuine author error must surface AS ITSELF, never be downgraded to the
1093
- // async path — which would also execute the module's side effects twice.
1094
- theme(
1095
- 'author-throws.ts',
1096
- `import * as fs from 'node:fs';
1097
- import {defineTheme} from '@astryxdesign/core/theme';
1098
- fs.appendFileSync(new URL('./author-throws.log', import.meta.url), 'x');
1099
- export const authorThrowsTheme = defineTheme({
1100
- name: 'author-throws',
1101
- tokens: {'--color-background': (() => { throw new Error('deliberate author bug'); })()},
1102
- });
1103
- `,
1104
- );
1105
- }, 120_000);
1106
-
1107
- afterAll(() => {
1108
- if (root) fs.rmSync(root, {recursive: true, force: true});
1109
- });
1110
-
1111
- describe('packed CLI against a core that predates adaptations', () => {
1112
- beforeAll(() => useCore('old'));
1113
-
1114
- it('rejects a family before an old core can erase adaptations', () => {
1115
- // prettier-ignore
1116
- const result = buildTheme(['adaptive-base.ts', 'extending.ts'], ['--family', '--family-key', 'adaptive-family']);
1117
- expect(result.envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1118
- });
1119
-
1120
- it('builds a non-adaptation theme', () => {
1121
- const {status, envelope} = buildTheme('plain.ts');
1122
-
1123
- expect({status, error: envelope.error}).toEqual({
1124
- status: 0,
1125
- error: undefined,
1126
- });
1127
- expect(envelope.type).toBe('theme.build');
1128
- const css = fs.readFileSync(path.join(consumer, 'plain.css'), 'utf8');
1129
- expect(css).toContain('--color-background: #fff;');
1130
- expect(css).toContain('border-radius: 4px;');
1131
- expect(css).toContain(`Core: @astryxdesign/core@${OLD_CORE_VERSION}`);
1132
- });
1133
-
1134
- it('keeps the shipped template type-compatible with Core 0.5.4', () => {
1135
- const template = fs.readFileSync(
1136
- path.join(CLI_PKG, 'assets/theme.template.ts'),
1137
- 'utf8',
1138
- );
1139
- expect(template).not.toMatch(/^\s{2}adaptations:/m);
1140
- expect(template).toMatch(/^\s{2}\/\/ adaptations: \{/m);
1141
-
1142
- const result = typecheckShippedTemplateAgainstCore054();
1143
- expect(
1144
- result.ok,
1145
- `Core 0.5.4 rejected the shipped theme template:\n${result.output}`,
1146
- ).toBe(true);
1147
- });
1148
-
1149
- it('builds a theme that only talks about adaptations in comments and strings', () => {
1150
- const {status, envelope} = buildTheme('commented.ts');
1151
-
1152
- expect({status, error: envelope.error}).toEqual({
1153
- status: 0,
1154
- error: undefined,
1155
- });
1156
- expect(
1157
- fs.readFileSync(path.join(consumer, 'commented.css'), 'utf8'),
1158
- ).toContain('border-radius: 4px;');
1159
- });
1160
-
1161
- it('builds a theme extending an installed theme package with no adaptation intent', () => {
1162
- // The documented pattern — `extends` a shipped theme's `/built` subpath.
1163
- // Its `__adaptations` is the default no-op map, so the bare specifier must
1164
- // resolve and the theme must build, not become an unresolved guess.
1165
- const {status, envelope} = buildTheme('extends-package.ts');
1166
-
1167
- expect({status, error: envelope.error}).toEqual({
1168
- status: 0,
1169
- error: undefined,
1170
- });
1171
- expect(
1172
- fs.readFileSync(path.join(consumer, 'extends-package.css'), 'utf8'),
1173
- ).toContain('--color-accent: #09f;');
1174
- });
1175
-
1176
- it.each([
1177
- ['a raw complete default adaptation map', 'no-op-adaptations'],
1178
- ['a plain re-export barrel', 'plain-reexport'],
1179
- ['a plain local factory', 'plain-factory'],
1180
- ['an ESM-only package base with no intent', 'extends-esm-plain-package'],
1181
- ['a runtime branch that skips adaptations', 'branch-plain'],
1182
- ['a spread of a plain base theme', 'spread-plain-base'],
1183
- ['a root `@astryxdesign/core` import', 'root-import-plain'],
1184
- ['an unused adaptive sibling in the same module', 'unused-sibling'],
1185
- ['an unused adaptive theme one module away', 'unused-imported'],
1186
- [
1187
- 'a package whose SOURCE defines a plain theme',
1188
- 'extends-src-plain-package',
1189
- ],
1190
- ])('builds a theme reaching the loader through %s', (_label, base) => {
1191
- const {status, envelope} = buildTheme(`${base}.ts`);
1192
-
1193
- expect({status, error: envelope.error}).toEqual({
1194
- status: 0,
1195
- error: undefined,
1196
- });
1197
- expect(fs.existsSync(path.join(consumer, `${base}.css`))).toBe(true);
1198
- });
1199
-
1200
- it('preserves exports that only the package ROOT has', () => {
1201
- // The wrapped root must be the root namespace, not the theme namespace
1202
- // wearing its name — a theme importing a component from
1203
- // `@astryxdesign/core` would otherwise get `undefined`.
1204
- const {status, envelope} = buildTheme('root-only-export.ts');
1205
-
1206
- expect({status, error: envelope.error}).toEqual({
1207
- status: 0,
1208
- error: undefined,
1209
- });
1210
- const css = fs.readFileSync(
1211
- path.join(consumer, 'root-only-export.css'),
1212
- 'utf8',
1213
- );
1214
- expect(css).not.toContain('MISSING');
1215
- expect(css).toContain('--color-background: #fff;');
1216
- });
1217
-
1218
- it.each([
1219
- ['in the entry file', 'tla-entry'],
1220
- ['in a relative sibling module', 'tla-sibling'],
1221
- ['with no package base at all', 'tla-self-contained'],
1222
- ])(
1223
- 'builds a plain theme when top-level await %s forces the fallback path',
1224
- (_label, base) => {
1225
- // Degraded, but not blind: the entry's own `defineTheme` still routes
1226
- // through the wrapped core on the async path, so the whole lineage was
1227
- // observed and there is nothing unproven. Failing these would make the
1228
- // guard fire on ordinary correct themes.
1229
- const {status, envelope} = buildTheme(`${base}.ts`);
1230
-
1231
- expect({status, error: envelope.error}).toEqual({
1232
- status: 0,
1233
- error: undefined,
1234
- });
1235
- expect(fs.existsSync(path.join(consumer, `${base}.css`))).toBe(true);
1236
- },
1237
- );
1238
-
1239
- it.each([
1240
- ['declared in the entry file', 'tla-entry-adaptive'],
1241
- ['inherited from a relative base', 'tla-sibling-adaptive'],
1242
- ])('still detects adaptations %s under top-level await', (_label, base) => {
1243
- // Degrading the load must not lose real intent: these are observed, and
1244
- // their captured raw input still carries the author's `adaptations`.
1245
- const {status, envelope} = buildTheme(`${base}.ts`);
1246
-
1247
- expect(status).toBe(1);
1248
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1249
- expect(envelope.error).toContain('generateAdaptationCSS');
1250
- expect(outputsExist(base)).toBe(false);
1251
- });
1252
-
1253
- it('refuses a package base that escaped observation on the fallback path', () => {
1254
- // The one genuinely unprovable shape: the async path does not transpile
1255
- // installed packages, so this base's own `defineTheme` is the real one.
1256
- // This core erases adaptations while resolving, so whether it had any is
1257
- // unknowable — and unproven must not build.
1258
- const {status, envelope} = buildTheme('tla-dependency.ts');
1259
-
1260
- expect(status).toBe(1);
1261
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1262
- expect(envelope.error).toMatch(/could not be observed/);
1263
- expect(envelope.error).toMatch(/top-level await/);
1264
- expect(envelope.error).toContain('srcPlainTheme');
1265
- expect(outputsExist('tla-dependency')).toBe(false);
1266
- });
1267
-
1268
- it('surfaces a genuine author error without executing the theme twice', () => {
1269
- // The narrow fallback exists for sync-loader limitations only. An author's
1270
- // own exception must reach them as itself — never be swallowed into a
1271
- // second, weaker load, which would also re-run every side effect the
1272
- // module had already performed.
1273
- const log = path.join(consumer, 'author-throws.log');
1274
- fs.rmSync(log, {force: true});
1275
-
1276
- const {status, envelope} = buildTheme('author-throws.ts');
1277
-
1278
- expect(status).toBe(1);
1279
- expect(envelope.code).toBe('ERR_THEME_LOAD');
1280
- expect(envelope.error).toContain('deliberate author bug');
1281
- // One 'x' per execution of the theme module.
1282
- expect(fs.readFileSync(log, 'utf8')).toBe('x');
1283
- });
1284
-
1285
- it('never serializes the lineage marker into generated output', () => {
1286
- buildTheme('unused-sibling.ts');
1287
-
1288
- for (const ext of ['css', 'js', 'd.ts']) {
1289
- const content = fs.readFileSync(
1290
- path.join(consumer, `unused-sibling.${ext}`),
1291
- 'utf8',
1292
- );
1293
- expect(content).not.toContain('astryx.theme.lineage');
1294
- expect(content).not.toContain('Symbol');
1295
- }
1296
- });
1297
-
1298
- it.each(MALFORMED_ADAPTATIONS)(
1299
- 'refuses malformed adaptation metadata in %s',
1300
- name => {
1301
- const base = `malformed-${name}`;
1302
- const {status, envelope} = buildTheme(`${base}.ts`);
1303
-
1304
- expect(status).toBe(1);
1305
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1306
- expect(outputsExist(base)).toBe(false);
1307
- },
1308
- );
1309
-
1310
- it('refuses a CommonJS source package when its core namespace cannot be wrapped', () => {
1311
- const base = 'extends-src-cjs-package';
1312
- const {status, envelope} = buildTheme(`${base}.ts`);
1313
-
1314
- expect(status).toBe(1);
1315
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1316
- expect(envelope.error).toMatch(/could not be observed/i);
1317
- expect(envelope.error).toMatch(/CommonJS/i);
1318
- expect(outputsExist(base)).toBe(false);
1319
- });
1320
-
1321
- it.each([
1322
- ['a direct `adaptations` property', 'adaptive'],
1323
- ['the object shorthand', 'shorthand'],
1324
- ['a spread of an imported config', 'spread'],
1325
- ['an `extends` base that declares them', 'extending'],
1326
- ['a custom width map with no rules', 'breakpoints-only'],
1327
- [
1328
- 'an installed theme package that declares them',
1329
- 'extends-adaptive-package',
1330
- ],
1331
- ['an `export {x} from` re-export barrel', 'reexport'],
1332
- ['an `export * from` barrel', 'star-reexport'],
1333
- ['a local factory wrapper', 'factory'],
1334
- ['an ESM-only installed package', 'extends-esm-package'],
1335
- ['a runtime branch that adds them', 'branch'],
1336
- ['an object spread of an adaptive base', 'spread-base'],
1337
- ['a direct `extends` of a raw object', 'direct-extends'],
1338
- ['a root `@astryxdesign/core` import', 'root-import'],
1339
- ['a CommonJS installed package base', 'extends-cjs-package'],
1340
- ['a package whose SOURCE calls defineTheme', 'extends-src-package'],
1341
- ])('refuses a theme declaring adaptations via %s', (_label, base) => {
1342
- const {status, envelope} = buildTheme(`${base}.ts`);
1343
-
1344
- expect(status).toBe(1);
1345
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1346
- expect(envelope.error).toContain('generateAdaptationCSS');
1347
- expect(outputsExist(base)).toBe(false);
1348
- });
1349
-
1350
- it('refuses a theme whose export shape it could never have read statically', () => {
1351
- // The loader builds this file happily, and no source analysis could
1352
- // attribute its export. Interception does not have to: the call happened,
1353
- // so the raw input was recorded.
1354
- const {status, envelope} = buildTheme('unreadable.ts');
1355
-
1356
- expect(status).toBe(1);
1357
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1358
- expect(envelope.error).toContain('generateAdaptationCSS');
1359
- expect(outputsExist('unreadable')).toBe(false);
1360
- });
1361
-
1362
- it('fails --check the same way, without reporting drift instead', () => {
1363
- const {status, envelope} = buildTheme('adaptive.ts', ['--check']);
1364
-
1365
- expect(status).toBe(1);
1366
- expect(envelope.code).toBe('ERR_CORE_INCOMPATIBLE');
1367
- });
1368
- });
1369
-
1370
- describe('the same themes once core supports adaptations', () => {
1371
- beforeAll(() => useCore('current'));
1372
-
1373
- it.each([
1374
- 'adaptive',
1375
- 'shorthand',
1376
- 'spread',
1377
- 'extending',
1378
- 'breakpoints-only',
1379
- 'extends-package',
1380
- 'extends-adaptive-package',
1381
- 'reexport',
1382
- 'star-reexport',
1383
- 'factory',
1384
- 'unreadable',
1385
- 'extends-esm-package',
1386
- 'branch',
1387
- 'spread-base',
1388
- 'direct-extends',
1389
- 'root-import',
1390
- 'extends-cjs-package',
1391
- 'no-op-adaptations',
1392
- 'extends-src-package',
1393
- 'extends-src-plain-package',
1394
- 'extends-src-cjs-package',
1395
- 'root-only-export',
1396
- 'tla-entry',
1397
- 'tla-entry-adaptive',
1398
- 'tla-sibling',
1399
- 'tla-sibling-adaptive',
1400
- 'tla-dependency',
1401
- 'tla-self-contained',
1402
- ])('builds %s', base => {
1403
- const {status, envelope} = buildTheme(`${base}.ts`);
1404
-
1405
- expect({status, error: envelope.error}).toEqual({
1406
- status: 0,
1407
- error: undefined,
1408
- });
1409
- // Also pins each fixture's theme NAME to its file name, which is what
1410
- // makes the "wrote nothing" assertions under the older core meaningful:
1411
- // outputs are named after the theme, so a drifting name would quietly
1412
- // turn those checks vacuous.
1413
- expect(fs.existsSync(path.join(consumer, `${base}.css`))).toBe(true);
1414
- });
1415
-
1416
- it('emits adaptation CSS from a CommonJS source package', () => {
1417
- buildTheme('extends-src-cjs-package.ts');
1418
-
1419
- const css = fs.readFileSync(
1420
- path.join(consumer, 'extends-src-cjs-package.css'),
1421
- 'utf8',
1422
- );
1423
- expect(css).toContain('prefers-reduced-motion: reduce');
1424
- expect(css).toContain('--motion-fast: 0ms;');
1425
- });
1426
-
1427
- it('emits the adaptation CSS the older core could not', () => {
1428
- buildTheme('adaptive.ts');
1429
-
1430
- const css = fs.readFileSync(path.join(consumer, 'adaptive.css'), 'utf8');
1431
- expect(css).toContain('pointer: coarse');
1432
- expect(css).toContain('--size-element-md: 44px;');
1433
- });
1434
- });
1435
-
1436
- describe('old-Core generative-axis round trip', () => {
1437
- it('preserves raw axes for a current-Core child with a partial radius adaptation', () => {
1438
- useCore('old');
1439
- const baseBuild = buildTheme('axis-base.ts');
1440
- expect({status: baseBuild.status, error: baseBuild.envelope.error}).toEqual(
1441
- {
1442
- status: 0,
1443
- error: undefined,
1444
- },
1445
- );
1446
- const builtBase = bodyOf('axis-base.js');
1447
- expect(builtBase).toContain('__axes');
1448
- expect(builtBase).toContain('"typography"');
1449
- expect(builtBase).toContain('"color"');
1450
- expect(builtBase).toContain('"radius"');
1451
- expect(builtBase).toContain('"motion"');
1452
- expect(builtBase).toContain('"base": 6');
1453
-
1454
- useCore('current');
1455
- const roundTripBuild = buildTheme('axis-roundtrip-child.ts');
1456
- expect({
1457
- status: roundTripBuild.status,
1458
- error: roundTripBuild.envelope.error,
1459
- }).toEqual({status: 0, error: undefined});
1460
- const roundTripCss = bodyOf('axis-child.css');
1461
-
1462
- const sourceBuild = buildTheme('axis-source-child.ts');
1463
- expect({
1464
- status: sourceBuild.status,
1465
- error: sourceBuild.envelope.error,
1466
- }).toEqual({
1467
- status: 0,
1468
- error: undefined,
1469
- });
1470
- expect(roundTripCss).toBe(bodyOf('axis-child.css'));
1471
- expect(roundTripCss).toContain('--radius-inner: 12px;');
1472
- expect(roundTripCss).toContain('--radius-container: 36px;');
1473
- });
1474
- });
1475
-
1476
- describe('output parity across the two cores', () => {
1477
- it('emits identical CSS for a theme with no adaptations', () => {
1478
- useCore('old');
1479
- buildTheme('plain.ts');
1480
- const oldCss = bodyOf('plain.css');
1481
-
1482
- useCore('current');
1483
- buildTheme('plain.ts');
1484
-
1485
- // Bodies only: the `@generated` header records the core version, which
1486
- // differs between two releases by design.
1487
- expect(oldCss).toBe(bodyOf('plain.css'));
1488
- });
1489
-
1490
- it('emits a JS module that differs only by resolved adaptation metadata', () => {
1491
- // Documented drift, not a defect: a current core normalizes `__adaptations`
1492
- // onto every theme and the built module serializes it for `extends`. An
1493
- // older core has no such metadata to serialize. This is why `--check`
1494
- // against outputs committed with a current core reports JS drift on an
1495
- // older one — the CSS is still identical.
1496
- useCore('old');
1497
- buildTheme('plain.ts');
1498
- const oldJs = bodyOf('plain.js');
1499
-
1500
- useCore('current');
1501
- buildTheme('plain.ts');
1502
- const currentJs = bodyOf('plain.js');
1503
-
1504
- expect(oldJs).not.toBe(currentJs);
1505
- expect(oldJs).not.toContain('__adaptations');
1506
- expect(currentJs).toContain('__adaptations');
1507
- // Nothing else moved: strip the metadata block and they agree.
1508
- expect(
1509
- currentJs.replace(/ {2}__adaptations: \{[\s\S]*?\n {2}\},\n/, ''),
1510
- ).toBe(oldJs);
1511
- });
1512
- });