@astryxdesign/cli 0.7.7 → 0.7.8-canary.36cde5e

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 (27) hide show
  1. package/api/gap-report/gap-report.mjs +9 -4
  2. package/api/integration/authoring-checks.mjs +31 -0
  3. package/api/integration/check/check.mjs +8 -3
  4. package/assets/codemods/transforms/next/index.mjs +11 -1
  5. package/assets/codemods/transforms/next/promote-tokenizer-presentation.mjs +174 -0
  6. package/assets/discover/official-packages.json +4 -8
  7. package/assets/templates/blocks/components/Hooks/useAnnounceHookUsage.doc.mjs +14 -0
  8. package/assets/templates/blocks/components/Hooks/useAnnounceHookUsage.tsx +90 -0
  9. package/assets/templates/blocks/components/Hooks/useFocusTrapHookUsage.doc.mjs +14 -0
  10. package/assets/templates/blocks/components/Hooks/useFocusTrapHookUsage.tsx +70 -0
  11. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -0
  12. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +1 -0
  13. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -0
  14. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -0
  15. package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.doc.mjs +14 -0
  16. package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.tsx +199 -0
  17. package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.doc.mjs +21 -0
  18. package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.tsx +210 -0
  19. package/assets/templates/pages/table-inbox/page.tsx +6 -0
  20. package/assets/templates/pages/work-item-detail/page.tsx +1 -0
  21. package/foundation/discovery/component-discovery.mjs +26 -6
  22. package/foundation/fs/listing-cache.d.mts +15 -0
  23. package/foundation/fs/listing-cache.mjs +50 -1
  24. package/foundation/fs/paths.mjs +50 -5
  25. package/foundation/integrations/public-imports.d.mts +24 -0
  26. package/foundation/integrations/public-imports.mjs +2 -2
  27. package/package.json +9 -9
@@ -13,7 +13,12 @@ import {createRequire} from 'node:module';
13
13
  import * as os from 'node:os';
14
14
  import * as path from 'node:path';
15
15
  import {fileURLToPath} from 'node:url';
16
- import {listDir, pathExists} from './listing-cache.mjs';
16
+ import {
17
+ findEntry,
18
+ listDir,
19
+ listingCacheActive,
20
+ pathExists,
21
+ } from './listing-cache.mjs';
17
22
  import {ERROR_CODES} from '../response/error-codes.mjs';
18
23
  import {carriedCore, runChoice} from '../release/run-context.mjs';
19
24
  import {findDeclaringPackage} from '../release/project.mjs';
@@ -867,6 +872,31 @@ export function listComponents(coreDir) {
867
872
  .sort();
868
873
  }
869
874
 
875
+ /**
876
+ * `path.relative(root, target)`, read straight off the string when `target`
877
+ * is a plain path under `root`. A resolver probes tens of thousands of such
878
+ * paths, and `path.relative` normalizes both on every call.
879
+ * @param {string} root
880
+ * @param {string} target
881
+ * @returns {string}
882
+ */
883
+ function relativeInside(root, target) {
884
+ const prefix = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
885
+ if (path.isAbsolute(root) && target.startsWith(prefix)) {
886
+ const rest = target.slice(prefix.length);
887
+ const plain =
888
+ rest !== '' &&
889
+ !(path.sep === '\\' && rest.includes('/')) &&
890
+ rest
891
+ .split(path.sep)
892
+ .every(
893
+ segment => segment !== '' && segment !== '.' && segment !== '..',
894
+ );
895
+ if (plain) return rest;
896
+ }
897
+ return path.relative(root, target);
898
+ }
899
+
870
900
  /**
871
901
  * Does `targetPath` exist with EXACTLY this spelling?
872
902
  *
@@ -883,13 +913,28 @@ export function listComponents(coreDir) {
883
913
  * @returns {boolean}
884
914
  */
885
915
  export function existsCaseExact(targetPath, rootDir) {
886
- if (!pathExists(targetPath)) return false;
887
-
888
- const rel = path.relative(rootDir, targetPath);
889
- if (rel === '') return true;
916
+ const rel = relativeInside(rootDir, targetPath);
917
+ if (rel === '') return pathExists(targetPath);
890
918
  if (path.isAbsolute(rel) || rel === '..' || rel.startsWith(`..${path.sep}`))
891
919
  return false;
892
920
 
921
+ if (listingCacheActive()) {
922
+ // Inside an operation the folders' listings answer, so a name that a
923
+ // listing lacks costs no probe of the disk. A symbolic link still needs
924
+ // its target.
925
+ let folder = rootDir;
926
+ let entry = null;
927
+ for (const segment of rel.split(path.sep)) {
928
+ entry = findEntry(folder, segment);
929
+ if (!entry) return false;
930
+ folder = folder.endsWith(path.sep)
931
+ ? `${folder}${segment}`
932
+ : `${folder}${path.sep}${segment}`;
933
+ }
934
+ return !entry?.isSymbolicLink() || pathExists(targetPath);
935
+ }
936
+
937
+ if (!pathExists(targetPath)) return false;
893
938
  let dir = rootDir;
894
939
  for (const segment of rel.split(path.sep)) {
895
940
  let entries;
@@ -36,6 +36,30 @@ export function moduleExportNames(file: string, cache?: ExportNameCache): {
36
36
  types: Set<string>;
37
37
  typed: boolean;
38
38
  };
39
+ /**
40
+ * Every file a declared subpath names, and whether each is on disk.
41
+ * @param {string} packageDir
42
+ * @param {SubpathDeclaration} declaration
43
+ * @returns {{files: string[], allPresent: boolean}}
44
+ */
45
+ export function declaredTargets(packageDir: string, declaration: SubpathDeclaration): {
46
+ files: string[];
47
+ allPresent: boolean;
48
+ };
49
+ /**
50
+ * The names an import statement asks for that the module provably lacks.
51
+ * A name is missing only when every file the subpath names is on disk and
52
+ * read in full, and at least one of those lists includes its types: any
53
+ * construct the reader does not model leaves the import unchecked.
54
+ * @param {ImportStatement} statement
55
+ * @param {string[]} files candidate targets on disk
56
+ * @param {ExportNameCache} cache
57
+ * @param {boolean} [allPresent] every target the subpath names is on disk
58
+ * @param {boolean} [values] every name is known to be a value (a component),
59
+ * so a list without the module's types can still judge it
60
+ * @returns {string[] | null} null when it cannot be judged
61
+ */
62
+ export function missingNames(statement: ImportStatement, files: string[], cache: ExportNameCache, allPresent?: boolean, values?: boolean): string[] | null;
39
63
  /**
40
64
  * Every public-import finding for one package, as notes, and the report of
41
65
  * what could not be judged. It returns no issues: the notes are listed
@@ -667,7 +667,7 @@ function readOwnExportNames(file, cache, stack) {
667
667
  * @param {SubpathDeclaration} declaration
668
668
  * @returns {{files: string[], allPresent: boolean}}
669
669
  */
670
- function declaredTargets(packageDir, declaration) {
670
+ export function declaredTargets(packageDir, declaration) {
671
671
  if (declaration.state !== 'declared') return {files: [], allPresent: false};
672
672
  const root = path.resolve(packageDir);
673
673
  const all = allTargets(declaration.value)
@@ -693,7 +693,7 @@ function declaredTargets(packageDir, declaration) {
693
693
  * so a list without the module's types can still judge it
694
694
  * @returns {string[] | null} null when it cannot be judged
695
695
  */
696
- function missingNames(
696
+ export function missingNames(
697
697
  statement,
698
698
  files,
699
699
  cache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.7",
3
+ "version": "0.7.8-canary.36cde5e",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "*",
128
- "@astryxdesign/core": "*",
129
- "@astryxdesign/lab": "*",
130
- "@astryxdesign/theme-neutral": "*"
127
+ "@astryxdesign/charts": "0.7.8-canary.36cde5e",
128
+ "@astryxdesign/core": "0.7.8-canary.36cde5e",
129
+ "@astryxdesign/lab": "0.7.8-canary.36cde5e",
130
+ "@astryxdesign/theme-neutral": "0.7.8-canary.36cde5e"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "*",
148
- "@astryxdesign/core": "*",
149
- "@astryxdesign/lab": "*",
150
- "@astryxdesign/theme-neutral": "*",
147
+ "@astryxdesign/charts": "0.7.8-canary.36cde5e",
148
+ "@astryxdesign/core": "0.7.8-canary.36cde5e",
149
+ "@astryxdesign/lab": "0.7.8-canary.36cde5e",
150
+ "@astryxdesign/theme-neutral": "0.7.8-canary.36cde5e",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",