@astryxdesign/cli 0.7.11 → 0.7.12-canary.19981aa

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 (113) hide show
  1. package/api/build/kit/rank.mjs +21 -4
  2. package/api/build/kit/words.d.mts +1 -0
  3. package/api/build/kit/words.mjs +1 -1
  4. package/api/component/__fixtures__/resolutions/modules.txt +2 -2
  5. package/api/docs/_adapter.d.mts +22 -0
  6. package/api/docs/_adapter.mjs +81 -3
  7. package/api/docs/docs.doc.mjs +5 -5
  8. package/api/docs/docs.type.d.mts +21 -0
  9. package/api/docs/docs.type.mjs +11 -0
  10. package/api/docs/list/list.d.mts +5 -1
  11. package/api/docs/list/list.mjs +72 -6
  12. package/api/docs/node/node.mjs +2 -40
  13. package/api/icon/_adapter.d.mts +3 -2
  14. package/api/icon/_adapter.mjs +8 -2
  15. package/api/icon/_authoring.d.mts +1 -0
  16. package/api/icon/_authoring.mjs +586 -66
  17. package/api/icon/_default-look.d.mts +155 -0
  18. package/api/icon/_default-look.mjs +474 -0
  19. package/api/icon/_records.d.mts +1 -1
  20. package/api/icon/_records.mjs +1 -0
  21. package/api/icon/add/add.mjs +224 -38
  22. package/api/icon/icon.type.d.mts +22 -2
  23. package/api/icon/icon.type.mjs +6 -2
  24. package/api/icon/iconAdd.doc.mjs +2 -2
  25. package/api/icon/iconNewDefinition.doc.mjs +3 -2
  26. package/api/icon/iconNewSet.doc.mjs +4 -4
  27. package/api/icon/search/search.mjs +10 -9
  28. package/api/index.d.mts +1 -0
  29. package/api/index.mjs +1 -0
  30. package/api/integration/add-helpers.d.mts +11 -1
  31. package/api/integration/add-helpers.mjs +5 -2
  32. package/api/integration/authoring-checks.d.mts +0 -2
  33. package/api/integration/authoring-checks.mjs +1 -6
  34. package/api/logger.mjs +2 -1
  35. package/api/render/_adapter.mjs +9 -0
  36. package/api/render/render.doc.mjs +2 -2
  37. package/api/search/_adapter.d.mts +22 -1
  38. package/api/search/_adapter.mjs +37 -20
  39. package/api/search/exportSearchIndex.doc.d.mts +10 -0
  40. package/api/search/exportSearchIndex.doc.mjs +58 -0
  41. package/api/search/rankSearchIndex.doc.d.mts +10 -0
  42. package/api/search/rankSearchIndex.doc.mjs +79 -0
  43. package/api/search/search-index.d.mts +44 -0
  44. package/api/search/search-index.mjs +270 -0
  45. package/api/search/search.type.d.mts +28 -0
  46. package/api/search/search.type.mjs +17 -0
  47. package/api/swizzle/_adapter.d.mts +1 -0
  48. package/api/swizzle/_adapter.mjs +4 -1
  49. package/api/swizzle/_moduleGraph.d.mts +178 -0
  50. package/api/swizzle/_moduleGraph.mjs +903 -0
  51. package/api/swizzle/copy/copy.d.mts +2 -43
  52. package/api/swizzle/copy/copy.mjs +287 -315
  53. package/api/swizzle/swizzle.d.mts +0 -2
  54. package/api/swizzle/swizzle.doc.mjs +13 -4
  55. package/api/swizzle/swizzle.mjs +3 -7
  56. package/api/swizzle/swizzle.type.d.mts +7 -1
  57. package/api/swizzle/swizzle.type.mjs +4 -2
  58. package/assets/discover/official-packages.json +20 -0
  59. package/assets/docs/browser-support.doc.mjs +2 -2
  60. package/assets/docs/styling-overview.doc.mjs +4 -0
  61. package/assets/docs/tree/icon-sets.doc.mjs +11 -5
  62. package/assets/docs/tree/render-pages.doc.mjs +2 -2
  63. package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.doc.mjs +14 -0
  64. package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.tsx +146 -0
  65. package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.doc.mjs +14 -0
  66. package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.tsx +173 -0
  67. package/assets/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +1 -1
  68. package/assets/templates/blocks/components/Table/TableRowIndexTable.tsx +2 -2
  69. package/assets/templates/pages/course-detail/page.tsx +699 -0
  70. package/assets/templates/pages/course-detail/template.doc.mjs +37 -0
  71. package/assets/templates/pages/file-explorer/page.tsx +103 -79
  72. package/assets/templates/pages/table-grouped/page.tsx +160 -232
  73. package/assets/templates/pages/table-grouped/template.doc.mjs +0 -2
  74. package/assets/templates/pages/theme-showcase/page.tsx +724 -792
  75. package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
  76. package/assets/templates/themes/butter/butterTheme.ts +1 -1
  77. package/assets/templates/themes/stone/stoneTheme.ts +1 -1
  78. package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
  79. package/authoring/doctypes/template/type.ts +1 -0
  80. package/clients/cli/commands/docs.doc.mjs +5 -1
  81. package/clients/cli/commands/docs.mjs +30 -2
  82. package/clients/cli/commands/experimental/icon.mjs +31 -10
  83. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  84. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
  85. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
  86. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  87. package/clients/cli/commands/swizzle.mjs +33 -9
  88. package/foundation/discovery/component-loader.d.mts +1 -1
  89. package/foundation/discovery/doc-types.mjs +9 -2
  90. package/foundation/discovery/icon-ranking.d.mts +27 -3
  91. package/foundation/discovery/icon-ranking.mjs +125 -8
  92. package/foundation/discovery/icon-set-checks.mjs +44 -35
  93. package/foundation/discovery/icon-set-discovery.d.mts +13 -0
  94. package/foundation/discovery/icon-set-discovery.mjs +25 -0
  95. package/foundation/discovery/icon-set-writer.d.mts +238 -16
  96. package/foundation/discovery/icon-set-writer.mjs +676 -79
  97. package/foundation/discovery/module-exports.d.mts +3 -2
  98. package/foundation/discovery/module-exports.mjs +167 -37
  99. package/foundation/fs/paths.d.mts +2 -1
  100. package/foundation/fs/paths.mjs +3 -4
  101. package/foundation/render/charts.d.mts +59 -0
  102. package/foundation/render/charts.mjs +216 -0
  103. package/foundation/render/embedded-imports.d.mts +7 -7
  104. package/foundation/render/embedded-imports.mjs +63 -54
  105. package/foundation/render/page-worker.mjs +339 -52
  106. package/foundation/render/render-page.mjs +26 -10
  107. package/foundation/render/ts-paths.d.mts +63 -0
  108. package/foundation/render/ts-paths.mjs +138 -0
  109. package/foundation/response/error-codes.doc.mjs +2 -2
  110. package/foundation/response/error-codes.mjs +3 -2
  111. package/foundation/text/shell-arg.d.mts +14 -0
  112. package/foundation/text/shell-arg.mjs +17 -0
  113. package/package.json +7 -6
@@ -0,0 +1,138 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A project's `compilerOptions.paths` (tsconfig.json or jsconfig.json),
5
+ * read and matched by TypeScript's rules, for `astryx experimental render`:
6
+ * an exact key matches only itself; a key may hold one `*` anywhere, and the
7
+ * longest matching prefix wins; a target may hold one `*`, which takes what
8
+ * the key's `*` matched; targets are tried in order, and when none exists the
9
+ * import resolves as a package. Only bare specifiers are matched. Targets
10
+ * resolve from `baseUrl` (default: the config's folder).
11
+ *
12
+ * @position foundation/render — used by page-worker.mjs and embedded-imports.mjs
13
+ */
14
+
15
+ import * as fs from 'node:fs';
16
+ import * as path from 'node:path';
17
+
18
+ /**
19
+ * @typedef {object} PathPattern
20
+ * @property {string} key - The key as written.
21
+ * @property {string} prefix - What comes before the key's `*` (all of it, for an exact key).
22
+ * @property {string} suffix - What comes after the key's `*`.
23
+ * @property {boolean} wildcard - Whether the key holds a `*`.
24
+ * @property {string[]} targets - Absolute target patterns, in order.
25
+ */
26
+
27
+ /** Extensions an extensionless candidate may stand for, in resolution order. */
28
+ const EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.mts', '.cts', '.json'];
29
+
30
+ /**
31
+ * The path patterns of the config in `dir` (tsconfig.json, else
32
+ * jsconfig.json), or none. Comments and trailing commas are allowed.
33
+ * @param {string} dir
34
+ * @returns {PathPattern[] | null} null when neither file is there
35
+ */
36
+ export function readPathsIn(dir) {
37
+ for (const name of ['tsconfig.json', 'jsconfig.json']) {
38
+ const file = path.join(dir, name);
39
+ if (!fs.existsSync(file)) continue;
40
+ try {
41
+ const text = fs
42
+ .readFileSync(file, 'utf8')
43
+ .replace(/("(?:[^"\\]|\\.)*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, str) => str ?? '')
44
+ .replace(/,(\s*[}\]])/g, '$1');
45
+ const options = JSON.parse(text)?.compilerOptions ?? {};
46
+ const base = path.resolve(dir, typeof options.baseUrl === 'string' ? options.baseUrl : '.');
47
+ /** @type {PathPattern[]} */
48
+ const out = [];
49
+ for (const [key, targets] of Object.entries(options.paths ?? {})) {
50
+ if (!Array.isArray(targets)) continue;
51
+ const star = key.indexOf('*');
52
+ if (star !== key.lastIndexOf('*')) continue;
53
+ out.push({
54
+ key,
55
+ prefix: star === -1 ? key : key.slice(0, star),
56
+ suffix: star === -1 ? '' : key.slice(star + 1),
57
+ wildcard: star !== -1,
58
+ targets: targets
59
+ .filter(t => typeof t === 'string' && t.indexOf('*') === t.lastIndexOf('*'))
60
+ .map(t => path.resolve(base, t)),
61
+ });
62
+ }
63
+ return out;
64
+ } catch {
65
+ return [];
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+
71
+ /**
72
+ * The pattern a specifier matches by TypeScript's rules, and what its `*`
73
+ * matched: an exact key first, else the wildcard key with the longest prefix.
74
+ * @param {PathPattern[]} patterns
75
+ * @param {string} spec
76
+ * @returns {{pattern: PathPattern, capture: string} | null}
77
+ */
78
+ export function matchPath(patterns, spec) {
79
+ // TypeScript applies `paths` only to bare specifiers.
80
+ if (/^\.{1,2}(\/|$)|^\//.test(spec)) return null;
81
+ const exact = patterns.find(p => !p.wildcard && p.key === spec);
82
+ if (exact) return {pattern: exact, capture: ''};
83
+ /** @type {{pattern: PathPattern, capture: string} | null} */
84
+ let best = null;
85
+ for (const p of patterns) {
86
+ if (!p.wildcard) continue;
87
+ if (spec.length < p.prefix.length + p.suffix.length) continue;
88
+ if (!spec.startsWith(p.prefix) || !spec.endsWith(p.suffix)) continue;
89
+ if (best && best.pattern.prefix.length >= p.prefix.length) continue;
90
+ best = {pattern: p, capture: spec.slice(p.prefix.length, spec.length - p.suffix.length)};
91
+ }
92
+ return best;
93
+ }
94
+
95
+ /**
96
+ * The absolute paths a match names, one per target, in order.
97
+ * @param {{pattern: PathPattern, capture: string}} match
98
+ * @returns {string[]}
99
+ */
100
+ export const candidatesOf = match => match.pattern.targets.map(t => t.replace('*', match.capture));
101
+
102
+ /**
103
+ * The file a candidate path stands for: itself, with an extension, or its
104
+ * folder's index; null when none exists.
105
+ * @param {string} candidate
106
+ * @returns {string | null}
107
+ */
108
+ export function existingFile(candidate) {
109
+ const isFile = (/** @type {string} */ f) => {
110
+ try {
111
+ return fs.statSync(f).isFile();
112
+ } catch {
113
+ return false;
114
+ }
115
+ };
116
+ if (isFile(candidate)) return candidate;
117
+ for (const ext of EXTENSIONS) if (isFile(candidate + ext)) return candidate + ext;
118
+ for (const ext of EXTENSIONS) if (isFile(path.join(candidate, `index${ext}`))) return path.join(candidate, `index${ext}`);
119
+ return null;
120
+ }
121
+
122
+ /**
123
+ * Resolve a specifier through path patterns: the first target that names an
124
+ * existing file wins.
125
+ * @param {PathPattern[]} patterns
126
+ * @param {string} spec
127
+ * @returns {string | null} the file, or null when the specifier matches no
128
+ * pattern or no target exists
129
+ */
130
+ export function resolvePath(patterns, spec) {
131
+ const match = matchPath(patterns, spec);
132
+ if (!match) return null;
133
+ for (const candidate of candidatesOf(match)) {
134
+ const file = existingFile(candidate);
135
+ if (file) return file;
136
+ }
137
+ return null;
138
+ }
@@ -338,13 +338,13 @@ export const doc = {
338
338
  value: 'ERR_RENDER_NOT_ASTRYX',
339
339
  stability: 'experimental',
340
340
  description:
341
- '`render --reverse` was given a file with no embedded source and no Astryx markup. Nothing was written. Raised only by the experimental render command.',
341
+ '`render --reverse` was given a file that a render did not write, with no embedded source and no Astryx markup. Nothing was written. Raised only by the experimental render command.',
342
342
  },
343
343
  {
344
344
  value: 'ERR_RENDER_SOURCE_DAMAGED',
345
345
  stability: 'experimental',
346
346
  description:
347
- '`render --reverse` refused the received file, and nothing was written: its embedded source is damaged (not valid, or a file does not match its checksum), lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its own imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds: a dotfile or dot-folder, anything under node_modules, a package manifest, lockfile or tool configuration, a file a test, story or benchmark runner would run, or any kind but a page module, stylesheet, JSON file or image. Raised only by the experimental render command.',
347
+ '`render --reverse` refused the received file, and nothing was written: its embedded source was removed (a file a render wrote, with no Astryx components left to rebuild from) or is damaged (not valid, or a file does not match its checksum), lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its own imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds: a dotfile or dot-folder, anything under node_modules, a package manifest, lockfile or tool configuration, a file a test, story or benchmark runner would run, or any kind but a page module, stylesheet, JSON file or image. Raised only by the experimental render command.',
348
348
  },
349
349
  ],
350
350
  };
@@ -298,8 +298,9 @@ export const ERROR_CODES = Object.freeze({
298
298
  */
299
299
  ERR_RENDER_FAILED: 'ERR_RENDER_FAILED',
300
300
  /**
301
- * `render --reverse` was given an HTML file that holds no Astryx markup and
302
- * no embedded source, so there is nothing to rebuild. Nothing was written.
301
+ * `render --reverse` was given an HTML file that a render did not write and
302
+ * that holds no Astryx markup and no embedded source, so there is nothing
303
+ * to rebuild. Nothing was written.
303
304
  */
304
305
  ERR_RENDER_NOT_ASTRYX: 'ERR_RENDER_NOT_ASTRYX',
305
306
  /**
@@ -0,0 +1,14 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file One command-line word for a printed command: a value as written when
6
+ * the shell reads it as one plain word, else single-quoted, so a printed
7
+ * command runs as printed and never substitutes anything.
8
+ */
9
+ /**
10
+ * A value as one shell word.
11
+ * @param {string} value
12
+ * @returns {string}
13
+ */
14
+ export function shellArg(value: string): string;
@@ -0,0 +1,17 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file One command-line word for a printed command: a value as written when
5
+ * the shell reads it as one plain word, else single-quoted, so a printed
6
+ * command runs as printed and never substitutes anything.
7
+ */
8
+
9
+ /**
10
+ * A value as one shell word.
11
+ * @param {string} value
12
+ * @returns {string}
13
+ */
14
+ export function shellArg(value) {
15
+ if (/^[A-Za-z0-9@/._-]+$/.test(value)) return value;
16
+ return `'${value.replace(/'/g, `'\\''`)}'`;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.11",
3
+ "version": "0.7.12-canary.19981aa",
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",
@@ -117,6 +117,7 @@
117
117
  "ignore": "^7.0.5",
118
118
  "jiti": "^2.7.0",
119
119
  "jscodeshift": "^17.3.0",
120
+ "linkedom": "^0.18.14",
120
121
  "node-diff3": "3.2.1",
121
122
  "postcss": "^8.5.23",
122
123
  "postcss-selector-parser": "^7.1.6",
@@ -124,7 +125,7 @@
124
125
  "zod": "^4.4.3"
125
126
  },
126
127
  "peerDependencies": {
127
- "@astryxdesign/core": "*"
128
+ "@astryxdesign/core": "0.7.12-canary.19981aa"
128
129
  },
129
130
  "peerDependenciesMeta": {
130
131
  "@astryxdesign/core": {
@@ -132,10 +133,10 @@
132
133
  }
133
134
  },
134
135
  "devDependencies": {
135
- "@astryxdesign/charts": "*",
136
- "@astryxdesign/core": "*",
137
- "@astryxdesign/lab": "*",
138
- "@astryxdesign/theme-neutral": "*",
136
+ "@astryxdesign/charts": "0.7.12-canary.19981aa",
137
+ "@astryxdesign/core": "0.7.12-canary.19981aa",
138
+ "@astryxdesign/lab": "0.7.12-canary.19981aa",
139
+ "@astryxdesign/theme-neutral": "0.7.12-canary.19981aa",
139
140
  "@heroicons/react": "^2.2.0",
140
141
  "@stylexjs/stylex": "^0.19.0",
141
142
  "@types/babel__core": "^7.20.5",