@astryxdesign/cli 0.7.17 → 0.7.18-canary.g6dfc0b6

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 (213) hide show
  1. package/README.md +1 -1
  2. package/api/discover/_adapter.d.mts +7 -5
  3. package/api/discover/_adapter.mjs +12 -11
  4. package/api/doctor/_adapter.d.mts +11 -62
  5. package/api/doctor/_adapter.mjs +242 -472
  6. package/api/doctor/doctor.d.mts +1 -1
  7. package/api/doctor/doctor.mjs +1 -1
  8. package/api/doctor/theme-checks.mjs +37 -45
  9. package/api/error.d.mts +21 -0
  10. package/api/error.mjs +89 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/icon.doc.mjs +1 -1
  13. package/api/icon/icon.type.mjs +1 -1
  14. package/api/icon/search/search.d.mts +4 -1
  15. package/api/icon/search/search.mjs +41 -4
  16. package/api/render/_adapter.mjs +233 -40
  17. package/api/render/render.type.d.mts +1 -1
  18. package/api/render/render.type.mjs +1 -1
  19. package/api/search/ORDERING.md +2 -2
  20. package/api/search/_candidate-score.mjs +32 -8
  21. package/api/search/_cards.json +1 -1
  22. package/api/search/_compound.d.mts +0 -1
  23. package/api/search/_compound.mjs +93 -2
  24. package/api/search/_lexical.mjs +177 -17
  25. package/api/search/_order.d.mts +3 -1
  26. package/api/search/_order.mjs +16 -5
  27. package/api/search/_result.d.mts +9 -0
  28. package/api/search/_result.mjs +10 -0
  29. package/api/search/_score.mjs +21 -3
  30. package/api/swizzle/_moduleGraph.d.mts +8 -0
  31. package/api/swizzle/_moduleGraph.mjs +61 -3
  32. package/api/template/copy/copy.mjs +5 -3
  33. package/api/theme/_adapter.mjs +48 -12
  34. package/api/theme/build/build.d.mts +4 -0
  35. package/api/theme/build/build.mjs +69 -18
  36. package/api/theme/build/style-keys.mjs +4 -5
  37. package/api/theme/build/theme-object.mjs +5 -0
  38. package/api/theme/palette/generate/color.d.mts +47 -0
  39. package/api/theme/palette/generate/color.mjs +58 -1
  40. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  41. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  42. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  43. package/api/theme/palette/generate/editor-look.mjs +550 -0
  44. package/api/theme/palette/generate/mapping.d.mts +94 -9
  45. package/api/theme/palette/generate/mapping.mjs +94 -22
  46. package/api/theme-edit/_adapter.mjs +10 -1
  47. package/api/theme-edit/_catalog.d.mts +13 -13
  48. package/api/theme-edit/_catalog.mjs +38 -16
  49. package/api/theme-edit/_check.d.mts +82 -6
  50. package/api/theme-edit/_check.mjs +1230 -223
  51. package/api/theme-edit/_color.d.mts +74 -0
  52. package/api/theme-edit/_color.mjs +168 -3
  53. package/api/theme-edit/_compiler.d.mts +3 -5
  54. package/api/theme-edit/_compiler.mjs +122 -23
  55. package/api/theme-edit/_context.d.mts +46 -5
  56. package/api/theme-edit/_context.mjs +97 -49
  57. package/api/theme-edit/_css.d.mts +11 -0
  58. package/api/theme-edit/_css.mjs +40 -0
  59. package/api/theme-edit/_edit.d.mts +13 -0
  60. package/api/theme-edit/_edit.mjs +1450 -128
  61. package/api/theme-edit/_how-commands.d.mts +12 -0
  62. package/api/theme-edit/_how-commands.mjs +96 -14
  63. package/api/theme-edit/_how-question.d.mts +73 -29
  64. package/api/theme-edit/_how-question.mjs +8131 -1209
  65. package/api/theme-edit/_how-sides.d.mts +22 -0
  66. package/api/theme-edit/_how-sides.mjs +173 -0
  67. package/api/theme-edit/_how-steps.d.mts +42 -0
  68. package/api/theme-edit/_how-steps.mjs +208 -0
  69. package/api/theme-edit/_how-values.d.mts +29 -0
  70. package/api/theme-edit/_how-values.mjs +111 -0
  71. package/api/theme-edit/_how-words.d.mts +15 -0
  72. package/api/theme-edit/_how-words.mjs +239 -0
  73. package/api/theme-edit/_how.d.mts +1 -1
  74. package/api/theme-edit/_how.mjs +412 -37
  75. package/api/theme-edit/_missed.d.mts +2 -1
  76. package/api/theme-edit/_missed.mjs +125 -13
  77. package/api/theme-edit/_normal.d.mts +5 -3
  78. package/api/theme-edit/_normal.mjs +54 -14
  79. package/api/theme-edit/_palette.d.mts +204 -4
  80. package/api/theme-edit/_palette.mjs +901 -25
  81. package/api/theme-edit/_part-pieces.d.mts +54 -0
  82. package/api/theme-edit/_part-pieces.mjs +179 -0
  83. package/api/theme-edit/_part-words.mjs +33 -5
  84. package/api/theme-edit/_parts.d.mts +133 -0
  85. package/api/theme-edit/_parts.mjs +599 -10
  86. package/api/theme-edit/_picture-traits.d.mts +259 -0
  87. package/api/theme-edit/_picture-traits.mjs +1030 -0
  88. package/api/theme-edit/_preview.d.mts +84 -4
  89. package/api/theme-edit/_preview.mjs +260 -24
  90. package/api/theme-edit/_project.d.mts +14 -4
  91. package/api/theme-edit/_project.mjs +95 -26
  92. package/api/theme-edit/_set-line.d.mts +29 -0
  93. package/api/theme-edit/_set-line.mjs +100 -0
  94. package/api/theme-edit/_settings.d.mts +625 -28
  95. package/api/theme-edit/_settings.mjs +4587 -880
  96. package/api/theme-edit/_tables.d.mts +25 -1
  97. package/api/theme-edit/_tables.mjs +115 -11
  98. package/api/theme-edit/_text-looks.d.mts +78 -0
  99. package/api/theme-edit/_text-looks.mjs +376 -0
  100. package/api/theme-edit/_vet.d.mts +3 -26
  101. package/api/theme-edit/_vet.mjs +5 -89
  102. package/api/theme-edit/how/how.d.mts +1 -1
  103. package/api/theme-edit/how/how.mjs +1 -1
  104. package/api/theme-edit/theme-edit.type.d.mts +54 -1
  105. package/api/theme-edit/theme-edit.type.mjs +17 -2
  106. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  107. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  108. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  109. package/api/theme-edit/themeEditShow.doc.mjs +4 -0
  110. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  111. package/assets/component-list.generated.json +1 -1
  112. package/assets/docs/author-a-theme.doc.mjs +7 -4
  113. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  114. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  115. package/assets/docs/use-a-theme.doc.mjs +89 -17
  116. package/assets/docs-routes.generated.json +1 -1
  117. package/assets/docs.generated.json +2 -2
  118. package/assets/icons/definitions/article.doc.mjs +9 -0
  119. package/assets/icons/template-icons.json +5 -0
  120. package/assets/search-catalog.generated.json +2 -2
  121. package/assets/self-audit.generated.json +1 -1
  122. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  123. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  124. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  125. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  126. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  127. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  128. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  129. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  130. package/assets/templates/components.generated.json +1 -1
  131. package/assets/templates/pages/ide/page.tsx +5 -10
  132. package/assets/templates/pages/payment-form/page.tsx +16 -60
  133. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  134. package/authoring/debug/parse.d.mts +1 -1
  135. package/authoring/doctypes/_schema.d.mts +13 -13
  136. package/authoring/gap-report/parse.d.mts +1 -1
  137. package/clients/cli/build-id.generated.json +1 -1
  138. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  139. package/clients/cli/commands/experimental/theme.mjs +46 -6
  140. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  141. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  142. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  143. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  144. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  145. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  146. package/clients/cli/commands/hook.mjs +7 -0
  147. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  148. package/clients/cli/index.mjs +6 -2
  149. package/clients/cli/lib/hook-format.mjs +41 -1
  150. package/clients/cli/lib/json-shim.mjs +34 -14
  151. package/clients/cli/lib/other-cli-words.mjs +7 -0
  152. package/clients/cli/lib/unknown-command.mjs +345 -46
  153. package/clients/cli/manifest.generated.json +1 -1
  154. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  155. package/foundation/agent-docs/agent-docs.mjs +51 -8
  156. package/foundation/config/project.d.mts +11 -1
  157. package/foundation/config/project.mjs +11 -2
  158. package/foundation/discovery/component-replacement.d.mts +5 -8
  159. package/foundation/discovery/component-replacement.mjs +12 -14
  160. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  161. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  162. package/foundation/discovery/core-elements.d.mts +6 -0
  163. package/foundation/discovery/core-elements.mjs +10 -2
  164. package/foundation/discovery/core-prop-types.d.mts +5 -0
  165. package/foundation/discovery/core-prop-types.mjs +10 -3
  166. package/foundation/discovery/core-props.d.mts +8 -0
  167. package/foundation/discovery/core-props.mjs +29 -13
  168. package/foundation/discovery/official-list.d.mts +17 -0
  169. package/foundation/discovery/official-list.mjs +77 -0
  170. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  171. package/foundation/discovery/unknown-core-props.mjs +601 -0
  172. package/foundation/discovery/written-prop-values.d.mts +35 -0
  173. package/foundation/discovery/written-prop-values.mjs +258 -0
  174. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  175. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  176. package/foundation/fs/package-name.d.mts +10 -0
  177. package/foundation/fs/package-name.mjs +37 -0
  178. package/foundation/fs/project-source-files.d.mts +27 -0
  179. package/foundation/fs/project-source-files.mjs +115 -0
  180. package/foundation/fs/project-sources.d.mts +25 -0
  181. package/foundation/fs/project-sources.mjs +83 -0
  182. package/foundation/fs/read-record.d.mts +18 -0
  183. package/foundation/fs/read-record.mjs +36 -2
  184. package/foundation/integrations/integration-warnings.d.mts +39 -7
  185. package/foundation/integrations/integration-warnings.mjs +141 -19
  186. package/foundation/integrations/missing-dependency.d.mts +11 -0
  187. package/foundation/integrations/missing-dependency.mjs +20 -5
  188. package/foundation/release/folder-lock.d.mts +5 -2
  189. package/foundation/release/folder-lock.mjs +9 -3
  190. package/foundation/release/notices.mjs +2 -8
  191. package/foundation/render/cut-short.d.mts +8 -2
  192. package/foundation/render/cut-short.mjs +50 -5
  193. package/foundation/render/drawn-contrast.d.mts +38 -0
  194. package/foundation/render/drawn-contrast.mjs +237 -0
  195. package/foundation/render/file-header.mjs +4 -0
  196. package/foundation/render/layers.d.mts +2 -1
  197. package/foundation/render/layers.mjs +22 -1
  198. package/foundation/render/page-worker.mjs +83 -18
  199. package/foundation/render/part-boxes.d.mts +27 -0
  200. package/foundation/render/part-boxes.mjs +45 -0
  201. package/foundation/render/picture-chrome.mjs +36 -4
  202. package/foundation/render/picture-playwright.mjs +26 -2
  203. package/foundation/render/picture-window.d.mts +29 -2
  204. package/foundation/render/picture-window.mjs +99 -1
  205. package/foundation/render/render-page.d.mts +39 -6
  206. package/foundation/render/render-page.mjs +26 -10
  207. package/foundation/render/ts-paths.mjs +2 -1
  208. package/foundation/response/error-codes.doc.mjs +1 -1
  209. package/foundation/response/error-codes.mjs +1 -1
  210. package/foundation/response/response-types.doc.mjs +1 -1
  211. package/foundation/text/written-string.d.mts +4 -1
  212. package/foundation/text/written-string.mjs +4 -1
  213. package/package.json +8 -7
@@ -2,16 +2,18 @@
2
2
 
3
3
  /**
4
4
  * @file The interfaces a Core declares for themes to widen by declaration
5
- * merging (`interface ButtonVariantMap`), the prop axes they widen, and the
6
- * keys a project adds to them.
5
+ * merging (`interface ButtonVariantMap`), the prop axes they widen, the
6
+ * keys a project adds to them, and the kinds of value a Core prop takes.
7
7
  * @input a Core package root; a theme target token or a component name and
8
8
  * a prop name; a project folder and a page
9
9
  * @output whether a Core subpath declares an interface; the interface a
10
10
  * theme's styling key on a target's prop enrolls in; every interface whose
11
- * keys a component prop's type takes; the keys a project adds to each
11
+ * keys a component prop's type takes; the keys a project adds to each; the
12
+ * kinds of value (string, number, object…) a prop's declared type takes
12
13
  * @position Read by theme build (api/theme/build/build.mjs), which augments
13
14
  * these interfaces, and by render (api/render/_adapter.mjs), which takes a
14
- * widened prop's added keys as values the prop has.
15
+ * widened prop's added keys as values the prop has and warns for a value
16
+ * of a kind the prop does not take.
15
17
  */
16
18
 
17
19
  import * as fs from 'node:fs';
@@ -785,6 +787,25 @@ function keyInterfaces(coreRoot, type, file, depth) {
785
787
  * @returns {Set<string> | null}
786
788
  */
787
789
  function typeWideningInterfaces(coreRoot, pascalName, prop) {
790
+ if (!coreRoot) return null;
791
+ return keyInterfacesOfAll(
792
+ coreRoot,
793
+ declaredPropTypes(coreRoot, pascalName, prop),
794
+ 0,
795
+ );
796
+ }
797
+
798
+ /**
799
+ * Every declared type of `<pascalName prop>` in Core's source: the prop on
800
+ * `<pascalName>Props`, found from the component's subpath, else from Core's
801
+ * root module. Null when Core's source is absent or the props type leads
802
+ * where this reader does not follow.
803
+ * @param {string | null} coreRoot
804
+ * @param {string} pascalName
805
+ * @param {string} prop
806
+ * @returns {{type: any, file: string}[] | null}
807
+ */
808
+ function declaredPropTypes(coreRoot, pascalName, prop) {
788
809
  if (!coreRoot) return null;
789
810
  const from = path.join(coreRoot, 'src', 'index.ts');
790
811
  for (const specifier of [`${CORE_PACKAGE}/${pascalName}`, CORE_PACKAGE]) {
@@ -792,15 +813,395 @@ function typeWideningInterfaces(coreRoot, pascalName, prop) {
792
813
  if (!entry) continue;
793
814
  const declarations = declarationsOf(coreRoot, entry, `${pascalName}Props`);
794
815
  if (!declarations || declarations.length === 0) continue;
795
- return keyInterfacesOfAll(
796
- coreRoot,
797
- propertyOfDeclarations(coreRoot, declarations, prop, 0),
798
- 0,
799
- );
816
+ return propertyOfDeclarations(coreRoot, declarations, prop, 0);
800
817
  }
801
818
  return null;
802
819
  }
803
820
 
821
+ /**
822
+ * @typedef {'string' | 'number' | 'boolean' | 'object' | 'array' | 'Date' | 'function'} ValueKind
823
+ * @typedef {{kinds: Set<ValueKind>, fields?: string[] | null, numbers: Set<number>, anyNumber: boolean}} PropKinds
824
+ */
825
+
826
+ /**
827
+ * The kinds of value the declared type of `<pascalName prop>` takes, read
828
+ * from Core's source by the same reader as {@link propWideningInterfaces}: a
829
+ * string (a literal, a template, `keyof` a map), a number, a boolean, an
830
+ * object (with the field names of the first object shape it names), an
831
+ * array, a `Date` or a function. `null` and `undefined` add no kind. Null
832
+ * when any part of the type leads where this reader does not follow (a React
833
+ * type, a generic parameter, an enum): such a prop's kinds are not certain.
834
+ * @param {string | null} coreRoot the Core package root
835
+ * @param {string} pascalName
836
+ * @param {string} prop
837
+ * @returns {PropKinds | null}
838
+ */
839
+ export function propValueKinds(coreRoot, pascalName, prop) {
840
+ const found = declaredPropTypes(coreRoot, pascalName, prop);
841
+ if (!found || found.length === 0 || !coreRoot) return null;
842
+ /** @type {PropKinds} */
843
+ const out = {kinds: new Set(), numbers: new Set(), anyNumber: false};
844
+ for (const {type, file} of found) {
845
+ if (!kindsOf(coreRoot, type, file, out, 0)) return null;
846
+ }
847
+ out.fields = out.fields?.length ? out.fields : null;
848
+ return out.kinds.size > 0 ? out : null;
849
+ }
850
+
851
+ /**
852
+ * The first written kind a prop's declared kinds do not take, or null when
853
+ * the prop takes every one. An array, a `Date` or a function passes where
854
+ * the type takes an object, since an object shape this reader names may
855
+ * still accept one.
856
+ * @param {ValueKind[]} written
857
+ * @param {PropKinds} declared
858
+ * @returns {ValueKind | null}
859
+ */
860
+ export function unacceptedKind(written, declared) {
861
+ const objectLike = /** @type {ValueKind[]} */ (['array', 'Date', 'function']);
862
+ return (
863
+ written.find(
864
+ kind =>
865
+ !declared.kinds.has(kind) &&
866
+ !(objectLike.includes(kind) && declared.kinds.has('object')),
867
+ ) ?? null
868
+ );
869
+ }
870
+
871
+ /** Utility types that keep their argument's keys. */
872
+ const KEY_KEEPING_TYPES = new Set([
873
+ 'Partial',
874
+ 'Required',
875
+ 'Readonly',
876
+ 'NonNullable',
877
+ ]);
878
+
879
+ /** Global types a prop's type may name, by the kind of value they take. */
880
+ const GLOBAL_KINDS = /** @type {Record<string, ValueKind>} */ ({
881
+ Date: 'Date',
882
+ Array: 'array',
883
+ ReadonlyArray: 'array',
884
+ Record: 'object',
885
+ Function: 'function',
886
+ });
887
+
888
+ /**
889
+ * Add the kinds a type node takes to `out`; false when it leads where this
890
+ * reader does not follow.
891
+ * @param {string} coreRoot
892
+ * @param {any} type
893
+ * @param {string} file
894
+ * @param {PropKinds} out
895
+ * @param {number} depth
896
+ * @returns {boolean}
897
+ */
898
+ function kindsOf(coreRoot, type, file, out, depth) {
899
+ if (!type || depth > 24) return false;
900
+ switch (type.type) {
901
+ case 'TSStringKeyword':
902
+ case 'TSTemplateLiteralType':
903
+ out.kinds.add('string');
904
+ return true;
905
+ case 'TSNumberKeyword':
906
+ out.kinds.add('number');
907
+ out.anyNumber = true;
908
+ return true;
909
+ case 'TSBooleanKeyword':
910
+ out.kinds.add('boolean');
911
+ return true;
912
+ case 'TSUndefinedKeyword':
913
+ case 'TSNullKeyword':
914
+ case 'TSVoidKeyword':
915
+ case 'TSNeverKeyword':
916
+ return true;
917
+ case 'TSLiteralType': {
918
+ const literal = type.literal;
919
+ const kind =
920
+ literal.type === 'StringLiteral' || literal.type === 'TemplateLiteral'
921
+ ? 'string'
922
+ : literal.type === 'NumericLiteral' ||
923
+ literal.type === 'UnaryExpression'
924
+ ? 'number'
925
+ : literal.type === 'BooleanLiteral'
926
+ ? 'boolean'
927
+ : null;
928
+ if (!kind) return false;
929
+ out.kinds.add(kind);
930
+ if (kind === 'number') {
931
+ const n =
932
+ literal.type === 'UnaryExpression'
933
+ ? -literal.argument.value
934
+ : literal.value;
935
+ if (typeof n === 'number') out.numbers.add(n);
936
+ else out.anyNumber = true;
937
+ }
938
+ return true;
939
+ }
940
+ case 'TSTypeLiteral':
941
+ return addObject(out, type.members);
942
+ case 'TSFunctionType':
943
+ case 'TSConstructorType':
944
+ out.kinds.add('function');
945
+ return true;
946
+ case 'TSArrayType':
947
+ case 'TSTupleType':
948
+ out.kinds.add('array');
949
+ return true;
950
+ case 'TSParenthesizedType':
951
+ case 'TSOptionalType':
952
+ return kindsOf(coreRoot, type.typeAnnotation, file, out, depth + 1);
953
+ case 'TSTypeOperator':
954
+ if (type.operator === 'keyof')
955
+ return keyKinds(coreRoot, type.typeAnnotation, file, out);
956
+ return (
957
+ type.operator === 'readonly' &&
958
+ kindsOf(coreRoot, type.typeAnnotation, file, out, depth + 1)
959
+ );
960
+ case 'TSUnionType':
961
+ return type.types.every((/** @type {any} */ part) =>
962
+ kindsOf(coreRoot, part, file, out, depth + 1),
963
+ );
964
+ case 'TSIntersectionType':
965
+ return intersectionKinds(coreRoot, type.types, file, out, depth);
966
+ case 'TSIndexedAccessType': {
967
+ const index = type.indexType;
968
+ if (
969
+ index.type !== 'TSLiteralType' ||
970
+ typeof index.literal?.value !== 'string'
971
+ )
972
+ return false;
973
+ const found = propertyOfType(
974
+ coreRoot,
975
+ type.objectType,
976
+ file,
977
+ index.literal.value,
978
+ depth + 1,
979
+ );
980
+ if (!found || found.length === 0) return false;
981
+ return found.every(f =>
982
+ kindsOf(coreRoot, f.type, f.file, out, depth + 1),
983
+ );
984
+ }
985
+ case 'TSTypeReference': {
986
+ if (type.typeName.type !== 'Identifier') return false;
987
+ const name = type.typeName.name;
988
+ if (PASS_THROUGH_TYPES.has(name)) {
989
+ /** @type {PropKinds} */
990
+ const inner = {kinds: new Set(), numbers: new Set(), anyNumber: false};
991
+ if (
992
+ !kindsOf(
993
+ coreRoot,
994
+ type.typeParameters?.params?.[0],
995
+ file,
996
+ inner,
997
+ depth + 1,
998
+ )
999
+ )
1000
+ return false;
1001
+ for (const kind of inner.kinds) out.kinds.add(kind);
1002
+ for (const n of inner.numbers) out.numbers.add(n);
1003
+ out.anyNumber ||= inner.anyNumber;
1004
+ // `Omit`, `Pick`, `Exclude` and `Extract` change which keys or members
1005
+ // remain, so the first argument's field names are not the prop's.
1006
+ if (inner.fields !== undefined)
1007
+ addShape(out, KEY_KEEPING_TYPES.has(name) ? inner.fields : null);
1008
+ return true;
1009
+ }
1010
+ const declarations = declarationsOf(coreRoot, file, name);
1011
+ if (
1012
+ declarations &&
1013
+ declarations.length > 0 &&
1014
+ declarations.every(d => d.node.type === 'TSInterfaceDeclaration')
1015
+ ) {
1016
+ // Every declaration of a merged interface is one shape.
1017
+ out.kinds.add('object');
1018
+ addShape(out, interfaceFields(coreRoot, declarations, depth + 1));
1019
+ return true;
1020
+ }
1021
+ if (declarations && declarations.length > 0) {
1022
+ return declarations.every(({node, file: at}) => {
1023
+ if (node.type === 'TSTypeAliasDeclaration')
1024
+ return kindsOf(coreRoot, node.typeAnnotation, at, out, depth + 1);
1025
+ if (node.type === 'TSInterfaceDeclaration') {
1026
+ out.kinds.add('object');
1027
+ addShape(
1028
+ out,
1029
+ interfaceFields(coreRoot, [{node, file: at}], depth + 1),
1030
+ );
1031
+ return true;
1032
+ }
1033
+ return false;
1034
+ });
1035
+ }
1036
+ if (declarations && Object.hasOwn(GLOBAL_KINDS, name)) {
1037
+ out.kinds.add(GLOBAL_KINDS[name]);
1038
+ return true;
1039
+ }
1040
+ return false;
1041
+ }
1042
+ default:
1043
+ return false;
1044
+ }
1045
+ }
1046
+
1047
+ /**
1048
+ * Add the kinds of the keys of an interface (`keyof ButtonVariantMap`): a
1049
+ * string for a named key, a number for a numeric one. False for the keys of
1050
+ * anything else (`keyof typeof styles` can hold numbers).
1051
+ * @param {string} coreRoot
1052
+ * @param {any} target the type `keyof` applies to
1053
+ * @param {string} file
1054
+ * @param {PropKinds} out
1055
+ * @returns {boolean}
1056
+ */
1057
+ function keyKinds(coreRoot, target, file, out) {
1058
+ if (
1059
+ target.type !== 'TSTypeReference' ||
1060
+ target.typeName.type !== 'Identifier'
1061
+ )
1062
+ return false;
1063
+ const declarations = declarationsOf(coreRoot, file, target.typeName.name);
1064
+ if (!declarations || declarations.length === 0) return false;
1065
+ if (!declarations.every(d => d.node.type === 'TSInterfaceDeclaration'))
1066
+ return false;
1067
+ for (const {node} of declarations) {
1068
+ for (const member of node.body.body) {
1069
+ if (member.type !== 'TSPropertySignature' || member.computed)
1070
+ return false;
1071
+ if (member.key.type === 'NumericLiteral') {
1072
+ out.kinds.add('number');
1073
+ out.numbers.add(member.key.value);
1074
+ } else out.kinds.add('string');
1075
+ }
1076
+ }
1077
+ return true;
1078
+ }
1079
+
1080
+ /**
1081
+ * The kinds of an intersection: those every part takes (`keyof Map & string`
1082
+ * is a string). False when a part cannot be followed.
1083
+ * @param {string} coreRoot
1084
+ * @param {any[]} parts
1085
+ * @param {string} file
1086
+ * @param {PropKinds} out
1087
+ * @param {number} depth
1088
+ * @returns {boolean}
1089
+ */
1090
+ function intersectionKinds(coreRoot, parts, file, out, depth) {
1091
+ /** @type {ValueKind[] | null} */
1092
+ let common = null;
1093
+ /** @type {(string[] | null)[]} */
1094
+ const shapes = [];
1095
+ for (const part of parts) {
1096
+ // `string & {}` keeps a string open to completion: `{}` adds no kind.
1097
+ if (part.type === 'TSTypeLiteral' && part.members.length === 0) continue;
1098
+ /** @type {PropKinds} */
1099
+ const each = {kinds: new Set(), numbers: new Set(), anyNumber: false};
1100
+ if (!kindsOf(coreRoot, part, file, each, depth + 1)) return false;
1101
+ common =
1102
+ common === null
1103
+ ? [...each.kinds]
1104
+ : common.filter(kind => each.kinds.has(kind));
1105
+ if (each.fields !== undefined) shapes.push(each.fields);
1106
+ }
1107
+ for (const kind of common ?? []) out.kinds.add(kind);
1108
+ // One object part names its fields; several make a shape this reader does
1109
+ // not merge.
1110
+ if (shapes.length > 0) addShape(out, shapes.length === 1 ? shapes[0] : null);
1111
+ // The numbers an intersection keeps are not worked out: it takes any.
1112
+ if (common?.includes('number')) out.anyNumber = true;
1113
+ return true;
1114
+ }
1115
+
1116
+ /**
1117
+ * The names of the fields an object type's members declare. A member typed
1118
+ * `never`, or one whose key is not a plain name (Core's brand keys are
1119
+ * module paths), is a marker no page writes.
1120
+ * @param {any[]} members
1121
+ * @returns {string[]}
1122
+ */
1123
+ function plainFields(members) {
1124
+ return members.flatMap(m => {
1125
+ if (m.type !== 'TSPropertySignature' || m.computed) return [];
1126
+ if (m.typeAnnotation?.typeAnnotation?.type === 'TSNeverKeyword') return [];
1127
+ const name = nameOf(m.key);
1128
+ return /^[A-Za-z_$][\w$]*$/.test(name) ? [name] : [];
1129
+ });
1130
+ }
1131
+
1132
+ /**
1133
+ * Record one object shape's fields in `out`. The message names fields only
1134
+ * when every shape the type allows has the same ones: two different shapes,
1135
+ * or a shape whose fields are not all known (null), leave none.
1136
+ * @param {PropKinds} out
1137
+ * @param {string[] | null} fields
1138
+ */
1139
+ function addShape(out, fields) {
1140
+ if (out.fields === undefined) out.fields = fields;
1141
+ else if (
1142
+ out.fields !== null &&
1143
+ (fields === null || out.fields.join() !== fields.join())
1144
+ )
1145
+ out.fields = null;
1146
+ }
1147
+
1148
+ /**
1149
+ * Every field an interface takes: its own, from each of its declarations,
1150
+ * and those of the interfaces it extends. Null when a base is generic or
1151
+ * cannot be found.
1152
+ * @param {string} coreRoot
1153
+ * @param {{node: any, file: string}[]} declarations
1154
+ * @param {number} depth
1155
+ * @returns {string[] | null}
1156
+ */
1157
+ function interfaceFields(coreRoot, declarations, depth) {
1158
+ if (depth > 16) return null;
1159
+ const fields = [];
1160
+ for (const {node, file} of declarations) {
1161
+ fields.push(...plainFields(node.body.body));
1162
+ for (const base of node.extends ?? []) {
1163
+ if (
1164
+ base.expression?.type !== 'Identifier' ||
1165
+ base.typeParameters ||
1166
+ base.typeArguments
1167
+ )
1168
+ return null;
1169
+ const found = declarationsOf(coreRoot, file, base.expression.name);
1170
+ if (!found || found.length === 0) return null;
1171
+ if (found.every(d => d.node.type === 'TSInterfaceDeclaration')) {
1172
+ const inherited = interfaceFields(coreRoot, found, depth + 1);
1173
+ if (!inherited) return null;
1174
+ fields.push(...inherited);
1175
+ } else if (
1176
+ found.length === 1 &&
1177
+ found[0].node.type === 'TSTypeAliasDeclaration' &&
1178
+ found[0].node.typeAnnotation.type === 'TSTypeLiteral'
1179
+ ) {
1180
+ fields.push(...plainFields(found[0].node.typeAnnotation.members));
1181
+ } else return null;
1182
+ }
1183
+ }
1184
+ return [...new Set(fields)];
1185
+ }
1186
+
1187
+ /**
1188
+ * Add an object type literal to `out`. A shape with only call signatures is
1189
+ * a function.
1190
+ * @param {PropKinds} out
1191
+ * @param {any[]} members
1192
+ * @returns {boolean}
1193
+ */
1194
+ function addObject(out, members) {
1195
+ const callable =
1196
+ members.length > 0 &&
1197
+ members.every(
1198
+ (/** @type {any} */ m) => m.type === 'TSCallSignatureDeclaration',
1199
+ );
1200
+ out.kinds.add(callable ? 'function' : 'object');
1201
+ if (!callable) addShape(out, plainFields(members));
1202
+ return true;
1203
+ }
1204
+
804
1205
  const CORE_PACKAGE = '@astryxdesign/core';
805
1206
 
806
1207
  /** A project's own TypeScript file, declarations included. */
@@ -27,3 +27,9 @@ export function coreImportOf(name: any, scope: any): {
27
27
  component: string;
28
28
  source: string;
29
29
  } | null;
30
+ /**
31
+ * A module that compiles its JSX with a runtime other than React's (a
32
+ * `@jsxImportSource` or `@jsx` pragma), which can give every component props
33
+ * of its own.
34
+ */
35
+ export const OTHER_JSX_RUNTIME: RegExp;
@@ -3,8 +3,9 @@
3
3
  /**
4
4
  * @file Which module paths and JSX elements name Core.
5
5
  * @input A module path, or a JSX element's name node and its Babel scope.
6
- * @output Whether the path is Core's package or one of its subpaths, and the
7
- * Core component an element draws.
6
+ * @output Whether the path is Core's package or one of its subpaths, the
7
+ * Core component an element draws, and whether a module's pragma compiles
8
+ * its JSX with another runtime.
8
9
  * @position Shared by doctor's prop check (core-props.mjs), the reader of
9
10
  * what augments Core (core-augmentation-points.mjs) and the page render
10
11
  * worker (render/page-worker.mjs), so that they agree on what is Core.
@@ -12,6 +13,13 @@
12
13
 
13
14
  const CORE_PACKAGE = '@astryxdesign/core';
14
15
 
16
+ /**
17
+ * A module that compiles its JSX with a runtime other than React's (a
18
+ * `@jsxImportSource` or `@jsx` pragma), which can give every component props
19
+ * of its own.
20
+ */
21
+ export const OTHER_JSX_RUNTIME = /@jsxImportSource\s+(?!react(?:\s|\*|$))\S|@jsx\s+(?!React\.createElement\b)[A-Za-z_$]/m;
22
+
15
23
  /**
16
24
  * Whether a module path names Core: the package or one of its subpaths.
17
25
  * @param {string} specifier
@@ -9,6 +9,7 @@
9
9
  * and SVG elements, DOM events and ARIA attributes included, and the props
10
10
  * JSX gives every component
11
11
  * @property {string | null} unread why the types could not be read, or null
12
+ * @property {string} [unreadFix] what to install so they can be read
12
13
  */
13
14
  /**
14
15
  * Read Core's own published types with the project's TypeScript, as the
@@ -62,4 +63,8 @@ export type CorePropTypes = {
62
63
  * why the types could not be read, or null
63
64
  */
64
65
  unread: string | null;
66
+ /**
67
+ * what to install so they can be read
68
+ */
69
+ unreadFix?: string | undefined;
65
70
  };
@@ -9,8 +9,9 @@
9
9
  * @output For each component TypeScript can read, whether its props type
10
10
  * takes each prop; the prop names React's types give HTML and SVG elements
11
11
  * and every component; or why the types could not be read.
12
- * @position Read by `astryx doctor` (api/doctor/_adapter.mjs) for the props a
13
- * page gives Core components that Core's docs do not list.
12
+ * @position Read by the Core prop check that `astryx doctor` and
13
+ * `astryx experimental export` share (unknown-core-props.mjs), for the
14
+ * props a page gives Core components that Core's docs do not list.
14
15
  */
15
16
 
16
17
  import * as path from 'node:path';
@@ -98,6 +99,7 @@ function isGeneric(ts, checker, type) {
98
99
  * and SVG elements, DOM events and ARIA attributes included, and the props
99
100
  * JSX gives every component
100
101
  * @property {string | null} unread why the types could not be read, or null
102
+ * @property {string} [unreadFix] what to install so they can be read
101
103
  */
102
104
 
103
105
  /**
@@ -199,7 +201,12 @@ export function readCorePropTypes({ts, projectDir, configDir, options: configOpt
199
201
  // A string index on what JSX gives every component takes every name.
200
202
  const takesEveryName = everywhere != null && checker.getIndexInfoOfType(everywhere, ts.IndexKind.String) != null;
201
203
  if (attributes.size === 0) {
202
- return {takes, attributes, unread: "TypeScript could not read React's types from this project"};
204
+ return {
205
+ takes,
206
+ attributes,
207
+ unread: "TypeScript could not read React's types from this project",
208
+ unreadFix: "Install React's types (`npm install -D @types/react`).",
209
+ };
203
210
  }
204
211
  // Core's types are unread only when its main module does not load; a
205
212
  // component whose own type TypeScript cannot read is not judged.
@@ -18,6 +18,14 @@
18
18
  * @returns {CorePropUse[] | null}
19
19
  */
20
20
  export function scanCoreProps(source: string): CorePropUse[] | null;
21
+ /**
22
+ * The props one JSX element gives a Core component by name, as
23
+ * `scanCoreProps` reads them. A module's reader that walks its own syntax
24
+ * tree calls this for each opening element, so it reads the same props.
25
+ * @param {any} path the opening element's Babel path
26
+ * @returns {CorePropUse[]}
27
+ */
28
+ export function corePropUsesOf(path: any): CorePropUse[];
21
29
  export type CorePropUse = {
22
30
  /**
23
31
  * the name Core exports the component by
@@ -5,8 +5,10 @@
5
5
  * @input One module's source text.
6
6
  * @output Each prop a Core component's element names, with the component,
7
7
  * the line and the column; or null when the module does not parse.
8
- * @position Read by `astryx doctor` (api/doctor/_adapter.mjs), which checks
9
- * each prop against the component's docs and Core's own types.
8
+ * @position Read by `astryx doctor` (api/doctor/_adapter.mjs) and, one
9
+ * element at a time, by the page render worker (render/page-worker.mjs);
10
+ * unknown-core-props.mjs checks each prop against the component's docs
11
+ * and Core's own types.
10
12
  */
11
13
 
12
14
  import {coreImportOf} from './core-elements.mjs';
@@ -47,18 +49,32 @@ export function scanCoreProps(source) {
47
49
  const uses = [];
48
50
  traverseTemplateSource(file, {
49
51
  JSXOpeningElement(/** @type {any} */ path) {
50
- const core = coreImportOf(path.node.name, path.scope);
51
- if (core == null || !/^[A-Z]/.test(core.component)) return;
52
- const {component, source} = core;
53
- for (const attribute of path.node.attributes) {
54
- if (attribute.type !== 'JSXAttribute' || attribute.name.type !== 'JSXIdentifier') continue;
55
- const prop = attribute.name.name;
56
- // JSX never checks a name with a hyphen against a props type.
57
- if (NOT_COMPONENT_PROPS.has(prop) || prop.includes('-')) continue;
58
- const start = attribute.loc?.start;
59
- uses.push({component, source, prop, line: start?.line ?? 0, column: (start?.column ?? 0) + 1});
60
- }
52
+ uses.push(...corePropUsesOf(path));
61
53
  },
62
54
  });
63
55
  return uses;
64
56
  }
57
+
58
+ /**
59
+ * The props one JSX element gives a Core component by name, as
60
+ * `scanCoreProps` reads them. A module's reader that walks its own syntax
61
+ * tree calls this for each opening element, so it reads the same props.
62
+ * @param {any} path the opening element's Babel path
63
+ * @returns {CorePropUse[]}
64
+ */
65
+ export function corePropUsesOf(path) {
66
+ const core = coreImportOf(path.node.name, path.scope);
67
+ if (core == null || !/^[A-Z]/.test(core.component)) return [];
68
+ const {component, source} = core;
69
+ /** @type {CorePropUse[]} */
70
+ const uses = [];
71
+ for (const attribute of path.node.attributes) {
72
+ if (attribute.type !== 'JSXAttribute' || attribute.name.type !== 'JSXIdentifier') continue;
73
+ const prop = attribute.name.name;
74
+ // JSX never checks a name with a hyphen against a props type.
75
+ if (NOT_COMPONENT_PROPS.has(prop) || prop.includes('-')) continue;
76
+ const start = attribute.loc?.start;
77
+ uses.push({component, source, prop, line: start?.line ?? 0, column: (start?.column ?? 0) + 1});
78
+ }
79
+ return uses;
80
+ }
@@ -0,0 +1,17 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The official list, parsed. A `file` other than the CLI's own is read as it
6
+ * is. For the CLI's own list, a checkout derives it from the repository
7
+ * (`root`, else the checkout), and a published CLI reads the file it was
8
+ * packed with. Throws when the list cannot be read or derived.
9
+ * @param {{file?: string, root?: string}} [options]
10
+ * @returns {any}
11
+ */
12
+ export function readOfficialList({ file, root }?: {
13
+ file?: string;
14
+ root?: string;
15
+ }): any;
16
+ /** The list `prepack` writes into the published CLI. */
17
+ export const OFFICIAL_LIST_FILE: string;